Commits

Jason McKesson committed 60e0496

FuncCpp style complete.

Comments (0)

Files changed (6)

 {
 	[[lua $<dir>LoadGen.lua -spec=gl -version=3.3 -profile=core -style=pointer_cpp -stdext=gl_ubiquitous.txt $<dir>test/ptr_cpp/test]],
 	[[lua $<dir>LoadGen.lua -spec=gl -version=3.3 -profile=core -style=pointer_c -stdext=gl_ubiquitous.txt $<dir>test/ptr_c/test]],
+	[[lua $<dir>LoadGen.lua -spec=gl -version=3.3 -profile=core -style=func_cpp -stdext=gl_ubiquitous.txt $<dir>test/func_cpp/test]],
 	[[lua $<dir>LoadGen.lua -spec=gl -version=3.3 -profile=compatibility -style=pointer_cpp -stdext=gl_ubiquitous.txt $<dir>test/ptr_cpp_comp/test]],
+	[[lua $<dir>LoadGen.lua -spec=gl -version=2.1 -style=func_cpp -stdext=gl_ubiquitous.txt $<dir>test/func_cpp_comp/test]],
 	[[lua $<dir>LoadGen.lua -spec=gl -version=3.3 -profile=compatibility -style=pointer_c -stdext=gl_ubiquitous.txt $<dir>test/ptr_c_comp/test]],
 	[[lua $<dir>LoadGen.lua -spec=gl -version=3.3 -profile=compatibility -style=noload_cpp  -stdext=gl_ubiquitous.txt $<dir>test/noload_cpp/test]],
 	[[lua $<dir>LoadGen.lua -spec=gl -version=3.3 -profile=compatibility -style=noload_cpp $<dir>test/noload_cpp_noext/test]],
 	{
 		[[lua $<dir>LoadGen.lua -spec=wgl -style=pointer_cpp -stdext=wgl_common.txt $<dir>test/ptr_cpp/test]],
 		[[lua $<dir>LoadGen.lua -spec=wgl -style=pointer_c -stdext=wgl_common.txt $<dir>test/ptr_c/test]],
+		[[lua $<dir>LoadGen.lua -spec=wgl -style=func_cpp -stdext=wgl_common.txt $<dir>test/func_cpp/test]],
 		[[lua $<dir>LoadGen.lua -spec=wgl -style=pointer_cpp -stdext=wgl_common.txt $<dir>test/ptr_cpp_comp/test]],
+		[[lua $<dir>LoadGen.lua -spec=wgl -style=func_cpp -stdext=wgl_common.txt $<dir>test/func_cpp_comp/test]],
 		[[lua $<dir>LoadGen.lua -spec=wgl -style=pointer_c -stdext=wgl_common.txt $<dir>test/ptr_c_comp/test]],
 		[[lua $<dir>LoadGen.lua -spec=wgl -style=noload_cpp  -stdext=wgl_common.txt $<dir>test/noload_cpp/test]],
 		[[lua $<dir>LoadGen.lua -spec=wgl -style=noload_cpp  -stdext=wgl_common.txt $<dir>test/noload_cpp_noext/test]],
 	{
 		[[lua $<dir>LoadGen.lua -spec=glX -style=pointer_cpp -stdext=glx_common.txt $<dir>test/ptr_cpp/test]],
 		[[lua $<dir>LoadGen.lua -spec=glX -style=pointer_c -stdext=glx_common.txt $<dir>test/ptr_c/test]],
+		[[lua $<dir>LoadGen.lua -spec=glX -style=func_cpp -stdext=glx_common.txt $<dir>test/func_cpp/test]],
 		[[lua $<dir>LoadGen.lua -spec=glX -style=pointer_cpp -stdext=glx_common.txt $<dir>test/ptr_cpp_comp/test]],
+		[[lua $<dir>LoadGen.lua -spec=glX -style=func_cpp -stdext=glx_common.txt $<dir>test/func_cpp_comp/test]],
 		[[lua $<dir>LoadGen.lua -spec=glX -style=pointer_c -stdext=glx_common.txt $<dir>test/ptr_c_comp/test]],
 		[[lua $<dir>LoadGen.lua -spec=glX -style=noload_cpp -stdext=glx_common.txt $<dir>test/noload_cpp/test]],
 		[[lua $<dir>LoadGen.lua -spec=glX -style=noload_cpp -stdext=glx_common.txt $<dir>test/noload_cpp_noext/test]],

modules/FuncCpp_Struct.lua

 						},
 					},
 				},
+				{ type="blank"},
+				{ type="block", name="FuncPtrDecl(hFile, spec, options)",
+					{ type="func-seen",
+						{ type="ext-iter",
+							{ type="block", name="ExtFuncPtrDecl(hFile, extName, spec, options)", cond="func-iter",
+								{type="func-iter",
+									{ type="write", name="FuncPtrDecl(hFile, func, typemap, spec, options, funcSeen)", },
+								},
+							},
+							{ type="blank"},
+						},
+						{ type="version-iter",
+							{ type="core-ext-cull-iter",
+								{ type="block", name="ExtFuncPtrDecl(hFile, extName, spec, options)", cond="func-iter",
+									{type="func-iter",
+										{ type="write", name="FuncPtrDecl(hFile, func, typemap, spec, options, funcSeen)", },
+									},
+								},
+								{ type="blank"},
+							},
+							{type="func-iter",
+								{ type="write", name="FuncPtrDecl(hFile, func, typemap, spec, options, funcSeen)", },
+								{ type="blank", last=true },
+							},
+						},
+					},
+				},
+				{ type="blank"},
 				{ type="block", name="FuncDecl(hFile, spec, options)",
 					{ type="func-seen",
 						{ type="ext-iter",
 						},
 					},
 				},
+				{ type="blank"},
 				{ type="block", name="SysDecl(hFile, spec, options)",
 					{ type="write", name="UtilityDecls(hFile, spec, options)",},
 					{ type="blank" },
 					{ type="blank", last=true},
 				},
 			},
-			{ type="func-seen",
-				{ type="ext-iter",
-					{ type="block", name="ExtFuncDef(hFile, extName, spec, options)", cond="func-iter",
-						{ type="func-iter",
-							{ type="write", name="FuncDef(hFile, func, typemap, spec, options, funcSeen)", },
-						},
-						{ type="blank"},
-						{ type="block", name="ExtLoader(hFile, extName, spec, options)",
+			{ type="blank"},
+			{ type="block", name="PtrDefs(hFile, spec, options)",
+				{ type="func-seen",
+					{ type="ext-iter",
+						{ type="block", name="ExtFuncPtrDef(hFile, extName, spec, options)", cond="func-iter",
 							{ type="func-iter",
-								{ type="write", name="ExtFuncLoader(hFile, func, typemap, spec, options)", }
-							}
-						},
-						{ type="blank"},
-					},
-				},
-				{ type="block", name="CoreFuncDef(hFile, spec, options)",
-					cond="core-funcs",
-					{ type="version-iter",
-						{ type="core-ext-cull-iter",
-							{ type="block", name="ExtFuncDef(hFile, extName, spec, options)", cond="func-iter",
-								{type="func-iter",
-									{ type="write", name="FuncDef(hFile, func, typemap, spec, options, funcSeen)", },
-								},
+								{ type="write", name="FuncPtrDef(hFile, func, typemap, spec, options, funcSeen)", },
+							},
+							{ type="blank"},
+							{ type="block", name="ExtLoader(hFile, extName, spec, options)",
+								{ type="func-iter",
+									{ type="write", name="ExtFuncLoader(hFile, func, typemap, spec, options)", }
+								}
 							},
 							{ type="blank"},
 						},
-						{type="func-iter",
-							{ type="write", name="FuncDef(hFile, func, typemap, spec, options, funcSeen)", },
-							{ type="blank", last=true },
+					},
+					{ type="block", name="CoreFuncPtrDef(hFile, spec, options)",
+						cond="core-funcs",
+						{ type="version-iter",
+							{ type="core-ext-cull-iter",
+								{ type="block", name="ExtFuncPtrDef(hFile, extName, spec, options)", cond="func-iter",
+									{type="func-iter",
+										{ type="write", name="FuncPtrDef(hFile, func, typemap, spec, options, funcSeen)", },
+									},
+								},
+								{ type="blank"},
+							},
+							{type="func-iter",
+								{ type="write", name="FuncPtrDef(hFile, func, typemap, spec, options, funcSeen)", },
+								{ type="blank", last=true },
+							},
 						},
-					},
-					{ type="block", name="CoreLoader(hFile, spec, options)",
-						{ type="version-iter",
-							{ type="core-ext-iter",
+						{ type="block", name="CoreLoader(hFile, spec, options)",
+							{ type="version-iter",
+								{ type="core-ext-iter",
+									{type="func-iter",
+										{ type="write", name="CoreFuncLoader(hFile, func, typemap, spec, options)", },
+									},
+								},
 								{type="func-iter",
 									{ type="write", name="CoreFuncLoader(hFile, func, typemap, spec, options)", },
 								},
 							},
-							{type="func-iter",
-								{ type="write", name="CoreFuncLoader(hFile, func, typemap, spec, options)", },
-							},
 						},
+						{ type="blank"},
 					},
-					{ type="blank"},
+					{ type="write", name="ExtStringFuncDef(hFile, specData, spec, options, funcSeen)"},
 				},
-				{ type="write", name="ExtStringFuncDef(hFile, specData, spec, options, funcSeen)"},
 			},
+			{ type="blank"},
 			{ type="block", name="SysDef(hFile, spec, options)",
 				{ type="write", name="UtilityDefs(hFile, specData, spec, options)",},
 				{ type="blank" },

modules/FuncCpp_Style.lua

 	end
 end
 
-function my_style.header.WriteBlockBeginFuncDecl(hFile, spec, options)
-	--Block containing all spec function declarations.
+function my_style.header.WriteBlockBeginFuncPtrDecl(hFile, spec, options)
+	StartNamespace(hFile, "_detail")
 end
 
-function my_style.header.WriteBlockEndFuncDecl(hFile, spec, options)
-	--Block containing all spec function declarations.
+function my_style.header.WriteBlockEndFuncPtrDecl(hFile, spec, options)
+	EndNamespace(hFile, "_detail")
 end
 
-function my_style.header.WriteBlockBeginExtFuncDecl(hFile, extName, spec, options)
+function my_style.header.WriteBlockBeginExtFuncPtrDecl(hFile, extName, spec, options)
 	--Block containing all spec function declarations for a particular extension.
 	--Useful for include-guards around extension function pointers.
 end
 
-function my_style.header.WriteBlockEndExtFuncDecl(hFile, extName, spec, options)
+function my_style.header.WriteBlockEndExtFuncPtrDecl(hFile, extName, spec, options)
 	--Block containing all spec function declarations for a particular extension.
 end
 
 		return func.name
 	end
 
+	local function GenFuncName(func, spec, options)
+		return func.name
+	end
+
 	local function GenFuncPtrTypedefName(func, spec, options)
 		return "PFN" .. GenFuncPtrName(func, spec, options):upper()
 	end
 			GenFuncPtrName(func, spec, options))
 	end
 
-function my_style.header.WriteFuncDecl(hFile, func, typemap, spec, options)
+function my_style.header.WriteFuncPtrDecl(hFile, func, typemap, spec, options)
 	hFile:write("extern ",
 		GenFuncPtrDefDirect(func, typemap, spec, options),
 		";\n")
 end
 
+function my_style.header.WriteBlockBeginFuncDecl(hFile, spec, options)
+end
+
+function my_style.header.WriteBlockEndFuncDecl(hFile, spec, options)
+end
+
+function my_style.header.WriteBlockBeginExtFuncDecl(hFile, extName, spec, options)
+	--Block containing all spec function declarations for a particular extension.
+	--Useful for include-guards around extension function pointers.
+end
+
+function my_style.header.WriteBlockEndExtFuncDecl(hFile, extName, spec, options)
+	--Block containing all spec function declarations for a particular extension.
+end
+
+function my_style.header.WriteFuncDecl(hFile, func, typemap, spec, options)
+	hFile:fmt("inline %s %s(%s){",
+			common.GetFuncReturnType(func, typemap),
+			GenFuncName(func, spec, options),
+			common.GetFuncParamList(func, typemap, true))
+
+	if(common.DoesFuncReturnSomething(func, typemap)) then
+		hFile:rawfmt('_detail::%s(%s);',
+			GenFuncPtrName(func, spec, options),
+			common.GetFuncParamCallList(func, typemap))
+	else
+		hFile:rawfmt('return _detail::%s(%s);',
+			GenFuncPtrName(func, spec, options),
+			common.GetFuncParamCallList(func, typemap))
+	end
+
+		
+	hFile:rawwrite("}\n")
+end
+
+
+
 function my_style.header.WriteBlockBeginSysDecl(hFile, spec, options)
 	StartNamespace(hFile, "sys")
 end
 		GenExtensionVarName(extName, spec, options));
 end
 
-function my_style.source.WriteBlockBeginExtFuncDef(hFile, extName, spec, options)
-	--Block containing the extension function definitions and load function
-	--for the functions in the extension `extName`.
+function my_style.source.WriteBlockBeginPtrDefs(hFile, spec, options)
+	StartNamespace(hFile, "_detail")
 end
 
-function my_style.source.WriteBlockEndExtFuncDef(hFile, extName, spec, options)
-	--Block containing the extension function definitions and load function
-	--for the functions in the extension `extName`.
+function my_style.source.WriteBlockEndPtrDefs(hFile, spec, options)
+	EndNamespace(hFile, "_detail")
 end
 
-function my_style.source.WriteFuncDef(hFile, func, typemap, spec, options)
+function my_style.source.WriteBlockBeginExtFuncPtrDef(hFile, extName, spec, options)
+end
+
+function my_style.source.WriteBlockEndExtFuncPtrDef(hFile, extName, spec, options)
+end
+
+function my_style.source.WriteFuncPtrDef(hFile, func, typemap, spec, options)
 	WriteFuncPtrTypedefStmt(hFile, func, typemap, spec, options)
 	hFile:write(GenFuncPtrDefTypedef(func, typemap, spec, options),
 		" = 0;\n")
 end
 
 	local function GenExtLoaderFuncName(extName, spec, options)
-		return "Load_" .. extName;
+		return "_detail::Load_" .. extName;
 	end
 
 function my_style.source.WriteBlockBeginExtLoader(hFile, extName, spec, options)
 	hFile:fmt('if(!%s) ++numFailed;\n', GenFuncPtrName(func, spec, options))
 end
 
-function my_style.source.WriteBlockBeginCoreFuncDef(hFile, version, spec, options)
-	--Block containing the core functions for `version`.
-	--The block also contains the loading function for this version.
+function my_style.source.WriteBlockBeginCoreFuncPtrDef(hFile, version, spec, options)
 end
 
-function my_style.source.WriteBlockEndCoreFuncDef(hFile, version, spec, options)
-	--Block containing the core functions for `version`.
+function my_style.source.WriteBlockEndCoreFuncPtrDef(hFile, version, spec, options)
 end
 
 	local function GenCoreLoaderFuncName(version, spec, options)
 	end
 	
 	local function GenQualifiedFuncPtrName(func, spec, options)
-		return GenQualifier(spec, options) .. GenFuncPtrName(func, spec, options)
+		return GenQualifier(spec, options) .. "_detail::"
+			.. GenFuncPtrName(func, spec, options)
 	end
 	
 	local function WriteAncillaryFuncs(hFile, specData, spec, options)
 
 	
 	local function WriteInMainFuncLoader(hFile, func, spec, options)
-		hFile:fmt('%s = reinterpret_cast<%s>(%s("%s%s"));\n',
+		hFile:fmt('_detail::%s = reinterpret_cast<_detail::%s>(%s("%s%s"));\n',
 			GenFuncPtrName(func, spec, options),
 			GenFuncPtrTypedefName(func, spec, options),
 			common.GetProcAddressName(spec),
 			spec.FuncNamePrefix(), func.name)
-		hFile:fmt('if(!%s) return exts::LoadTest();\n',
+		hFile:fmt('if(!_detail::%s) return exts::LoadTest();\n',
 			GenFuncPtrName(func, spec, options))
 	end
 
 	
 	if(options.version) then
 		hFile:write "\n"
-		hFile:fmt("int numFailed = %s();\n",
+		hFile:fmt("int numFailed = _detail::%s();\n",
 			GenCoreLoaderFuncName(options.version, spec, options))
 		
 		hFile:write("return exts::LoadTest(true, numFailed);\n")
 		hFile:writeblock([[
 static void GetGLVersion()
 {
-	GetIntegerv(MAJOR_VERSION, &g_major_version);
-	GetIntegerv(MINOR_VERSION, &g_minor_version);
+	_detail::GetIntegerv(MAJOR_VERSION, &g_major_version);
+	_detail::GetIntegerv(MINOR_VERSION, &g_minor_version);
 }
 ]])
 	else
 		hFile:writeblock([[
 static void GetGLVersion()
 {
-	ParseVersionFromString(&g_major_version, &g_minor_version, GetString(VERSION));
+	ParseVersionFromString(&g_major_version, &g_minor_version, (const char *)_detail::GetString(VERSION));
 }
 ]])
 	end

test/func_cpp/test.cpp

+#include <string>
+#include <exception>
+#include <stdexcept>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "gl_test.hpp"
+#ifdef _WIN32
+#include "wgl_test.hpp"
+#else
+#include "glx_test.hpp"
+#endif
+#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);
+
+	gl::exts::LoadTest didLoad = gl::sys::LoadFunctions();
+	if(!didLoad)
+		printf("OpenGL: %i\n", didLoad.GetNumMissing());
+	else
+		printf("OpenGL Loaded!\n");
+
+	init();
+
+#ifdef _WIN32
+	HDC hdc = wglGetCurrentDC();
+	wgl::exts::LoadTest load = wgl::sys::LoadFunctions(hdc);
+	if(!load)
+		printf("WGL: %i\n", load.GetNumMissing());
+	else
+		printf("WGL Loaded!\n");
+#else
+#endif
+
+	glutDisplayFunc(display); 
+	glutReshapeFunc(reshape);
+	glutKeyboardFunc(keyboard);
+	glutMainLoop();
+	return 0;
+}

test/func_cpp_comp/test.cpp

+#include <string>
+#include <exception>
+#include <stdexcept>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "gl_test.hpp"
+#ifdef _WIN32
+#include "wgl_test.hpp"
+#else
+#include "glx_test.hpp"
+#endif
+#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()
+{
+	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_COMPATIBILITY_PROFILE);
+	glutInitWindowSize (width, height); 
+	glutInitWindowPosition (300, 200);
+	glutCreateWindow (argv[0]);
+
+	glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_CONTINUE_EXECUTION);
+
+	gl::exts::LoadTest didLoad = gl::sys::LoadFunctions();
+	if(!didLoad)
+		printf("OpenGL: %i\n", didLoad.GetNumMissing());
+	else
+		printf("OpenGL Loaded!\n");
+
+	init();
+
+#ifdef _WIN32
+	HDC hdc = wglGetCurrentDC();
+	wgl::exts::LoadTest load = wgl::sys::LoadFunctions(hdc);
+	if(!load)
+		printf("WGL: %i\n", load.GetNumMissing());
+	else
+		printf("WGL Loaded!\n");
+#else
+#endif
+
+	glutDisplayFunc(display); 
+	glutReshapeFunc(reshape);
+	glutKeyboardFunc(keyboard);
+	glutMainLoop();
+	return 0;
+}

test/premake4.lua

 	{name = "ptr_c"},
 	{name = "ptr_cpp_comp"},
 	{name = "ptr_c_comp"},
+	{name = "func_cpp"},
+	{name = "func_cpp_comp"},
 	{name = "noload_cpp"},
 	{name = "noload_cpp_noext"},
 }
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.