Skip to main content
Share Your Experience: Take the 2024 Developer Survey

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
72 votes
6 answers
52k views

How can I debug GLSL shaders?

When writing non-trivial shaders (just as when writing any other piece of non-trivial code), people make mistakes.[citation needed] However, I can't just debug it like any other code - you can't just ...
Martin Ender's user avatar
  • 2,730
66 votes
10 answers
47k views

Should new graphics programmers be learning Vulkan instead of OpenGL? [closed]

From the wiki: "the Vulkan API was initially referred to as the 'next generation OpenGL initiative' by Khrono", and that it is "a grounds-up redesign effort to unify OpenGL and OpenGL ES into one ...
galois's user avatar
  • 895
28 votes
2 answers
20k views

What is fwidth and how does it work?

The OpenGL documentation states that fwidth returns the sum of the absolute value of derivatives in x and y. What does this mean in less mathematical terms, and is ...
ApoorvaJ's user avatar
  • 597
27 votes
2 answers
44k views

GLSL. Can someone explain why gl_FragCoord.xy / screenSize is performed and for what reason?

I'm new to shaders and know that you can color pixels with gl_FragColor but sometimes there is this thing: ...
idchlife's user avatar
  • 373
26 votes
1 answer
11k views

What does "st" mean in the context of OpenGL?

I've seen the term st come up a few times when looking at other OpenGL fragment shaders. However, I don't know what it stands for or what it's used for. Here's an ...
Edward Loveall's user avatar
18 votes
3 answers
6k views

How can I debug what is being rendered to a Frame Buffer Object in OpenGL?

I have a point cloud that is being rendered to the screen. Each point has its position and color as well as an ID. I was asked to render the IDs for each point to a texture so I created a FBO and ...
BRabbit27's user avatar
  • 969
18 votes
1 answer
8k views

What does "makeContextCurrent" do exactly?

I am pretty confused about that function. GLFW Context reference says as follow: This function makes the OpenGL or OpenGL ES context of the specified window current on the calling thread. A ...
Adrian's user avatar
  • 667
18 votes
2 answers
12k views

Cause of shadow acne

I know how shadow mapping works but I am not getting the cause of shadow acne! Can anyone tell me cause of shadow acne in a simple way and how is it related to depth map resolution?
videogamechef's user avatar
18 votes
2 answers
21k views

GL_STATIC_DRAW vs GL_DYNAMIC_DRAW vs GL_STREAM_DRAW: does it matter?

In OpenGL the buffer object functions (glBufferData, glBufferSubData, and probably a few others) have a parameter ...
Julien Guertault's user avatar
18 votes
1 answer
2k views

Is there any way to generate primitives in a geometry shader without any input geometry?

A few years ago I tried to implement this GPU Gem in OpenGL to generate 3D procedural terrain using Marching Cubes. The article suggests to implement Marching Cubes in a geometry shader to maximum ...
Martin Ender's user avatar
  • 2,730
16 votes
3 answers
6k views

What are some methods to render transparency in OpenGL

Alpha blending can be turned on to make surfaces transparent, like so: ...
jozxyqk's user avatar
  • 679
16 votes
2 answers
14k views

How to implement a trackball in OpenGL?

After so much reading about transformations it is time to implement a trackball for my app. I understand I have to create a vector from the origin to where the mouse is clicked and then another from ...
BRabbit27's user avatar
  • 969
15 votes
1 answer
2k views

When to disable perspective correct interpolation ( noperspective )

In GLSL, perspective correct interpolation of vertex attributes is the default setting - one can disable it for specific vertex attributes by using the noperspective qualifier. Other than in post-...
gemse's user avatar
  • 253
15 votes
1 answer
3k views

Synchronizing successive OpenGL Compute Shader invocations

I have a couple of compute shaders that need to be executed in a certain order and whose outputs depend on previous inputs. Ideally, I'll never need to copy a buffer client-side and do all of my work ...
Mokosha's user avatar
  • 1,144
15 votes
1 answer
3k views

OpenGL compatibility, naming conventions and ARB vs EXT

I thought I had formed a general understanding of how OpenGL naming conventions and extensions worked, until I stumbled upon a case that confused me. Here's my understanding so far: No suffix -- e.g....
ApoorvaJ's user avatar
  • 597
14 votes
1 answer
5k views

Do I need to rebind uniforms or attributes when changing shader programs?

Rendering the scene usually involves more than one shader program which, in my case, all use the same attributes and share at least some of the uniforms. To have them working properly, I currently ...
Nero's user avatar
  • 1,320
14 votes
2 answers
4k views

Derivative maps vs. Tangent Space Normal maps

I discovered that some engines use derivative maps instead of tangent space normal maps. After some reading, it seems to be a really awesome way to replace tangent space normals but are there some ...
MaT's user avatar
  • 1,229
13 votes
1 answer
20k views

OpenGL GLSL - Sobel Edge Detection Filter

With respect to this topic I've successfully implemented the Sobel Edge Detection filter in GLSL. Here is the fragment shader code of the filter: ...
enne87's user avatar
  • 601
13 votes
1 answer
7k views

Loop performance in a shader

I am wondering what's the best way to integrate a dynamic loop function in a shader? First, it seems that dynamic arrays are not possible. So, is it better to create a maximum size array and only ...
MaT's user avatar
  • 1,229
12 votes
3 answers
18k views

Dynamic Array in GLSL

Is it possible to have a dynamic array in a GLSL shader? For instance, what if I have something like this in my GLSL Shader: ...
Archmede's user avatar
  • 491
12 votes
2 answers
11k views

OpenGL - Detection of edges

I'd like to load arbitrary meshes and draw thick black lines along the edges to get a toon-shading like look. I managed to draw a black silhouette around the objects by using the stencil buffer. You ...
enne87's user avatar
  • 601
12 votes
4 answers
2k views

Does it matter whether I learn OpenGL or Direct3D?

Are the differences between these two APIs minor implementation details that mean once I have learned one I can use it for everything? Or are there reasons for learning one rather than the other if I ...
trichoplax is on Codidact now's user avatar
12 votes
2 answers
863 views

Is it possible to find out how many fragments made it through the stencil test?

I have an OpenGL application which uses stencil tests quite extensively to render irregular shapes (a bit like a simple 2-D CSG). If I could find out how many fragments passed the stencil test and ...
Martin Ender's user avatar
  • 2,730
12 votes
1 answer
776 views

Is modifying a texture (painting on it) considered a "state change"?

The convention in graphics is that performing fewer state changes is better than performing more state changes (switching shaders, binding buffers, binding textures, etc.). For textures, it is faster ...
TheBuzzSaw's user avatar
12 votes
2 answers
39k views

Is there any reason to prefer Direct3D over OpenGL?

So I was reading this, I sort of got the reason why there are a lot more games on Microsoft windows than on any other OS. The main issue presented was that Direct3D is preferred over OpenGL. What I ...
user avatar
11 votes
4 answers
13k views

Multiple viewports with modern OpenGL?

I use SDL2. Currently my only shader has a MVP matrix, and transforms the points with it. I calculate my View and Projection matrix for a camera with GLM: ...
Tudvari's user avatar
  • 313
11 votes
1 answer
1k views

Why do adjacent triangles never overlap when rasterized?

Apologies for the following noob question, it's just I can't find a satisfactory answer anywhere... When I render a simple axis-aligned quad made up of two triangles, I don't understand why there's ...
Reuben Scratton's user avatar
11 votes
1 answer
354 views

Do the alignement and declaration order of uniforms matter?

In the section 6.4 Constant Buffers of the book Practical Rendering & Computation with Direct3D 11 (pages 325, 326) it is mentioned: By default, the HLSL compiler will attempt to align ...
Julien Guertault's user avatar
10 votes
3 answers
6k views

How to do texturing with OpenGL direct state access?

How do you use textures with direct state access in OpenGL? I have the following in my code, which seems to work: ...
LinAGKar's user avatar
  • 183
10 votes
1 answer
2k views

What is the modern equivalent of display lists?

Display lists were an OpenGL feature that could, in theory, accelerate any part of the API by storing a group of commands for later use. In my understanding, this makes a lot of sense with regards to ...
Julien Guertault's user avatar
10 votes
1 answer
2k views

Is it good practice to use all the available texture units?

When applying multiple textures to a mesh, like for bump-mapping, I usually bind the textures to the first few fixed texture units, e.g.: diffuse = unit 0, bump = unit 1, specular = unit 2, then keep ...
glampert's user avatar
  • 1,499
10 votes
1 answer
3k views

Screen capture of game video

I'd like to "hook" into a running game, say Mario Bros, and capture each frame rendered... saving that frame to an image file. A good example of something similar is FRAPS. --Note: I don't want to ...
pookie's user avatar
  • 269
10 votes
1 answer
550 views

What are sample gaps during scan conversion?

In this tutorial, It is very often the case that triangles are rendered that share edges. OpenGL offers a guarantee that, so long as the shared edge vertex positions are identical, there will be no ...
AlexWei's user avatar
  • 237
10 votes
1 answer
613 views

Creating shared vertex normals on GPU

I've mostly succeeded at porting an implementation of Marching Cubes from CPU over to OpenGL compute shaders, but I haven't tackled normals yet and wondering the best way to go about it. My ...
russ's user avatar
  • 2,392
10 votes
1 answer
2k views

Optimal memory access when using lookup tables on GPU?

I'm exploring isosurface algorithms on GPU for a bachelor's project (specifically concentrating on just binary in/out voxel data rather than real-valued fields). So I have a CPU implementation of good ...
russ's user avatar
  • 2,392
10 votes
1 answer
560 views

Rendering fog underneath water

I'm aware of glFog, which blends between the fog and surface colour based on distance to the camera, like this: The equations are even given in the docs. But the fog is applied immediately in front ...
jozxyqk's user avatar
  • 679
10 votes
1 answer
2k views

Is it possible to alpha blend multiple render targets using a specified alpha?

Say I have render targets 0 through N and RT 0 happens to have in its fourth component an alpha channel specified by a material or mask or something. Is it possible to have the hardware compositor ...
jeremyong's user avatar
  • 267
10 votes
1 answer
234 views

Per Vertex Computation in OpenGL Tesselation

I try to implement a position based cloth simulation using hardware tesselation. This means I want to just upload a control quad to the graphics card and then use tesselation and geometry shading to ...
Dragonseel's user avatar
  • 1,810
9 votes
3 answers
16k views

Understanding VAO and VBO

I'm reading through Learn OpenGL to refresh the basic concepts as I haven't touched in quite some time. Specifically I still think I cannot quite understand the meaning of VAO and VBO, the book mainly ...
user8469759's user avatar
9 votes
1 answer
17k views

How to use GLSL texelFetch?

I have read the OpenGl documentation of texelFetch, which is: gvec4 texelFetch(gsampler2D sampler, ivec2 P, int lod). I know the first argument "sampler" is just a texture. But I am very confused ...
yuchen's user avatar
  • 475
9 votes
2 answers
300 views

When is it better to upload partial model matrices to the vertex shader?

As of now, when rendering my scene and while iterating through the scene graph, for each node its model matrix is calculated from the parent's model matrix and the scene node's pose. This is quite ...
Nero's user avatar
  • 1,320
9 votes
1 answer
2k views

Shadow Mapping artefacts

I've been playing around with shadow mapping in OpenGL using depth textures. The depth texture is fine and I can map it onto the scene but I have some strange artefacts on the back of the object: My ...
Blarglenarf's user avatar
9 votes
1 answer
3k views

OpenGL specular shading - Gradient banding issues

I use Phong shading as my lighting model. Nevertheless, the specular shading produces gradients in the light cone: Hopefully you can see the gradient starting from the lower left corner expanding ...
enne87's user avatar
  • 601
9 votes
1 answer
735 views

Why different result when change input order in GL_LINES?

Code: ...
zombielei's user avatar
  • 121
9 votes
1 answer
2k views

Are draw calls executed in parallel or sequentially or both?

This a follow up for a question I answered on GameDev SE. The question was simply Is glDrawArraysInstanced in OpenGL parallel when drawing those instances? My answer was in the lines of "the GPU ...
concept3d's user avatar
  • 243
9 votes
2 answers
10k views

Why do I need to inverse the orientation matrix of a camera to be able to translate it in the direction it is facing?

I've been going over some OpenGL learning resources and one of them is this article: Modern OpenGL 04 - Cameras, Vectors & Input in which the author presents an approach to building a ...
Mihai Bişog's user avatar
9 votes
1 answer
2k views

Writing to a compressed texture using a compute shader, with no extra copies

I'm trying to figure out what the best way is to generate an OpenGL texture using a compute shader. So far, I've read that pixel buffer objects are good for non-blocking CPU -> GPU transfers, and that ...
Mokosha's user avatar
  • 1,144
9 votes
2 answers
895 views

How to unproject quadrilateral into rectangle?

tl;dr: Math problem in projective geometry: How does one find some 4x4 camera matrix that gives a projection as illustrated below, such that points A,B,C,D are somewhere on the edges of the unit box (...
ninjagecko's user avatar
8 votes
3 answers
15k views

How to do error handling with OpenGL?

Whenever I make semantic or syntax errors in OpenGL, either I get a black screen or the program crashes. I looked up on internet on how to do error handling in OpenGL and in the documentations I found ...
user8277998's user avatar
8 votes
2 answers
4k views

Uses for Stencil Buffer

I've been doing OpenGL tutorials using LearnOpenGL. Currently I'm reading about Stencil Buffers and in his example he uses a Stencil Buffer to draw an outline around an object. I've also read that it ...
Archmede's user avatar
  • 491

1
2 3 4 5
15