Jump to content
  • Advertisement
Sign in to follow this  
transistor09

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

This topic is 3053 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'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);
PFNGLCREATESHADERPROC glCreateShader = NULL;

//later
glCreateShader = (PFNGLCREATESHADERPROC) wglGetProcAddress ("glCreateShader");
if (!glCreateShader) MessageBox (hwnd, TEXT("fail at glCreateShader"), L"ERROR", MB_OK | MB_ICONSTOP);

//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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
Share on other sites
Quote:
Original post by transistor09
So 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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites
Quote:
Original post by transistor09
Despite 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 this post


Link to post
Share on other sites
Quote:
Original post by swiftcoder
Quote:
Original post by transistor09
Despite 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 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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!