GLEW support to OpenGL 3.0

Does anyone know if GLEW plans to support OpenGL 3.0? And eventually when?

I’d be interested in GLee too, while we’re at it.

I suspect we’ll see something once all the dust settles.

Since both GLEW and GLEE give extension access across all platforms, they’re both probably waiting on the GLX and Apple GL3 extensions before upgrading.

Both GLEW and GLee seem kinda dead. Neither have been updated since last year.

I don’t think there have been any new extensions since last year, so no updates actually makes sense.

But they could be dead. It won’t matter if the SDK gets off the ground, it’ll come with an extension loader.

Glee shouldn’t be dead as long as there is a driver out that has support for the extensions. I contacted Ben with G80 extensions when it first came out and he made Glee 5.2 IIRC. Nvidia uses GLEW so I would expect that it will be updated. BTW why would they update either when the extensions been stagnate since G80 first came out… Plus Apple IIRC doesn’t need an extension loader Apple puts them in for you, unlike Windows.

Glee seems to support 2.1 just fine. My (cpp) project complained about missing libc… needed to add glee.c directly. Pretty darn nifty not needing to mess with the extension stuff (not that it’s all that difficult).

I tried to build glew fron the new spec files and stuff, but it created garbage :frowning:

Probably be a bit easier to deal with once those files are in xml format. Recent notes on the registry page seem to suggest this is forthcoming.

I thought about trying something like this, but those spec files look kinda scary… probably more trouble than it’s worth right now (unless someone else does it for you of course :-)).

Recent notes??

Do you mean “(Yes, these databases should be moved to a modern XML-based format. Patience.)” on http://www.opengl.org/registry ?

I may be wrong, but isn’t that announcement there for years now?

CatDog

Dunno… first I’ve noticed it.

Anyone got any news on this?

I made my own. It’s a perl script that translates the .spec files into a large header file with the function entry points. I can post it somewhere if anyone wants it, no support.

Well, I never turn down free software.

I made a sourceforge project glfuncsupport which I probably won’t maintain. It will take some business days to be allowed to post. Hopefully people can help fix this script up, add features, etc.

Here is the script:


#!/usr/bin/perl -w

# c.pl version 1.0 Sept 20, 2008
#
# public domain
#
# Put this file in the same directory as all the *.spec files
# outputs GlFunctions.h , a C++ class with the function pointers and proper defines
# outputs categories.txt, so when the compiler fails, you can ignore the category in the "ignoreCategories_tmp" hash
# an example would be an extension that is listed in the .spec file, but there's no gl*.h file that specifies it.
# GlExt.h, GlExt.cpp : uses GlFunctions.h
# You will need an uptodate glext.h file with Opengl 3.0 in the correct include location to use this.



use strict;

my %glTypes;
my $GLX = "glX";
my $GL = "gl";
my $WGL = "wgl";
my $OUTPUTFN = "GlFunctions.h";
my %glCategories;
my $CAT_POS = 0;
my $RET_POS = 1;
my $FUNC_POS = 2;
my $PARAM_POS = 3;

# -------------- **********NOTE ********* 
#any functions that are not in the gl.h files or you dont want to include them, put the category here, from categories.txt
my @ignoreCategories_tmp = ( 
#added my own assumed GL_ prefix.
# GL_ for gl.spec glext.spec
# GLX_ for glxext.spec glx.spec
# WGL_ for wglext.spec
# they should map to the *h files from the registry.
"GL_display-list" ,
"GL_drawing", 
"GL_drawing-control", 
"GL_feedback", 
"GL_framebuf", 
"GL_misc", 
"GL_modeling", 
"GL_pixel-op", 
"GL_pixel-rw", 
"GL_state-req", 
"GL_xform", 
"GL_1_1", 
"GLW_wgl", 
"GLX_glx", 
"GL_ARB_draw_instanced",
"GL_ARB_framebuffer_object",
"GL_ARB_geometry_shader4",
"GL_ARB_instanced_arrays",
"GL_ARB_map_buffer_range",
"GL_ARB_texture_buffer_object",
"GL_ARB_vertex_array_object",
"GL_EXT_transform_feedback",
"GL_NV_conditional_render",
"GLX_SGIX_dmbuffer",
"GLX_SGIX_video_source",
"GLX_VERSION_1_3",
"GLX_VERSION_1_4",
# linux doesnt support Opengl 3.0 yet
"GL_VERSION_3_0" 
);

my %ignoreCategories;
foreach my $el (@ignoreCategories_tmp)
{
	$ignoreCategories{$el} = 1;
	
}

sub grabTypes
{
	open (FILE, "gl.tm") or die("Cannot open gl.tm");
	while (<FILE>)
	{
		if (/^\s*#/) { next; }
		if (/^\s*$/) { next; }
		if (/^(\w+),\*,\*,\s*([\w\* ]+),\*,\*,?\s*$/)
		{
			$glTypes{"$1"} = "$2";
#	print "$1 $2
";
		}
		else
		{
			print "Error parsing: ". $_;
		}

	}
# hack for void
	$glTypes{"void"} = "void";

	close(FILE);
}

sub translateType
{
	my $t = $_[0];
	if (!defined($glTypes{"$t"}))
	{
#	print "Warning: undefined translation for $t, using it untranslated
";
		return "$t";
	}
#print "$t returning " .$glTypes{$t}. "
";
	return $glTypes{$t};

}

sub grabSpec
{
	my $filename = $_[0];
	my ($version_major, $version_minor) = split(/\./, $_[1]);
	open (FILE, $filename) or die("Cannot open $filename");
	my @glFunctions;
	my @varlist;
	my $currIndex = @glFunctions;
	my $inFunction = "";
	my $returnType;
	my $category;
	my $useit;
	while (<FILE>)
	{
		if ($inFunction eq "" )
		{
			if (/^\s*#/) { next; }
			if (/^\s*$/) { next; }
			if (/^passthru:\s*(.*)$/)
			{	
				next;
			}
			if (/^\w+:\w*$/) { next; }

			if (/^(\w+)\s*(.+)\)\s*$/)
			{
				$inFunction = "$1";
				next;
			}
		}
		else
		{
			if (/^\s+return\s+(.+)\s+$/)
			{
				$returnType = translateType("$1");
				next;
			}

			if (/^\s+category\s+(.+)\s+$/)
			{
				$category = translateType("$1");
				next;
			}


			if (/^\s+param\s+(\w+)\s+(\w+)\s+(in|out)\s+(value|array)/)
			{
				my $mid = "";
				if ($4 eq "array")
				{	
					$mid = "* ";
				}
				my $t = translateType("$2");
				push @varlist, "$t ${mid}$1";
				next;
			}
			if (/^\s+version\s*(\d+)\.(\d+)/)
			{
				if (($1 == $version_major && $2 >= $version_minor) || $1 >= $version_major)
				{
					$useit=1;
				}
				else
				{
					$useit=0;
				}
			}
			if (/^\s*$/)
			{
				if ($useit || !defined($useit))
				{
					push @{$glFunctions[$currIndex]} , "$category";
					push @{$glFunctions[$currIndex]} , "$returnType";
					push @{$glFunctions[$currIndex]} , "$inFunction";
					push @{$glFunctions[$currIndex]} , @varlist;
					$currIndex++;
				}
				$inFunction = "";
				undef $useit;
				undef @varlist;
				undef $returnType;
				undef $category;
				next;
			}
#print "ERROR parsing: " .$_;
		}
	}

	close (FILE);
	return @glFunctions;
}

sub functionPtr
{
	return  "PFN" . uc($_[0]) . "PROC";
}


sub outputFunctions
{
	my $prefix = $_[0];
	my $catprefix = $_[1];
	my @glFunctions = @{ $_[2]};
	for (my $i=0; $i < @glFunctions; $i++)
	{
		if (defined($ignoreCategories{$catprefix.$glFunctions[$i][$CAT_POS]})) { next; }
		my $real = $prefix . $glFunctions[$i][$FUNC_POS];
		my $func = functionPtr(${real}); 
#print GLEXT "		typedef $glFunctions[$i][0] (*${func})(";
		print GLEXT "#ifdef $catprefix". $glFunctions[$i][$CAT_POS]. "
";
#for (my $x = $PARAM_POS; $x < @{$glFunctions[$i]}; $x++)
#		{
#			if ($x >$PARAM_POS)
#			{
#				print GLEXT ",";
#			}
#			print GLEXT $glFunctions[$i][$x];
#		}
#		print GLEXT ");
"; 

		print GLEXT "		$func _$real;
";
		print GLEXT "#define $real GlExt::current()->_$real
";
		print GLEXT "#endif
";
	}
}

open (GLEXT, ">$OUTPUTFN") or die("failed");


print GLEXT <<END;
#ifndef _GlFunctions_h
#define _GlFunctions_h


class GlFunctions
{
public:

END


grabTypes;


my @glF = grabSpec("gl.spec", "1.0");
outputFunctions($GL, "GL_", \@glF);

print GLEXT "
#ifndef _WIN32
";
my @glxF =  grabSpec("glxext.spec", "1.0");
outputFunctions($GLX, "GLX_", \@glxF);

my @wglF = grabSpec("wglext.spec","1.0");
print GLEXT "
#else
";
outputFunctions($WGL, "WGL_", \@wglF);
print GLEXT "
#endif
";

print GLEXT <<END;

void * getAddress(const char * name)
{
#ifdef _WIN32
// prevent macro expansion
#undef wglGetProcAddress
	return (void*)wglGetProcAddress((LPCSTR)name);
#else
#undef glXGetProcAddress
	// GLX
	return (void*)glXGetProcAddress((const GLubyte *)name);
#endif
}

GlFunctions()
{

END

sub setValues
{
	my $prefix = $_[0];
	my $catprefix = $_[1];
	my @glFunctions = @{ $_[2] };
	for (my $i=0; $i < @glFunctions; $i++)
	{
		if (defined($ignoreCategories{"$catprefix" . "$glFunctions[$i][$CAT_POS]"})) { next; }
		print GLEXT "#ifdef $catprefix".$glFunctions[$i][$CAT_POS]."
";
		my $real = $prefix.$glFunctions[$i][$FUNC_POS];
		print GLEXT "		_$real = (" . functionPtr($real) . ") getAddress(\"$real\");
";
		print GLEXT "#endif
";
	}
}

setValues($GL, "GL_", \@glF);
print GLEXT "#ifndef _WIN32
";
setValues($GLX, "GLX_", \@glxF);
print GLEXT "#else
";
setValues($WGL, "WGL_", \@wglF);
print GLEXT "#endif
";



print GLEXT <<END;
	} // end GlFunctions()

}; // end class

#endif

END



close(GLEXT);



sub cate
{	
	my $prefix = $_[0];
	my @glF = @{$_[1]};
	for (my $i=0; $i < @glF; $i++)
	{
		my $real = uc("PFN".$prefix.$glF[$i][$FUNC_POS]."PROC");
		print FILE "$real ${prefix}_"."$glF[$i][$CAT_POS]
";
	}
}

#write out quick map
open (FILE, ">categories.txt") or die("could not open");
cate("GL", \@glF);
cate("GLX", \@glxF);
cate("WGL", \@wglF);
close FILE;


partial result: GlFunctions.h


#ifndef _GlFunctions_h
#define _GlFunctions_h


class GlFunctions
{
public:

#ifdef GL_VERSION_1_2
		PFNGLBLENDCOLORPROC _glBlendColor;
#define glBlendColor GlExt::current()->_glBlendColor
#endif
....

void * getAddress(const char * name)
{
#ifdef _WIN32
// prevent macro expansion
#undef wglGetProcAddress
	return (void*)wglGetProcAddress((LPCSTR)name);
#else
#undef glXGetProcAddress
	// GLX
	return (void*)glXGetProcAddress((const GLubyte *)name);
#endif
}

GlFunctions()
{

#ifdef GL_VERSION_1_2
		_glBlendColor = (PFNGLBLENDCOLORPROC) getAddress("glBlendColor");
#endif

Sample Glext.h


class GlExt
{
public:
	// need to call this to init
	static void init() { _i.reset(new GlFunctions()); }
	static GlFunctions * current() { assert(_i.get()); return _i.get(); }
public:
	static boost::thread_specific_ptr<GlFunctions>  _i;
};

GLEE is updated now for 3.0
http://elf-stone.com/glee.php

GLEW also

http://glew.sourceforge.net/