Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build test, forward compatible context init #17

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 18 additions & 0 deletions CMakeLists.txt
@@ -1,5 +1,7 @@
cmake_minimum_required(VERSION 2.8)

option(BUILD_TESTS "build test examples" OFF)

project(gl3w)

include_directories(include)
Expand All @@ -9,3 +11,19 @@ add_library(gl3w src/gl3w.c)
if (UNIX)
target_link_libraries(gl3w dl)
endif()

if (BUILD_TESTS)
find_package(OpenGL REQUIRED)
find_package(GLUT REQUIRED)

include_directories(${GLUT_INCLUDE_DIR})

add_executable(gl3wtest
src/test.c
)
target_link_libraries(gl3wtest
gl3w
${GLUT_glut_LIBRARY}
${OPENGL_gl_LIBRARY}
)
endif (BUILD_TESTS)
7 changes: 6 additions & 1 deletion src/test.c
Expand Up @@ -5,6 +5,7 @@
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#include <GL/freeglut_ext.h>
#endif

static int width = 600, height = 600;
Expand Down Expand Up @@ -38,8 +39,12 @@ int main(int argc, char **argv)
unsigned mode = GLUT_RGBA | GLUT_DEPTH | GLUT_DOUBLE;
#ifdef __APPLE__
mode |= GLUT_3_2_CORE_PROFILE;
#endif
glutInitDisplayMode(mode);
#else
glutInitDisplayMode(mode);
glutInitContextVersion (3, 2);
glutInitContextFlags(GLUT_FORWARD_COMPATIBLE);
#endif
glutInitWindowSize(width, height);
glutCreateWindow("cookie");

Expand Down