Home > Articles > Programming > Graphic Programming

OpenGL Is Alive and Well: New Features, Capabilities, and Strengths for Modern Graphics

With new APIs, rendering effects, and other features changing the world of graphics, should you still care about OpenGL? Graham Sellers, lead author of OpenGL SuperBible, Seventh Edition, discusses why OpenGL is not only relevant, but offers updated features that rival some of the vaunted capabilities of newer technologies.
Like this article? We recommend

Over the last few months in 2015, we have heard a lot of talk about new APIs and how they enable new rendering effects and unprecedented performance. I am actually involved in the development of Vulkan, Khronos Group's new graphics and compute API. However, I believe there is still a place for the venerable OpenGL, which is why OpenGL SuperBible, Seventh Edition incorporates new features from OpenGL 4.5 and brings in discussion of extensions.

Some key topics addressed in this latest edition are part of what has become known as the "Approaching Zero Driver Overhead" (AZDO) suite of features:

  • Zero-copy features enabled by persistent mapped buffers
  • Arrayed indirect draws (multi-draw indirect, or MDI)
  • Sparse textures
  • Bindless textures
  • Advanced use of compute shaders

The book contains examples of the use of all of these features, some of which are available only on very recent hardware with up-to-date drivers that expose specific extensions. This marks a departure from the previous edition, in which I stayed away from extensions in order to ensure the widest possible user base for the code. Because these extensions have become more ubiquitous, I decided to showcase them. However, these features represent the cutting edge of graphics technology; at this point in 2015, OpenGL is the only way to get them.

Persistent Mapped Buffers

Possibly the most interesting of the new features introduced since OpenGL 4.3 is persistent mapped buffers, which were included with the GL_ARB_buffer_storage extension and are now part of OpenGL 4.4 and 4.5. In prior versions of OpenGL, it was an error to attempt to render from a buffer while that buffer was mapped. However, because the overhead is so great for a driver to attempt to figure out whether any mapped buffer might be used by a particular draw, it wasn't guaranteed that you'd actually see that error, and most drivers didn't do the check at all. Sometimes this kind of rendering would work, sometimes it would generate an error, and sometimes it wouldn't work but also wouldn't generate an error. OpenGL 4.4 made this use legal and well defined, so long as the application specifies its intention to use the buffer this way when it's allocated. This change allows an application to share a piece of memory between the CPU and GPU, and even deal with synchronization itself, which has implications for multithreading, fine-grained work generation, and efficient read-backs from the GPU to the CPU. Demonstrations of using persistent mapped buffers for shader parameters, vertex data, and texture data are included with the book's sample code in the pmbstreaming, ompparticles, and pmbfractal examples, respectively.

Multi-Draw Indirect (MDI) Functions

Another feature expanded in recent versions of OpenGL is the set of MDI functions, which allow a large list of parameters for draws to be placed in a buffer object and then sent to the GPU at once. (The sixth edition showed an example of this feature rendering an asteroid field.) In the original version of the function call, introduced in OpenGL 4.2, the number of draws in the buffer was passed as a parameter. This meant that if the draws were generated on the GPU, a roundtrip back to the CPU would be necessary–retrieving the value only to send it straight back to the GPU. GL_ARB_indirect_parameters added a feature to allow the draw count to be placed in a buffer as well. This change allows for using a shader or other GPU functionality to generate both a list of draws and the count, without CPU intervention. The seventh edition's cullindirect example demonstrates this feature.

Bindless Textures

Next, we come to bindless textures, an exciting new feature available only through the GL_ARB_bindless_texture extension. In traditional OpenGL, textures are bound to texture units, of which there are a finite number. While it's possible for an implementation to expose an arbitrarily large number of units, in practice most implementations expose only the minimum number required by the OpenGL specification. In GLSL shaders, textures are represented by sampler variables that normally refer to texture units and are declared as uniforms at global scope. Using bindless textures, the storage for a sampler variable becomes transparent as a 64-bit driver-supplied value, which can be passed to a shader in any manner the application chooses (such as inside a uniform block). The number of unique textures available to a single shader essentially becomes limited only by the resources available to the GPU. The bindlesstex example in the new book shows a simple demonstration of the feature.

Sparse Textures

Also extending OpenGL's texturing functionality are sparse textures, which are exposed by the GL_ARB_sparse_texture functionality. This extension separates the logical texture, its dimensions, format, and so on from the memory that backs it, allowing them to be allocated and managed separately. In addition, it allows a texture to be partially (sparsely) populated with memory. By using this feature, applications can create enormous textures that normally wouldn't fit into a graphics card's memory. Only the parts of the texture containing useful data are resident, allowing those parts to fit. This design makes more efficient use of video memory, reduces waste by not consuming memory for large parts of textures that are blank (for example, the gaps between segments in a texture atlas), and gives the application control over what's in video memory at any given time.

Direct State Access (DSA)

While that wraps up much of the AZDO feature set, OpenGL 4.4 and 4.5 have still more to offer. A big feature that finally made its way into core OpenGL with version 4.5 is Direct State Access (DSA), which provides a more object-oriented approach to OpenGL programming. To modify the state of an object in prior versions of OpenGL, you needed to bind the object to the OpenGL context and then call commands that would implicitly operate on the bound object. DSA adds commands that allow a program to specify the object to be modified without binding it, which prevents disturbing context state. The texture selector is eliminated, which can halve the number of API calls needed to set up texturing. In all, the GL_ARB_direct_state_access extension is possibly the largest single modification ever applied to the OpenGL API, and touches most parts of it. Where appropriate, we've updated the book's code and text to use DSA.

Final Thoughts

In addition to showcasing new API features, this latest edition of the OpenGL SuperBible demonstrates new techniques. Using multiple threads from an OpenGL program is covered by parallelizing application usage of OpenGL commands, as well as through generation of data in parallel using OpenMP. New samples demonstrate texture compression; culling from compute shaders; rendering of text and fonts; non-obvious uses for distance fields; and various new texture formats, blending modes, and other less dramatic features of OpenGL.

With the many improvements in the latest OpenGL specification, it's clear that there will be a place for OpenGL—and a need for updates to the venerable OpenGL SuperBible—for many years to come.

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020