Khronos Combined OpenGL Registry

repository·main·Indexed 21 days ago

https://github.com/khronosgroup/opengl-registry

A comprehensive registry for the OpenGL family, including OpenGL, OpenGL ES, and OpenGL SC. It provides API specifications, Khronos- and vendor-approved extensions, and an XML API Registry used for enumerant management, extension registration, and automated C/C++ header generation.

Tokens
6.6K
Snippets
16
Records
34
Agent score
71%

What's inside opengl-registry

  1. Overview of the OpenGL-Registry

    main

    The opengl-registry repository serves as the central backing store for the Khronos web registry. It contains the API and Extension registries for the OpenGL family, including OpenGL, OpenGL ES, and OpenGL SC.

    Key components include:

    • API Specifications: PDF specifications for all APIs (found in specs/).
    • Header Files: C/C++ headers for all APIs (found in api/). Note that OpenGL ES and OpenGL SC headers depend on khrplatform.h from the EGL Registry.
    • Extension Specifications: Documentation for Khronos- and vendor-approved extensions (found in extensions/).
    • XML API Registry: The XML definitions of each API and related tools (found in xml/).

    Note: This repository does not contain the OpenGL and OpenGL ES Reference Pages; those are located in the KhronosGroup/OpenGL-Refpages repository.

  2. Overview of the OpenGL XML API Registry

    main

    The OpenGL XML API Registry contains the formal definitions for OpenGL, GLX, and WGL interfaces. These XML files serve three primary purposes:

    1. Reserving Enumerant Ranges: Allowing vendors to reserve specific ranges for new extensions.
    2. Registering Extensions: Formally registering extension interfaces when they are published.
    3. Header Generation: Serving as the source for the Khronos-supplied header files located in the ../api directory.

    The core registry files are:

    • gl.xml (OpenGL)
    • glx.xml (GLX)
    • wgl.xml (WGL)

    Note: The canonical versions of these registries are maintained in the master branch of the official GitHub repository.

  3. Understand the OpenGL RGBA Image Rendering Pipeline

    main

    The OpenGL RGBA Image Rendering Pipeline describes the sequence of operations performed when rendering image data to an RGBA visual. The pipeline is a combination of core OpenGL operations and specific imaging extensions.

    Pipeline Stages

    1. Data Source: Image data exists in main memory (RGBA or color index values).
    2. Subimage Extraction: Extract subimage, performing byte swapping if necessary.
    3. RGBA Conversion (Logical): Convert RGBA components to floats and component groups to full RGBA.
    4. Component Transformation:
      • For RGBA: Perform ax+b operation on each component.
      • For Color Index: Perform index shift and offset on each index value.
    5. Primary Lookup Table (LUT):
      • For RGBA: Use OpenGL RGBA to RGBA lookup (controlled by GL_MAP_COLOR).
      • For Color Index: Use OpenGL color index to RGBA lookup (controlled by GL_MAP_COLOR).
    6. SGI Color Table: LUT via COLOR_TABLE_SGI extension.
    7. Convolution: Perform convolution, including post-convolution scale and bias (EXT_convolution).
    8. Post-Convolution LUT: LUT via POST_CONVOLUTION_COLOR_TABLE_SGI extension.
    9. Color Matrix: Apply color matrix, including post-color matrix scale and bias (SGI_color_matrix).
    10. Post-Color Matrix LUT: LUT via POST_COLOR_MATRIX_COLOR_TABLE_SGI extension.
    11. Statistics: Histogram and min/max calculations (EXT_histogram).
    12. Zoom: Zoom operation.
    13. Fragment Output: Write fragments to the display (includes texture, fog, blend, etc.).
  4. Use the GL_ANGLE_texture_usage extension

    main

    The GL_ANGLE_texture_usage extension allows you to specify the intended usage of a texture before its backing storage is allocated. This helps the implementation choose the optimal memory format and type, preventing costly re-allocations or reformatting if the usage is discovered later.

    Important Constraints:

    • You must specify the texture usage via glTexParameteri (or glTexParameteriv) before defining the texture contents using glTexImage2D or glTexStorage2DEXT.
    • If you change the usage after the texture contents have been defined, the change will have no effect unless the texture is redefined (e.g., via glTexImage2D).
    • Specifying incorrect usage values may result in reduced functionality or significantly degraded performance.
    /* create and bind texture */
    glGenTextures(1, &texture);
    glActiveTexture(GL_TEXTURE0);
    bindTexture(GL_TEXTURE_2D, texture);
    
    /* specify texture parameters */
    glTexParameteri(GL_TEXTURE_2D, GL_*, ...);  /* as before */
    
    /* specify that we'll be rendering to the texture */
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_USAGE_ANGLE, GL_FRAMEBUFFER_ATTACHMENT_ANGLE);
    
    /* Allocation must happen AFTER specifying usage */
    glTexStorage2DEXT(GL_TEXTURE_2D, levels, ...); 
    
    /* Initialisation */
    for(int level = 0; level < levels; ++level)
        glTexSubImage2D(GL_TEXTURE_2D, level, ...);
  5. How to define a new extension

    main

    To create and register a new extension specification, follow these steps:

    1. Request Enumerants: Add reservation(s) for unused enumerant blocks to the end of gl.xml, glx.xml, and/or wgl.xml to secure space in the GL, GLX, or WGL namespaces.
    2. Wait for Acceptance: Once your pull request modifying the XML files is accepted into main, you have control over those enumerant blocks.
    3. Create Specification: Create an extension specification following the model of existing vendor specifications found in extensions/*vendor*/.
    4. Review and Signoff: Obtain necessary review and implementation signoff from affected parties.
    5. Add Specification: Place the specification under extensions/*vendor*/*extension*.
    6. Update Registry:
      • Run extensions/nextfree.py to find the next available ARB, GL, and/or ES extension numbers.
      • Modify extensions/registry.py to include the extension using those numbers.
      • Run make in the extensions/ directory to update the PHP include files (requires GNU make and Python 3).
    7. Finalize Specification: Add the extension number(s) to the 'Number' block in your specification.
    8. Update XML Registry: Add the extension interfaces and enumerant assignments to xml/gl.xml, glx.xml, and/or wgl.xml.
    9. Verify Headers: Run make in the xml/ directory to ensure the relevant extension headers are generated correctly (requires the lxml Python module).
    10. Submit: Once the pull request is accepted, your extension is officially registered.
  6. Include KaTeX via CDN

    main

    To use KaTeX in your web project, you can include the required CSS and JavaScript files directly from a CDN. You must include both katex.min.css and katex.min.js for in-browser rendering.

    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.6.0/katex.min.css">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.6.0/katex.min.js"></script>
  7. Track missed frame swaps with frame tracking functions

    main

    The WGL_I3D_swap_frame_usage extension provides a mechanism to track if frame swaps are being missed based on the specified swap interval.

    1. Start Tracking

    Call wglBeginFrameTrackingI3D() to reset the "missed frame" count and synchronize with the next frame vertical sync.

    2. Query Statistics

    Call wglQueryFrameTrackingI3D() to retrieve the number of swaps that occurred, the number of missed frames, and the usage value of the last missed frame.

    3. Stop Tracking

    Call wglEndFrameTrackingI3D() to disable tracking. Note: This function will not return until all pending swaps have occurred. You can call wglQueryFrameTrackingI3D immediately after this to get the final counts.

    // Start tracking
    wglBeginFrameTrackingI3D();
    
    // ... perform rendering and swaps ...
    
    // Stop tracking (blocks until swaps occur)
    wglEndFrameTrackingI3D();
    
    // Query final results
    DWORD frameCount, missedFrames;
    float lastMissedUsage;
    if (wglQueryFrameTrackingI3D(&frameCount, &missedFrames, &lastMissedUsage)) {
        // Use frameCount, missedFrames, and lastMissedUsage
    }
  8. Access the OpenGL, OpenGL ES, and OpenGL SC Registries

    main

    The Khronos Combined OpenGL Registry provides API specifications, Khronos- and vendor-approved extensions, header files, and the XML API Registry for the OpenGL family. You can access specific registries via the following index pages:

    • OpenGL ES Registry Index: index_es.php
    • OpenGL Registry Index: index_gl.php
    • OpenGL SC Registry Index: index_sc.php