Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

isolate calls that do not compile with mesa

  • Loading branch information...
commit 0837638a0c7aac1e406c95aa94500f94a8fc3ed7 1 parent 7e432dd
@lubosz authored
View
6 CMakeLists.txt
@@ -9,6 +9,8 @@ option(RELEASE "Release" OFF)
option(CHECKSTYLE "Check Style" OFF)
option(BUILD_TESTS "Build Tests" OFF)
+option(USE_OPENGL3 "Use OpenGL3+ Calls (can be disabled to build with mesa)" On)
+
option(USE_QT_WINDOWS "Use Qt Windows For All Apps" OFF)
option(USE_GLEW "Use Qt Windows For All Apps" OFF)
@@ -24,6 +26,10 @@ if(USE_GLEW)
ADD_DEFINITIONS(-DUSE_GLEW)
endif()
+if(USE_OPENGL3)
+ ADD_DEFINITIONS(-DUSE_OPENGL3)
+endif()
+
if(USE_QT_WINDOWS)
ADD_DEFINITIONS(-DUSE_QT_WINDOWS)
endif()
View
4 apps/deferred.cpp
@@ -279,6 +279,7 @@ void DeferredLightApp::initLightBuffer(ShaderProgram * shader, const string& buf
lightBuffer = new UniformBuffer();
lightBuffer->bind();
+ #ifdef USE_OPENGL3
GLuint uniBlockIndex = glGetUniformBlockIndex(shader->getHandle(), bufferName.c_str());
glGetActiveUniformBlockiv(
shader->getHandle(),
@@ -286,6 +287,7 @@ void DeferredLightApp::initLightBuffer(ShaderProgram * shader, const string& buf
GL_UNIFORM_BLOCK_DATA_SIZE,
&lightBufferSize
);
+#endif
LogDebug << "Light Uniform Buffer Size" << lightBufferSize;
@@ -306,7 +308,9 @@ void DeferredLightApp::initLightBuffer(ShaderProgram * shader, const string& buf
lightBuffer->write(lightBufferData, lightBufferSize);
// shader->uniformBuffers.push_back(lightBuffer);
+ #ifdef USE_OPENGL3
shader->bindUniformBuffer(bufferName,0,lightBuffer->getHandle());
+ #endif
}
int main(int argc, char *argv[]) {
View
2  apps/tesselation.cpp
@@ -102,8 +102,10 @@ class TesselationApp: public Application {
// glEnable(GL_CULL_FACE);
groundNode->setView(camera);
glError;
+ #ifdef USE_OPENGL3
glPatchParameteri(GL_PATCH_VERTICES, 3);
groundNode->draw();
+ #endif
glError;
}
};
View
4 src/Material/ShaderProgram.cpp
@@ -253,7 +253,7 @@ void ShaderProgram::translateUniformf(unsigned id, const vector<float> & values)
uniforms[id].values[i] += values[i];
uniforms[id].init(handle);
}
-
+#ifdef USE_OPENGL3
void ShaderProgram::bindUniformBuffer(string name, GLuint bindIndex, GLuint bufferHandle) {
glBindBufferBase(GL_UNIFORM_BUFFER, bindIndex, bufferHandle);
GLuint blockIndex = glGetUniformBlockIndex(handle, name.c_str());
@@ -262,7 +262,7 @@ void ShaderProgram::bindUniformBuffer(string name, GLuint bindIndex, GLuint buff
glUniformBlockBinding(handle, blockIndex, bindIndex);
glError;
}
-
+#endif
void ShaderProgram::addTexture(Texture * texture) {
textures.push_back(texture);
}
View
3  src/Material/ShaderProgram.h
@@ -56,8 +56,9 @@ class ShaderProgram {
void translateUniformf(unsigned id, const vector<float> & values);
void initUniforms();
+ #ifdef USE_OPENGL3
void bindUniformBuffer(string name, GLuint bindIndex, GLuint bufferHandle);
-
+ #endif
void samplerUniforms();
void addTexture(Texture * texture);
void addTextures(const vector<Texture *> &addTextures);
View
3  src/Mesh/Mesh.cpp
@@ -124,8 +124,11 @@ void Mesh::draw() {
foreach(Mesh * mesh, subMeshes)
mesh->draw();
} else {
+
+#ifdef USE_OPENGL3
glBindVertexArray(vao);
glDrawElements(drawType, indexSize, GL_UNSIGNED_INT, 0);
+#endif
glError;
}
}
View
6 src/Renderer/OpenGL.cpp
@@ -138,19 +138,17 @@ void OpenGL::checkVersion() {
glGetIntegerv(GL_NUM_EXTENSIONS, &numext);
LogInfo << "Found " << numext << " GL_EXTENSIONS";
-
+#ifdef USE_OPENGL3
glGetIntegerv(GL_MAX_VERTEX_UNIFORM_BLOCKS, &uniformSize);
LogInfo << "GL_MAX_VERTEX_UNIFORM_BLOCKS" << uniformSize;
-
glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_BLOCKS, &uniformSize);
LogInfo << "GL_MAX_FRAGMENT_UNIFORM_BLOCKS" << uniformSize;
-
glGetIntegerv(GL_MAX_GEOMETRY_UNIFORM_BLOCKS, &uniformSize);
LogInfo << "GL_MAX_GEOMETRY_UNIFORM_BLOCKS" << uniformSize;
glGetIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE, &uniformSize);
LogInfo << "GL_MAX_UNIFORM_BLOCK_SIZE" << uniformSize;
-
+#endif
// print max # of colorbuffers supported by FBO
int colorBufferCount = 0;
glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, &colorBufferCount);
View
4 src/Scene/InstancedSponge.cpp
@@ -99,8 +99,10 @@
shader->activateAndBindTextures();
foreach (UniformBuffer * buffer, positionBuffers){
buffer->bind();
+ #ifdef USE_OPENGL3
shader->bindUniformBuffer("positions", 0,
buffer->getHandle());
+ #endif
mesh->draw(positionBufferDataSize);
}
}
@@ -137,8 +139,10 @@
positionBuffer->write(positionBufferData->data(), positionBufferSize);
+ #ifdef USE_OPENGL3
shader->bindUniformBuffer("positions", 0,
positionBuffer->getHandle());
+ #endif
glError;
return positionBuffer;
}
View
5 src/System/TemplateEngine.cpp
@@ -24,7 +24,12 @@ TemplateEngine::TemplateEngine() {
vector<int> glContext = Config::Instance().values<int>("GLcontext");
+#ifdef USE_OPENGL3
QString version = QString::number(glContext[0]) + QString::number(glContext[1]) + "0 core";
+#else
+ QString version = "130";
+#endif
+
c.insert("version", version);
}
View
8 src/Window/XCB/XCBWindow.cpp
@@ -125,7 +125,7 @@ void XCBWindow::createGLContext() {
};
/* Get a pointer to the context creation function for GL 3.0 */
-
+#ifdef USE_OPENGL3
const GLubyte *procname =
reinterpret_cast<const GLubyte*>("glXCreateContextAttribsARB");
@@ -139,6 +139,10 @@ void XCBWindow::createGLContext() {
context = glXCreateContextAttribs(display, fb_config, NULL, True,
attribs);
+#else
+ XVisualInfo * foo = glXGetVisualFromFBConfig( display, fb_config );
+ context = glXCreateContext(display, foo, NULL, True);
+#endif
if (!context) LogError << "glXCreateNewContext failed";
}
@@ -194,6 +198,7 @@ void XCBWindow::createWindow() {
LogError << "glXMakeContextCurrent failed";
// Set swap interval
+#ifdef USE_OPENGL3
PFNGLXSWAPINTERVALSGIPROC
glXSwapInterval =
reinterpret_cast<PFNGLXSWAPINTERVALSGIPROC> (glXGetProcAddress(
@@ -203,6 +208,7 @@ void XCBWindow::createWindow() {
} else {
glXSwapInterval(Config::Instance().value<int>("Vsync"));
}
+#endif
setWindowTitle(programTile);
}
Please sign in to comment.
Something went wrong with that request. Please try again.