OpenGL Shaders 101

Started by
6 comments, last by V-man 15 years, 2 months ago
Hi, I'm currently using a fixed-pipeline for my OpenGL projects. I stopped programming as a hobby a good few years back (2000/2001) and my word, things have changed! I REALLY want to get into the bowels of my videocard and use vertex shaders but I am really unsure how to go about this... I've read lots of articles but they all seem to rely on some nVidia CGL thing which I have absolutely no idea what this is (propriety?). I would be most grateful if someone could give me the lowdown of what I need to install and what I need to setup to use shaders in OGL. DX seesm to do this transparently via the usual API calls... is this an edge that X has over OGL? will I have to use proprietary extension that tie me down to one manufacturer? My video card supports OGL 1.4 Thanks in advance and please be kind about my ignorance on the topic :D
Advertisement
http://www.lighthouse3d.com/opengl/glsl/index.php?intro

here You have some grate and quite simple info to start coding in opengl using shaders.

As far as I know You need to have at least opengl 1.5 or better - opengl 2.0 gfx card to support shaders.

Se my programming blog: Code and Graphics

Thanks for the reply.

Sorry, my bad, my card supports OGL 1.5 :D I have a final major project for uni coming up in a few weeks... I'm used to multitexturing with fixed pipeline, in ur experience would it be worth detouring to learn shaders? I am under the impression they are far more flexible than the fixed p method, but would the learning curve be too steep (and thus stick to waht I know)?

again, thanks for the advice :D

edit: I have 1.5 compiance but the Lighthouse page says I need the GL_ARB_fragment_shader extension which, according to OpenGL Extension Viewer 3.0 is an OpenGL 2.0 extension, unless I'm missing something?
You need GL 2.0 to have GLSL support
Also, read this
http://www.opengl.org/wiki/Common_Mistakes#Extensions_and_OpenGL_Versions
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
hmm... intersting! I found this document: http://mindfuck.de-brauwer.be/articles/shader/index.php

Furthermore, my card supports the following extensions:

GL_ARB_vertex_program
GL_ARB_fragment_program

In this thread (http://www.gamedev.net/community/forums/topic.asp?topic_id=514368), the following dialogue takes place:

Quote:ok, so i found that the intel GMA 950 supports

GL_ARB_fragment_program
GL_ARB_vertex_program

but not

GL_ARB_shader_objects
GL_ARB_shading_language_100

does that make sense? what are they two above good for if you cant make shaders without the two below?

thanks!



Quote:GL_ARB_vertex/fragment_program is different from GL_ARB_vertex/fragment_shader. The first one is a separate, and old, shader interface. Second one is the newer you use with GL_ARB_shader_objects.


Quote:ah i see the difference now. thanks brother bob.

so how is it possible to get a GLSL shader running with those two extensions only?


Quote:Cg can compile GLSL code to those assembly forms (GL_ARB_fragment_program, GL_ARB_vertex_program)


Is this information correct?
http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=231684
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
thanks for the info!

I managed to get shaders working and the setup was actually relatively painless! I am eagerly looking forward to multitexturing in this manner as it appears much more simple this way than the vintage FP approach :D
I have added this just for you
http://www.opengl.org/wiki/Shading_languages:_Which_shading_language_should_I_use%3F

at the bottom, "Intel, S3".
Have fun with your Intel.
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

This topic is closed to new replies.

Advertisement