Jump to content
  • Advertisement
Sign in to follow this  
rotalever

OpenGL SDL + Opengl + CG

This topic is 4353 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

Hi, I want to use CG-Shading Language with SDL and OpenGL. I've downloaded the CG-Compiler (Linux-Version) and installed it. Sample programs run fine. But how can I use shaders in my own code which uses SDL? I've found only a few tutorials (like http://www.3ddrome.com/articles/cgshaders.php), but no one talks about SDL. Can anyone explain me howto do? Or is it impossible to use shaders in combination with SDL?

Share this post


Link to post
Share on other sites
Advertisement
CG and Shaders have NOTHING to do with SDL. just setup cg like you can see in the examples and leave the sdl opengl window like it is.

Share this post


Link to post
Share on other sites
shader.c: In function ‘get_proc_address’:
shader.c:14: warning: implicit declaration of function ‘glXGetProcAddress’
shader.c: In function ‘load_shader’:
shader.c:71: warning: implicit declaration of function ‘glGenProgramsARB’
shader.c:72: warning: implicit declaration of function ‘glBindProgramARB’
shader.c:73: warning: implicit declaration of function ‘glProgramStringARB’

I copied the shader loading functions from the tutorial into my code. I get those errors when compiling... The example itself compiles good, but it uses GLUT and I use SDL.
My Libs included:

#include <SDL/SDL.h>
#include <SDL/SDL_ttf.h>

#include <GL/gl.h>

#include <GL/glu.h>

#include <GL/glpng.h>

#include <stdlib.h>

#include <stdio.h>

#include <string.h>

#include <math.h>
#include <time.h>


Relevant gcc flags:
-lGL -lGLU -lglpng -lSDL -lSDL_ttf -lCgGL -lCg

So what to do? I've just copied some code from his tutorial to my code and it cannot compile. Which library do I have to add and which gcc flag?

Share this post


Link to post
Share on other sites
those funcs aint core GL (well they are now since gl2.0)
use a opengl extension librray to see up the extension entry points
eg glew (check the faq for others)

Share this post


Link to post
Share on other sites
Except for glXGetProcAddress - there you should use SDL_GL_GetProcAddress.

Share this post


Link to post
Share on other sites
Thanks for SDL_GL_GetProcAddress, that works.
But the other three *ARB functions do not work.
I've included glext.h which contains those functions as prototypes -> no effect, same error during compilation. What can I do now?
@zedzeek: I installed glew: Many errors during compilation and in the end gcc still prints "warning: implicit declaration of function...." Which faq do you mean?
The guy with the tutorial don't use those extions, just glut,glext,glx as "special" libs. And his code works.

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!