You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: blog/2024/2024-11-01-my-screen-is-black/index.md
+59-33
Original file line number
Diff line number
Diff line change
@@ -23,14 +23,16 @@ Setup `glDebugMessageCallback` see [here](https://deccer.github.io/OpenGL-Gettin
23
23
24
24
If you use `glGetError` with or without macros like `GLCALL` or `GLCHECK` or rolled your own, get rid of it. `glDebugMessageCallback` will replace those. There is a high chance that you used it incorrectly anyway because you copy pasted it from some questionable source.
25
25
26
-
Make sure you check that shader compilation _and_ linking was successful. See `glGetShaderiv` & `glGetProgramiv` on compile and link status.
26
+
Make sure you check that shader compilation *and* linking was successful. See `glGetShaderiv` & `glGetProgramiv` on compile and link status.
27
27
28
28
### You are on a Mac
29
29
30
-
Seriously port your engine to `metal`, or `webgpu` at least. There is no support for `KHR_debug` and you cannot use anything > gl 4.1 is enough reason
30
+
Please port your engine to `metal` or `webgpu` at least, seriously. There is no support for `KHR_debug` and you cannot use anything > gl 4.1. That is enough reason
31
31
32
32
You are getting `UNSUPPORTED (log once): POSSIBLE ISSUE: unit 0 GLD_TEXTURE_INDEX_2D is unloadable and bound to sampler type (Float) - using zero texture because texture unloadable`. You need to call glGenerateMipmap(GL_TEXTURE_2D) after glTexImage2D() or set max level to 0 if you dont need/want mips.
33
33
34
+
If you insist on using Mac, stay with OpenGL 3.3.
35
+
34
36
### RenderDoc is crashing when trying to run your application
35
37
36
38
This is most likely **not** RenderDoc's fault, but yours. Something in your code is fishy and RenderDoc doesnt like it. Use a debugger/code-sanitizer to figure out
@@ -72,44 +74,55 @@ You most likely have no indexbuffer is bound. Or it is not associated to/with th
72
74
You probably want to draw more primitives than you have in your vertexbuffer, check arguments of your `glDrawArrays` call.
73
75
Potentially you might not have set the vertex count variable and that contains an ununitialized value because you used c/c++ and are a doofus.
74
76
75
-
### Textures are black
77
+
### Textures/Triangles are black
78
+
79
+
Did you forget to bind the texture in question?
80
+
81
+
When you are not using `glXXXTextureStorage` but not good and old `glTexImageXX` make sure the texture is complete.
82
+
**Check** with **OpenGL Specification** what completeness entails.
83
+
84
+
If it was not complete it should have told you about it in the debug callback. **Shame on you** if you still have not set it up.
76
85
77
-
- no textures bound
78
-
- are your textures complete? if not should produce an output in debug callback, so, go check that (hmm this might not be the case for glXXXTextureStorage i might take this one off the list)
79
-
- no samplers bound (check your sampler objects if you use them as separate objects)
80
-
- fucked uvs
81
-
- you might be sampling from a corner of your texture where its actually black, check uvs
86
+
You might be using sampler objects. Make sure you bind one.
82
87
83
-
### Your Triangle is black
88
+
You might be sampling from a corner of your texture where its actually black, Check your UVs.
84
89
85
-
- smells like your vao is fucked. make sure you setup the attributes (and stride when binding le vbo using DSA)
86
-
- fucked uvs?
87
-
- forgot to bind a texture?
90
+
Another very likely reason is you didn't understand VAOs and copy pastaed it from learnopengl and added your own twist to it.
91
+
Check that your VAO setup is correct. Make sure stride, offset is set correctly. And if you are using multiple vertexbuffers for all your attributes, make sure
92
+
they are bound properly.
93
+
94
+
You tried to use vertex colors, but you didn't setup the VAO properly.
95
+
Vertex colors might just be black. If it wasn't intentional, check the contents of your VBO.
88
96
89
97
### Screen is Black
90
98
91
-
-check if your screen is on/connected properly
92
-
-camera (projection/view matrices are fucked) is not looking at the scene in question
93
-
-no texture is sampled due to missing or wrong uvs => default value is 0 aka black (depends on the driver)
94
-
-no shader bound (especially fragment shader)
95
-
-fragment shader doesnt write anything to its output
96
-
-no viewport is set/is too small
97
-
- you might be rendering to a framebuffer, but not blitting that framebuffer to the default one
98
-
-let clearcolor be something else than pure black
99
-
- are you doing MRT?
100
-
- if yes, check that you called the right `gl(Named)DrawBuffers` and not n times `gl(Named)DrawBuffer`one per render target
101
-
- are you playing with depthprepass-isms?
102
-
- make sure the gl state between passes is the same, face winding, cullmode, etc, see Appending A.3 in the gl spec for more clues
99
+
-Check if your screen is on/connected properly
100
+
-Camera (projection/view matrices are fucked) is not looking at the scene in question
101
+
-No texture is sampled due to missing or wrong uvs => default value is 0 aka black (depends on the driver)
102
+
-No shader bound (especially fragment shader)
103
+
-Fragment shader doesnt write anything to its output
104
+
-No viewport is set/is too small
105
+
- you might be rendering to a framebuffer, but not blitting that framebuffer to the default one or using it in a way to see its contents.
106
+
-Let clearcolor be something else than pure black
107
+
- are you rendering to multiple render targets?
108
+
- if yes, check that you called the right `gl(Named)DrawBuffers`. Check that you didnt call `gl(Named)DrawBuffer`once per render target.
109
+
- are you playing with depth-pre-pass-isms?
110
+
- make sure the gl state between passes is the same, face winding, cullmode, etc. See Appending A.3 in the gl spec for more clues about invariance.
103
111
- check winding order and cullmode, you might be looking at the wrong side of your faces
104
-
- you check renderdoc and wonder why the vertex list contains the same (perhaps even first element) only, for all vertices => make sure your `glDrawElements(..., ..., GL_UNSIGNED_INT, ...)` or whatever datatype your indexbuffer consists of matches that parameter
112
+
- you check renderdoc and wonder why the vertex list contains the same (perhaps even first element) only, for all vertices. Make sure your `glDrawElements(..., ..., GL_UNSIGNED_INT, ...)` or whatever datatype your indexbuffer consists of matches that parameter
113
+
114
+
All these things can be checked with a graphics debugger of your choice.
105
115
106
116
### Textures look funny, like a garbled version of the actual image
107
117
108
-
- make sure your internalformat and actual pixel format match. You probably used stb_image to load, but used 0 as the last parameter,
109
-
and pixel data has 3 components, instead of the 4 (GL_RGBA) you told OpenGL about -> request 4 channels from stb_image
118
+
Make sure your internalformat and actual pixel format match.
119
+
You probably used stb_image to load, but used 0 as the last parameter, and pixel data has 3 components, instead of the 4 (GL_RGBA) you told OpenGL about.
120
+
Request 4 channels from stb_image. There is almost never a reason to request 3 or less channels for color bearing pixelmaps.
110
121
111
122
### Textures look like one color component is more prominent than others
112
123
124
+
Happens when you are used to DirectXisms.
125
+
113
126
- Colors are more shifted towards blue
114
127
115
128
- You probably messed up the format and asked for GL_BRG.. of sorts => make sure they match
@@ -118,23 +131,36 @@ Potentially you might not have set the vertex count variable and that contains a
118
131
119
132
- Original pixeldata was probably in BGR... but you asked for GL_RGB... of sorts => make sure they match
120
133
121
-
### Textures seem to work, but mesh also appear to be shaded weirdly as if black Fog is on
134
+
### Textures seem to work, but the mesh also appears to be shaded weirdly as if its in some black fog
122
135
123
136
Did you generate mipmaps?
124
137
125
138
### Render artifacts like small missing tiles on a floor
126
139
127
-
- synchronization issues - perhaps a missing glMemoryBarrier at the right spot
128
-
- ubo/ssbo alignment issue - check std140/430 rule in the glsl spec
129
-
- binding multiple textures to the same slot - check your glBindTextureUnit calls
130
-
- you might be using a float to index into a buffer to grab material/texture info, use a flat int
140
+
VERY likely an alignment issue. **Check** the alignment rules in the **GLSL Specification**.
141
+
142
+
Other reasons could be that you are binding multiple textures to the same slot/unit. Check your `glBindTextureUnit` calls and if you are stuck in non DSA land,
143
+
check your `glBindTexture/glActiveTexture/glUniform1f` combinations.
144
+
145
+
Another classic is not using a flat index when indexing into material buffers or texture arrays.
146
+
147
+
```glsl
148
+
layout(location = n) flat int in v_material_index;
149
+
```
150
+
151
+
Synchronization issues could be yet another reason. Perhaps a missing `glMemoryBarrier` at the right spot.
131
152
132
153
### Depth buffer not cleared
133
154
134
155
- Despite calling `glClear(GL_DEPTH_BUFFER_BIT)` => check if `glDepthMask` was set to `GL_FALSE`. When you use FBOs migrate to glClearNamedFramebuffer() if you havent already (still requires glDepthMask set properly)
135
156
136
-
### Weird "Z-fighting"
157
+
### Weird "Z-Fighting"
137
158
138
159
- check your depth buffer, near and far planes... try near 0.1f and 512/1024 as farplane
139
160
- your depth buffer might be too small and is set to D16 only, set it to something D24 or D32
140
161
- you use SDL2 and on your platform the default might be set to D16, find the SDL2_GL_Set_Attribute which sets the depth bits for the default fbo
162
+
163
+
### PS
164
+
165
+
`RenderDoc` is not a profiler, the frametimes you see reported there are not really usable. Use an actual gpu profiler like `NSight Graphics`. I hear you complain already
166
+
that Version YYYY.XX doesnt support your potato GPU. NVidia provides downloads for older versions as well, you just dont get the latest bling features with it.
0 commit comments