preparation to replace glew by glad
This commit is contained in:
@@ -35,7 +35,7 @@
|
||||
if _OPTIONS["enable_system_opengl"] and (os.isdir("/usr/include") and os.isfile("/usr/include/GL/gl.h")) then
|
||||
links {"GL"}
|
||||
else
|
||||
print("No GL/gl.h found, using dynamic loading of GL using glew")
|
||||
print("No GL/gl.h found, using dynamic loading of GL using glad")
|
||||
defines {"GLEW_INIT_OPENGL11_FUNCTIONS=1"}
|
||||
links {"dl"}
|
||||
end
|
||||
@@ -50,24 +50,20 @@
|
||||
configuration {"Windows"}
|
||||
defines { "GLEW_STATIC"}
|
||||
includedirs {
|
||||
projectRootDir .. "examples/ThirdPartyLibs/Glew"
|
||||
projectRootDir .. "examples/ThirdPartyLibs/glad"
|
||||
}
|
||||
files { projectRootDir .. "examples/ThirdPartyLibs/Glew/glew.c"}
|
||||
files { projectRootDir .. "examples/ThirdPartyLibs/glad/glad.c"}
|
||||
end
|
||||
if os.is("Linux") then
|
||||
configuration{"Linux"}
|
||||
if _OPTIONS["enable_system_opengl"] and (os.isdir("/usr/include") and os.isfile("/usr/include/GL/gl.h") and os.isfile("/usr/include/GL/glew.h")) then
|
||||
links {"GLEW"}
|
||||
print ("linking against system GLEW")
|
||||
else
|
||||
print("Using static glew and dynamic loading of glx functions")
|
||||
print("Using glad and dynamic loading of glx functions")
|
||||
defines { "GLEW_STATIC","GLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS=1"}
|
||||
includedirs {
|
||||
projectRootDir .. "examples/ThirdPartyLibs/Glew"
|
||||
projectRootDir .. "examples/ThirdPartyLibs/glad"
|
||||
}
|
||||
files { projectRootDir .. "examples/ThirdPartyLibs/Glew/glew.c"}
|
||||
files { projectRootDir .. "examples/ThirdPartyLibs/glad/glad.c",
|
||||
projectRootDir .. "examples/ThirdPartyLibs/glad/glad_glx.c"}
|
||||
links {"dl"}
|
||||
end
|
||||
|
||||
end
|
||||
configuration{}
|
||||
|
||||
Binary file not shown.
@@ -33,7 +33,9 @@ float shadowMapWorldSize=10;
|
||||
#else
|
||||
#ifndef __APPLE__
|
||||
#ifndef glVertexAttribDivisor
|
||||
|
||||
#ifndef NO_GLEW
|
||||
|
||||
#define glVertexAttribDivisor glVertexAttribDivisorARB
|
||||
#endif //NO_GLEW
|
||||
#endif //glVertexAttribDivisor
|
||||
|
||||
@@ -170,7 +170,7 @@ void dumpInfo(void)
|
||||
if (m_resizeCallback)
|
||||
{
|
||||
(*m_resizeCallback)(width,height);
|
||||
}
|
||||
|
||||
#ifndef NO_OPENGL3
|
||||
NSRect backingBounds = [self convertRectToBacking:[self bounds]];
|
||||
GLsizei backingPixelWidth = (GLsizei)(backingBounds.size.width),
|
||||
@@ -183,6 +183,8 @@ void dumpInfo(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[m_context setView: self];
|
||||
[m_context makeCurrentContext];
|
||||
|
||||
@@ -236,7 +238,7 @@ void dumpInfo(void)
|
||||
[fmt release];
|
||||
[m_context makeCurrentContext];
|
||||
|
||||
checkError("makeCurrentContext");
|
||||
//checkError("makeCurrentContext");
|
||||
}
|
||||
|
||||
-(void) MakeCurrent
|
||||
@@ -420,7 +422,7 @@ int Mac_createWindow(struct MacOpenGLWindowInternalData* m_internalData,struct M
|
||||
|
||||
// float newBackingScaleFactor = [m_internalData->m_window backingScaleFactor];
|
||||
|
||||
dumpInfo();
|
||||
//dumpInfo();
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -21,33 +21,7 @@ subject to the following restrictions:
|
||||
#include "glad/glad.h"
|
||||
#include <GLFW/glfw3.h>
|
||||
#else
|
||||
//think different
|
||||
#if defined(__APPLE__) && !defined (VMDMESA)
|
||||
#include <OpenGL/OpenGL.h>
|
||||
#include <OpenGL/gl.h>
|
||||
#else
|
||||
|
||||
#ifdef GLEW_STATIC
|
||||
#include "CustomGL/glew.h"
|
||||
#else
|
||||
#ifdef NO_GLEW
|
||||
#define GL_GLEXT_LEGACY
|
||||
#include "third_party/GL/gl/include/GL/gl.h"
|
||||
#include "third_party/GL/gl/include/GL/glext.h"
|
||||
#else
|
||||
#include <GL/glew.h>
|
||||
#endif //NO_GLEW
|
||||
#endif //GLEW_STATIC
|
||||
|
||||
#ifdef _WINDOWS
|
||||
#include <windows.h>
|
||||
//#include <GL/gl.h>
|
||||
//#include <GL/glu.h>
|
||||
#else
|
||||
//#include <GL/gl.h>
|
||||
//#include <GL/glu.h>
|
||||
#endif //_WINDOWS
|
||||
#endif //APPLE
|
||||
#include "glad/glad.h"
|
||||
#endif //B3_USE_GLFW
|
||||
//disable glGetError
|
||||
//#undef glGetError
|
||||
|
||||
@@ -21,56 +21,8 @@ subject to the following restrictions:
|
||||
#include <glad/glad.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
#else
|
||||
//think different
|
||||
#if defined(__APPLE__) && !defined (VMDMESA)
|
||||
#include <OpenGL/OpenGL.h>
|
||||
//#include <OpenGL/gl.h>
|
||||
//#include <OpenGL/glu.h>
|
||||
//#import <Cocoa/Cocoa.h>
|
||||
#if defined (USE_OPENGL2) || defined (NO_OPENGL3)
|
||||
#include <OpenGL/gl.h>
|
||||
#else
|
||||
#include <OpenGL/gl3.h>
|
||||
#endif
|
||||
#else
|
||||
|
||||
|
||||
#ifdef GLEW_STATIC
|
||||
#include "CustomGL/glew.h"
|
||||
#else
|
||||
#ifdef NO_GLEW
|
||||
#define GL_GLEXT_LEGACY
|
||||
#include "third_party/GL/gl/include/GL/gl.h"
|
||||
#include "third_party/GL/gl/include/GL/glext.h"
|
||||
#else
|
||||
#include <GL/glew.h>
|
||||
#endif //NO_GLEW
|
||||
#endif //GLEW_STATIC
|
||||
|
||||
#ifdef _WINDOWS
|
||||
#include <windows.h>
|
||||
//#include <GL/gl.h>
|
||||
//#include <GL/glu.h>
|
||||
#else
|
||||
//#include <GL/gl.h>
|
||||
//#include <GL/glu.h>
|
||||
#endif //_WINDOWS
|
||||
#endif //APPLE
|
||||
#endif
|
||||
//disable glGetError
|
||||
//#undef glGetError
|
||||
//#define glGetError MyGetError
|
||||
//
|
||||
//GLenum inline MyGetError()
|
||||
//{
|
||||
// return 0;
|
||||
//}
|
||||
|
||||
///on Linux only glDrawElementsInstancedARB is defined?!?
|
||||
//#ifdef __linux
|
||||
//#define glDrawElementsInstanced glDrawElementsInstancedARB
|
||||
//
|
||||
//#endif //__linux
|
||||
#include "glad/glad.h"
|
||||
#endif //B3_USE_GLFW
|
||||
|
||||
#endif //__OPENGL_INCLUDE_H
|
||||
|
||||
|
||||
@@ -44,6 +44,8 @@ static SimpleOpenGL2App* gApp2=0;
|
||||
|
||||
static void Simple2ResizeCallback( float widthf, float heightf)
|
||||
{
|
||||
glViewport(0, 0, widthf, heightf);
|
||||
|
||||
int width = (int)widthf;
|
||||
int height = (int)heightf;
|
||||
if (gApp2->m_renderer && gApp2->m_window)
|
||||
@@ -141,11 +143,14 @@ SimpleOpenGL2App::SimpleOpenGL2App(const char* title, int width, int height)
|
||||
#ifndef _WIN32
|
||||
#ifndef B3_USE_GLFW
|
||||
//some Linux implementations need the 'glewExperimental' to be true
|
||||
glewExperimental = GL_TRUE;
|
||||
#endif//B3_USE_GLFW
|
||||
#endif //_WIN32
|
||||
|
||||
#ifndef B3_USE_GLFW
|
||||
//gladLoadGLLoader((GLADloadproc) glfwGetProcAddress);
|
||||
|
||||
|
||||
#if 0
|
||||
if (glewInit() != GLEW_OK)
|
||||
{
|
||||
b3Error("glewInit failed");
|
||||
@@ -156,6 +161,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
|
||||
#endif //B3_USE_GLFW
|
||||
#endif //__APPLE__
|
||||
#endif //NO_GLEW
|
||||
|
||||
@@ -71,6 +71,8 @@ static SimpleOpenGL3App* gApp=0;
|
||||
|
||||
static void SimpleResizeCallback( float widthf, float heightf)
|
||||
{
|
||||
|
||||
|
||||
int width = (int)widthf;
|
||||
int height = (int)heightf;
|
||||
if (gApp && gApp->m_instancingRenderer)
|
||||
@@ -285,6 +287,14 @@ struct MyRenderCallbacks : public RenderCallbacks
|
||||
}
|
||||
};
|
||||
|
||||
static void printGLString(const char *name, GLenum s) {
|
||||
const char *v = (const char *) glGetString(s);
|
||||
printf("%s = %s\n",name, v);
|
||||
}
|
||||
|
||||
bool sOpenGLVerbose = true;
|
||||
|
||||
|
||||
SimpleOpenGL3App::SimpleOpenGL3App( const char* title, int width,int height, bool allowRetina)
|
||||
{
|
||||
gApp = this;
|
||||
@@ -308,8 +318,17 @@ SimpleOpenGL3App::SimpleOpenGL3App( const char* title, int width,int height, boo
|
||||
|
||||
m_window->setWindowTitle(title);
|
||||
|
||||
|
||||
|
||||
|
||||
b3Assert(glGetError() ==GL_NO_ERROR);
|
||||
|
||||
{
|
||||
printGLString("Version", GL_VERSION);
|
||||
printGLString("Vendor", GL_VENDOR);
|
||||
printGLString("Renderer", GL_RENDERER);
|
||||
}
|
||||
|
||||
glClearColor( m_backgroundColorRGB[0],
|
||||
m_backgroundColorRGB[1],
|
||||
m_backgroundColorRGB[2],
|
||||
@@ -321,7 +340,10 @@ SimpleOpenGL3App::SimpleOpenGL3App( const char* title, int width,int height, boo
|
||||
|
||||
b3Assert(glGetError() ==GL_NO_ERROR);
|
||||
|
||||
#ifndef NO_GLEW
|
||||
//gladLoadGLLoader((GLADloadproc) glfwGetProcAddress);
|
||||
|
||||
|
||||
#ifdef USE_GLEW
|
||||
#ifndef __APPLE__
|
||||
#ifndef _WIN32
|
||||
#ifndef B3_USE_GLFW
|
||||
@@ -337,7 +359,8 @@ SimpleOpenGL3App::SimpleOpenGL3App( const char* title, int width,int height, boo
|
||||
exit(1); // or handle the error in a nicer way
|
||||
#endif //B3_USE_GLFW
|
||||
#endif //__APPLE__
|
||||
#endif //NO_GLEW
|
||||
#endif //USE_GLEW
|
||||
|
||||
glGetError();//don't remove this call, it is needed for Ubuntu
|
||||
|
||||
b3Assert(glGetError() ==GL_NO_ERROR);
|
||||
|
||||
@@ -25,12 +25,6 @@ subject to the following restrictions:
|
||||
#include "Win32InternalWindowData.h"
|
||||
#include <stdio.h>
|
||||
|
||||
static void printGLString(const char *name, GLenum s) {
|
||||
const char *v = (const char *) glGetString(s);
|
||||
printf("%s = %s\n",name, v);
|
||||
}
|
||||
|
||||
bool sOpenGLVerbose = true;
|
||||
|
||||
void Win32OpenGLWindow::enableOpenGL()
|
||||
{
|
||||
@@ -63,12 +57,7 @@ void Win32OpenGLWindow::enableOpenGL()
|
||||
m_data->m_hRC = wglCreateContext( m_data->m_hDC );
|
||||
wglMakeCurrent( m_data->m_hDC, m_data->m_hRC );
|
||||
|
||||
if (sOpenGLVerbose)
|
||||
{
|
||||
printGLString("Version", GL_VERSION);
|
||||
printGLString("Vendor", GL_VENDOR);
|
||||
printGLString("Renderer", GL_RENDERER);
|
||||
}
|
||||
|
||||
//printGLString("Extensions", GL_EXTENSIONS);
|
||||
|
||||
}
|
||||
@@ -147,6 +136,7 @@ void Win32OpenGLWindow::endRendering()
|
||||
|
||||
int Win32OpenGLWindow::fileOpenDialog(char* fileName, int maxFileNameLength)
|
||||
{
|
||||
#if 0
|
||||
//wchar_t wideChars[1024];
|
||||
|
||||
OPENFILENAME ofn ;
|
||||
@@ -176,9 +166,9 @@ int Win32OpenGLWindow::fileOpenDialog(char* fileName, int maxFileNameLength)
|
||||
ofn.Flags = OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST ;
|
||||
GetOpenFileName( &ofn );
|
||||
return strlen(fileName);
|
||||
|
||||
|
||||
//return 0;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int Win32OpenGLWindow::getWidth() const
|
||||
|
||||
@@ -413,7 +413,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
sData->m_fullWindowHeight = wr.bottom-wr.top;//LOWORD (lParam) HIWORD (lParam);
|
||||
sData->m_openglViewportWidth = clientRect.right;
|
||||
sData->m_openglViewportHeight = clientRect.bottom;
|
||||
glViewport(0, 0, sData->m_openglViewportWidth, sData->m_openglViewportHeight);
|
||||
//glViewport(0, 0, sData->m_openglViewportWidth, sData->m_openglViewportHeight);
|
||||
|
||||
if (sData->m_resizeCallback)
|
||||
(*sData->m_resizeCallback)(sData->m_openglViewportWidth,sData->m_openglViewportHeight);
|
||||
|
||||
@@ -7,15 +7,15 @@
|
||||
#include<stdio.h>
|
||||
#include<stdlib.h>
|
||||
#ifdef GLEW_STATIC
|
||||
#include "CustomGL/glew.h"
|
||||
#include "glad/glad.h"
|
||||
#else
|
||||
#include <GL/glew.h>
|
||||
#endif//GLEW_STATIC
|
||||
|
||||
#ifdef GLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS
|
||||
#include "CustomGL/glxew.h"
|
||||
#include "glad/glad_glx.h"
|
||||
#else
|
||||
#include<GL/glx.h>
|
||||
#include "GL/glx.h"
|
||||
#endif // GLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS
|
||||
#include <assert.h>
|
||||
|
||||
@@ -473,20 +473,12 @@ void X11OpenGLWindow::enableOpenGL()
|
||||
glXMakeCurrent(m_data->m_dpy, m_data->m_win, m_data->m_glc);
|
||||
}
|
||||
|
||||
#ifdef GLEW_INIT_OPENGL11_FUNCTIONS
|
||||
{
|
||||
GLboolean res = glewOpenGL11Init();
|
||||
if (res==0)
|
||||
{
|
||||
printf("glewOpenGL11Init OK!\n");
|
||||
} else
|
||||
{
|
||||
fprintf(stderr, "ERROR: glewOpenGL11Init failed, exiting!\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if(!gladLoadGL()) {
|
||||
printf("gladLoadGL failed!\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
#endif //GLEW_INIT_OPENGL11_FUNCTIONS
|
||||
|
||||
|
||||
const GLubyte* ven = glGetString(GL_VENDOR);
|
||||
printf("GL_VENDOR=%s\n", ven);
|
||||
@@ -530,18 +522,16 @@ void X11OpenGLWindow::createWindow(const b3gWindowConstructionInfo& ci)
|
||||
|
||||
m_data->m_root = DefaultRootWindow(m_data->m_dpy);
|
||||
|
||||
|
||||
#ifdef GLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS
|
||||
GLboolean res = glewXInit();
|
||||
if (res==0)
|
||||
|
||||
int res=gladLoadGLX(m_data->m_dpy,DefaultScreen(m_data->m_dpy));
|
||||
if (!res)
|
||||
{
|
||||
printf("glewXInit OK\n");
|
||||
} else
|
||||
{
|
||||
fprintf(stderr, "glewXInit failed, exit\n");
|
||||
exit(EXIT_FAILURE);
|
||||
printf("Error in gladLoadGLX\n");
|
||||
exit(0);
|
||||
}
|
||||
#endif //GLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
if (ci.m_openglVersion < 3)
|
||||
|
||||
@@ -72,7 +72,7 @@ project ("App_RobotSimulator")
|
||||
|
||||
includedirs {"../../src", "../../examples",
|
||||
"../../examples/ThirdPartyLibs"}
|
||||
defines {"PHYSICS_IN_PROCESS_EXAMPLE_BROWSER"}
|
||||
defines {"B3_USE_ROBOTSIM_GUI", "PHYSICS_IN_PROCESS_EXAMPLE_BROWSER"}
|
||||
|
||||
hasCL = findOpenCL("clew")
|
||||
|
||||
|
||||
@@ -6587,7 +6587,10 @@ bool PhysicsServerCommandProcessor::processSendPhysicsParametersCommand(const st
|
||||
clientCmd.m_physSimParamArgs.m_gravityAcceleration[1],
|
||||
clientCmd.m_physSimParamArgs.m_gravityAcceleration[2]);
|
||||
this->m_data->m_dynamicsWorld->setGravity(grav);
|
||||
#ifndef SKIP_SOFT_BODY_MULTI_BODY_DYNAMICS_WORLD
|
||||
m_data->m_dynamicsWorld->getWorldInfo().m_gravity=grav;
|
||||
|
||||
#endif
|
||||
if (m_data->m_verboseOutput)
|
||||
{
|
||||
b3Printf("Updated Gravity: %f,%f,%f",grav[0],grav[1],grav[2]);
|
||||
|
||||
@@ -78,7 +78,7 @@ int main(int argc, char* argv[])
|
||||
b3CommandLineArgs myArgs(argc, argv);
|
||||
|
||||
|
||||
SimpleOpenGLApp* app = new SimpleOpenGLApp("SimpleOpenGL3App", gWidth, gHeight);
|
||||
SimpleOpenGLApp* app = new SimpleOpenGLApp("SimpleOpenGL3App", 1024, 768);
|
||||
|
||||
app->m_renderer->getActiveCamera()->setCameraDistance(13);
|
||||
app->m_renderer->getActiveCamera()->setCameraPitch(0);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -15,7 +15,7 @@
|
||||
#include <OpenGL/gl.h>
|
||||
#else
|
||||
#ifdef GLEW_STATIC
|
||||
#include "CustomGL/glew.h"
|
||||
#include "glad/glad.h"
|
||||
#else
|
||||
#ifdef NO_GLEW
|
||||
#define GL_GLEXT_LEGACY
|
||||
|
||||
@@ -1991,7 +1991,7 @@ static void load_GL_VERSION_3_2(GLADloadproc load) {
|
||||
glad_glSampleMaski = (PFNGLSAMPLEMASKIPROC)load("glSampleMaski");
|
||||
}
|
||||
static void load_GL_VERSION_3_3(GLADloadproc load) {
|
||||
if(!GLAD_GL_VERSION_3_3) return;
|
||||
//if(!GLAD_GL_VERSION_3_3) return;
|
||||
glad_glBindFragDataLocationIndexed = (PFNGLBINDFRAGDATALOCATIONINDEXEDPROC)load("glBindFragDataLocationIndexed");
|
||||
glad_glGetFragDataIndex = (PFNGLGETFRAGDATAINDEXPROC)load("glGetFragDataIndex");
|
||||
glad_glGenSamplers = (PFNGLGENSAMPLERSPROC)load("glGenSamplers");
|
||||
|
||||
@@ -355,9 +355,8 @@ int main()
|
||||
#ifndef __APPLE__
|
||||
#ifndef _WIN32
|
||||
//we need glewExperimental on Linux
|
||||
glewExperimental = GL_TRUE;
|
||||
#endif // _WIN32
|
||||
glewInit();
|
||||
gladLoadGL();
|
||||
#endif
|
||||
#endif //B3_USE_GLFW
|
||||
//we ned to call glGetError twice, because of some Ubuntu/Intel/OpenGL issue
|
||||
|
||||
Reference in New Issue
Block a user