enable option to use GLFW, instead of our own cross-platform X11/Cocoa/Windows OpenGLWindow classes
This commit is contained in:
@@ -238,6 +238,9 @@ end
|
|||||||
targetdir( _OPTIONS["targetdir"] or "../bin" )
|
targetdir( _OPTIONS["targetdir"] or "../bin" )
|
||||||
location("./" .. act .. postfix)
|
location("./" .. act .. postfix)
|
||||||
|
|
||||||
|
projectRootDir = os.getcwd() .. "/../"
|
||||||
|
print("Project root directory: " .. projectRootDir);
|
||||||
|
|
||||||
if not _OPTIONS["python_include_dir"] then
|
if not _OPTIONS["python_include_dir"] then
|
||||||
_OPTIONS["python_include_dir"] = default_python_include_dir
|
_OPTIONS["python_include_dir"] = default_python_include_dir
|
||||||
end
|
end
|
||||||
@@ -246,21 +249,74 @@ end
|
|||||||
_OPTIONS["python_lib_dir"] = default_python_lib_dir
|
_OPTIONS["python_lib_dir"] = default_python_lib_dir
|
||||||
end
|
end
|
||||||
|
|
||||||
|
newoption
|
||||||
|
{
|
||||||
|
trigger = "glfw_include_dir",
|
||||||
|
value = default_glfw_include_dir,
|
||||||
|
description = "GLFW 3.x include directory"
|
||||||
|
}
|
||||||
|
|
||||||
projectRootDir = os.getcwd() .. "/../"
|
newoption
|
||||||
print("Project root directory: " .. projectRootDir);
|
{
|
||||||
|
trigger = "glfw_lib_dir",
|
||||||
|
value = default_glfw_lib_dir,
|
||||||
|
description = "(optional) GLFW 3.x library directory "
|
||||||
|
}
|
||||||
|
|
||||||
dofile ("findOpenCL.lua")
|
newoption
|
||||||
dofile ("findDirectX11.lua")
|
{
|
||||||
|
trigger = "enable_glfw",
|
||||||
|
value = false,
|
||||||
|
description = "(optional) use GLFW 3.x library"
|
||||||
|
}
|
||||||
|
|
||||||
|
if _OPTIONS["enable_glfw"] then
|
||||||
|
defines {"B3_USE_GLFW"}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function initOpenGL()
|
||||||
|
includedirs {
|
||||||
|
projectRootDir .. "examples/ThirdPartyLibs/glad"
|
||||||
|
}
|
||||||
|
|
||||||
|
includedirs {
|
||||||
|
_OPTIONS["glfw_include_dir"],
|
||||||
|
}
|
||||||
|
|
||||||
|
libdirs {
|
||||||
|
_OPTIONS["glfw_lib_dir"]
|
||||||
|
}
|
||||||
|
links {"glfw3"}
|
||||||
|
files { projectRootDir .. "examples/ThirdPartyLibs/glad/glad.c" }
|
||||||
|
end
|
||||||
|
function findOpenGL3()
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
function initGlew()
|
||||||
|
end
|
||||||
|
|
||||||
|
else
|
||||||
dofile ("findOpenGLGlewGlut.lua")
|
dofile ("findOpenGLGlewGlut.lua")
|
||||||
|
|
||||||
if (not findOpenGL3()) then
|
if (not findOpenGL3()) then
|
||||||
defines {"NO_OPENGL3"}
|
defines {"NO_OPENGL3"}
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
dofile ("findOpenCL.lua")
|
||||||
|
dofile ("findDirectX11.lua")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
language "C++"
|
language "C++"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if _OPTIONS["audio"] then
|
if _OPTIONS["audio"] then
|
||||||
include "../examples/TinyAudio"
|
include "../examples/TinyAudio"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -28,7 +28,9 @@ float shadowMapWorldSize=10;
|
|||||||
#include "OpenGLInclude.h"
|
#include "OpenGLInclude.h"
|
||||||
#include "../CommonInterfaces/CommonWindowInterface.h"
|
#include "../CommonInterfaces/CommonWindowInterface.h"
|
||||||
//#include "Bullet3Common/b3MinMax.h"
|
//#include "Bullet3Common/b3MinMax.h"
|
||||||
|
#ifdef B3_USE_GLFW
|
||||||
|
|
||||||
|
#else
|
||||||
#ifndef __APPLE__
|
#ifndef __APPLE__
|
||||||
#ifndef glVertexAttribDivisor
|
#ifndef glVertexAttribDivisor
|
||||||
#ifndef NO_GLEW
|
#ifndef NO_GLEW
|
||||||
@@ -44,6 +46,7 @@ float shadowMapWorldSize=10;
|
|||||||
#endif //NO_GLEW
|
#endif //NO_GLEW
|
||||||
#endif
|
#endif
|
||||||
#endif //__APPLE__
|
#endif //__APPLE__
|
||||||
|
#endif//B3_USE_GLFW
|
||||||
#include "GLInstancingRenderer.h"
|
#include "GLInstancingRenderer.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|||||||
@@ -17,7 +17,10 @@ subject to the following restrictions:
|
|||||||
#ifndef __OPENGL_INCLUDE_H
|
#ifndef __OPENGL_INCLUDE_H
|
||||||
#define __OPENGL_INCLUDE_H
|
#define __OPENGL_INCLUDE_H
|
||||||
|
|
||||||
|
#ifdef B3_USE_GLFW
|
||||||
|
#include "glad/glad.h"
|
||||||
|
#include <GLFW/glfw3.h>
|
||||||
|
#else
|
||||||
//think different
|
//think different
|
||||||
#if defined(__APPLE__) && !defined (VMDMESA)
|
#if defined(__APPLE__) && !defined (VMDMESA)
|
||||||
#include <OpenGL/OpenGL.h>
|
#include <OpenGL/OpenGL.h>
|
||||||
@@ -45,7 +48,7 @@ subject to the following restrictions:
|
|||||||
//#include <GL/glu.h>
|
//#include <GL/glu.h>
|
||||||
#endif //_WINDOWS
|
#endif //_WINDOWS
|
||||||
#endif //APPLE
|
#endif //APPLE
|
||||||
|
#endif //B3_USE_GLFW
|
||||||
//disable glGetError
|
//disable glGetError
|
||||||
//#undef glGetError
|
//#undef glGetError
|
||||||
//#define glGetError MyGetError
|
//#define glGetError MyGetError
|
||||||
|
|||||||
@@ -17,7 +17,10 @@ subject to the following restrictions:
|
|||||||
#ifndef __OPENGL_INCLUDE_H
|
#ifndef __OPENGL_INCLUDE_H
|
||||||
#define __OPENGL_INCLUDE_H
|
#define __OPENGL_INCLUDE_H
|
||||||
|
|
||||||
|
#ifdef B3_USE_GLFW
|
||||||
|
#include <glad/glad.h>
|
||||||
|
#include <GLFW/glfw3.h>
|
||||||
|
#else
|
||||||
//think different
|
//think different
|
||||||
#if defined(__APPLE__) && !defined (VMDMESA)
|
#if defined(__APPLE__) && !defined (VMDMESA)
|
||||||
#include <OpenGL/OpenGL.h>
|
#include <OpenGL/OpenGL.h>
|
||||||
@@ -31,6 +34,7 @@ subject to the following restrictions:
|
|||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
|
||||||
#ifdef GLEW_STATIC
|
#ifdef GLEW_STATIC
|
||||||
#include "CustomGL/glew.h"
|
#include "CustomGL/glew.h"
|
||||||
#else
|
#else
|
||||||
@@ -52,7 +56,7 @@ subject to the following restrictions:
|
|||||||
//#include <GL/glu.h>
|
//#include <GL/glu.h>
|
||||||
#endif //_WINDOWS
|
#endif //_WINDOWS
|
||||||
#endif //APPLE
|
#endif //APPLE
|
||||||
|
#endif
|
||||||
//disable glGetError
|
//disable glGetError
|
||||||
//#undef glGetError
|
//#undef glGetError
|
||||||
//#define glGetError MyGetError
|
//#define glGetError MyGetError
|
||||||
|
|||||||
@@ -13,6 +13,11 @@
|
|||||||
#include "stdlib.h"
|
#include "stdlib.h"
|
||||||
#include "TwFonts.h"
|
#include "TwFonts.h"
|
||||||
#include "SimpleOpenGL2Renderer.h"
|
#include "SimpleOpenGL2Renderer.h"
|
||||||
|
|
||||||
|
#ifdef B3_USE_GLFW
|
||||||
|
#include "GLFWOpenGLWindow.h"
|
||||||
|
#else
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#include "MacOpenGLWindow.h"
|
#include "MacOpenGLWindow.h"
|
||||||
#else
|
#else
|
||||||
@@ -30,6 +35,8 @@
|
|||||||
#endif //BT_USE_EGL
|
#endif //BT_USE_EGL
|
||||||
#endif //_WIN32
|
#endif //_WIN32
|
||||||
#endif//__APPLE__
|
#endif//__APPLE__
|
||||||
|
#endif //#ifdef B3_USE_GLFW
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "../CommonInterfaces/CommonRenderInterface.h"
|
#include "../CommonInterfaces/CommonRenderInterface.h"
|
||||||
|
|
||||||
@@ -129,7 +136,7 @@ SimpleOpenGL2App::SimpleOpenGL2App(const char* title, int width, int height)
|
|||||||
glewExperimental = GL_TRUE;
|
glewExperimental = GL_TRUE;
|
||||||
#endif //_WIN32
|
#endif //_WIN32
|
||||||
|
|
||||||
|
#ifndef B3_USE_GLFW
|
||||||
if (glewInit() != GLEW_OK)
|
if (glewInit() != GLEW_OK)
|
||||||
{
|
{
|
||||||
b3Error("glewInit failed");
|
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");
|
b3Error("GLEW_VERSION_2_1 needs to support 2_1");
|
||||||
exit(1); // or handle the error in a nicer way
|
exit(1); // or handle the error in a nicer way
|
||||||
}
|
}
|
||||||
|
#endif //B3_USE_GLFW
|
||||||
#endif //__APPLE__
|
#endif //__APPLE__
|
||||||
#endif //NO_GLEW
|
#endif //NO_GLEW
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,11 @@
|
|||||||
|
|
||||||
#include "SimpleOpenGL3App.h"
|
#include "SimpleOpenGL3App.h"
|
||||||
#include "ShapeData.h"
|
#include "ShapeData.h"
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef B3_USE_GLFW
|
||||||
|
#include "GLFWOpenGLWindow.h"
|
||||||
|
#else
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#include "MacOpenGLWindow.h"
|
#include "MacOpenGLWindow.h"
|
||||||
#else
|
#else
|
||||||
@@ -19,6 +24,8 @@
|
|||||||
#endif //BT_USE_EGL
|
#endif //BT_USE_EGL
|
||||||
#endif //_WIN32
|
#endif //_WIN32
|
||||||
#endif//__APPLE__
|
#endif//__APPLE__
|
||||||
|
#endif //B3_USE_GLFW
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "GLPrimitiveRenderer.h"
|
#include "GLPrimitiveRenderer.h"
|
||||||
@@ -321,12 +328,12 @@ SimpleOpenGL3App::SimpleOpenGL3App( const char* title, int width,int height, boo
|
|||||||
glewExperimental = GL_TRUE;
|
glewExperimental = GL_TRUE;
|
||||||
#endif //_WIN32
|
#endif //_WIN32
|
||||||
|
|
||||||
|
#ifndef B3_USE_GLFW
|
||||||
if (glewInit() != GLEW_OK)
|
if (glewInit() != GLEW_OK)
|
||||||
exit(1); // or handle the error in a nicer way
|
exit(1); // or handle the error in a nicer way
|
||||||
if (!GLEW_VERSION_2_1) // check that the machine supports the 2.1 API.
|
if (!GLEW_VERSION_2_1) // check that the machine supports the 2.1 API.
|
||||||
exit(1); // or handle the error in a nicer way
|
exit(1); // or handle the error in a nicer way
|
||||||
|
#endif //B3_USE_GLFW
|
||||||
#endif //__APPLE__
|
#endif //__APPLE__
|
||||||
#endif //NO_GLEW
|
#endif //NO_GLEW
|
||||||
glGetError();//don't remove this call, it is needed for Ubuntu
|
glGetError();//don't remove this call, it is needed for Ubuntu
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#ifndef B3_USE_GLFW
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2012 Advanced Micro Devices, Inc.
|
Copyright (c) 2012 Advanced Micro Devices, Inc.
|
||||||
@@ -197,4 +198,4 @@ int Win32OpenGLWindow::getHeight() const
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif //B3_USE_GLFW
|
||||||
@@ -1281,9 +1281,13 @@ bool CMainApplication::SetupTexturemaps()
|
|||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
GLfloat fLargest;
|
GLfloat fLargest;
|
||||||
|
#ifdef B3_USE_GLFW
|
||||||
|
glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY, &fLargest);
|
||||||
|
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY, fLargest);
|
||||||
|
#else
|
||||||
glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &fLargest);
|
glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &fLargest);
|
||||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, fLargest);
|
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, fLargest);
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
glBindTexture( GL_TEXTURE_2D, 0 );
|
glBindTexture( GL_TEXTURE_2D, 0 );
|
||||||
|
|
||||||
@@ -2295,9 +2299,14 @@ bool CGLRenderModel::BInit( const vr::RenderModel_t & vrModel, const vr::RenderM
|
|||||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
|
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
GLfloat fLargest;
|
GLfloat fLargest;
|
||||||
|
#ifdef B3_USE_GLFW
|
||||||
|
glGetFloatv( GL_MAX_TEXTURE_MAX_ANISOTROPY, &fLargest );
|
||||||
|
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY, fLargest );
|
||||||
|
#else
|
||||||
glGetFloatv( GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &fLargest );
|
glGetFloatv( GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &fLargest );
|
||||||
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, fLargest );
|
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, fLargest );
|
||||||
#endif
|
#endif //B3_USE_GLFW
|
||||||
|
#endif//_WIN32
|
||||||
glBindTexture( GL_TEXTURE_2D, 0 );
|
glBindTexture( GL_TEXTURE_2D, 0 );
|
||||||
|
|
||||||
m_unVertexCount = vrModel.unTriangleCount * 3;
|
m_unVertexCount = vrModel.unTriangleCount * 3;
|
||||||
@@ -2388,6 +2397,7 @@ int main(int argc, char *argv[])
|
|||||||
if (gVideoFileName)
|
if (gVideoFileName)
|
||||||
pMainApplication->getApp()->dumpFramesToVideo(gVideoFileName);
|
pMainApplication->getApp()->dumpFramesToVideo(gVideoFileName);
|
||||||
|
|
||||||
|
#ifndef B3_USE_GLFW
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
//request disable VSYNC
|
//request disable VSYNC
|
||||||
typedef bool (APIENTRY *PFNWGLSWAPINTERVALFARPROC)(int);
|
typedef bool (APIENTRY *PFNWGLSWAPINTERVALFARPROC)(int);
|
||||||
@@ -2397,7 +2407,7 @@ int main(int argc, char *argv[])
|
|||||||
if (wglSwapIntervalEXT)
|
if (wglSwapIntervalEXT)
|
||||||
wglSwapIntervalEXT(0);
|
wglSwapIntervalEXT(0);
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
GLint sync = 0;
|
GLint sync = 0;
|
||||||
CGLContextObj ctx = CGLGetCurrentContext();
|
CGLContextObj ctx = CGLGetCurrentContext();
|
||||||
|
|||||||
@@ -5,6 +5,10 @@
|
|||||||
#include "Gwen/Texture.h"
|
#include "Gwen/Texture.h"
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#ifdef B3_USE_GLFW
|
||||||
|
#include "glad/glad.h"
|
||||||
|
#include <GLFW/glfw3.h>
|
||||||
|
#else
|
||||||
|
|
||||||
#if defined(__APPLE__) && !defined (VMDMESA)
|
#if defined(__APPLE__) && !defined (VMDMESA)
|
||||||
#include <OpenGL/OpenGL.h>
|
#include <OpenGL/OpenGL.h>
|
||||||
@@ -22,6 +26,7 @@
|
|||||||
#endif //NO_GLEW
|
#endif //NO_GLEW
|
||||||
#endif //GLEW_STATIC
|
#endif //GLEW_STATIC
|
||||||
#endif//(__APPLE__)
|
#endif//(__APPLE__)
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "FontData.h"
|
#include "FontData.h"
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,10 @@
|
|||||||
extern unsigned char OpenSansData[];
|
extern unsigned char OpenSansData[];
|
||||||
|
|
||||||
#include "Gwen/Renderers/OpenGL_DebugFont.h"
|
#include "Gwen/Renderers/OpenGL_DebugFont.h"
|
||||||
|
|
||||||
|
#ifdef B3_USE_GLFW
|
||||||
|
#include "OpenGLWindow/GLFWOpenGLWindow.h"
|
||||||
|
#else
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#include "OpenGLWindow/MacOpenGLWindow.h"
|
#include "OpenGLWindow/MacOpenGLWindow.h"
|
||||||
#else
|
#else
|
||||||
@@ -21,7 +25,7 @@ extern unsigned char OpenSansData[];
|
|||||||
#include "OpenGLWindow/X11OpenGLWindow.h"
|
#include "OpenGLWindow/X11OpenGLWindow.h"
|
||||||
#endif //_WIN32
|
#endif //_WIN32
|
||||||
#endif//__APPLE__
|
#endif//__APPLE__
|
||||||
|
#endif //B3_USE_GLFW
|
||||||
#include "OpenGLWindow/opengl_fontstashcallbacks.h"
|
#include "OpenGLWindow/opengl_fontstashcallbacks.h"
|
||||||
#ifndef NO_OPENGL3
|
#ifndef NO_OPENGL3
|
||||||
#include "OpenGLWindow/GwenOpenGL3CoreRenderer.h"
|
#include "OpenGLWindow/GwenOpenGL3CoreRenderer.h"
|
||||||
@@ -345,7 +349,7 @@ int main()
|
|||||||
if (majorGlVersion>=3 && wci.m_openglVersion>=3)
|
if (majorGlVersion>=3 && wci.m_openglVersion>=3)
|
||||||
{
|
{
|
||||||
float retinaScale = 1.f;
|
float retinaScale = 1.f;
|
||||||
|
#ifndef B3_USE_GLFW
|
||||||
#ifndef __APPLE__
|
#ifndef __APPLE__
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
//we need glewExperimental on Linux
|
//we need glewExperimental on Linux
|
||||||
@@ -353,7 +357,7 @@ int main()
|
|||||||
#endif // _WIN32
|
#endif // _WIN32
|
||||||
glewInit();
|
glewInit();
|
||||||
#endif
|
#endif
|
||||||
|
#endif //B3_USE_GLFW
|
||||||
//we ned to call glGetError twice, because of some Ubuntu/Intel/OpenGL issue
|
//we ned to call glGetError twice, because of some Ubuntu/Intel/OpenGL issue
|
||||||
|
|
||||||
GLuint err = glGetError();
|
GLuint err = glGetError();
|
||||||
|
|||||||
@@ -44,6 +44,9 @@
|
|||||||
"**.cpp",
|
"**.cpp",
|
||||||
"**.h",
|
"**.h",
|
||||||
}
|
}
|
||||||
|
files {
|
||||||
|
"../../examples/OpenGLWindow/GLFWOpenGLWindow.cpp",
|
||||||
|
}
|
||||||
if os.is("Windows") then
|
if os.is("Windows") then
|
||||||
files {
|
files {
|
||||||
"../../examples/OpenGLWindow/Win32OpenGLWindow.cpp",
|
"../../examples/OpenGLWindow/Win32OpenGLWindow.cpp",
|
||||||
@@ -62,7 +65,6 @@
|
|||||||
end
|
end
|
||||||
if os.is("MacOSX") then
|
if os.is("MacOSX") then
|
||||||
links{"Cocoa.framework"}
|
links{"Cocoa.framework"}
|
||||||
print("hello!")
|
|
||||||
files{
|
files{
|
||||||
"../../examples/OpenGLWindow/MacOpenGLWindow.cpp",
|
"../../examples/OpenGLWindow/MacOpenGLWindow.cpp",
|
||||||
"../../examples/OpenGLWindow/MacOpenGLWindow.h",
|
"../../examples/OpenGLWindow/MacOpenGLWindow.h",
|
||||||
|
|||||||
Reference in New Issue
Block a user