Sign in to follow this  

Help getting started with GLSL?

Recommended Posts

Chaosenemy    152
I'm trying to get a very simple vertex shader running but nothing seems to be happening. The shader loads, compiles, and links successfully - no errors. When I try to use it however, nothing renders. Here is my shader code:

void main(void)
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;

As far as I know, the above code should just render the vertex like usual, correct?
Here is my drawing code in the application itself:


glColor3f(0.0f, 1.0f, 0.0f);
glVertex3f(0.0f, -1.0f, -1.0f);
glVertex3f(0.0f, -1.0f, 1.0f);
glVertex3f(0.0f, 1.0f, 1.0f);
glVertex3f(0.0f, 1.0f, -1.0f);

If I comment out 'glUseProgram(programObject)' the quad renders just fine. Otherwise, nothing is rendered at all from what I can see anyways.

I know this is simple but I swear I've Googled the hell out of it and can't figure out what I'm doing wrong. Any help would be much appreciated. Thanks.

EDIT: Figured it out. Apparently if you don't specify a color in the shader source, it draws the vertex black. So I wasn't seeing it on my black background. D'oh!

Share this post

Link to post
Share on other sites
Nairou    430
If you really want to get into GLSL, you should learn with a newer version of OpenGL (3.1 or higher), as the old-school functions used in your post have been deprecated. Here is a tutorial I found easy to follow: [url=""][/url]

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this