enable option to use GLFW, instead of our own cross-platform X11/Cocoa/Windows OpenGLWindow classes

This commit is contained in:
erwincoumans
2017-09-19 21:10:54 -07:00
parent 2919e51d9d
commit 390f111547
11 changed files with 127 additions and 25 deletions

View File

@@ -28,7 +28,9 @@ float shadowMapWorldSize=10;
#include "OpenGLInclude.h"
#include "../CommonInterfaces/CommonWindowInterface.h"
//#include "Bullet3Common/b3MinMax.h"
#ifdef B3_USE_GLFW
#else
#ifndef __APPLE__
#ifndef glVertexAttribDivisor
#ifndef NO_GLEW
@@ -44,6 +46,7 @@ float shadowMapWorldSize=10;
#endif //NO_GLEW
#endif
#endif //__APPLE__
#endif//B3_USE_GLFW
#include "GLInstancingRenderer.h"
#include <string.h>

View File

@@ -17,7 +17,10 @@ subject to the following restrictions:
#ifndef __OPENGL_INCLUDE_H
#define __OPENGL_INCLUDE_H
#ifdef B3_USE_GLFW
#include "glad/glad.h"
#include <GLFW/glfw3.h>
#else
//think different
#if defined(__APPLE__) && !defined (VMDMESA)
#include <OpenGL/OpenGL.h>
@@ -45,7 +48,7 @@ subject to the following restrictions:
//#include <GL/glu.h>
#endif //_WINDOWS
#endif //APPLE
#endif //B3_USE_GLFW
//disable glGetError
//#undef glGetError
//#define glGetError MyGetError

View File

@@ -17,7 +17,10 @@ subject to the following restrictions:
#ifndef __OPENGL_INCLUDE_H
#define __OPENGL_INCLUDE_H
#ifdef B3_USE_GLFW
#include <glad/glad.h>
#include <GLFW/glfw3.h>
#else
//think different
#if defined(__APPLE__) && !defined (VMDMESA)
#include <OpenGL/OpenGL.h>
@@ -31,6 +34,7 @@ subject to the following restrictions:
#endif
#else
#ifdef GLEW_STATIC
#include "CustomGL/glew.h"
#else
@@ -52,7 +56,7 @@ subject to the following restrictions:
//#include <GL/glu.h>
#endif //_WINDOWS
#endif //APPLE
#endif
//disable glGetError
//#undef glGetError
//#define glGetError MyGetError

View File

@@ -13,6 +13,11 @@
#include "stdlib.h"
#include "TwFonts.h"
#include "SimpleOpenGL2Renderer.h"
#ifdef B3_USE_GLFW
#include "GLFWOpenGLWindow.h"
#else
#ifdef __APPLE__
#include "MacOpenGLWindow.h"
#else
@@ -30,6 +35,8 @@
#endif //BT_USE_EGL
#endif //_WIN32
#endif//__APPLE__
#endif //#ifdef B3_USE_GLFW
#include <stdio.h>
#include "../CommonInterfaces/CommonRenderInterface.h"
@@ -129,7 +136,7 @@ SimpleOpenGL2App::SimpleOpenGL2App(const char* title, int width, int height)
glewExperimental = GL_TRUE;
#endif //_WIN32
#ifndef B3_USE_GLFW
if (glewInit() != GLEW_OK)
{
b3Error("glewInit failed");
@@ -140,7 +147,7 @@ SimpleOpenGL2App::SimpleOpenGL2App(const char* title, int width, int height)
b3Error("GLEW_VERSION_2_1 needs to support 2_1");
exit(1); // or handle the error in a nicer way
}
#endif //B3_USE_GLFW
#endif //__APPLE__
#endif //NO_GLEW
@@ -580,4 +587,4 @@ int SimpleOpenGL2App::registerCubeShape(float halfExtentsX,float halfExtentsY, f
int shapeId = m_renderer->registerShape(&verts[0].xyzw[0],numVertices,cube_indices,numIndices,B3_GL_TRIANGLES,textureIndex);
return shapeId;
}
}

View File

@@ -2,6 +2,11 @@
#include "SimpleOpenGL3App.h"
#include "ShapeData.h"
#ifdef B3_USE_GLFW
#include "GLFWOpenGLWindow.h"
#else
#ifdef __APPLE__
#include "MacOpenGLWindow.h"
#else
@@ -19,6 +24,8 @@
#endif //BT_USE_EGL
#endif //_WIN32
#endif//__APPLE__
#endif //B3_USE_GLFW
#include <stdio.h>
#include "GLPrimitiveRenderer.h"
@@ -321,12 +328,12 @@ SimpleOpenGL3App::SimpleOpenGL3App( const char* title, int width,int height, boo
glewExperimental = GL_TRUE;
#endif //_WIN32
#ifndef B3_USE_GLFW
if (glewInit() != GLEW_OK)
exit(1); // or handle the error in a nicer way
if (!GLEW_VERSION_2_1) // check that the machine supports the 2.1 API.
exit(1); // or handle the error in a nicer way
#endif //B3_USE_GLFW
#endif //__APPLE__
#endif //NO_GLEW
glGetError();//don't remove this call, it is needed for Ubuntu

View File

@@ -1,3 +1,4 @@
#ifndef B3_USE_GLFW
#ifdef _WIN32
/*
Copyright (c) 2012 Advanced Micro Devices, Inc.
@@ -196,5 +197,5 @@ int Win32OpenGLWindow::getHeight() const
#endif
#endif //B3_USE_GLFW