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" )
|
||||
location("./" .. act .. postfix)
|
||||
|
||||
projectRootDir = os.getcwd() .. "/../"
|
||||
print("Project root directory: " .. projectRootDir);
|
||||
|
||||
if not _OPTIONS["python_include_dir"] then
|
||||
_OPTIONS["python_include_dir"] = default_python_include_dir
|
||||
end
|
||||
@@ -246,21 +249,74 @@ end
|
||||
_OPTIONS["python_lib_dir"] = default_python_lib_dir
|
||||
end
|
||||
|
||||
newoption
|
||||
{
|
||||
trigger = "glfw_include_dir",
|
||||
value = default_glfw_include_dir,
|
||||
description = "GLFW 3.x include directory"
|
||||
}
|
||||
|
||||
newoption
|
||||
{
|
||||
trigger = "glfw_lib_dir",
|
||||
value = default_glfw_lib_dir,
|
||||
description = "(optional) GLFW 3.x library directory "
|
||||
}
|
||||
|
||||
newoption
|
||||
{
|
||||
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")
|
||||
if (not findOpenGL3()) then
|
||||
defines {"NO_OPENGL3"}
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
projectRootDir = os.getcwd() .. "/../"
|
||||
print("Project root directory: " .. projectRootDir);
|
||||
|
||||
dofile ("findOpenCL.lua")
|
||||
dofile ("findDirectX11.lua")
|
||||
dofile ("findOpenGLGlewGlut.lua")
|
||||
|
||||
if (not findOpenGL3()) then
|
||||
defines {"NO_OPENGL3"}
|
||||
end
|
||||
|
||||
|
||||
language "C++"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if _OPTIONS["audio"] then
|
||||
include "../examples/TinyAudio"
|
||||
end
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifndef B3_USE_GLFW
|
||||
#ifdef _WIN32
|
||||
/*
|
||||
Copyright (c) 2012 Advanced Micro Devices, Inc.
|
||||
@@ -197,4 +198,4 @@ int Win32OpenGLWindow::getHeight() const
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#endif //B3_USE_GLFW
|
||||
@@ -1281,9 +1281,13 @@ bool CMainApplication::SetupTexturemaps()
|
||||
|
||||
#ifdef WIN32
|
||||
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);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, fLargest);
|
||||
#endif
|
||||
#endif
|
||||
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 );
|
||||
#ifdef _WIN32
|
||||
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 );
|
||||
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, fLargest );
|
||||
#endif
|
||||
#endif //B3_USE_GLFW
|
||||
#endif//_WIN32
|
||||
glBindTexture( GL_TEXTURE_2D, 0 );
|
||||
|
||||
m_unVertexCount = vrModel.unTriangleCount * 3;
|
||||
@@ -2388,6 +2397,7 @@ int main(int argc, char *argv[])
|
||||
if (gVideoFileName)
|
||||
pMainApplication->getApp()->dumpFramesToVideo(gVideoFileName);
|
||||
|
||||
#ifndef B3_USE_GLFW
|
||||
#ifdef _WIN32
|
||||
//request disable VSYNC
|
||||
typedef bool (APIENTRY *PFNWGLSWAPINTERVALFARPROC)(int);
|
||||
@@ -2397,7 +2407,7 @@ int main(int argc, char *argv[])
|
||||
if (wglSwapIntervalEXT)
|
||||
wglSwapIntervalEXT(0);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#ifdef __APPLE__
|
||||
GLint sync = 0;
|
||||
CGLContextObj ctx = CGLGetCurrentContext();
|
||||
|
||||
@@ -5,6 +5,10 @@
|
||||
#include "Gwen/Texture.h"
|
||||
|
||||
#include <math.h>
|
||||
#ifdef B3_USE_GLFW
|
||||
#include "glad/glad.h"
|
||||
#include <GLFW/glfw3.h>
|
||||
#else
|
||||
|
||||
#if defined(__APPLE__) && !defined (VMDMESA)
|
||||
#include <OpenGL/OpenGL.h>
|
||||
@@ -22,6 +26,7 @@
|
||||
#endif //NO_GLEW
|
||||
#endif //GLEW_STATIC
|
||||
#endif//(__APPLE__)
|
||||
#endif
|
||||
|
||||
#include "FontData.h"
|
||||
|
||||
|
||||
@@ -9,6 +9,10 @@
|
||||
extern unsigned char OpenSansData[];
|
||||
|
||||
#include "Gwen/Renderers/OpenGL_DebugFont.h"
|
||||
|
||||
#ifdef B3_USE_GLFW
|
||||
#include "OpenGLWindow/GLFWOpenGLWindow.h"
|
||||
#else
|
||||
#ifdef __APPLE__
|
||||
#include "OpenGLWindow/MacOpenGLWindow.h"
|
||||
#else
|
||||
@@ -21,7 +25,7 @@ extern unsigned char OpenSansData[];
|
||||
#include "OpenGLWindow/X11OpenGLWindow.h"
|
||||
#endif //_WIN32
|
||||
#endif//__APPLE__
|
||||
|
||||
#endif //B3_USE_GLFW
|
||||
#include "OpenGLWindow/opengl_fontstashcallbacks.h"
|
||||
#ifndef NO_OPENGL3
|
||||
#include "OpenGLWindow/GwenOpenGL3CoreRenderer.h"
|
||||
@@ -345,7 +349,7 @@ int main()
|
||||
if (majorGlVersion>=3 && wci.m_openglVersion>=3)
|
||||
{
|
||||
float retinaScale = 1.f;
|
||||
|
||||
#ifndef B3_USE_GLFW
|
||||
#ifndef __APPLE__
|
||||
#ifndef _WIN32
|
||||
//we need glewExperimental on Linux
|
||||
@@ -353,7 +357,7 @@ int main()
|
||||
#endif // _WIN32
|
||||
glewInit();
|
||||
#endif
|
||||
|
||||
#endif //B3_USE_GLFW
|
||||
//we ned to call glGetError twice, because of some Ubuntu/Intel/OpenGL issue
|
||||
|
||||
GLuint err = glGetError();
|
||||
|
||||
@@ -44,6 +44,9 @@
|
||||
"**.cpp",
|
||||
"**.h",
|
||||
}
|
||||
files {
|
||||
"../../examples/OpenGLWindow/GLFWOpenGLWindow.cpp",
|
||||
}
|
||||
if os.is("Windows") then
|
||||
files {
|
||||
"../../examples/OpenGLWindow/Win32OpenGLWindow.cpp",
|
||||
@@ -62,7 +65,6 @@
|
||||
end
|
||||
if os.is("MacOSX") then
|
||||
links{"Cocoa.framework"}
|
||||
print("hello!")
|
||||
files{
|
||||
"../../examples/OpenGLWindow/MacOpenGLWindow.cpp",
|
||||
"../../examples/OpenGLWindow/MacOpenGLWindow.h",
|
||||
|
||||
Reference in New Issue
Block a user