Introduction to qt's support for OpenGL (ES) 2.0 and advanced opengl_api

Source: Internet
Author: User
Introduction to qt's support for OpenGL (ES) 2.0 and advanced opengl_api

Compared with qt4, qt5 has greatly changed and has increased support for OpenGL. If qt5.0 has made experimental changes to OpenGL, the OpenGL-related functions and encapsulation in qt5.1 are optimized and slightly fine-tuned. As early as the time when qt5.1 was not released, some foreign experts released the relevant features supported by qt5.1 for OpenGL (link here ).

Windows is a fixed-step system that supports OpenGL only to opengl1.1. Fortunately, Major graphics card manufacturers still have their own program operations. By replacing opengl32.dll with the vendor's own opengl32.dll, they can support OpenGL extension. Linux is an open-source system. Although GUI support is not as good as Windows and Mac OSX due to architecture reasons, OpenGL support is quite good, major graphics card manufacturers have also launched graphics card drivers suitable for Linux OpenGL. Finally, some open source forces have made outstanding contributions to OpenGL support. Mesa provides software implementation for almost all OpenGL APIs. Therefore, the implementation provided by Mesa cannot be used on a machine that cannot start hardware acceleration.

If you use the glut framework, you must use the simple extension glee to use OpenGL advanced APIs. The emergence of glew is to use a framework to replace glut + Glee, while QT takes a further step. Strictly speaking, the basic API of OpenGL is based on the C language. QT encapsulates these APIs to a certain extent and uses many concepts of C ++, these APIs are truly easy to use.

Next I will introduce one of the classes.

The qopenglfunctions class is called qglfunctions in qt4. It provides a set of OpenGL (ES) 2.0api, removing the need for developers to manually parse these function symbols. If you use glut and Glee, you must have a deep understanding. If you have read the glee source code and qopenglfunctions, you should know that qopenglfunctions and Glee have the same functions. It can bind VBO, specify shader, and so on. The most common method should be to inherit from glwidget directly, so that you can directly call the function starting with gl in the paintgl () function of glwidget. This is also a common encoding method for OpenGL developers. However, during compilation, we will find that the functions starting with GL are actually encapsulated. Before using functions starting with GL, call the initializeopenglfunctions () function to ensure that these functions are correctly parsed.

The following is a small example written by myself. It generates and binds VBO, uses indexes to draw graphs, generates and binds color buffer objects, and draws a color cube ). It is built using qt5.1. It is worth noting that I have used the enginio library. You can view the feedback of this program or send the feedback to the enginio backend. This is a good attempt. I can learn from your comments and suggestions on the example program I wrote.


Demo program: here

Program source code: here

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.