GLES20.glUseProgram(0);

I am using this shorthand code to get a blank screen that renders at 60fps on my tablet:

GLES20.glUseProgram(0);

I have not created a program 0.

I wonder if this will work on other devices? I don’t get any errors, and I wonder if program zero has a special meaning in OpenGL.

I am of course being lazy and should write a proper shader program…

According to the official docs, program 0 is an invalid program and the effect of glDraw* calls are undefined. It can be essentially treated as 0 = no program, but that is not wise to use in production at all.

You have to use glUseProgram(0) to turn off shaders, but yeah I wouldn’t recommend using it to just to get a blank screen.

@thedanisaur: given that there is no fixed function pipeline in OpenGL ES, why would you want to turn off shaders?

@ags1: you need at least one shader in your game to render anything at all, so why not use that one when ‘rendering’ a blank screen.

Silly me, I skipped over the fact that it was GLES. Regardless, shouldn’t you still call glUseProgram(0) when you’re finished drawing? Wouldn’t it be the same as calling glBindBuffer(GL.GL_ARRAY_BUFFER, 0), or am I mistaken?

Calling glBindBuffer(0) or glBindTexture(0) after you’re done is equally redundant.

OpenGL is a state machine, you set it up to make draw calls have the desired effect. There is no need to do a cleanup afterwards - you just make sure that the state is properly set again when doing the next draw call - whether it is in the same frame or not.

You should attempt to transition from state to state with minimal state changes, instead of tearing everything down when you’re done drawing, and then setting the state from scratch again.

@Riven, I have come to my senses and used a real shader. Shader Program Zero was just a random discovery when I loaded a program with an unititialized int handle.