Sign in to follow this  
rotalever

OpenGL SDL + Opengl + CG

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
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
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

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