Questions tagged [opengl]

OpenGL (Open Graphics Library) is a graphics standard and API which is platform independent and available for desktop, workstation and mobile devices. It is designed to provide hardware-accelerated rendering, and hence gives greatly improved performance over traditional software rendering. OpenGL is used for applications like CAD software and computer games. The OpenGL standard, as well as OpenGL ES, is controlled by the Khronos group.

OpenGL (Open Graphics Library) is an API used to interact with GPUs (Graphics Processing Units). Originally developed by SGI (Silicon Graphics Inc.) in the early 90's, the current API is being developed by the Khronos Group.

OpenGL is platform independent and available for desktop, workstation and mobile devices. It is designed to provide hardware-accelerated rendering and is typically used for applications such as CAD software and computer games.

The tag should only be used for questions about desktop OpenGL. OpenGL ES (OpenGL for Embedded Systems) and WebGL have their own tags - and . When posting in the tag, remember to always specify your target OpenGL version in order to get more precise answers. The tags , , and exist for this purpose.

Official Documentation

  • The Red Book - Tutorial GL
  • The Orange Book - Tutorial for GLSL
  • The Green Book - Tutorial for GLX
  • The Blue Book - API references for GL (out of print; replaced by online reference pages)
  • The White Book - Tutorial for WGL

Successor

Khronos Group announced API at GDC (Game Developers Conference) 2015. Vulkan, previously known as glNext or the "Next Generation OpenGL Initiative", is widely thought of as the successor to OpenGL and shares many similarities to the API. It is a complete redesign aimed to unify the OpenGL and OpenGL-ES API's into one common API that will not be backwards compatible.

External resources

Unofficial Tutorials

Books

Release Dates

  • OpenGL 1.0 - January 1992
  • OpenGL 1.1 - January 1997
  • OpenGL 1.2.1 - October 1998
  • OpenGL 1.3 - August 2001
  • OpenGL 1.4 - July 2002
  • OpenGL 1.5 - July 2003
  • OpenGL 2.0 - September 2004
  • OpenGL 2.1 - July 2006
  • OpenGL 3.0 - August 2008
  • OpenGL 3.1 - March 2009
  • OpenGL 3.2 - August 2009
  • OpenGL 3.3 - March 2010
  • OpenGL 4.0 - March 2010
  • OpenGL 4.1 - July 2010
  • OpenGL 4.2 - August 2011
  • OpenGL 4.3 - August 2012
  • OpenGL 4.4 - July 2013
  • OpenGL 4.5 - August 2014
  • OpenGL 4.6 - July 31, 2017
37973 questions
110
votes
6 answers

Is OpenGL coordinate system left-handed or right-handed?

I am trying to understand the OpenGL coordinate system. However, some tutorials say the default coordinate system is left handed (see http://www.c-sharpcorner.com/UploadFile/jeradus/OpenGLBasics11172005014307AM/OpenGLBasics.aspx) and others say it…
341008
  • 9,862
  • 11
  • 52
  • 84
110
votes
1 answer

How to properly link libraries with cmake?

I can't get the additional libraries I am working with to link into my project properly. I am using CLion, which uses cmake to build it's projects. I am trying to use several libraries in conjunction with OpenGL to texture some objects. I initially…
Cache Staheli
  • 3,510
  • 7
  • 32
  • 51
109
votes
8 answers

How to make an OpenGL rendering context with transparent background?

Rendering contexts usually have a solid color on the background (black or whatever, see the image below): I'm wondering if it's possible to setup a window, with no decorations AND with the transparent background, while allowing me to render OpenGL…
karlphillip
  • 92,053
  • 36
  • 243
  • 426
109
votes
2 answers

Do conditional statements slow down shaders?

I want to know if "if-statements" inside shaders (vertex / fragment / pixel...) are really slowing down the shader performance. For example: Is it better to use this: vec3 output; output = input*enable + input2*(1-enable); instead of using…
Thomas
  • 2,093
  • 3
  • 21
  • 40
104
votes
13 answers

OpenGL ES versus OpenGL

What are the differences between OpenGL ES and OpenGL ?
kml_ckr
  • 2,211
  • 3
  • 22
  • 35
103
votes
3 answers

How to use glOrtho() in OpenGL?

I can't understand the usage of glOrtho. Can someone explain what it is used for? Is it used to set the range of x y and z coordinates limit? glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0); It means that the x, y and z range is from -1 to 1?
ufk
  • 30,912
  • 70
  • 235
  • 386
99
votes
5 answers

Confusion between C++ and OpenGL matrix order (row-major vs column-major)

I'm getting thoroughly confused over matrix definitions. I have a matrix class, which holds a float[16] which I assumed is row-major, based on the following observations: float matrixA[16] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15…
Mark Ingram
  • 71,849
  • 51
  • 176
  • 230
96
votes
2 answers

How does the fragment shader know what variable to use for the color of a pixel?

I see a lot of different fragment shaders, #version 130 out vec4 flatColor; void main(void) { flatColor = vec4(0.0,1.0,0.0,0.5); } And they all use a different variable for the "out color" (in this case flatColor). So how does OpenGL know…
mpen
  • 272,448
  • 266
  • 850
  • 1,236
96
votes
4 answers

How does OpenGL work at the lowest level?

I understand how to write OpenGL/DirectX programs, and I know the maths and the conceptual stuff behind it, but I'm curious how the GPU-CPU communication works on a low level. Say I've got an OpenGL program written in C that displays a triangle and…
Benno
  • 5,288
  • 5
  • 42
  • 60
95
votes
2 answers

glVertexAttribPointer clarification

Just want to make sure I understand this correctly (I'd ask on SO Chat, but it's dead in there!): We've got a Vertex Array, which we make "current" by binding it then we've got a Buffer, which we bind to a Target then we fill that Target via…
mpen
  • 272,448
  • 266
  • 850
  • 1,236
93
votes
2 answers

What does "immediate mode" mean in OpenGL?

What is "immediate mode"? Give a code example. When do I have to use immediate mode instead of retained mode? What are pros and cons of using each method?
Dmitriy
  • 5,357
  • 8
  • 45
  • 57
92
votes
11 answers

OpenGL vs. OpenCL, which to choose and why?

What features make OpenCL unique to choose over OpenGL with GLSL for calculations? Despite the graphic related terminology and inpractical datatypes, is there any real caveat to OpenGL? For example, parallel function evaluation can be done by…
dronus
  • 10,774
  • 8
  • 54
  • 80
88
votes
5 answers

What is the role of glBindVertexArrays vs glBindBuffer and what is their relationship?

I'm new to OpenGL and Graphics Programming. I've been reading a textbook which has been really thorough and well-written so far.However, I've hit a point in the code that I'm not quite understanding and I'd like to make sense of these lines before I…
DashAnimal
  • 935
  • 1
  • 7
  • 10
86
votes
4 answers

OpenGL VAO best practices

Im facing an issue which I believe to be VAO-dependant, but Im not sure.. I am not sure about the correct usage of a VAO, what I used to do during GL initialization was a simple glGenVertexArrays(1,&vao) followed by a glBindVertexArray(vao) and…
user815129
  • 2,236
  • 2
  • 20
  • 40
84
votes
2 answers

Creating a GLSL Arrays of Uniforms?

I would like to leave OpenGL's lights and make my own. I would like my shaders to allow for a variable number of lights. Can we declare an array of uniforms in GLSL shaders? If so, how would we set the values of those uniforms?
Miles
  • 1,858
  • 1
  • 21
  • 34