OpenGL
lastmod 2025-05-14created 2014-02-0391 edits
| |
|
OpenGL (Open Graphics Library) is a standard API specification for 2D and 3D graphics created by Silicon Graphics in 1992, supporting cross-language, cross-platform application programming. Using about 250 function calls, the API can generate anything from simple geometric shapes to complex three-dimensional scenes.
OpenGL is currently used in fields such as CAD, virtual reality, information visualization, and flight simulation. It is also widely used in computer games, and together with Microsoft's Direct3D it divides the world of computer graphics in two. Unlike Direct3D, the standard is shaped by discussion and proposals among many related companies, so version updates tend to be slow. Representative games developed with OpenGL are id Software's Quake and Doom 3 series. It is currently managed by the Khronos Group, a non-profit technology consortium.
OpenGL Reference Guide
|
|
|
Quick Reference Cards
- OpenGL 4.4 Reference Card
- OpenGL 4.3 Reference Card
- OpenGL 4.2 Reference Card
- OpenGL 4.2 (Core Profile) Reference Card
- OpenGL 4.1 Reference Card
- OpenGL 4.0 Reference Card
- OpenGL 3.2 Reference Card 1
- The OpenGL 4.3 Quick Reference Guide (including GLSL 4.30)
- http://www.khronos.org/files/opengl43-quick-reference-card.pdf
-
Opengl43-quick-reference-card.pdf
- The OpenGL 4.2 Quick Reference Guide (including GLSL 4.20)
- http://www.khronos.org/files/opengl42-quick-reference-card.pdf
-
Opengl42-quick-reference-card.pdf
- The OpenGL 3.2 Quick Reference Guide (including GLSL 1.50)
- http://www.khronos.org/files/opengl-quick-reference-card.pdf
-
Opengl32-quick-reference-card.pdf
Brief description of functions by category
- http://cafe414.daum.net/c21/bbs_search_read?grpid=nDQL&fldid=ATP6&datanum=1&contentval=&docid=nDQLATP6120101208175712
- http://dink8621.tistory.com/75
- http://cafe.naver.com/houdinilife/214
- http://skyswim42.egloos.com/3558397
- Difference between glFinish vs glFlush
- Android Opengl ES 2.0: How to use glDrawArrays and glDrawElements
Describes the list of OpenGL functions and what they do.
WGL
- wglCreateContext(): Creates a rendering context.
- wglDeleteContext(): Deletes a rendering context.
- wglMakeCurrent(): Sets the current rendering context.
- wglGetProcAddress(): Returns an extension function pointer.
- wglUseFontBitmap(): Creates OpenGL display lists for the currently selected GDI font.
- wgluseFontOutlines(): Creates display lists for something like the current outline font.
GLUT
- glutTimerFunc(): Calls the specified function once after the specified time. To call it again, call the function again
Pixel format
- ChoosePIxelFormat(): Determines the closest matching pixel format.
- SetPixelFormat(): Sets the pixel format on the device context.
Display settings
- ChangeDisplaySetting(): Switches to full screen.
- SwapBuffer(): Swaps the back buffer with the front buffer
- glClear(): Clears the screen and buffers.
- glClearColor(): Sets the screen background color.
Drawing
- glBegin(): Starts drawing primitives.
- glEnd(): Finishes drawing primitives.
- glVertex[2,3,4][d,f,i,s]v: Specifies a vertex.
- glColor[3,4]b,d,f,i,s,f: Specifies a color.
Points
- glPointSize(): Changes the point size.
Lines
- glLineWidth(): Changes the line width.
- glLineStipple(): Sets the dashed-line pattern.
Polygons
- glPolygonMode(): Sets how front and back polygons are drawn (points, lines, filled faces).
- glCullFac(): Culls faces.
- glFrontFace(): Changes which side is the front face.
- glEdgeFlag(): Hides edges. Used while specifying vertices.
- glPolygonStipple(): Sets the polygon pattern
Drawing other shapes
- glRectf(): Draws a rectangle.
- auxSolidCube(): Draws a cube.
- auxSolidShpere(): Draws a sphere.
- auxSolidTorus(): Draws a torus.
Querying state
- glGetString(): Gets the OpenGL version and the list of extensions.
- glGetBooleanv(): Gets state of type GLboolean.
- glGetDoublev(): Gets state of type GLdouble.
- glGetFloatv(): State of type GLfloat
- glGetIntegerv(): State of type GLint
- glEnable(): Enables a capability.
- glDisable(): Disables a capability.
Matrices
- glMatrixMode(): Sets the current matrix.
- glLoadIdentity(): Makes the current matrix the identity matrix.
- glLoadMatrixf,d: Loads the specified matrix onto the top of the matrix stack.
- glMultMatrixf,d: Multiplies the current matrix by the specified matrix.
Stack
- glPushAttrib(): Temporarily saves the current settings.
- glPopAttrib(): Restores the previous settings.
Viewing transformation
- gluLookAt(): Sets the camera position and direction.
Modeling transformation
Projection
- glOrtho(): Orthographic projection with a specified range
- gluOrth2D: Orthographic projection with a range of -1 ~ 1
- glFrustum(): Asymmetric frustum perspective projection
- gluPerspective(): Perspective projection
- glViewport(): Sets the viewport.
Shading
- glshadeModel(): Sets the shading model.
Lighting
- glMaterialf,i,fv,iv: Sets surface material.
- glLightf,i,fv,iv: Sets light sources.
- glColorMaterial(): Color tracking. Makes the color specified with glColor be set as a material property.
- glLightModelf,i,fv,iv: Sets the lighting model.
- glNormal3b,d,f,i,s: Sets a normalized normal vector.
Blending
- glBlendFunc(): Sets blending between source and destination
Depth
- glDepthMask(): Sets the depth buffer mode (read-only, write).
Bitmaps
- glRasterPos[2,3,4]s,i,f,d: Sets the position where a bitmap or image will be drawn. Draws from the bottom-left.
- glBitmap(): Draws a bitmap.
- glDrawPixels(): Draws a pixmap.
- glReadPixels(): Reads pixels.
- glCopyPixes(): Copies screen data.
- glPixelZoom(): Scales up, scales down, or flips an image.
- glPixelStorei(): Sets the pixel storage mode.
- auxDIBImageLoad(): Loads a DIB image.
- AUX_RGBImageRec: Struct that stores image data loaded with auxDIBImageLoad
Textures
- glGenTextures memory exhaustion problem
- Memory over flow issue when changing textures in Android OpenGL ES
- Understanding Filtering & MIP-MAP
Summary of texture-related functions
- glGenTextures: Generates texture names.
- glDeleteTexture: delete named textures.
- glBindTexture: Binds a texture name to texture data.
- glTexSubImage2D: specify a two-dimensional texture subimage.
- glTexParameter (f,i,fv,iv): Sets the texture filtering mode.
- glTexEnvi: Sets how texture colors relate to existing pixel colors when a texture is applied.
- glTexImage2D: Loads a 2D image into memory as a texture.
- glTexImage1D: Loads a 1D image into memory as a texture.
- glTexCoord2 (f,fv): Sets texture coordinates.
- gluBuild2DMipmaps: Generates mipmaps automatically.
- glTexGen (d,f,i,v,fv,iv): Generates texture coordinates automatically.
- glTexParameteri: OpenGL BMP texture loading.
Multitexturing
- PFNGLMULTITEXCOORD2FARBPROC: glMultiTexCoord2fARB Specifies text coordinates for multitexturing. (Used by obtaining the function pointer)
- PFNGLACTIVETEXTUREARBPROC: glActiveTextureARB Sets the texture unit. (Used by obtaining the function pointer)
- PFNGLCLIENTACTIVETEXTUREARBPROC: glClientActiveTextureARB Activates the texture unit for vertex arrays. (Used by obtaining the function pointer)
Display lists
- glGenLists(): Creates the specified number of display lists
- glIsList(): Checks whether a list name is valid.
- glNewList(): Starts recording commands into a display list.
- glEndList(): Stops recording commands into a display list.
- glCallList(): Executes a display list.
- glCallLists(): Executes multiple display lists.
- glListName(): Executes commands starting from the specified position.
- glDeleteLists(): Frees display lists.
- glListBase()
Vertex arrays
- glEnableClientState(): Enables vertex arrays.
- glDisableClientState(): Disables vertex arrays.
- glColorPointer(): Uses a color array
- glEdgeFlagPointer(): Specifies an array of edge flags.
- glIndexPointer(): Specifies an array of color indices in palette mode.
- glNormalPointer(): Specifies an array of normal vectors for each vertex.
- glTexCoordPointer(): Specifies an array of texture coordinates for each vertex.
- glVertexPointer(): Specifies an array of vertex position coordinates.
- glDrawArrays(): Draws the specified primitive using each vertex of the currently enabled arrays in order.
- glDrawElements(): Draws primitives using an index array to use arbitrary elements in arbitrary order.
- glDrawRangeElements(): Draws primitives using only a specific range of the index array.
- glArrayElement(): Uses only one specific element of the vertex array.
- PFNGLLOCKARRAYSEXTPROC: glLockArraysEXT Locks arrays. (Used by obtaining the function pointer.)
- PFNGLUNLOCKARRAYSEXTPROC: glUnlockArraysEXT Unlocks arrays. (Used by obtaining the function pointer.)
Version history
- 1.1: Texture objects
- 1.2: 3D textures, BGRA and packed pixel formats
- 1.3: Multitexturing, multisampling, texture compression
- 1.4: Depth textures
- 1.5: Vertex buffer objects (VBO), Occlusion Queries
- 2.0: GLSL 1.1, MRT, non-power-of-two textures, point sprites, stencil
- 2.1: GLSL 1.2, pixel buffer objects (PBO), sRGB textures
- 3.0: GLSL 1.3, texture arrays, conditional rendering, framebuffer objects (FBO)
- 3.1: GLSL 1.4, Instancing, texture buffer objects, uniform buffer objects, Primitive restart
- 3.2: GLSL 1.5, geometry shaders, multisampled textures
- 3.3: GLSL Backports as much functionality possible from the OpenGL specification
- 4.0: GLSL 4.00, tessellation on the GPU, shaders with 64-bit precision
OpenGL 3D computer graphics course
PART 01. Principles of 3D computer graphics
- Chapter 01. OpenGL and Modeling: Chapter_01_-_OpenGL,_Modeling.pdf
- Chapter 02. Callback Programming: Chapter_02_-_Callback_Programming.pdf
- Chapter 03. Model transformation and viewing transformation: Chapter_03_-_Transformation,_Camera.pdf
- Chapter 04. Projection and Viewport transformation: Chapter_04_-_Projection,_Viewport.pdf
- Chapter 05. Lighting and Shading: Chapter_05_-_Lighting,_Shading.pdf
- Chapter 06. Texture Mapping: Chapter_06_-_Texture_Mapping.pdf
PART 02. Applications of 3D computer graphics
- Chapter 07. Shadow: Chapter_07_-_Shadow.pdf
- Chapter 08. Particle Systems: Chapter_08_-_Particle_Systems.pdf
- Chapter 09. Useful features: Chapter_09_-_Utility.pdf
- Chapter 10. Motion Animation: Chapter_10_-_Motion_Animatioin.pdf
PART 03. Advanced theory and extensions
- Chapter 11. Curves and Surfaces: Chapter_11_-_Curves,_Surfaces.pdf
- Chapter 12. OpenGL and GUI: Chapter_12_-_OpenGL_GUI.pdf
Coordinates system
Coordinates_system_-_OpenGL_and_DirectX.png
Select a graphic device
- Stackoverflow - Select a graphic device in windows + opengl
- Stackoverflow - OpenGL rendering in Windows XP with multiple video cards
- HD is now 8MP & HDR - Ian Williams – Manager, PSG Applied Engineering 3
NVidia provided an extension called WGL_nv_gpu_affinity. I'm not sure if this is still available and whether it works as you would like.
GLUT
GLUT was originally written by Mark Kilgard to support the sample programs in the second edition OpenGL 'RedBook'. Since then, GLUT has been used in a wide variety of practical applications because it is simple, widely available and highly portable.
FreeGLUT
freeglut is an open source alternative to the OpenGL Utility Toolkit (GLUT) library. GLUT (and hence freeglut) allows the user to create and manage windows containing OpenGL contexts on a wide range of platforms and also read the mouse, keyboard and joystick functions. freeglut is intended to be a full replacement for GLUT, and has only a few differences.
Since GLUT has gone into stagnation, freeglut is in development to improve the toolkit. It is released under the X Consortium license.
Downloading Man Page Sources
The Docbook XML source for the man pages is available for anonymous checkout in Khronos' Subversion server, and you can build a man page distribution of your own using open source tools. See the OpenGL.org technical Wiki pages describing the XML Toolchain and Man Pages for more information.
Troubleshooting
Not found libGL.so
On Ubuntu, the following error message may appear.
In this case, install the package as follows.
See also
Libraries
- OpenGL Utility Toolkit (GLUT)
- FreeGLUT (freeglut)
- OpenGL Mathematics (GLM)
- OpenGL Image
- OpenGL Extension Wrangler (GLEW)
- OpenGL Samples Pack
- Simple OpenGL Image Library
- Simple and Fast Multimedia Library (SFML)
- GLFW
- Magnum
- Mesa
- SGL
- ImGUI - Bloat-free Graphical User interface for C++ with minimal dependencies
- moderngl (python)
- PyOpenGL (python)
Favorite site
- OpenGL website
- Wikipedia (en) article on OpenGL
- OpenGL wiki Main page
- OpenGL Error list
- The OpenGL Reference Pages
- [Recommended] docs.gl
- Good GUI for OpenGL
- Converting YUV420 format colors to RGB using an OpenGL Shader
- Understanding the principles of 3D graphics
- Texture ma in OpenGL programming using a shader architecture
- Shader release
- [Recommended] MFC project setup for Android 3D Programming
- [Recommended] Basic concepts of OpenGL, part 1
- [Recommended] iOS OpenGL ES tutorial part 1
- [Recommended] OpenGL ES 00: Xcode Project Set Up
Guide
- [Recommended] 3D Graphics with OpenGL Basic Theory 4
- [Recommended] iOS OpenGL ES part 13: Explanation of perspective projection
- [Recommended] Implementing the gluPerspective() function in OpenGL ES
- Example of three rectangles repeatedly revolving and rotating using transformation matrices
- Attributes Uniform, Varying?
- OpenGL Installation (for Windows)
- Programming OpenGL in C/C++ How To Setup and Get Started
- Drawing 2D and 3D at the same time in OpenGL
- [Recommended] Tutorial: OpenGL 3.1 The First Triangle (C++/Win)
- [Recommended] Example using OpenGL 3.0+ with SDL2 and GLEW 5
- GL_CULL_FACE / GL_DEPTH_TEST
- Explanation of GL_CULL_FACE (back-face culling) / GL_DEPTH_TEST (hidden surface removal)
- Explanation of glPolygonMode(), glCullFace() (how to draw front and back faces)
- glVertexPointer() specifies the array of vertex data coordinates used by the OpenGL vertex array feature
- OpenGL programming: simple polygon rendering
- How to use glDrawArrays() and glDrawElements()
- Applying Antialiasing when using Opengl
- Brief (Korean) descriptions of OpenGL functions
- Drawing polylines by tessellation
- [Recommended] Avoiding 16 Common OpenGL Pitfalls
- Explanation of GL_CULL_FACE (back-face culling) / GL_DEPTH_TEST (hidden surface removal)
- Explanation of glPolygonMode(), glCullFace() (how to draw front and back faces)
- GL_CULL_FACE/GL_DEPTH_TEST - Explanation of back-face culling and hidden surface removal
- glVertexPointer() specifies the array of vertex data coordinates used by the OpenGL vertex array feature
- OpenGL programming: simple polygon rendering
- How to use glDrawArrays() and glDrawElements()
- Applying Antialiasing when using Opengl
- freeglut Windows Development Libraries
- Using freeglut or GLUT with MinGW
- Brief (Korean) descriptions of OpenGL functions
- Drawing polylines by tessellation 6
- Creating a Voxel Engine (like Minecraft) from Scratch in Python - YouTube (Minecraft; OpenGL; Voxel Engine; Python)
Tutorial
- [Recommended] The Official Guide to Learning OpenGL, Version 1.1 7
- [Recommended] This site is dedicated to tutorials for OpenGL 3.3 and later ! 8
Tutorial: C/SDL OpenGL
- Tutorial1: Creating a Cross Platform OpenGL 3.2 Context in SDL (C / SDL)
- Tutorial2: VAOs, VBOs, Vertex and Fragment Shaders (C / SDL)
- Tutorial3: Rendering 3D Objects (C /SDL)
- Tutorial4: Using Indices and Geometry Shaders (C /SDL)
Multithreaded Rendering on OpenGL
- Stackoverflow: How to draw opengl graphics from different threads?
- Stackoverflow: Multithreaded Rendering on OpenGL
- Understanding OpenGL ES: Multi-thread and multi-window rendering
- Windows, Buffers, and Rendering Contexts
- OpenGL and multithreading
- Parallel OpenGL FAQ
References
-
Opengl32-quick-reference-card.pdf ↩
-
Soenlab_com.7z - See the explanation of OpenGL space transformations on the
soenlab.com/lecture/library/opengl/opengl-8.htmpage ↩ -
NVISION08-8MP_HDR.pdf ↩
-
3D_Graphics_with_OpenGL_-_The_Basic_Theory.pdf ↩
-
Fragment shader compile success: Sdl2-opengl-sample.zip ↩
-
Drawing_polylines_by_tessellation.pdf ↩
-
Www_glprogramming_com_red.zip ↩
-
Code download: https://code.google.com/p/opengl-tutorial-org/ ↩
-
Nehe.gamedev.net.zip ↩
-
Soenlab_com.7z ↩
-
Modern_OpenGL_Guide.pdf ↩
- AndEngine
- Android
- Android.opengl.GLSurfaceView
- Android:OpenGLES
- Computer Graphics
- Computer Sciences
- Desktop environment
- Display manager
- Freedesktop.org
- Fyne
- Game Programming
- GL PROJECTION
- GLAN
- GlBindTexture
- GlDrawPixels
- GlEnable
- GlFrustum
- GlGenTextures
- GlGetTexImage
- GlOrtho
- GlTexImage2D
- GlTexParameteri
- GluPerspective
- GPU
- Khronos Group
- Minecraft
- OpenCV:Troubleshooting
- OpenGL ES
- OpenGL Utility Toolkit
- OpenGL:Framebuffers
- OpenGL:PixelBufferObjects
- OpenGL:Textures
- Programming
- Pygame
- PyOpenGL
- Python-mpv
- Python:Libraries
- SDL OpenGL
- SDL ttf
- SGL
- Shader
- Simple DirectMedia Layer
- User Interface
- Voxel
- Vulkan
- Wavefront
- WebGL
- Wgpu
- Window Manager
- X Window System