Jump to content
  • Advertisement
Sign in to follow this  
rm2000

OpenGL Beginning to work with GLSL

This topic is 4212 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I want to begin working with GLSL to create object shaders. I started at Lighthouse3D Tutorials, downloading the GLSL ARB Extensions Syntax VC code, which compiles fine. http://www.lighthouse3d.com/opengl/glsl/index.php?minimal There are two lines: vs = textFileRead("minimal.vert"); fs = textFileRead("minimal.frag"); which appears to attach the vertex and fragment shaders to the rendered model in the Visual Studio project. As I began testing, I downloaded TyphoonLabs Shader Designer and opened, modified a basic lighting shader. I noticed the Shader Designer also had several other predesigned shader projects, with vert and frag files. However, if I just change the text file parsing to read the sample files (i.e. vs = textFileRead("stripes.vert");) it doesn't work -- the model stays a single, black entity. The Shader Designer syntax looks pretty straight-forward, but how can I get this implemented into a Visual Studio OpenGL project?

Share this post


Link to post
Share on other sites
Advertisement
There's something you should take into account when programming with GLSL, for example the function glShaderSource takes as input the actual shader code as a C-string (i.e. null terminated).

Perhaps the textFileRead() function in Lighthouse3D tutorial is reading the file in some different way.

Share this post


Link to post
Share on other sites
I'd use ATI's RenderMonkey rather than Shader Designer - much better - got me started on GLSL in a few hours :)

Share this post


Link to post
Share on other sites
Thank you for your help so far.

I downloaded RenderMonkey, put a model in and added some effects. I then pulled up the vert and frag code windows, copied and pasted the code into .frag and .vert files and tried again. Still no luck. I tried opening the lighthouse code and using these files and the teapot still shows up all black, and I thought it would have my texture, lighting effects in RenderMonkey.

I understand how to load 3ds files, models, etc. using OpenGL and I think I understand how these editors work. But I am missing the connection between the two, it seems.

and didn't know if anyone want to take a look. I'm either (a) not exporting the shader information correctly or (b) not understanding how lighthouse loads a shader and applies it to a model. Can't seem to find any RenderMonkey GLSL tutorial anywhere...

[Edited by - rm2000 on March 12, 2007 11:24:42 AM]

Share this post


Link to post
Share on other sites
You are not passing the "uniform" and "varying" variables to the shader.

I'm pretty sure lighthouse3D explains what they are and how to use them.

Share this post


Link to post
Share on other sites
Thank you GamerYZ that seemed to be the problem.

An additional question if I may, I'm trying to get this to compile (now) using Code:Blocks (MINGW) instead of Visual Studio. I keep getting linker errors:

i.e.

undefined reference to '_imp____glewCreateShaderObjectARB'
undefined reference to '_imp____glewCreateShaderObjectARB'
undefined reference to '_imp____glewCreateShaderObjectARB'
undefined reference to '_imp____glewShaderSourceARB'

...etc...etc

I have included glew.h and glut.h into the file as an include and I have set my link libraries to:

libopengl32.a
libwinmm.a
libglu32.a
libglut.a
libglu32.a
glew32s.lib
glew32.lib

glew32.dll has been copied to %SYSROOT% and to the codeblocks lib folder

(I use some of the other libraries for other parts of my code). Am I missing anything else?

Thanks again

Share this post


Link to post
Share on other sites
Are you initializing glew and making sure glew knows where the functions are (if i remember correctly the glew documentation goes into detail on getting entry points to the correct functions);

Share this post


Link to post
Share on other sites
Everything, code-wise, seems to be okay. The same project builds fine under Visual Studio. I did notice the glew lib extensions are .lib where the ones for codeblocks are .a.

Share this post


Link to post
Share on other sites
Setting up the extensions isn't at all hard to do manually - I'd try it yourself rather than using GLEW, and then you know exactly what's going on rather than relying on the GLEW 'magic'.

Share this post


Link to post
Share on other sites
Maybe I'll try giving that a shot. Any good sites for reference? I was able to finally get it to build by attaching the glew32.dll file (not the library). It doesn't make a whole lot of sense to me why the dll worked.

If I may continue the conversation further, do I need to use GLUT to use these extensions? I was able to set up a window using GLUT and such, but if I draw a Window and use just OpenGL I get the no GLSL support on the following:

glewInit();

if (GLEW_ARB_vertex_shader && GLEW_ARB_fragment_shader)

Much thanks.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!