# Is GLEW necessary to use shaders? [solved: NOT necessary]

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

## Recommended Posts

I've been able to use shaders with GLEW but now I'm trying to wglGetProcAddress manually. It doesn't leave empty pointers but doesn't work either. I define the funtions
typedef GLuint (APIENTRY * PFNGLCREATESHADERPROC) (GLenum type);

//later

//finally
vert = glCreateShader (GL_VERTEX_SHADER);
Same with glShaderSource, glCompileShader, glCreateProgram, glAttachShader, glLinkProgram, glUseProgram. No warnings, no errors, no hangs, just the same old fixed function. So is GLEW (or any other lib for that matter) necessary or am I missing something? [Edited by - transistor09 on February 10, 2010 11:00:45 AM]

##### Share on other sites
Of course that GLEW, GLEE, or similar libs are not necessary to get pointers to GL functions. To skip extensive post, I suggest you to take a look at Introduction to OpenGL 3.2 - Tutorial 01

##### Share on other sites
My code seems to be doing the same damn thing; no cookie though.
FILE * sourceFile = fopen ("shaders/vert", "rb");fseek (sourceFile, 0, SEEK_END);unsigned long size = ftell (sourceFile);rewind (sourceFile);char * source = (char *) malloc (size + 1);size = fread (source, 1, sizeof (char), sourceFile);source[size] = 0;vert = glCreateShader (GL_VERTEX_SHADER);glShaderSource (vert, 1, (const char **) &source, NULL);glCompileShader (vert);sourceFile = freopen ("shaders/frag", "rb", sourceFile);fseek (sourceFile, 0, SEEK_END);size = ftell (sourceFile);rewind (sourceFile);source = (char *) realloc (source, size + 1);size = fread (source, sizeof (char), size, sourceFile);source[size] = 0;frag = glCreateShader (GL_FRAGMENT_SHADER);glShaderSource (frag, 1, (const char **) &source, NULL);glCompileShader (frag);fclose (sourceFile);free (source);prog = glCreateProgram ();glAttachShader (prog, vert);glAttachShader (prog, frag);glLinkProgram (prog);GLint linked;glGetProgramiv (prog, GL_LINK_STATUS, &linked);if (linked) MessageBox (hwnd, TEXT("program liked"), L"message", MB_OK | MB_ICONSTOP);

I get no "program liked" message

##### Share on other sites
Quote:
 Original post by transistor09So is GLEW (or any other lib for that matter) necessary or am I missing something?
GLee/GLEW are not in any way necessary, but they exist to make your life easier. Unless you are working on a 4k intro, I see little point in putting yourself through the hell that is the OpenGL extensions mechanism.

##### Share on other sites
Quote:
 Original post by swiftcoder[...] Unless you are working on a 4k intro, I see little point in putting yourself through the hell that is the OpenGL extensions mechanism.

Is it really that hard?

I just don't know which lib is the best so I'm trying to do with no lib at all

##### Share on other sites
Quote:
Original post by transistor09
Quote:
 Original post by swiftcoder[...] Unless you are working on a 4k intro, I see little point in putting yourself through the hell that is the OpenGL extensions mechanism.
Is it really that hard?
It isn't hard at all - it is just pages and pages of boilerplate code that someone else has already written for you.
Quote:
 I just don't know which lib is the best so I'm trying to do with no lib at all
Take this argument to its conclusion, and you will wind up implementing your own OS because "I don't know whether Windows or Mac is better" [smile]

##### Share on other sites
Yeah, I'm not a guy that likes high-level too much. Despite that, have anything to recommend, swiftcoder?

##### Share on other sites
I like GLEW. It makes my program run 5 times faster. You have to call glewInit.

##### Share on other sites
Quote:
 Original post by transistor09Despite that, have anything to recommend, swiftcoder?
I never tried GLEW - GLee was simpler to install on a Mac back when I discovered it, so that is what I have used ever since. It is about zero hassle - compile it in or link to it, and include GLee.h instead of GL.h.

##### Share on other sites
Quote:
Original post by swiftcoder
Quote:
 Original post by transistor09Despite that, have anything to recommend, swiftcoder?
I never tried GLEW - GLee was simpler to install on a Mac back when I discovered it, so that is what I have used ever since. It is about zero hassle - compile it in or link to it, and include GLee.h instead of GL.h.

Just as a little aside, GLEW is now incredibly easy on the Mac. Download, run Make, put in /usr/local/lib and /usr/local/include respectively.

No fuss.

##### Share on other sites
http://www.gamedev.net/community/forums/topic.asp?topic_id=557319&whichpage=1�

##### Share on other sites
Oh, OK. Gonna stick with the GLEW; thanks everyone!

##### Share on other sites
Umm, scratch that, there was an error (you can clearly see it in my posted code) in my file loader. Everything works fine without GLEW.

For me, binding extensions is easier than converting a VC6 project to work with CodeBlocks.

##### Share on other sites
Quote:
 Original post by V-manI like GLEW. It makes my program run 5 times faster. You have to call glewInit.
Please tell me that's a joke. On the small chance you're serious... why so? Also, do you need to call the glewInit() function if you compile the GLEW files into your program (and thus not link it in)?

##### Share on other sites
Quote:
 Also, do you need to call the glewInit() function if you compile the GLEW files into your program (and thus not link it in)?

Yes. I bet its the function that GLEW uses to bind extensions. If you try to use any function before glewInit(), the program fails. [GL]Extensions are done differently than linking. You have to manually initialize the function pointer to it's prototype.

##### Share on other sites
Quote:
Original post by transistor09
Quote:
 Also, do you need to call the glewInit() function if you compile the GLEW files into your program (and thus not link it in)?

Yes. I bet its the function that GLEW uses to bind extensions. If you try to use any function before glewInit(), the program fails. [GL]Extensions are done differently than linking. You have to manually initialize the function pointer to it's prototype.
Correct. However, GLee handles this under the hood (unlike GLEW).

##### Share on other sites
Quote:
Original post by maxgpgpu
Quote:
 Original post by V-manI like GLEW. It makes my program run 5 times faster. You have to call glewInit.
Please tell me that's a joke. On the small chance you're serious... why so? Also, do you need to call the glewInit() function if you compile the GLEW files into your program (and thus not link it in)?

It was a joke. This thread seems kind of too boring for my taste.
Anyway, GLEW is the best.
GLEE, every time you call a gl function, GLEE checks to see if it has initialized. It might not have an effect on performance, but I prefer GLEW's way.

Have fun with GL!

##### Share on other sites
Quote:
 Original post by V-manThis thread seems kind of too boring for my taste.
Better than homework assignment solution request or illegible Engrish.