GLEW license

Hi

I apologize if it is not the appropriate forum ,but from information at glew website I didn’t understand…

Is GLEW free for commercial use?

Thanks

It takes just a few minutes to remove dependencies on GLEW.

Your main header file (i.e “common.h”) :


#define OPENGL_MACRO(proc,proctype) extern proctype proc
#define OPTIONAL_EXT(proc,proctype) extern proctype proc
#include "gl_extensions.h"

Your main.cpp:


#define OPENGL_MACRO(proc,proctype) proctype proc
#define OPTIONAL_EXT(proc,proctype) proctype proc
#include "gl_extensions.h"

static PROC uglGetProcAddress(const char* pName,bool IsOptional){
	PROC res = wglGetProcAddress(pName);
	if(res || IsOptional)return res;
	MessageBox(0,pName,"Missing OpenGL extention proc!",0);
	ExitProcess(0);
}

static void InitGLExtentions(){
	#define OPENGL_MACRO(proc,proctype) proc = (proctype)uglGetProcAddress(#proc,false)
	#define OPTIONAL_EXT(proc,proctype) proc = (proctype)uglGetProcAddress(#proc,true)
	#include "gl_extensions.h"
}

Example “gl_extensions.h” file:



OPENGL_MACRO(glCompressedTexImage2D,PFNGLCOMPRESSEDTEXIMAGE2DPROC);
OPENGL_MACRO(glGenerateMipmapEXT,PFNGLGENERATEMIPMAPEXTPROC);

OPENGL_MACRO(glGenBuffersARB,PFNGLGENBUFFERSARBPROC);
OPENGL_MACRO(glBindBufferARB,PFNGLBINDBUFFERARBPROC);
OPENGL_MACRO(glBufferDataARB,PFNGLBUFFERDATAARBPROC);
OPENGL_MACRO(glMapBufferARB,PFNGLMAPBUFFERARBPROC);
OPENGL_MACRO(glUnmapBufferARB,PFNGLUNMAPBUFFERARBPROC);
OPENGL_MACRO(glDeleteBuffersARB,PFNGLDELETEBUFFERSARBPROC);
OPENGL_MACRO(glGetBufferParameterivARB,PFNGLGETBUFFERPARAMETERIVARBPROC);


OPENGL_MACRO(glVertexAttribPointer,PFNGLVERTEXATTRIBPOINTERPROC);
OPENGL_MACRO(glEnableVertexAttribArray,PFNGLENABLEVERTEXATTRIBARRAYPROC);
OPENGL_MACRO(glDisableVertexAttribArray,PFNGLDISABLEVERTEXATTRIBARRAYPROC);


OPENGL_MACRO(glProgramStringARB,PFNGLPROGRAMSTRINGARBPROC);
OPENGL_MACRO(glGenProgramsARB,PFNGLGENPROGRAMSARBPROC);
OPENGL_MACRO(glBindProgramARB,PFNGLBINDPROGRAMARBPROC);
OPENGL_MACRO(glDeleteProgramsARB,PFNGLDELETEPROGRAMSARBPROC);
OPENGL_MACRO(glProgramLocalParameter4fARB,PFNGLPROGRAMLOCALPARAMETER4FARBPROC);
OPENGL_MACRO(glProgramLocalParameter4fvARB,PFNGLPROGRAMLOCALPARAMETER4FVARBPROC);
OPTIONAL_EXT(glProgramLocalParameters4fvEXT,PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC);


#undef OPENGL_MACRO
#undef OPTIONAL_EXT

Let’s see how to add access to another extension-proc. glDrawBuffers, for instance.

add the line:
OPENGL(glDrawBuffers,glDrawBuffers);
around the second parameter, add the “PFN” prefix, and “PROC” suffix. Mark the whole word, and convert to uppercase (Ctrl+Shift+U in VisualStudio). Done :slight_smile:

Is GLEW free for commercial use?

Yep. See license.txt in the source distribution for details.

Btw, it looks like donations are accepted :wink:

Thanks ,modus

Ilian ,thanks for the helpful piece. I will definitely
use this option for one of next releases and get rid of GLEW , but meantime it saved me time writing some code since I’m using many extensions