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.

Filter by
Sorted by
Tagged with
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 ...
Armen Tsirunyan's user avatar
245 votes
10 answers
168k views

How do you render primitives as wireframes in OpenGL?

How do you render primitives as wireframes in OpenGL?
user avatar
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?
Franck Freiburger's user avatar
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 ...
Ben Voigt's user avatar
  • 281k
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% ?
jmasterx's user avatar
  • 53.4k
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 ...
Louise's user avatar
  • 6,463
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 ...
adivasile's user avatar
  • 2,427
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,...
Samssonart's user avatar
  • 3,523
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 ...
eonil's user avatar
  • 84.9k
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 ...
mpen's user avatar
  • 278k
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....
Alexander's user avatar
  • 3,047
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?). ...
Patrick's user avatar
  • 1,936
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 ...
jay.lee's user avatar
  • 19.6k
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?
MegaByte's user avatar
  • 6,795
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?
Yuriy Vikulov's user avatar
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 ...
Cache Staheli's user avatar
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*...
Thomas's user avatar
  • 2,153
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/...
341008's user avatar
  • 10k
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 ...
karlphillip's user avatar
  • 92.8k
106 votes
13 answers
74k views

OpenGL ES versus OpenGL [closed]

What are the differences between OpenGL ES and OpenGL ?
kml_ckr's user avatar
  • 2,231
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 ...
ufk's user avatar
  • 31.5k
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,...
Mark Ingram's user avatar
  • 72.8k
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&...
mpen's user avatar
  • 278k
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 ...
Benno's user avatar
  • 5,376
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, ...
dronus's user avatar
  • 11.1k
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 ...
mpen's user avatar
  • 278k
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?
Dmitriy's user avatar
  • 5,437
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 ...
DashAnimal's user avatar
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,&...
user815129's user avatar
  • 2,254
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 ...
Carven's user avatar
  • 15.3k
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 ...
Ville Krumlinde's user avatar
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 ...
Miles's user avatar
  • 1,868
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 ...
Paige Watson's user avatar
  • 1,218
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?
cdxf's user avatar
  • 5,559
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 ...
Cashif Ilyas's user avatar
  • 1,683
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 ...
Rookie's user avatar
  • 3,773
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 ...
Korchkidu's user avatar
  • 4,938
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, ...
mk.'s user avatar
  • 11.5k
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 ...
Thomas's user avatar
  • 179k
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 ...
Hannesh's user avatar
  • 7,398
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 ...
w4etwetewtwet's user avatar
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. ...
user1796942's user avatar
  • 3,358
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, ...
Maiss's user avatar
  • 1,661
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 ...
dreamlax's user avatar
  • 94.7k
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. ...
Nicol Bolas's user avatar
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 ...
nkint's user avatar
  • 11.7k
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 ...
user717572's user avatar
  • 3,636
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); ...
Yongwei Xing's user avatar
  • 13.2k
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 ...
LunchMarble's user avatar
  • 5,111
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 ...
Matt Esch's user avatar
  • 22.8k

1
2 3 4 5
762