Voxel engine blank screen

I’m trying to write a voxel engine, and wrote a renderer for a chunk, but only a blank red screen (from glClearColor) is rendered. None of the OpenGL functions have any errors. The fragment shader sets gl_Fragcolor to green, so that it should be easily visible. I tried changing the camera angle, in case the chunk is behind the camera. The program still just shows a blank red screen. I know some parts of the code are inefficient, but I want to get it working for now. Can anyone give me a hint about what the problem is?

Link to code: https://github.com/io12/voxels

It might be due to the fact that you are using a GL 3 context while still using deprecated functionalities.

The simplest thing you could try is to create a simple GL 2 context.

It looks like my code used SDL_GL_SetAttribute to change to OpenGL 2.0 ES already, but it was after the context was created. I fixed it, and used SDL_GL_GetAttribute to make sure OpenGL 2.0 ES is actually being used, but the problem still exists and the window is still red. I tried to look for an OpenGL debugger, but most either didn’t work or didn’t work on Linux. What functionality was I using that was deprecated?

AFAIK, OpenGL ES 2.x does not allow deprecation at all. I am not sure but I highly believe that the OpenGL ES API should not declare any deprecated features from OpenGL… If your API provides functions like glPushMatrix, glBegin, glTranslate, glMaterial, glLight, don’t use them.

The other easy thing you can try is to create a simple “hello triangle” and sees if that work.

I got the triangle to appear, but whenever the Z coordinate for any vertex is greater than zero or less than -1, the triangle doesn’t appear.


For the Z issue, this is certainly normal, depending on your frustum. This might also be the reason why you could not see anything from your all voxel engine… Hard to say now. You should now go step by step, and also check any potential GL errors.

Okay, I got depth working, but now rotation of the camera rotates the triangle erratically.

I highly suggest you to have a deep look at an OpenGL tutorial, this one for example. Even if it focuses on GL instead of GL ES, the main things will remain the same. Don’t hesitate to play with them. Switch to a specific GL ES tutorial if needed.