GLEW alternative
ive been toying with GLEW for a while and many people have pointed out that its not OGL 2.0 compliant. can anyone suggest something similar to GLEW but is OGL 2.0?
The latest GLEW (1.3.3) is supposedly OpenGL 2.0 compliant. I haven't had any issues yet.
http://glew.sourceforge.net/
http://glew.sourceforge.net/
Really depends what you mean by "Opengl 2.0 compliant", if you mean "Does it support every single one of the ogl 2.0 extensions, maybe not, but until you need them, I think you should use GLEW
Mark
Mark
The way I use GLee is to include the .c file in the project and ensure i have the .h file somewhere in the header path, gets around having to worry about libs [smile]
ive been looking around for a different way to do shaders. if you have seen or read any of my last thread [link]http://www.gamedev.net/community/forums/topic.asp?topic_id=328736[/link] it would make sense to why i want to switch.
why not just load the extensions yourself the manual way? ...it is pretty basic todo, a little tedious i know but i personally prefer it that way,just load the extensions you know you are going to use. GLEW and GLEE just take all the fun out of it LOL
I looked through your other thread, so unless you don't want to use GLSL(or don't want to use the opengl functions to use it), I don't know what's wrong with GLEW (you can use GLee if you want, but I don't see what you need that GLEW lacks). The below is a working example (which lacks a lot error detection) of Using GLSL with GLEW (1.3.3) and it's using 2.0 interface to GLSL (so glCreateProgram instead of glCreateProgramObjectARB)
#include <SDL/SDL.h>#include <GL/glew.h> //replaces SDL_opengl.h#include <iostream>using namespace std;const int Width = 1280;const int Height = 1024;SDL_Surface *screen;bool done = false;GLUquadricObj *quadratic;GLuint programObject;const GLcharARB *vextexProgram="varying vec3 normal, lightDir;""void main()""{"" lightDir = normalize(vec3(gl_LightSource[0].position));"" normal = normalize(gl_NormalMatrix * gl_Normal);"" gl_Position = ftransform();""}";const GLcharARB* fragmentProgram="varying vec3 normal, lightDir;""void main()""{"" float intensity;"" vec3 n;"" vec4 color;"" n = normalize(normal);"" intensity = max(dot(lightDir,n),0.0); "" if (intensity > 0.98)"" color = vec4(0.8,0.8,0.8,1.0);"" else if (intensity > 0.5)"" color = vec4(0.4,0.4,0.8,1.0); "" else if (intensity > 0.25)"" color = vec4(0.2,0.2,0.4,1.0);"" else"" color = vec4(0.1,0.1,0.1,1.0);"" gl_FragColor = color;""}";void initWindow(){ SDL_Init(SDL_INIT_EVERYTHING); SDL_GL_SetAttribute(SDL_GL_RED_SIZE,8); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE,8); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE,8); SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE,8); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER,1); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE,24); screen = SDL_SetVideoMode(Width, Height, 32, SDL_OPENGL | SDL_HWSURFACE | SDL_FULLSCREEN); SDL_WM_SetCaption ("SDL+OpenGL+GLEW", NULL);}void initGL(){ glViewport(0, 0, Width,Height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45.0f,Width/Height,0.1f,1000.0f); glMatrixMode(GL_MODELVIEW); glClearColor(0.5f, 0.4f, 0.3f, 1.0); glEnable(GL_DEPTH_TEST); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); glEnable(GL_LIGHTING); float AmbientColor[] = { 0.0f, 0.1f, 0.2f, 0.0f }; glLightfv(GL_LIGHT0, GL_AMBIENT, AmbientColor); float DiffuseColor[] = { 1.0f, 1.0f, 1.0f, 1.0f }; glLightfv(GL_LIGHT0, GL_DIFFUSE, DiffuseColor); float SpecularColor[] = { 0.0f, 0.0f, 0.0f, 0.0f }; glLightfv(GL_LIGHT0, GL_SPECULAR, SpecularColor); float Position[] = { 100.0f, 100.0f, 100.0f, 1.0f }; glLightfv(GL_LIGHT0, GL_POSITION, Position); glEnable(GL_LIGHT0); quadratic=gluNewQuadric(); gluQuadricNormals(quadratic, GLU_SMOOTH);}void drawGL(){ static float xrot=0.0; static float yrot=0.0; xrot += 0.16; yrot += 0.12; glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glLoadIdentity( ); glTranslatef( 0.0f, 0.0f, -5.0f); glRotatef( xrot, 1.0f, 0.0f, 0.0f); glRotatef( yrot, 0.0f, 1.0f, 0.0f); //gluSphere(quadratic,1.3f,32,32); gluCylinder(quadratic,1.3f,0.6f,1.3f,256,256);}void processInput(){ SDL_Event event; while (SDL_PollEvent (&event)){ switch (event.type){ case SDL_KEYDOWN: switch (event.key.keysym.sym){ case SDLK_ESCAPE: done = true; break; default: break; } break; case SDL_QUIT: done = true; break; default: break; } } }void setupshader(){ GLuint vertexShader,fragmentShader; vertexShader=glCreateShader(GL_VERTEX_SHADER); fragmentShader=glCreateShader(GL_FRAGMENT_SHADER); glShaderSource(vertexShader, 1, &vextexProgram,NULL); glShaderSource(fragmentShader, 1, &fragmentProgram,NULL); glCompileShader(vertexShader); glCompileShader(fragmentShader); programObject = glCreateProgram(); glAttachShader(programObject,fragmentShader); glAttachShader(programObject,vertexShader); glLinkProgram(programObject); glUseProgram(programObject); }int main(int argc, char *argv[]){ initWindow(); initGL(); GLenum err = glewInit(); if (err != GLEW_OK) cout << reinterpret_cast<const char*>(glewGetErrorString(err)) << endl; if (!GLEW_VERSION_2_0){ cout << "Need OpenGL 2.0" << endl; exit(-1); } setupshader(); while (!done){ processInput(); drawGL(); SDL_GL_SwapBuffers(); } SDL_Quit();}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement