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.
38,086
questions
284
votes
3
answers
14k
views
Once upon a time, when > was faster than < ... Wait, what?
I am reading an awesome OpenGL tutorial. It's really great, trust me. The topic I am currently at is Z-buffer. Aside from explaining what's it all about, the author mentions that we can perform custom ...
245
votes
10
answers
168k
views
How do you render primitives as wireframes in OpenGL?
How do you render primitives as wireframes in OpenGL?
241
votes
13
answers
206k
views
How to debug a GLSL shader?
I need to debug a GLSL program but I don't know how to output intermediate result.
Is it possible to make some debug traces (like with printf) with GLSL without using external software like glslDevil?
208
votes
5
answers
82k
views
What is state-of-the-art for text rendering in OpenGL as of version 4.1? [closed]
There are already a number of questions about text rendering in OpenGL, such as:
How to do OpenGL live text-rendering for a GUI?
But mostly what is discussed is rendering textured quads using the ...
190
votes
17
answers
9k
views
How are 3D games so efficient? [closed]
There is something I have never understood. How can a great big PC game like GTA IV use 50% of my CPU and run at 60fps while a DX demo of a rotating Teapot @ 60fps uses a whopping 30% ?
179
votes
7
answers
308k
views
How to compile for Windows on Linux with gcc/g++?
I have written some effects in C++ (g++) using freeglut on Linux, and I compile them with
g++ -Wall -lglut part8.cpp -o part8
So I was wondering if it is possible to have g++ make static compiled ...
166
votes
5
answers
127k
views
Vertex shader vs Fragment Shader [duplicate]
I've read some tutorials regarding Cg, yet one thing is not quite clear to me.
What exactly is the difference between vertex and fragment shaders?
And for what situations is one better suited than the ...
165
votes
5
answers
100k
views
What is the correct file extension for GLSL shaders? [closed]
I'm learning glsl shading and I've come across different file formats. I've seen people giving their vertex and fragment shaders .vert and .frag extensions. But I've also seen .vsh and .fsh extensions,...
161
votes
2
answers
52k
views
What's the concept of and differences between Framebuffer and Renderbuffer in OpenGL?
I'm confused about concept of Framebuffer and Renderbuffer. I know that they're required to render, but I want to understand them before use.
I know some bitmap buffer is required to store the ...
152
votes
3
answers
46k
views
Differences and relationship between glActiveTexture and glBindTexture
From what I gather, glActiveTexture sets the active "texture unit". Each texture unit can have multiple texture targets (usually GL_TEXTURE_1D, 2D, 3D or CUBE_MAP).
If I understand correctly, you ...
146
votes
6
answers
99k
views
What does glLoadIdentity() do in OpenGL?
I'm new to OpenGL and I'm a little overwhelmed with all of the random functions that I have in my code. They work and I know when to use them, but I don't know why I need them or what they actually do....
146
votes
5
answers
86k
views
What are Vertex Array Objects?
I am just starting to learn OpenGL today from this tutorial: http://openglbook.com/the-book/
I got to chapter 2, where I draw a triangle, and I understand everything except VAOs (is this acronym OK?). ...
126
votes
9
answers
83k
views
opengl: glFlush() vs. glFinish()
I'm having trouble distinguishing the practical difference between calling glFlush() and glFinish().
The docs say that glFlush() and glFinish() will push all buffered operations to OpenGL so that one ...
125
votes
9
answers
182k
views
Using OpenGl with C#? [closed]
Is there free OpenGL support libraries for C#? If so, which one do I use and where do I find sample projects?
Does C# provide classes for OpenGL?
121
votes
2
answers
110k
views
The purpose of Model View Projection Matrix
For what purposes are we using Model View Projection Matrix?
Why do shaders require Model View Projection Matrix?
115
votes
1
answer
240k
views
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 ...
113
votes
2
answers
82k
views
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*...
110
votes
6
answers
76k
views
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/...
109
votes
8
answers
70k
views
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 ...
106
votes
13
answers
74k
views
OpenGL ES versus OpenGL [closed]
What are the differences between OpenGL ES and OpenGL ?
104
votes
3
answers
135k
views
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 ...
101
votes
5
answers
80k
views
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,...
97
votes
2
answers
41k
views
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&...
97
votes
4
answers
43k
views
How does OpenGL work at the lowest level? [closed]
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 ...
96
votes
11
answers
100k
views
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, ...
95
votes
2
answers
50k
views
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 ...
95
votes
2
answers
50k
views
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?
89
votes
5
answers
38k
views
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 ...
86
votes
4
answers
49k
views
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,&...
85
votes
10
answers
116k
views
Drawing Sphere in OpenGL without using gluSphere()?
Are there any tutorials out there that explain how I can draw a sphere in OpenGL without having to use gluSphere()?
Many of the 3D tutorials for OpenGL are just on cubes. I have searched but most of ...
85
votes
4
answers
48k
views
Passing a list of values to fragment shader
I want to send a list of values into a fragment shader. It is a possibly large (couple of thousand items long) list of single precision floats. The fragment shader needs random access to this list and ...
85
votes
2
answers
87k
views
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 ...
80
votes
3
answers
92k
views
Python - No handlers could be found for logger "OpenGL.error"
Okay, what is it, and why does it occur on Win2003 server, but not on WinXP.
It doesn't seem to affect my application at all, but I get this error message when I close the application. And it's ...
80
votes
7
answers
239k
views
How to get the GL library/headers?
#include <gl\gl.h>
#include <gl\glu.h>
#include <gl\glaux.h>
This is an example, but where to get GL headers?
73
votes
4
answers
153k
views
Understanding glm::lookAt()
I am following a tutorial to learn OpenGL in which they used glm::lookAt() function to build a view but I cannot understand the working of glm::lookAt() and apparently, there is no detailed ...
73
votes
3
answers
68k
views
What is so bad about GL_QUADS?
I hear that GL_QUADS are going to be removed in the OpenGL versions > 3.0, why is that? Will my old programs not work in the future then? I have benchmarked, and GL_TRIANGLES or GL_QUADS have no ...
70
votes
11
answers
47k
views
How to Practically Ship GLSL Shaders with your C++ Software
During OpenGL initialization, the program is supposed to do something like:
<Get Shader Source Code>
<Create Shader>
<Attach Source Code To Shader>
<Compile Shader>
Getting ...
70
votes
4
answers
119k
views
About OpenGL texture coordinates
I know that I must call one of the following before each call to glVertex:
glTexCoord(0,0);
glTexCoord(0,1);
glTexCoord(1,1);
glTexCoord(1,0);
But I have no idea what they mean. I know, however, ...
70
votes
5
answers
17k
views
Why does OpenGL use degrees instead of radians?
The OpenGL designers were never afraid of mathematics, and knowledge of linear algebra is essential for all but the simplest OpenGL applications. I think it can safely be assumed that OpenGL ...
69
votes
3
answers
57k
views
Getting the true z value from the depth buffer
Sampling from a depth buffer in a shader returns values between 0 and 1, as expected.
Given the near- and far- clip planes of the camera, how do I calculate the true z value at this point, i.e. the ...
68
votes
3
answers
60k
views
How does glDrawArrays know what to draw?
I am following some begginer OpenGL tutorials, and am a bit confused about this snippet of code:
glBindBuffer(GL_ARRAY_BUFFER, vertexBufferObject); //Bind GL_ARRAY_BUFFER to our handle
...
67
votes
5
answers
46k
views
Why transform normals with the transpose of the inverse of the modelview matrix?
I am working on some shaders, and I need to transform normals.
I read in few tutorials the way you transform normals is you multiply them with the transpose of the inverse of the modelview matrix. ...
67
votes
2
answers
36k
views
What is the difference between OpenCL and OpenGL's compute shader?
I know OpenCL gives control of the GPU's memory architecture and thus allows better optimization, but, leaving this aside, can we use Compute Shaders for vector operations (addition, multiplication, ...
65
votes
11
answers
43k
views
What is the best way to debug OpenGL? [closed]
I find that a lot of the time, OpenGL will show you it failed by not drawing anything. I'm trying to find ways to debug OpenGL programs, by inspecting the transformation matrix stack and so on. What ...
65
votes
2
answers
18k
views
Rendering meshes with multiple indices
I have some vertex data. Positions, normals, texture coordinates. I probably loaded it from a .obj file or some other format. Maybe I'm drawing a cube. But each piece of vertex data has its own index. ...
65
votes
2
answers
60k
views
Camera position in world coordinate from cv::solvePnP
I have a calibrated camera (intrinsic matrix and distortion coefficients) and I want to know the camera position knowing some 3d points and their corresponding points in the image (2d points).
I know ...
64
votes
11
answers
43k
views
Why use hexadecimal constants?
Sometimes I see Integer constants defined in hexadecimal, instead of decimal numbers. This is a small part I took from a GL10 class:
public static final int GL_STACK_UNDERFLOW = 0x0504;
public static ...
64
votes
1
answer
32k
views
set the texture for by glUniform1i
I have a question about how to set the texture by glUniform1i. I have seen code like below.
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texture0);
glUniform1i(_textureUniform, 0);
...
63
votes
3
answers
48k
views
What exactly does glEnableVertexAttribArray do?
I was reading: Dissecting Display, Chapter 1. Hello, Triangle!.
What exactly does glEnableVertexAttribArray do? I think it enables the use of a given VBO, but I am not sure.
I thought that is what ...
63
votes
6
answers
37k
views
Rendering SVG with OpenGL (and OpenGL ES)
I am currently investigating the possibility of rendering vector graphics from an SVG file using OpenGL and OpenGL ES. I intend to target Windows and Android. My ideal solution would be to have a ...