# How to use vertex and fragment shaders without using VBOs and VAOs?

Recently, I am trying to make a 3D game in LWJGL 2, not LWJGL 3, just because I am more familiar with LWJGL 2. Since LWJGL decided to shut down their legacy wiki website, I've been researching alot lately on adding shaders. The thing is, most of these tutorials use VBOs and VAOs to render objects.

I am trying to use vertex and fragment shaders to edit the objects. Yes, I am using the depreciated methods glBegin(); and those rendering methods to draw shapes. I am not sure if this affects the use of shaders or not, so that is why I am asking this question.

If anyone wants to know, I am using the depreciated methods because I don't want to really use VAOs and VBOs, I know it reduces performance to use the depreciated methods, but I am fine with this for now.

There's nothing special you need to do for this - shaders work just fine with glBegin/glEnd code.

You create and bind shaders in the normal way, set uniforms in the normal way. You still need to pay attention to the parts of the OpenGL pipeline that shaders replace, but that's the case no matter how you do your vertex submission.

For reading your vertex data in your vertex shader, you might find it easier to use the legacy built-in vertex attributes (https://www.opengl.org/sdk/docs/tutorials/ClockworkCoders/attributes.php) but if you wanted you could use standalone glVertexAttrib calls with glBegin/glEnd too.

• Ok, I used some code to load the vertex and fragment shaders, yet the colors are not passing through (the cube is just all white even though the color isn't) May 11 at 1:56
• Wait I got it working thank you for the link! May 11 at 2:00
• wait shaders aren't updating May 11 at 2:01
• @Pale_Gray - there are many reasons why this could be happening, and you'll need to post the code you use for updating uniforms in order to help us to help you. Also look at where you're making your glGetUniformLocation calls. May 11 at 9:33
• I am never using glGetUniformLocation at all... I guess that's why I can't update the color, but where should I even put it? Should I make a custom method called update in the shader program class? I'm calling glGetUniformLocation in the !Display.isCloseRequested. I think I don't need to get the variable every frame, so do I just make a method to bind the shader data and then call glUniform1f in the !Display.isCloseRequested code? May 11 at 11:19
GL20.glUniformXf(GL20.glGetUniformLocation(shader.getProgID(), variablename), a);
Where variablename is the name of your uniform variable in either shader file (vertes or fragment), where X is specified uniform (4, 2, 1, etc), and where a is the number you want to set it to (what the variable will equal to)