Commits

Jason McKesson committed e3900dc

GL Load finished and working on Windows.
Need to test on Linux and Code::Blocks.

Comments (0)

Files changed (6)

modules/StructGLLoad.lua

 
 local source_cpp_struct = 
 { type="group",
+	--includes
+	{ type="write", name="Includes(hFile, spec, options)", },
+	{ type="blank", },
+
+	{ type="block", name="ExternC(hFile, spec, options)",
+		{ type="ext-iter",
+			{ type="write", name="CExtVarDecl(hFile, extName, spec, options)"},
+		},
+		{ type="blank", },
+		{ type="ext-iter",
+			{ type="func-iter",
+				{ type="write", name="CFuncDecl(hFile, func, typemap, spec, options)"},
+			},
+		},
+		{ type="version-iter",
+			{ type="func-iter",
+				{ type="write", name="CFuncDecl(hFile, func, typemap, spec, options)"},
+			},
+		},
+		{ type="blank", },
+		{ type="write", name="CLoaderFunc(hFile, spec, options)", },
+		{ type="blank", },
+		{ type="write", name="CExtraFuncs(hFile, spec, options)", cond="version-iter"},
+		{ type="blank", cond="version-iter" },
+	},
+	{ type="blank", },
+	{ type="block", name="Definitions(hFile, spec, options)",
+		--define extension variables
+		{ type="block", name="ExtVariables(hFile, spec, options)",
+			{ type="ext-iter",
+				{ type="write", name="ExtVariable(hFile, extName, spec, options)"},
+			},
+		},
+		{ type="blank", },
+		
+		--define pointers
+		{ type="ext-iter",
+			{ type="func-iter",
+				{ type="write", name="FuncDef(hFile, func, typemap, spec, options)"},
+				{type="blank", last=true, },
+			},
+		},
+		
+		{ type="version-iter",
+			{ type="func-iter",
+				{ type="write", name="FuncDef(hFile, func, typemap, spec, options)"},
+				{type="blank", last=true, },
+			},
+		},
+		
+		--function to copy variables from C-version
+		{ type="block", name="CopyExtVariables(hFile, spec, options)",
+			{ type="ext-iter",
+				{ type="write", name="CopyExtVariable(hFile, extName, spec, options)"},
+			},
+		},
+		{ type="blank", },
+		
+		--function to copy pointers from C-version
+		{ type="block", name="CopyFunctionPtrs(hFile, spec, options)",
+			{ type="ext-iter",
+				{ type="func-iter",
+					{ type="write", name="CopyFunctionPtr(hFile, func, typemap, spec, options)"},
+				},
+			},
+			
+			{ type="version-iter",
+				{ type="func-iter",
+					{ type="write", name="CopyFunctionPtr(hFile, func, typemap, spec, options)"},
+				},
+			},
+		},
+		{ type="blank", },
+	},
+	--Loaders et. al.
+	{ type="block", name="SystemDefs(hFile, spec, options)",
+		{ type="write", name="MainLoader(hFile, specData, spec, options)", },
+		{ type="blank", },
+		{ type="write", name="MainExtraFuncs(hFile, specData, spec, options)", cond="version-iter" },
+	},
 }
 
 local my_struct =
 	},
 	
 	{ type="group", style="cpp",
+		{ type="file", name="GetFilename(basename, spec, options)", style="load_test",
+			{ type="block", name="IncludeGuard(hFile, spec, options)",
+				{ type="write", name="LoadTest(hFile, spec, options)", },
+			},
+		},
+
 		decl_header_struct,
 		
 		include_header_struct,

modules/Structure.lua

 - block: Represents a block. Must be in a file scope.
 -		name: Part of the function name to call. When starting the block, it will call "WriteBlockBegin"..name. To end it, it will call "WriteBlockEnd"..name. The default parameters are (hFile, spec, options).
 
-- group: Represents a collection of stuff. Has no particular semantics (though it can have conditionals and such.
+- group: Represents a collection of stuff. Has no particular semantics (though it can have conditionals and such).
 
 - write: Simply calls a given writing function. Must be in a file scope.
 -		name: Part of the function name to call. The complete function name is "Write"..name. The default parameters are (hFile, specData, spec, options).

modules/StyleGLLoad.lua

 local struct = require "StructGLLoad"
 local common = require "CommonStyle"
 local glload = require "glload_util"
-
+local glload_c = require "glload_util"
 
 local my_style
 
+
 ----------------------------------------------------------
 -- Type header.
 local type_hdr = {}
 end
 
 function source.WriteMainExtraFuncs(hFile, specData, spec, options)
-	hFile:writeblock[[
-int GetMajorVersion() { return g_majorVersion; }
-int GetMinorVersion() { return g_minorVersion; }
+	local output = [[
+int %<prefix>GetMajorVersion() { return g_majorVersion; }
+int %<prefix>GetMinorVersion() { return g_minorVersion; }
 
-int IsVersionGEQ( int testMajorVersion, int testMinorVersion )
+int %<prefix>IsVersionGEQ( int testMajorVersion, int testMinorVersion )
 {
 	if(g_majorVersion > testMajorVersion) return 1;
 	if(g_majorVersion < testMajorVersion) return 0;
 	return 0;
 }
 ]]
+
+	output = output:gsub("%%<prefix>", spec.DeclPrefix())
+	
+	hFile:writeblock(output)
 end
 
 ----------------------------------------------------------
 cpp.incl_hdr = util.DeepCopyTable(incl_hdr)
 cpp.load_hdr = util.DeepCopyTable(load_hdr)
 cpp.source = {}
+cpp.load_test = {}
 
 function cpp._init()
 	glload = glload.cpp
 end
 
 function cpp._exit()
-	glload = require "glload_util"
+	glload = glload_c
 end
 
+
+----------------------------------------------------------
+-- C++ header for LoadTest.
+
+function cpp.load_test.GetFilename(basename, spec, options)
+	local basename, dir = util.ParsePath(basename)
+	return dir .. glload.headerDirectory .. glload.GetLoadTestBasename(spec, options)
+end
+
+glload.CreateIncludeGuardWriters(cpp.load_test, "IncludeGuard", 
+	function(...) return glload.GetLoadTestFileIncludeGuard(...) end)
+
+function cpp.load_test.WriteLoadTest(hFile, spec, options)
+	glload.WriteNamespaceBegin(hFile, "glload")
+	hFile:writeblock(glload.LoadTestClassDef())
+	glload.WriteNamespaceEnd(hFile, "glload")
+end
+
+
+----------------------------------------------------------
+-- C++ header stuff.
 function cpp.ext_hdr.WriteBlockBeginExtern(hFile, spec, options)
+	hFile:fmt('#include "%s"\n', glload.GetLoadTestBasename(spec, options))
 	glload.WriteNamespaceBegin(hFile, spec.FuncNamePrefix())
 end
 
 
 function cpp.ext_hdr.WriteBlockBeginExtVariables(hFile, spec, options)
 	glload.WriteNamespaceBegin(hFile, "exts")
-	hFile:writeblock(glload.LoadTestClassDef())
-	hFile:write "\n"
 end
 
 function cpp.ext_hdr.WriteBlockEndExtVariables(hFile, spec, options)
 	glload.WriteNamespaceEnd(hFile)
 end
 
+function cpp.ext_hdr.WriteExtVariable(hFile, extName, spec, options)
+	hFile:fmt("extern glload::LoadTest %s;\n",
+		glload.GetExtVariableName(extName, spec, options))
+end
+
 function cpp.ext_hdr.FilterEnumsAllAtOnce() return true end
 cpp.ext_hdr.FilterEnumsPerExtInGroup = nil
 
 	hFile:write "};\n"
 end
 
-function cpp.ext_hdr.WriteEnumerator(hFile, enum, enumTable, spec, options)
-	local enumName = glload.GetCppEnumName(enum)
-	local lenEnum = #enumName
-	local numIndent = 33
-	
-	local numSpaces = numIndent - lenEnum
-	if(numSpaces < 1) then
-		numSpaces = 1
+function cpp.ext_hdr.WriteEnumerator(hFile, enum, enumTable, spec, options, enumSeen)
+	if(enumSeen[enum.name]) then
+		hFile:fmt("//%s taken from %s\n",
+			enum.name,
+			enumSeen[enum.name])
+	else
+		local enumName = glload.GetCppEnumName(enum)
+		local lenEnum = #enumName
+		local numIndent = 33
+		
+		local numSpaces = numIndent - lenEnum
+		if(numSpaces < 1) then
+			numSpaces = 1
+		end
+
+		hFile:fmt("%s%s= %s,\n",
+			enumName,
+			string.rep(" ", numSpaces),
+			common.ResolveEnumValue(enum, enumTable))
 	end
-
-	hFile:fmt("%s%s= %s,\n",
-		enumName,
-		string.rep(" ", numSpaces),
-		common.ResolveEnumValue(enum, enumTable))
 end
 
 function cpp.ext_hdr.WriteBlockBeginFuncTypedefs(hFile, spec, options)
 
 cpp.core_hdr.WriteBlockBeginEnumerators = cpp.ext_hdr.WriteBlockBeginEnumerators
 cpp.core_hdr.WriteBlockEndEnumerators = cpp.ext_hdr.WriteBlockEndEnumerators
-
-function cpp.core_hdr.WriteEnumerator(hFile, enum, enumTable, spec, options, enumSeen)
-	if(enumSeen[enum.name]) then
-		hFile:fmt("//%s taken from %s",
-			enum.name,
-			enumSeen[enum.name])
-	else
-		cpp.ext_hdr.WriteEnumerator(hFile, enum, enumTable, spec, options, enumSeen)
-	end
-end
+cpp.core_hdr.WriteEnumerator = cpp.ext_hdr.WriteEnumerator
 
 cpp.core_hdr.WriteBlockBeginFuncTypedefs = cpp.ext_hdr.WriteBlockBeginFuncTypedefs
 cpp.core_hdr.WriteBlockEndFuncTypedefs = cpp.ext_hdr.WriteBlockEndFuncTypedefs
 -- Source CPP file.
 function cpp.source.GetFilename(basename, spec, options)
 	local basename, dir = util.ParsePath(basename)
-	return dir .. glload.sourceDirectory .. spec.FilePrefix() .. "load.cpp"
+	return dir .. glload.sourceDirectory .. spec.FilePrefix() .. "load_cpp.cpp"
 end
 
 
+function cpp.source.WriteIncludes(hFile, spec, options)
+	hFile:writeblock([[
+#include <algorithm>
+#include <vector>
+#include <string.h>
+]])
+	hFile:fmt('#include "%s"\n', glload.includeDirectory .. 
+		glload.GetAllBasename(spec, options))
+	hFile:fmt('#include "%s"\n', glload.includeDirectory .. 
+		glload.GetLoaderBasename(spec, options))
+end
+
+function cpp.source.WriteBlockBeginExternC(hFile, spec, options)
+	hFile:writeblock(glload.GetBeginExternBlock())
+end
+
+function cpp.source.WriteBlockEndExternC(hFile, spec, options)
+	hFile:writeblock(glload.GetEndExternBlock())
+end
+
+function cpp.source.WriteCExtVarDecl(hFile, extName, spec, options)
+	hFile:fmt("extern int %s;\n",
+		glload_c.GetExtVariableName(extName, spec, options))
+end
+
+function cpp.source.WriteCFuncDecl(hFile, func, typemap, spec, options)
+	hFile:fmt("extern %s::%s::%s %s;\n",
+		spec.FuncNamePrefix(),
+		glload.GetFuncPtrTypedefNamespace(),
+		glload.GetFuncTypedefName(func, spec, options),
+		glload_c.GetFuncPtrName(func, spec, options))
+end
+
+function cpp.source.WriteCLoaderFunc(hFile, spec, options)
+	hFile:fmt("int %sLoadFunctions(%s);\n",
+		spec.DeclPrefix(),
+		spec.GetLoaderParams())
+end
+
+function cpp.source.WriteCExtraFuncs(hFile, spec, options)
+	hFile:fmtblock([[
+int %sGetMajorVersion();
+int %sGetMinorVersion();
+int %sIsVersionGEQ(int, int);
+]],
+		spec.DeclPrefix(), spec.DeclPrefix(), spec.DeclPrefix())
+
+end
+
+function cpp.source.WriteBlockBeginDefinitions(hFile, spec, options)
+	glload.WriteNamespaceBegin(hFile, spec.FuncNamePrefix())
+end
+
+function cpp.source.WriteBlockEndDefinitions(hFile, spec, options)
+	glload.WriteNamespaceEnd(hFile)
+end
+
+function cpp.source.WriteBlockBeginExtVariables(hFile, spec, options)
+	glload.WriteNamespaceBegin(hFile, "exts")
+end
+
+function cpp.source.WriteBlockEndExtVariables(hFile, spec, options)
+	glload.WriteNamespaceEnd(hFile)
+end
+
+function cpp.source.WriteExtVariable(hFile, extName, spec, options)
+	hFile:fmt("glload::LoadTest %s;\n",
+		glload.GetExtVariableName(extName, spec, options))
+end
+
+function cpp.source.WriteFuncDef(hFile, func, typemap, spec, options)
+	hFile:fmt("%s::%s %s = 0;\n",
+		glload.GetFuncPtrTypedefNamespace(),
+		glload.GetFuncTypedefName(func, spec, options),
+		func.name)
+end
+
+function cpp.source.WriteBlockBeginCopyExtVariables(hFile, spec, options)
+	hFile:write("static void CopyExtensionVariables()\n")
+	hFile:write("{\n")
+	hFile:inc()
+end
+
+function cpp.source.WriteBlockEndCopyExtVariables(hFile, spec, options)
+	hFile:dec()
+	hFile:write("}\n")
+end
+
+function cpp.source.WriteCopyExtVariable(hFile, extName, spec, options)
+	local cppExtVarname = glload.GetExtVariableName(extName, spec, options)
+	local cExtVarname = glload_c.GetExtVariableName(extName, spec, options)
+	
+	hFile:fmt("exts::%s = glload::LoadTest((::%s == 0), ::%s - 1);\n",
+		cppExtVarname,
+		cExtVarname,
+		cExtVarname)
+end
+
+function cpp.source.WriteBlockBeginCopyFunctionPtrs(hFile, spec, options)
+	hFile:write("static void CopyFunctionPointers()\n")
+	hFile:write("{\n")
+	hFile:inc()
+end
+
+function cpp.source.WriteBlockEndCopyFunctionPtrs(hFile, spec, options)
+	hFile:dec()
+	hFile:write("}\n")
+end
+
+function cpp.source.WriteCopyFunctionPtr(hFile, func, typemap, spec, options)
+	hFile:fmt("%s = %s;\n",
+		func.name,
+		glload_c.GetFuncPtrName(func, spec, options))
+end
+
+function cpp.source.WriteBlockBeginSystemDefs(hFile, spec, options)
+	glload.WriteNamespaceBegin(hFile, "glload")
+end
+
+function cpp.source.WriteBlockEndSystemDefs(hFile, spec, options)
+	glload.WriteNamespaceEnd(hFile)
+end
+
+function cpp.source.WriteMainLoader(hFile, specData, spec, options)
+	hFile:fmt("glload::LoadTest LoadFunctions(%s)\n", spec.GetLoaderParams())
+	hFile:write "{\n"
+	hFile:inc()
+	
+	hFile:fmt("int test = ::%sLoadFunctions(%s);\n",
+		spec.DeclPrefix(),
+		spec.GetExtStringParamList(function() return "" end))
+		
+	hFile:fmtblock([[
+%s::CopyExtensionVariables();
+%s::CopyFunctionPointers();
+
+if(test == 0)
+	return glload::LoadTest(false, 0);
+return glload::LoadTest(true, test - 1);
+]],
+		spec.FuncNamePrefix(), spec.FuncNamePrefix())
+	
+	hFile:dec()
+	hFile:write "}\n"
+end
+
+function cpp.source.WriteMainExtraFuncs(hFile, specData, spec, options)
+	output = [[
+int GetMajorVersion() { return ::%<prefix>GetMajorVersion(); }
+int GetMinorVersion() { return ::%<prefix>GetMinorVersion(); }
+
+int IsVersionGEQ( int testMajorVersion, int testMinorVersion )
+{
+	return ::%<prefix>IsVersionGEQ(testMajorVersion, testMinorVersion);
+}
+]]
+	output = output:gsub("%%<prefix>", spec.DeclPrefix())
+	
+	hFile:writeblock(output)
+
+end
+
 ------------------------------------------------------
 -- Filters
 

modules/glload_util.lua

 -- CPP-specific
 data.cpp = util.DeepCopyTable(data)
 
+function data.cpp.GetLoadTestBasename(spec, options)
+	return data.internalPrefix .. "load_test.hpp"
+end
+
 function data.cpp.GetLoaderBasename(spec, options)
 	return spec.FilePrefix() .. "load.hpp"
 end
 	return data.internalPrefix .. spec.FilePrefix() .. version:gsub("%.", "_") .. "_rem.hpp"
 end
 
+function data.cpp.GetLoadTestFileIncludeGuard(spec, options)
+	return "GENERATED_LOAD_TEST_HPP"
+end
+
 function data.cpp.GetTypeHdrFileIncludeGuard(spec, options)
 	return spec.GetIncludeGuardString() .. "_GEN_TYPE" .. "_HPP"
 end
 	int GetNumMissing() const {return m_numMissing;}
 	
 	LoadTest() : m_isLoaded(false), m_numMissing(0) {}
-	LoadTest(bool isLoaded, int numMissing) : m_isLoaded(isLoaded), m_numMissing(numMissing) {}
+	LoadTest(bool isLoaded, int numMissing) : m_isLoaded(isLoaded), m_numMissing(isLoaded ? numMissing : 0) {}
 private:
 	bool m_isLoaded;
 	int m_numMissing;
 
 **/
 
+#include "$<loadtest>"
 
 ///\addtogroup module_glload_cppinter
 ///@{
 
 ///The core namespace for the C++ interface for the OpenGL initialization functions.
-namespace $<funcspec>
+namespace glload
 {
-	namespace sys
-	{
-		/**
-		\brief The loading status returned by the loader function.
-
-		**/
-]=]
-.. data.cpp.LoadTestClassDef() ..
-[=[
-
-		/**
-		\brief Loads all of the function pointers available.
+	/**
+	\brief Loads all of the function pointers available.
 
 $<desc>
 
-		\return A sys::LoadTest object that defines whether the loading was successful.
-		**/
-		LoadTest LoadFunctions($<params>);
+	\return A sys::LoadTest object that defines whether the loading was successful.
+	**/
+	glload::LoadTest LoadFunctions($<params>);
 
 $<extra>
-	}
 }
 ///@}
 ]=]
 	ret = ret:gsub("%$%<desc%>", hdr_desc[options.spec])
 	ret = ret:gsub("%$%<params%>", spec.GetLoaderParams())
 	ret = ret:gsub("%$%<funcspec%>", spec.FuncNamePrefix())	
+	ret = ret:gsub("%$<loadtest>", data.cpp.GetLoadTestBasename(spec, options))
 	return ret
 end
 

test/glload_cpp/test.cpp

+#include <string>
+#include <exception>
+#include <stdexcept>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "glload/gl_all.hpp"
+#include "glload/gl_load.hpp"
+#include "glload/wgl_all.hpp"
+#include "glload/wgl_load.hpp"
+#include <GL/freeglut.h>
+
+GLuint positionBufferObject;
+GLuint program;
+GLuint vao;
+
+GLuint BuildShader(GLenum eShaderType, const std::string &shaderText)
+{
+	GLuint shader = gl::CreateShader(eShaderType);
+	const char *strFileData = shaderText.c_str();
+	gl::ShaderSource(shader, 1, &strFileData, NULL);
+
+	gl::CompileShader(shader);
+
+	GLint status;
+	gl::GetShaderiv(shader, gl::COMPILE_STATUS, &status);
+	if (status == gl::FALSE_)
+	{
+		GLint infoLogLength;
+		gl::GetShaderiv(shader, gl::INFO_LOG_LENGTH, &infoLogLength);
+
+		GLchar *strInfoLog = new GLchar[infoLogLength + 1];
+		gl::GetShaderInfoLog(shader, infoLogLength, NULL, strInfoLog);
+
+		const char *strShaderType = NULL;
+		switch(eShaderType)
+		{
+		case gl::VERTEX_SHADER: strShaderType = "vertex"; break;
+//		case gl::GEOMETRY_SHADER: strShaderType = "geometry"; break;
+		case gl::FRAGMENT_SHADER: strShaderType = "fragment"; break;
+		}
+
+		fprintf(stderr, "Compile failure in %s shader:\n%s\n", strShaderType, strInfoLog);
+		delete[] strInfoLog;
+
+		throw std::runtime_error("Compile failure in shader.");
+	}
+
+	return shader;
+}
+
+
+void init()
+{
+	gl::GenVertexArrays(1, &vao);
+	gl::BindVertexArray(vao);
+
+	const float vertexPositions[] = {
+		0.75f, 0.75f, 0.0f, 1.0f,
+		0.75f, -0.75f, 0.0f, 1.0f,
+		-0.75f, -0.75f, 0.0f, 1.0f,
+	};
+
+	gl::GenBuffers(1, &positionBufferObject);
+	gl::BindBuffer(gl::ARRAY_BUFFER, positionBufferObject);
+	gl::BufferData(gl::ARRAY_BUFFER, sizeof(vertexPositions), vertexPositions, gl::STATIC_DRAW);
+	gl::BindBuffer(gl::ARRAY_BUFFER, 0);
+
+	const std::string vertexShader(
+		"#version 330\n"
+		"layout(location = 0) in vec4 position;\n"
+		"void main()\n"
+		"{\n"
+		"   gl_Position = position;\n"
+		"}\n"
+		);
+
+	const std::string fragmentShader(
+		"#version 330\n"
+		"out vec4 outputColor;\n"
+		"void main()\n"
+		"{\n"
+		"   outputColor = vec4(0.0f, 0.0f, 0.0f, 1.0f);\n"
+		"}\n"
+		);
+
+	GLuint vertShader = BuildShader(gl::VERTEX_SHADER, vertexShader);
+	GLuint fragShader = BuildShader(gl::FRAGMENT_SHADER, fragmentShader);
+
+	program = gl::CreateProgram();
+	gl::AttachShader(program, vertShader);
+	gl::AttachShader(program, fragShader);	
+	gl::LinkProgram(program);
+
+	GLint status;
+	gl::GetProgramiv (program, gl::LINK_STATUS, &status);
+	if (status == gl::FALSE_)
+	{
+		GLint infoLogLength;
+		gl::GetProgramiv(program, gl::INFO_LOG_LENGTH, &infoLogLength);
+
+		GLchar *strInfoLog = new GLchar[infoLogLength + 1];
+		gl::GetProgramInfoLog(program, infoLogLength, NULL, strInfoLog);
+		fprintf(stderr, "Linker failure: %s\n", strInfoLog);
+		delete[] strInfoLog;
+
+		throw std::runtime_error("Shader could not be linked.");
+	}
+}
+
+//Called to update the display.
+//You should call glutSwapBuffers after all of your rendering to display what you rendered.
+//If you need continuous updates of the screen, call glutPostRedisplay() at the end of the function.
+void display()
+{
+	gl::ClearColor(1.0f, 1.0f, 1.0f, 1.0f);
+	gl::Clear(gl::COLOR_BUFFER_BIT);
+
+	gl::UseProgram(program);
+
+	gl::BindBuffer(gl::ARRAY_BUFFER, positionBufferObject);
+	gl::EnableVertexAttribArray(0);
+	gl::VertexAttribPointer(0, 4, gl::FLOAT, gl::FALSE_, 0, 0);
+
+	gl::DrawArrays(gl::TRIANGLES, 0, 3);
+
+	gl::DisableVertexAttribArray(0);
+	gl::UseProgram(0);
+
+	glutSwapBuffers();
+}
+
+//Called whenever the window is resized. The new window size is given, in pixels.
+//This is an opportunity to call gl::Viewport or gl::Scissor to keep up with the change in size.
+void reshape (int w, int h)
+{
+	gl::Viewport(0, 0, (GLsizei) w, (GLsizei) h);
+}
+
+//Called whenever a key on the keyboard was pressed.
+//The key is given by the ''key'' parameter, which is in ASCII.
+//It's often a good idea to have the escape key (ASCII value 27) call glutLeaveMainLoop() to 
+//exit the program.
+void keyboard(unsigned char key, int x, int y)
+{
+	switch (key)
+	{
+	case 27:
+		glutLeaveMainLoop();
+		break;
+	}
+}
+
+
+int main(int argc, char** argv)
+{
+	glutInit(&argc, argv);
+
+	int width = 500;
+	int height = 500;
+	unsigned int displayMode = GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH | GLUT_STENCIL;
+
+	glutInitDisplayMode(displayMode);
+	glutInitContextVersion (3, 3);
+	glutInitContextProfile(GLUT_CORE_PROFILE);
+	glutInitWindowSize (width, height); 
+	glutInitWindowPosition (300, 200);
+	glutCreateWindow (argv[0]);
+
+	glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_CONTINUE_EXECUTION);
+
+	glload::LoadTest didLoad = glload::LoadFunctions();
+	if(!didLoad)
+		printf("OpenGL: %i\n", didLoad.GetNumMissing());
+	else
+		printf("OpenGL Loaded!\n");
+
+	init();
+
+	HDC hdc = wglGetCurrentDC();
+	glload::LoadTest load = glload::LoadFunctions(hdc);
+	if(!load)
+		printf("WGL: %i\n", load.GetNumMissing());
+	else
+		printf("WGL Loaded!\n");
+
+	glutDisplayFunc(display); 
+	glutReshapeFunc(reshape);
+	glutKeyboardFunc(keyboard);
+	glutMainLoop();
+	return 0;
+}

test/premake4.lua

 {
 	{name = "ptr_cpp"},
 	{name = "glload_c", include = "include"},
+	{name = "glload_cpp", include = "include"},
 }
 
 local oldDir = os.getcwd()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.