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
|
if _OPTIONS["enable_system_opengl"] and (os.isdir("/usr/include") and os.isfile("/usr/include/GL/gl.h")) then
|
||||||
links {"GL"}
|
links {"GL"}
|
||||||
else
|
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"}
|
defines {"GLEW_INIT_OPENGL11_FUNCTIONS=1"}
|
||||||
links {"dl"}
|
links {"dl"}
|
||||||
end
|
end
|
||||||
@@ -50,24 +50,20 @@
|
|||||||
configuration {"Windows"}
|
configuration {"Windows"}
|
||||||
defines { "GLEW_STATIC"}
|
defines { "GLEW_STATIC"}
|
||||||
includedirs {
|
includedirs {
|
||||||
projectRootDir .. "examples/ThirdPartyLibs/Glew"
|
projectRootDir .. "examples/ThirdPartyLibs/glad"
|
||||||
}
|
}
|
||||||
files { projectRootDir .. "examples/ThirdPartyLibs/Glew/glew.c"}
|
files { projectRootDir .. "examples/ThirdPartyLibs/glad/glad.c"}
|
||||||
end
|
end
|
||||||
if os.is("Linux") then
|
if os.is("Linux") then
|
||||||
configuration{"Linux"}
|
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
|
print("Using glad and dynamic loading of glx functions")
|
||||||
links {"GLEW"}
|
|
||||||
print ("linking against system GLEW")
|
|
||||||
else
|
|
||||||
print("Using static glew and dynamic loading of glx functions")
|
|
||||||
defines { "GLEW_STATIC","GLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS=1"}
|
defines { "GLEW_STATIC","GLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS=1"}
|
||||||
includedirs {
|
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"}
|
links {"dl"}
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
configuration{}
|
configuration{}
|
||||||
|
|||||||
Binary file not shown.
@@ -33,7 +33,9 @@ float shadowMapWorldSize=10;
|
|||||||
#else
|
#else
|
||||||
#ifndef __APPLE__
|
#ifndef __APPLE__
|
||||||
#ifndef glVertexAttribDivisor
|
#ifndef glVertexAttribDivisor
|
||||||
|
|
||||||
#ifndef NO_GLEW
|
#ifndef NO_GLEW
|
||||||
|
|
||||||
#define glVertexAttribDivisor glVertexAttribDivisorARB
|
#define glVertexAttribDivisor glVertexAttribDivisorARB
|
||||||
#endif //NO_GLEW
|
#endif //NO_GLEW
|
||||||
#endif //glVertexAttribDivisor
|
#endif //glVertexAttribDivisor
|
||||||
@@ -132,7 +134,7 @@ struct b3GraphicsInstance
|
|||||||
int m_numIndices;
|
int m_numIndices;
|
||||||
int m_numVertices;
|
int m_numVertices;
|
||||||
|
|
||||||
|
|
||||||
int m_numGraphicsInstances;
|
int m_numGraphicsInstances;
|
||||||
b3AlignedObjectArray<int> m_tempObjectUids;
|
b3AlignedObjectArray<int> m_tempObjectUids;
|
||||||
int m_instanceOffset;
|
int m_instanceOffset;
|
||||||
@@ -217,7 +219,7 @@ struct InternalDataRenderer : public GLInstanceRendererInternalData
|
|||||||
|
|
||||||
SimpleCamera m_defaultCamera1;
|
SimpleCamera m_defaultCamera1;
|
||||||
CommonCameraInterface* m_activeCamera;
|
CommonCameraInterface* m_activeCamera;
|
||||||
|
|
||||||
GLfloat m_projectionMatrix[16];
|
GLfloat m_projectionMatrix[16];
|
||||||
GLfloat m_viewMatrix[16];
|
GLfloat m_viewMatrix[16];
|
||||||
GLfloat m_viewMatrixInverse[16];
|
GLfloat m_viewMatrixInverse[16];
|
||||||
@@ -230,9 +232,9 @@ struct InternalDataRenderer : public GLInstanceRendererInternalData
|
|||||||
|
|
||||||
GLRenderToTexture* m_shadowMap;
|
GLRenderToTexture* m_shadowMap;
|
||||||
GLuint m_shadowTexture;
|
GLuint m_shadowTexture;
|
||||||
|
|
||||||
GLuint m_renderFrameBuffer;
|
GLuint m_renderFrameBuffer;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
b3ResizablePool< b3PublicGraphicsInstance> m_publicGraphicsInstances;
|
b3ResizablePool< b3PublicGraphicsInstance> m_publicGraphicsInstances;
|
||||||
@@ -256,7 +258,7 @@ struct InternalDataRenderer : public GLInstanceRendererInternalData
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -471,7 +473,7 @@ void GLInstancingRenderer::readSingleInstanceTransformFromCPU(int srcIndex2, flo
|
|||||||
position[0] = m_data->m_instance_positions_ptr[srcIndex*4+0];
|
position[0] = m_data->m_instance_positions_ptr[srcIndex*4+0];
|
||||||
position[1] = m_data->m_instance_positions_ptr[srcIndex*4+1];
|
position[1] = m_data->m_instance_positions_ptr[srcIndex*4+1];
|
||||||
position[2] = m_data->m_instance_positions_ptr[srcIndex*4+2];
|
position[2] = m_data->m_instance_positions_ptr[srcIndex*4+2];
|
||||||
|
|
||||||
orientation[0] = m_data->m_instance_quaternion_ptr[srcIndex*4+0];
|
orientation[0] = m_data->m_instance_quaternion_ptr[srcIndex*4+0];
|
||||||
orientation[1] = m_data->m_instance_quaternion_ptr[srcIndex*4+1];
|
orientation[1] = m_data->m_instance_quaternion_ptr[srcIndex*4+1];
|
||||||
orientation[2] = m_data->m_instance_quaternion_ptr[srcIndex*4+2];
|
orientation[2] = m_data->m_instance_quaternion_ptr[srcIndex*4+2];
|
||||||
@@ -640,11 +642,11 @@ void GLInstancingRenderer::writeTransforms()
|
|||||||
//B3_PROFILE("b3Assert(glGetError() 2");
|
//B3_PROFILE("b3Assert(glGetError() 2");
|
||||||
b3Assert(glGetError() ==GL_NO_ERROR);
|
b3Assert(glGetError() ==GL_NO_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef B3_DEBUG
|
#ifdef B3_DEBUG
|
||||||
{
|
{
|
||||||
|
|
||||||
//B3_PROFILE("m_data->m_totalNumInstances == totalNumInstances");
|
//B3_PROFILE("m_data->m_totalNumInstances == totalNumInstances");
|
||||||
|
|
||||||
int totalNumInstances= 0;
|
int totalNumInstances= 0;
|
||||||
@@ -693,8 +695,8 @@ void GLInstancingRenderer::writeTransforms()
|
|||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for (int k=0;k<m_graphicsInstances.size();k++)
|
for (int k=0;k<m_graphicsInstances.size();k++)
|
||||||
{
|
{
|
||||||
@@ -703,7 +705,7 @@ void GLInstancingRenderer::writeTransforms()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
char* base = orgBase;
|
char* base = orgBase;
|
||||||
|
|
||||||
@@ -831,7 +833,7 @@ void GLInstancingRenderer::rebuildGraphicsInstances()
|
|||||||
curOffset++;
|
curOffset++;
|
||||||
int objectUniqueId = m_graphicsInstances[i]->m_tempObjectUids[g];
|
int objectUniqueId = m_graphicsInstances[i]->m_tempObjectUids[g];
|
||||||
b3PublicGraphicsInstance* pg = m_data->m_publicGraphicsInstances.getHandle(objectUniqueId);
|
b3PublicGraphicsInstance* pg = m_data->m_publicGraphicsInstances.getHandle(objectUniqueId);
|
||||||
|
|
||||||
registerGraphicsInstanceInternal(objectUniqueId,pg->m_position,pg->m_orientation,pg->m_color,pg->m_scale);
|
registerGraphicsInstanceInternal(objectUniqueId,pg->m_position,pg->m_orientation,pg->m_color,pg->m_scale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -857,7 +859,7 @@ int GLInstancingRenderer::registerGraphicsInstanceInternal(int newUid, const flo
|
|||||||
// b3Assert(pg);
|
// b3Assert(pg);
|
||||||
// int objectIndex = pg->m_internalInstanceIndex;
|
// int objectIndex = pg->m_internalInstanceIndex;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
b3GraphicsInstance* gfxObj = m_graphicsInstances[shapeIndex];
|
b3GraphicsInstance* gfxObj = m_graphicsInstances[shapeIndex];
|
||||||
int index = gfxObj->m_numGraphicsInstances + gfxObj->m_instanceOffset;
|
int index = gfxObj->m_numGraphicsInstances + gfxObj->m_instanceOffset;
|
||||||
@@ -949,7 +951,7 @@ int GLInstancingRenderer::registerTexture(const unsigned char* texels, int width
|
|||||||
b3Assert(glGetError() ==GL_NO_ERROR);
|
b3Assert(glGetError() ==GL_NO_ERROR);
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
int textureIndex = m_data->m_textureHandles.size();
|
int textureIndex = m_data->m_textureHandles.size();
|
||||||
// const GLubyte* image= (const GLubyte*)texels;
|
// const GLubyte* image= (const GLubyte*)texels;
|
||||||
GLuint textureHandle;
|
GLuint textureHandle;
|
||||||
glGenTextures(1,(GLuint*)&textureHandle);
|
glGenTextures(1,(GLuint*)&textureHandle);
|
||||||
glBindTexture(GL_TEXTURE_2D,textureHandle);
|
glBindTexture(GL_TEXTURE_2D,textureHandle);
|
||||||
@@ -1031,7 +1033,7 @@ void GLInstancingRenderer::updateTexture(int textureIndex, const unsigned cha
|
|||||||
void GLInstancingRenderer::activateTexture(int textureIndex)
|
void GLInstancingRenderer::activateTexture(int textureIndex)
|
||||||
{
|
{
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
|
||||||
if (textureIndex>=0 && textureIndex < m_data->m_textureHandles.size())
|
if (textureIndex>=0 && textureIndex < m_data->m_textureHandles.size())
|
||||||
{
|
{
|
||||||
glBindTexture(GL_TEXTURE_2D,m_data->m_textureHandles[textureIndex].m_glTexture);
|
glBindTexture(GL_TEXTURE_2D,m_data->m_textureHandles[textureIndex].m_glTexture);
|
||||||
@@ -1057,7 +1059,7 @@ void GLInstancingRenderer::updateShape(int shapeIndex, const float* vertices)
|
|||||||
glBufferSubData( GL_ARRAY_BUFFER,vertexStrideInBytes*gfxObj->m_vertexArrayOffset,sz,
|
glBufferSubData( GL_ARRAY_BUFFER,vertexStrideInBytes*gfxObj->m_vertexArrayOffset,sz,
|
||||||
vertices);
|
vertices);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int GLInstancingRenderer::registerShape(const float* vertices, int numvertices, const int* indices, int numIndices,int primitiveType, int textureId)
|
int GLInstancingRenderer::registerShape(const float* vertices, int numvertices, const int* indices, int numIndices,int primitiveType, int textureId)
|
||||||
@@ -1087,7 +1089,7 @@ int GLInstancingRenderer::registerShape(const float* vertices, int numvertices,
|
|||||||
gfxObj->m_numVertices = numvertices;
|
gfxObj->m_numVertices = numvertices;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int vertexStrideInBytes = 9*sizeof(float);
|
int vertexStrideInBytes = 9*sizeof(float);
|
||||||
int sz = numvertices*vertexStrideInBytes;
|
int sz = numvertices*vertexStrideInBytes;
|
||||||
int totalUsed = vertexStrideInBytes*gfxObj->m_vertexArrayOffset+sz;
|
int totalUsed = vertexStrideInBytes*gfxObj->m_vertexArrayOffset+sz;
|
||||||
@@ -1102,10 +1104,10 @@ int GLInstancingRenderer::registerShape(const float* vertices, int numvertices,
|
|||||||
#if 0
|
#if 0
|
||||||
|
|
||||||
char* dest= (char*)glMapBuffer( GL_ARRAY_BUFFER,GL_WRITE_ONLY);//GL_WRITE_ONLY
|
char* dest= (char*)glMapBuffer( GL_ARRAY_BUFFER,GL_WRITE_ONLY);//GL_WRITE_ONLY
|
||||||
|
|
||||||
|
|
||||||
#ifdef B3_DEBUG
|
#ifdef B3_DEBUG
|
||||||
|
|
||||||
#endif//B3_DEBUG
|
#endif//B3_DEBUG
|
||||||
|
|
||||||
memcpy(dest+vertexStrideInBytes*gfxObj->m_vertexArrayOffset,vertices,sz);
|
memcpy(dest+vertexStrideInBytes*gfxObj->m_vertexArrayOffset,vertices,sz);
|
||||||
@@ -1148,13 +1150,13 @@ void GLInstancingRenderer::InitShaders()
|
|||||||
|
|
||||||
{
|
{
|
||||||
triangleShaderProgram = gltLoadShaderPair(triangleVertexShaderText,triangleFragmentShader);
|
triangleShaderProgram = gltLoadShaderPair(triangleVertexShaderText,triangleFragmentShader);
|
||||||
|
|
||||||
//triangle_vpos_location = glGetAttribLocation(triangleShaderProgram, "vPos");
|
//triangle_vpos_location = glGetAttribLocation(triangleShaderProgram, "vPos");
|
||||||
//triangle_vUV_location = glGetAttribLocation(triangleShaderProgram, "vUV");
|
//triangle_vUV_location = glGetAttribLocation(triangleShaderProgram, "vUV");
|
||||||
|
|
||||||
triangle_mvp_location = glGetUniformLocation(triangleShaderProgram, "MVP");
|
triangle_mvp_location = glGetUniformLocation(triangleShaderProgram, "MVP");
|
||||||
triangle_vcol_location = glGetUniformLocation(triangleShaderProgram, "vCol");
|
triangle_vcol_location = glGetUniformLocation(triangleShaderProgram, "vCol");
|
||||||
|
|
||||||
glLinkProgram(triangleShaderProgram);
|
glLinkProgram(triangleShaderProgram);
|
||||||
glUseProgram(triangleShaderProgram);
|
glUseProgram(triangleShaderProgram);
|
||||||
|
|
||||||
@@ -1434,7 +1436,7 @@ void GLInstancingRenderer::updateCamera(int upAxis)
|
|||||||
m_data->m_activeCamera->getCameraViewMatrix(m_data->m_viewMatrix);
|
m_data->m_activeCamera->getCameraViewMatrix(m_data->m_viewMatrix);
|
||||||
b3Scalar viewMat[16];
|
b3Scalar viewMat[16];
|
||||||
b3Scalar viewMatInverse[16];
|
b3Scalar viewMatInverse[16];
|
||||||
|
|
||||||
for (int i=0;i<16;i++)
|
for (int i=0;i<16;i++)
|
||||||
{
|
{
|
||||||
viewMat[i] = m_data->m_viewMatrix[i];
|
viewMat[i] = m_data->m_viewMatrix[i];
|
||||||
@@ -1688,7 +1690,7 @@ void GLInstancingRenderer::drawTexturedTriangleMesh(float worldPosition[3], floa
|
|||||||
b3Quaternion orn(worldOrientation[0],worldOrientation[1],worldOrientation[2],worldOrientation[3]);
|
b3Quaternion orn(worldOrientation[0],worldOrientation[1],worldOrientation[2],worldOrientation[3]);
|
||||||
b3Vector3 pos = b3MakeVector3(worldPosition[0],worldPosition[1],worldPosition[2]);
|
b3Vector3 pos = b3MakeVector3(worldPosition[0],worldPosition[1],worldPosition[2]);
|
||||||
|
|
||||||
|
|
||||||
b3Transform worldTrans(orn,pos);
|
b3Transform worldTrans(orn,pos);
|
||||||
b3Scalar worldMatUnk[16];
|
b3Scalar worldMatUnk[16];
|
||||||
worldTrans.getOpenGLMatrix(worldMatUnk);
|
worldTrans.getOpenGLMatrix(worldMatUnk);
|
||||||
@@ -1706,7 +1708,7 @@ void GLInstancingRenderer::drawTexturedTriangleMesh(float worldPosition[3], floa
|
|||||||
|
|
||||||
glUniform3f(triangle_vcol_location,colorRGBA[0],colorRGBA[1],colorRGBA[2]);
|
glUniform3f(triangle_vcol_location,colorRGBA[0],colorRGBA[1],colorRGBA[2]);
|
||||||
checkError("glUniform3f");
|
checkError("glUniform3f");
|
||||||
|
|
||||||
glBindVertexArray(triangleVertexArrayObject);
|
glBindVertexArray(triangleVertexArrayObject);
|
||||||
checkError("glBindVertexArray");
|
checkError("glBindVertexArray");
|
||||||
|
|
||||||
@@ -1721,15 +1723,15 @@ void GLInstancingRenderer::drawTexturedTriangleMesh(float worldPosition[3], floa
|
|||||||
PointerCaster uvCast;
|
PointerCaster uvCast;
|
||||||
uvCast.m_baseIndex = 8*sizeof(float);
|
uvCast.m_baseIndex = 8*sizeof(float);
|
||||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(GfxVertexFormat0), posCast.m_pointer);
|
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(GfxVertexFormat0), posCast.m_pointer);
|
||||||
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(GfxVertexFormat0), uvCast.m_pointer);
|
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(GfxVertexFormat0), uvCast.m_pointer);
|
||||||
checkError("glVertexAttribPointer");
|
checkError("glVertexAttribPointer");
|
||||||
glEnableVertexAttribArray(0);
|
glEnableVertexAttribArray(0);
|
||||||
glEnableVertexAttribArray(1);
|
glEnableVertexAttribArray(1);
|
||||||
|
|
||||||
glVertexAttribDivisor(0,0);
|
glVertexAttribDivisor(0,0);
|
||||||
glVertexAttribDivisor(1,0);
|
glVertexAttribDivisor(1,0);
|
||||||
checkError("glVertexAttribDivisor");
|
checkError("glVertexAttribDivisor");
|
||||||
|
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, triangleIndexVbo);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, triangleIndexVbo);
|
||||||
int indexBufferSizeInBytes = numIndices*sizeof(int);
|
int indexBufferSizeInBytes = numIndices*sizeof(int);
|
||||||
|
|
||||||
@@ -1881,7 +1883,7 @@ void GLInstancingRenderer::drawLine(const double fromIn[4], const double toIn[4]
|
|||||||
}
|
}
|
||||||
void GLInstancingRenderer::drawLine(const float from[4], const float to[4], const float color[4], float lineWidth)
|
void GLInstancingRenderer::drawLine(const float from[4], const float to[4], const float color[4], float lineWidth)
|
||||||
{
|
{
|
||||||
|
|
||||||
b3Assert(glGetError() ==GL_NO_ERROR);
|
b3Assert(glGetError() ==GL_NO_ERROR);
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
@@ -1959,9 +1961,9 @@ B3_ATTRIBUTE_ALIGNED16(struct) SortableTransparentInstance
|
|||||||
B3_ATTRIBUTE_ALIGNED16(struct) TransparentDistanceSortPredicate
|
B3_ATTRIBUTE_ALIGNED16(struct) TransparentDistanceSortPredicate
|
||||||
{
|
{
|
||||||
|
|
||||||
inline bool operator() (const SortableTransparentInstance& a, const SortableTransparentInstance& b) const
|
inline bool operator() (const SortableTransparentInstance& a, const SortableTransparentInstance& b) const
|
||||||
{
|
{
|
||||||
|
|
||||||
return (a.m_projection > b.m_projection);
|
return (a.m_projection > b.m_projection);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -2029,7 +2031,7 @@ void GLInstancingRenderer::renderSceneInternal(int orgRenderMode)
|
|||||||
#else//OLD_SHADOWMAP_INIT
|
#else//OLD_SHADOWMAP_INIT
|
||||||
//Reduce size of shadowMap if glTexImage2D call fails as may happen in some cases
|
//Reduce size of shadowMap if glTexImage2D call fails as may happen in some cases
|
||||||
//https://github.com/bulletphysics/bullet3/issues/40
|
//https://github.com/bulletphysics/bullet3/issues/40
|
||||||
|
|
||||||
int size;
|
int size;
|
||||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &size);
|
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &size);
|
||||||
if (size < shadowMapWidth){
|
if (size < shadowMapWidth){
|
||||||
@@ -2040,8 +2042,8 @@ void GLInstancingRenderer::renderSceneInternal(int orgRenderMode)
|
|||||||
}
|
}
|
||||||
GLuint err;
|
GLuint err;
|
||||||
do {
|
do {
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT16,
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT16,
|
||||||
shadowMapWidth, shadowMapHeight,
|
shadowMapWidth, shadowMapHeight,
|
||||||
0, GL_DEPTH_COMPONENT, GL_FLOAT, 0);
|
0, GL_DEPTH_COMPONENT, GL_FLOAT, 0);
|
||||||
err = glGetError();
|
err = glGetError();
|
||||||
if (err!=GL_NO_ERROR){
|
if (err!=GL_NO_ERROR){
|
||||||
@@ -2155,7 +2157,7 @@ b3Assert(glGetError() ==GL_NO_ERROR);
|
|||||||
{
|
{
|
||||||
totalNumInstances+=m_graphicsInstances[i]->m_numGraphicsInstances;
|
totalNumInstances+=m_graphicsInstances[i]->m_numGraphicsInstances;
|
||||||
}
|
}
|
||||||
|
|
||||||
b3AlignedObjectArray<SortableTransparentInstance> transparentInstances;
|
b3AlignedObjectArray<SortableTransparentInstance> transparentInstances;
|
||||||
{
|
{
|
||||||
int curOffset = 0;
|
int curOffset = 0;
|
||||||
@@ -2167,18 +2169,18 @@ b3Assert(glGetError() ==GL_NO_ERROR);
|
|||||||
m_data->m_activeCamera->getCameraForwardVector(fwd);
|
m_data->m_activeCamera->getCameraForwardVector(fwd);
|
||||||
b3Vector3 camForwardVec;
|
b3Vector3 camForwardVec;
|
||||||
camForwardVec.setValue(fwd[0],fwd[1],fwd[2]);
|
camForwardVec.setValue(fwd[0],fwd[1],fwd[2]);
|
||||||
|
|
||||||
|
|
||||||
for (int obj=0;obj<m_graphicsInstances.size();obj++)
|
for (int obj=0;obj<m_graphicsInstances.size();obj++)
|
||||||
{
|
{
|
||||||
b3GraphicsInstance* gfxObj = m_graphicsInstances[obj];
|
b3GraphicsInstance* gfxObj = m_graphicsInstances[obj];
|
||||||
if (gfxObj->m_numGraphicsInstances)
|
if (gfxObj->m_numGraphicsInstances)
|
||||||
{
|
{
|
||||||
SortableTransparentInstance inst;
|
SortableTransparentInstance inst;
|
||||||
|
|
||||||
inst.m_shapeIndex = obj;
|
inst.m_shapeIndex = obj;
|
||||||
|
|
||||||
|
|
||||||
if ((gfxObj->m_flags&eGfxTransparency)==0)
|
if ((gfxObj->m_flags&eGfxTransparency)==0)
|
||||||
{
|
{
|
||||||
inst.m_instanceId = curOffset;
|
inst.m_instanceId = curOffset;
|
||||||
@@ -2207,12 +2209,12 @@ b3Assert(glGetError() ==GL_NO_ERROR);
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
TransparentDistanceSortPredicate sorter;
|
TransparentDistanceSortPredicate sorter;
|
||||||
|
|
||||||
transparentInstances.quickSort(sorter);
|
transparentInstances.quickSort(sorter);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//two passes: first for opaque instances, second for transparent ones.
|
//two passes: first for opaque instances, second for transparent ones.
|
||||||
for (int pass = 0; pass<2;pass++)
|
for (int pass = 0; pass<2;pass++)
|
||||||
{
|
{
|
||||||
@@ -2222,17 +2224,17 @@ b3Assert(glGetError() ==GL_NO_ERROR);
|
|||||||
int shapeIndex = transparentInstances[i].m_shapeIndex;
|
int shapeIndex = transparentInstances[i].m_shapeIndex;
|
||||||
|
|
||||||
b3GraphicsInstance* gfxObj = m_graphicsInstances[shapeIndex];
|
b3GraphicsInstance* gfxObj = m_graphicsInstances[shapeIndex];
|
||||||
|
|
||||||
//only draw stuff (opaque/transparent) if it is the right pass
|
//only draw stuff (opaque/transparent) if it is the right pass
|
||||||
int drawThisPass = (pass==0) == ((gfxObj->m_flags&eGfxTransparency)==0);
|
int drawThisPass = (pass==0) == ((gfxObj->m_flags&eGfxTransparency)==0);
|
||||||
|
|
||||||
//transparent objects don't cast shadows (to simplify things)
|
//transparent objects don't cast shadows (to simplify things)
|
||||||
if (gfxObj->m_flags&eGfxTransparency)
|
if (gfxObj->m_flags&eGfxTransparency)
|
||||||
{
|
{
|
||||||
if (renderMode==B3_CREATE_SHADOWMAP_RENDERMODE)
|
if (renderMode==B3_CREATE_SHADOWMAP_RENDERMODE)
|
||||||
drawThisPass = 0;
|
drawThisPass = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (drawThisPass && gfxObj->m_numGraphicsInstances)
|
if (drawThisPass && gfxObj->m_numGraphicsInstances)
|
||||||
{
|
{
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
@@ -2358,7 +2360,7 @@ b3Assert(glGetError() ==GL_NO_ERROR);
|
|||||||
glUseProgram(instancingShader);
|
glUseProgram(instancingShader);
|
||||||
glUniformMatrix4fv(ProjectionMatrix, 1, false, &m_data->m_projectionMatrix[0]);
|
glUniformMatrix4fv(ProjectionMatrix, 1, false, &m_data->m_projectionMatrix[0]);
|
||||||
glUniformMatrix4fv(ModelViewMatrix, 1, false, &m_data->m_viewMatrix[0]);
|
glUniformMatrix4fv(ModelViewMatrix, 1, false, &m_data->m_viewMatrix[0]);
|
||||||
|
|
||||||
b3Vector3 gLightDir = m_data->m_lightPos;
|
b3Vector3 gLightDir = m_data->m_lightPos;
|
||||||
gLightDir.normalize();
|
gLightDir.normalize();
|
||||||
glUniform3f(regularLightDirIn,gLightDir[0],gLightDir[1],gLightDir[2]);
|
glUniform3f(regularLightDirIn,gLightDir[0],gLightDir[1],gLightDir[2]);
|
||||||
@@ -2367,7 +2369,7 @@ b3Assert(glGetError() ==GL_NO_ERROR);
|
|||||||
|
|
||||||
if ( gfxObj->m_flags&eGfxTransparency)
|
if ( gfxObj->m_flags&eGfxTransparency)
|
||||||
{
|
{
|
||||||
|
|
||||||
int instanceId = transparentInstances[i].m_instanceId;
|
int instanceId = transparentInstances[i].m_instanceId;
|
||||||
glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, 0, (GLvoid *)((instanceId)*4*sizeof(float)+m_data->m_maxShapeCapacityInBytes));
|
glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, 0, (GLvoid *)((instanceId)*4*sizeof(float)+m_data->m_maxShapeCapacityInBytes));
|
||||||
glVertexAttribPointer(2, 4, GL_FLOAT, GL_FALSE, 0, (GLvoid *)((instanceId)*4*sizeof(float)+m_data->m_maxShapeCapacityInBytes+POSITION_BUFFER_SIZE));
|
glVertexAttribPointer(2, 4, GL_FLOAT, GL_FALSE, 0, (GLvoid *)((instanceId)*4*sizeof(float)+m_data->m_maxShapeCapacityInBytes+POSITION_BUFFER_SIZE));
|
||||||
@@ -2375,18 +2377,18 @@ b3Assert(glGetError() ==GL_NO_ERROR);
|
|||||||
glVertexAttribPointer(6, 3, GL_FLOAT, GL_FALSE, 0, (GLvoid *)((instanceId)*3*sizeof(float)+m_data->m_maxShapeCapacityInBytes+POSITION_BUFFER_SIZE+ORIENTATION_BUFFER_SIZE+COLOR_BUFFER_SIZE));
|
glVertexAttribPointer(6, 3, GL_FLOAT, GL_FALSE, 0, (GLvoid *)((instanceId)*3*sizeof(float)+m_data->m_maxShapeCapacityInBytes+POSITION_BUFFER_SIZE+ORIENTATION_BUFFER_SIZE+COLOR_BUFFER_SIZE));
|
||||||
|
|
||||||
glDrawElements(GL_TRIANGLES, indexCount, GL_UNSIGNED_INT, 0);
|
glDrawElements(GL_TRIANGLES, indexCount, GL_UNSIGNED_INT, 0);
|
||||||
|
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
glDrawElementsInstanced(GL_TRIANGLES, indexCount, GL_UNSIGNED_INT, indexOffset, gfxObj->m_numGraphicsInstances);
|
glDrawElementsInstanced(GL_TRIANGLES, indexCount, GL_UNSIGNED_INT, indexOffset, gfxObj->m_numGraphicsInstances);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( gfxObj->m_flags&eGfxTransparency)
|
if ( gfxObj->m_flags&eGfxTransparency)
|
||||||
{
|
{
|
||||||
glDisable (GL_BLEND);
|
glDisable (GL_BLEND);
|
||||||
glDepthMask(true);
|
glDepthMask(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case B3_CREATE_SHADOWMAP_RENDERMODE:
|
case B3_CREATE_SHADOWMAP_RENDERMODE:
|
||||||
@@ -2405,7 +2407,7 @@ b3Assert(glGetError() ==GL_NO_ERROR);
|
|||||||
glEnable (GL_BLEND);
|
glEnable (GL_BLEND);
|
||||||
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
}
|
}
|
||||||
|
|
||||||
glUseProgram(useShadowMapInstancingShader);
|
glUseProgram(useShadowMapInstancingShader);
|
||||||
glUniformMatrix4fv(useShadow_ProjectionMatrix, 1, false, &m_data->m_projectionMatrix[0]);
|
glUniformMatrix4fv(useShadow_ProjectionMatrix, 1, false, &m_data->m_projectionMatrix[0]);
|
||||||
//glUniformMatrix4fv(useShadow_ModelViewMatrix, 1, false, &m_data->m_viewMatrix[0]);
|
//glUniformMatrix4fv(useShadow_ModelViewMatrix, 1, false, &m_data->m_viewMatrix[0]);
|
||||||
@@ -2416,7 +2418,7 @@ b3Assert(glGetError() ==GL_NO_ERROR);
|
|||||||
glUniform3f(useShadow_lightSpecularIntensity, m_data->m_lightSpecularIntensity[0],m_data->m_lightSpecularIntensity[1],m_data->m_lightSpecularIntensity[2]);
|
glUniform3f(useShadow_lightSpecularIntensity, m_data->m_lightSpecularIntensity[0],m_data->m_lightSpecularIntensity[1],m_data->m_lightSpecularIntensity[2]);
|
||||||
glUniform3f(useShadow_materialSpecularColor, gfxObj->m_materialSpecularColor[0],gfxObj->m_materialSpecularColor[1],gfxObj->m_materialSpecularColor[2]);
|
glUniform3f(useShadow_materialSpecularColor, gfxObj->m_materialSpecularColor[0],gfxObj->m_materialSpecularColor[1],gfxObj->m_materialSpecularColor[2]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
float MVP[16];
|
float MVP[16];
|
||||||
if (reflectionPass)
|
if (reflectionPass)
|
||||||
@@ -2434,7 +2436,7 @@ b3Assert(glGetError() ==GL_NO_ERROR);
|
|||||||
b3Matrix4x4Mul16(m_data->m_projectionMatrix,m_data->m_viewMatrix,MVP);
|
b3Matrix4x4Mul16(m_data->m_projectionMatrix,m_data->m_viewMatrix,MVP);
|
||||||
glCullFace(GL_BACK);
|
glCullFace(GL_BACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
glUniformMatrix4fv(useShadow_MVP, 1, false, &MVP[0]);
|
glUniformMatrix4fv(useShadow_MVP, 1, false, &MVP[0]);
|
||||||
//gLightDir.normalize();
|
//gLightDir.normalize();
|
||||||
glUniform3f(useShadow_lightPosIn,m_data->m_lightPos[0],m_data->m_lightPos[1],m_data->m_lightPos[2]);
|
glUniform3f(useShadow_lightPosIn,m_data->m_lightPos[0],m_data->m_lightPos[1],m_data->m_lightPos[2]);
|
||||||
@@ -2442,14 +2444,14 @@ b3Assert(glGetError() ==GL_NO_ERROR);
|
|||||||
m_data->m_activeCamera->getCameraPosition(camPos);
|
m_data->m_activeCamera->getCameraPosition(camPos);
|
||||||
glUniform3f(useShadow_cameraPositionIn,camPos[0],camPos[1],camPos[2]);
|
glUniform3f(useShadow_cameraPositionIn,camPos[0],camPos[1],camPos[2]);
|
||||||
glUniform1f(useShadow_materialShininessIn,gfxObj->m_materialShinyNess);
|
glUniform1f(useShadow_materialShininessIn,gfxObj->m_materialShinyNess);
|
||||||
|
|
||||||
glUniformMatrix4fv(useShadow_DepthBiasModelViewMatrix, 1, false, &depthBiasMVP[0][0]);
|
glUniformMatrix4fv(useShadow_DepthBiasModelViewMatrix, 1, false, &depthBiasMVP[0][0]);
|
||||||
glActiveTexture(GL_TEXTURE1);
|
glActiveTexture(GL_TEXTURE1);
|
||||||
glBindTexture(GL_TEXTURE_2D, m_data->m_shadowTexture);
|
glBindTexture(GL_TEXTURE_2D, m_data->m_shadowTexture);
|
||||||
glUniform1i(useShadow_shadowMap,1);
|
glUniform1i(useShadow_shadowMap,1);
|
||||||
|
|
||||||
//sort transparent objects
|
//sort transparent objects
|
||||||
|
|
||||||
//gfxObj->m_instanceOffset
|
//gfxObj->m_instanceOffset
|
||||||
|
|
||||||
if ( gfxObj->m_flags&eGfxTransparency)
|
if ( gfxObj->m_flags&eGfxTransparency)
|
||||||
@@ -2464,7 +2466,7 @@ b3Assert(glGetError() ==GL_NO_ERROR);
|
|||||||
{
|
{
|
||||||
glDrawElementsInstanced(GL_TRIANGLES, indexCount, GL_UNSIGNED_INT, indexOffset, gfxObj->m_numGraphicsInstances);
|
glDrawElementsInstanced(GL_TRIANGLES, indexCount, GL_UNSIGNED_INT, indexOffset, gfxObj->m_numGraphicsInstances);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( gfxObj->m_flags&eGfxTransparency)
|
if ( gfxObj->m_flags&eGfxTransparency)
|
||||||
{
|
{
|
||||||
glDisable (GL_BLEND);
|
glDisable (GL_BLEND);
|
||||||
|
|||||||
@@ -170,17 +170,19 @@ void dumpInfo(void)
|
|||||||
if (m_resizeCallback)
|
if (m_resizeCallback)
|
||||||
{
|
{
|
||||||
(*m_resizeCallback)(width,height);
|
(*m_resizeCallback)(width,height);
|
||||||
}
|
|
||||||
#ifndef NO_OPENGL3
|
#ifndef NO_OPENGL3
|
||||||
NSRect backingBounds = [self convertRectToBacking:[self bounds]];
|
NSRect backingBounds = [self convertRectToBacking:[self bounds]];
|
||||||
GLsizei backingPixelWidth = (GLsizei)(backingBounds.size.width),
|
GLsizei backingPixelWidth = (GLsizei)(backingBounds.size.width),
|
||||||
backingPixelHeight = (GLsizei)(backingBounds.size.height);
|
backingPixelHeight = (GLsizei)(backingBounds.size.height);
|
||||||
|
|
||||||
// Set viewport
|
// Set viewport
|
||||||
glViewport(0, 0, backingPixelWidth, backingPixelHeight);
|
glViewport(0, 0, backingPixelWidth, backingPixelHeight);
|
||||||
#else
|
#else
|
||||||
glViewport(0,0,(GLsizei)width,(GLsizei)height);
|
glViewport(0,0,(GLsizei)width,(GLsizei)height);
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[m_context setView: self];
|
[m_context setView: self];
|
||||||
@@ -236,7 +238,7 @@ void dumpInfo(void)
|
|||||||
[fmt release];
|
[fmt release];
|
||||||
[m_context makeCurrentContext];
|
[m_context makeCurrentContext];
|
||||||
|
|
||||||
checkError("makeCurrentContext");
|
//checkError("makeCurrentContext");
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void) MakeCurrent
|
-(void) MakeCurrent
|
||||||
@@ -420,7 +422,7 @@ int Mac_createWindow(struct MacOpenGLWindowInternalData* m_internalData,struct M
|
|||||||
|
|
||||||
// float newBackingScaleFactor = [m_internalData->m_window backingScaleFactor];
|
// float newBackingScaleFactor = [m_internalData->m_window backingScaleFactor];
|
||||||
|
|
||||||
dumpInfo();
|
//dumpInfo();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -21,33 +21,7 @@ subject to the following restrictions:
|
|||||||
#include "glad/glad.h"
|
#include "glad/glad.h"
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
#else
|
#else
|
||||||
//think different
|
#include "glad/glad.h"
|
||||||
#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
|
|
||||||
#endif //B3_USE_GLFW
|
#endif //B3_USE_GLFW
|
||||||
//disable glGetError
|
//disable glGetError
|
||||||
//#undef glGetError
|
//#undef glGetError
|
||||||
|
|||||||
@@ -21,56 +21,8 @@ subject to the following restrictions:
|
|||||||
#include <glad/glad.h>
|
#include <glad/glad.h>
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
#else
|
#else
|
||||||
//think different
|
#include "glad/glad.h"
|
||||||
#if defined(__APPLE__) && !defined (VMDMESA)
|
#endif //B3_USE_GLFW
|
||||||
#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
|
|
||||||
|
|
||||||
#endif //__OPENGL_INCLUDE_H
|
#endif //__OPENGL_INCLUDE_H
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,8 @@ static SimpleOpenGL2App* gApp2=0;
|
|||||||
|
|
||||||
static void Simple2ResizeCallback( float widthf, float heightf)
|
static void Simple2ResizeCallback( float widthf, float heightf)
|
||||||
{
|
{
|
||||||
|
glViewport(0, 0, widthf, heightf);
|
||||||
|
|
||||||
int width = (int)widthf;
|
int width = (int)widthf;
|
||||||
int height = (int)heightf;
|
int height = (int)heightf;
|
||||||
if (gApp2->m_renderer && gApp2->m_window)
|
if (gApp2->m_renderer && gApp2->m_window)
|
||||||
@@ -141,12 +143,15 @@ SimpleOpenGL2App::SimpleOpenGL2App(const char* title, int width, int height)
|
|||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
#ifndef B3_USE_GLFW
|
#ifndef B3_USE_GLFW
|
||||||
//some Linux implementations need the 'glewExperimental' to be true
|
//some Linux implementations need the 'glewExperimental' to be true
|
||||||
glewExperimental = GL_TRUE;
|
|
||||||
#endif//B3_USE_GLFW
|
#endif//B3_USE_GLFW
|
||||||
#endif //_WIN32
|
#endif //_WIN32
|
||||||
|
|
||||||
#ifndef B3_USE_GLFW
|
#ifndef B3_USE_GLFW
|
||||||
if (glewInit() != GLEW_OK)
|
//gladLoadGLLoader((GLADloadproc) glfwGetProcAddress);
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
if (glewInit() != GLEW_OK)
|
||||||
{
|
{
|
||||||
b3Error("glewInit failed");
|
b3Error("glewInit failed");
|
||||||
exit(1);
|
exit(1);
|
||||||
@@ -156,6 +161,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
|
||||||
#endif //B3_USE_GLFW
|
#endif //B3_USE_GLFW
|
||||||
#endif //__APPLE__
|
#endif //__APPLE__
|
||||||
#endif //NO_GLEW
|
#endif //NO_GLEW
|
||||||
|
|||||||
@@ -71,6 +71,8 @@ static SimpleOpenGL3App* gApp=0;
|
|||||||
|
|
||||||
static void SimpleResizeCallback( float widthf, float heightf)
|
static void SimpleResizeCallback( float widthf, float heightf)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
int width = (int)widthf;
|
int width = (int)widthf;
|
||||||
int height = (int)heightf;
|
int height = (int)heightf;
|
||||||
if (gApp && gApp->m_instancingRenderer)
|
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)
|
SimpleOpenGL3App::SimpleOpenGL3App( const char* title, int width,int height, bool allowRetina)
|
||||||
{
|
{
|
||||||
gApp = this;
|
gApp = this;
|
||||||
@@ -308,7 +318,16 @@ SimpleOpenGL3App::SimpleOpenGL3App( const char* title, int width,int height, boo
|
|||||||
|
|
||||||
m_window->setWindowTitle(title);
|
m_window->setWindowTitle(title);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
b3Assert(glGetError() ==GL_NO_ERROR);
|
b3Assert(glGetError() ==GL_NO_ERROR);
|
||||||
|
|
||||||
|
{
|
||||||
|
printGLString("Version", GL_VERSION);
|
||||||
|
printGLString("Vendor", GL_VENDOR);
|
||||||
|
printGLString("Renderer", GL_RENDERER);
|
||||||
|
}
|
||||||
|
|
||||||
glClearColor( m_backgroundColorRGB[0],
|
glClearColor( m_backgroundColorRGB[0],
|
||||||
m_backgroundColorRGB[1],
|
m_backgroundColorRGB[1],
|
||||||
@@ -321,7 +340,10 @@ SimpleOpenGL3App::SimpleOpenGL3App( const char* title, int width,int height, boo
|
|||||||
|
|
||||||
b3Assert(glGetError() ==GL_NO_ERROR);
|
b3Assert(glGetError() ==GL_NO_ERROR);
|
||||||
|
|
||||||
#ifndef NO_GLEW
|
//gladLoadGLLoader((GLADloadproc) glfwGetProcAddress);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef USE_GLEW
|
||||||
#ifndef __APPLE__
|
#ifndef __APPLE__
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
#ifndef B3_USE_GLFW
|
#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
|
exit(1); // or handle the error in a nicer way
|
||||||
#endif //B3_USE_GLFW
|
#endif //B3_USE_GLFW
|
||||||
#endif //__APPLE__
|
#endif //__APPLE__
|
||||||
#endif //NO_GLEW
|
#endif //USE_GLEW
|
||||||
|
|
||||||
glGetError();//don't remove this call, it is needed for Ubuntu
|
glGetError();//don't remove this call, it is needed for Ubuntu
|
||||||
|
|
||||||
b3Assert(glGetError() ==GL_NO_ERROR);
|
b3Assert(glGetError() ==GL_NO_ERROR);
|
||||||
|
|||||||
@@ -25,12 +25,6 @@ subject to the following restrictions:
|
|||||||
#include "Win32InternalWindowData.h"
|
#include "Win32InternalWindowData.h"
|
||||||
#include <stdio.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()
|
void Win32OpenGLWindow::enableOpenGL()
|
||||||
{
|
{
|
||||||
@@ -63,12 +57,7 @@ void Win32OpenGLWindow::enableOpenGL()
|
|||||||
m_data->m_hRC = wglCreateContext( m_data->m_hDC );
|
m_data->m_hRC = wglCreateContext( m_data->m_hDC );
|
||||||
wglMakeCurrent( m_data->m_hDC, m_data->m_hRC );
|
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);
|
//printGLString("Extensions", GL_EXTENSIONS);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -147,6 +136,7 @@ void Win32OpenGLWindow::endRendering()
|
|||||||
|
|
||||||
int Win32OpenGLWindow::fileOpenDialog(char* fileName, int maxFileNameLength)
|
int Win32OpenGLWindow::fileOpenDialog(char* fileName, int maxFileNameLength)
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
//wchar_t wideChars[1024];
|
//wchar_t wideChars[1024];
|
||||||
|
|
||||||
OPENFILENAME ofn ;
|
OPENFILENAME ofn ;
|
||||||
@@ -176,9 +166,9 @@ int Win32OpenGLWindow::fileOpenDialog(char* fileName, int maxFileNameLength)
|
|||||||
ofn.Flags = OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST ;
|
ofn.Flags = OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST ;
|
||||||
GetOpenFileName( &ofn );
|
GetOpenFileName( &ofn );
|
||||||
return strlen(fileName);
|
return strlen(fileName);
|
||||||
|
#else
|
||||||
|
return 0;
|
||||||
//return 0;
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int Win32OpenGLWindow::getWidth() const
|
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_fullWindowHeight = wr.bottom-wr.top;//LOWORD (lParam) HIWORD (lParam);
|
||||||
sData->m_openglViewportWidth = clientRect.right;
|
sData->m_openglViewportWidth = clientRect.right;
|
||||||
sData->m_openglViewportHeight = clientRect.bottom;
|
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)
|
if (sData->m_resizeCallback)
|
||||||
(*sData->m_resizeCallback)(sData->m_openglViewportWidth,sData->m_openglViewportHeight);
|
(*sData->m_resizeCallback)(sData->m_openglViewportWidth,sData->m_openglViewportHeight);
|
||||||
|
|||||||
@@ -7,15 +7,15 @@
|
|||||||
#include<stdio.h>
|
#include<stdio.h>
|
||||||
#include<stdlib.h>
|
#include<stdlib.h>
|
||||||
#ifdef GLEW_STATIC
|
#ifdef GLEW_STATIC
|
||||||
#include "CustomGL/glew.h"
|
#include "glad/glad.h"
|
||||||
#else
|
#else
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
#endif//GLEW_STATIC
|
#endif//GLEW_STATIC
|
||||||
|
|
||||||
#ifdef GLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS
|
#ifdef GLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS
|
||||||
#include "CustomGL/glxew.h"
|
#include "glad/glad_glx.h"
|
||||||
#else
|
#else
|
||||||
#include<GL/glx.h>
|
#include "GL/glx.h"
|
||||||
#endif // GLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS
|
#endif // GLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
@@ -473,20 +473,12 @@ void X11OpenGLWindow::enableOpenGL()
|
|||||||
glXMakeCurrent(m_data->m_dpy, m_data->m_win, m_data->m_glc);
|
glXMakeCurrent(m_data->m_dpy, m_data->m_win, m_data->m_glc);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef GLEW_INIT_OPENGL11_FUNCTIONS
|
if(!gladLoadGL()) {
|
||||||
{
|
printf("gladLoadGL failed!\n");
|
||||||
GLboolean res = glewOpenGL11Init();
|
exit(-1);
|
||||||
if (res==0)
|
}
|
||||||
{
|
|
||||||
printf("glewOpenGL11Init OK!\n");
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
fprintf(stderr, "ERROR: glewOpenGL11Init failed, exiting!\n");
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif //GLEW_INIT_OPENGL11_FUNCTIONS
|
|
||||||
|
|
||||||
const GLubyte* ven = glGetString(GL_VENDOR);
|
const GLubyte* ven = glGetString(GL_VENDOR);
|
||||||
printf("GL_VENDOR=%s\n", ven);
|
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);
|
m_data->m_root = DefaultRootWindow(m_data->m_dpy);
|
||||||
|
|
||||||
|
|
||||||
#ifdef GLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS
|
#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
|
printf("Error in gladLoadGLX\n");
|
||||||
{
|
exit(0);
|
||||||
fprintf(stderr, "glewXInit failed, exit\n");
|
}
|
||||||
exit(EXIT_FAILURE);
|
#endif
|
||||||
}
|
|
||||||
#endif //GLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS
|
|
||||||
|
|
||||||
|
|
||||||
if (ci.m_openglVersion < 3)
|
if (ci.m_openglVersion < 3)
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ project ("App_RobotSimulator")
|
|||||||
|
|
||||||
includedirs {"../../src", "../../examples",
|
includedirs {"../../src", "../../examples",
|
||||||
"../../examples/ThirdPartyLibs"}
|
"../../examples/ThirdPartyLibs"}
|
||||||
defines {"PHYSICS_IN_PROCESS_EXAMPLE_BROWSER"}
|
defines {"B3_USE_ROBOTSIM_GUI", "PHYSICS_IN_PROCESS_EXAMPLE_BROWSER"}
|
||||||
|
|
||||||
hasCL = findOpenCL("clew")
|
hasCL = findOpenCL("clew")
|
||||||
|
|
||||||
@@ -297,4 +297,4 @@ end
|
|||||||
if os.is("Linux") then
|
if os.is("Linux") then
|
||||||
initX11()
|
initX11()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -6587,7 +6587,10 @@ bool PhysicsServerCommandProcessor::processSendPhysicsParametersCommand(const st
|
|||||||
clientCmd.m_physSimParamArgs.m_gravityAcceleration[1],
|
clientCmd.m_physSimParamArgs.m_gravityAcceleration[1],
|
||||||
clientCmd.m_physSimParamArgs.m_gravityAcceleration[2]);
|
clientCmd.m_physSimParamArgs.m_gravityAcceleration[2]);
|
||||||
this->m_data->m_dynamicsWorld->setGravity(grav);
|
this->m_data->m_dynamicsWorld->setGravity(grav);
|
||||||
|
#ifndef SKIP_SOFT_BODY_MULTI_BODY_DYNAMICS_WORLD
|
||||||
m_data->m_dynamicsWorld->getWorldInfo().m_gravity=grav;
|
m_data->m_dynamicsWorld->getWorldInfo().m_gravity=grav;
|
||||||
|
|
||||||
|
#endif
|
||||||
if (m_data->m_verboseOutput)
|
if (m_data->m_verboseOutput)
|
||||||
{
|
{
|
||||||
b3Printf("Updated Gravity: %f,%f,%f",grav[0],grav[1],grav[2]);
|
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);
|
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()->setCameraDistance(13);
|
||||||
app->m_renderer->getActiveCamera()->setCameraPitch(0);
|
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>
|
#include <OpenGL/gl.h>
|
||||||
#else
|
#else
|
||||||
#ifdef GLEW_STATIC
|
#ifdef GLEW_STATIC
|
||||||
#include "CustomGL/glew.h"
|
#include "glad/glad.h"
|
||||||
#else
|
#else
|
||||||
#ifdef NO_GLEW
|
#ifdef NO_GLEW
|
||||||
#define GL_GLEXT_LEGACY
|
#define GL_GLEXT_LEGACY
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
APIs: gl=4.6
|
APIs: gl=4.6
|
||||||
Profile: compatibility
|
Profile: compatibility
|
||||||
Extensions:
|
Extensions:
|
||||||
|
|
||||||
Loader: True
|
Loader: True
|
||||||
Local files: False
|
Local files: False
|
||||||
Omit khrplatform: False
|
Omit khrplatform: False
|
||||||
@@ -1939,7 +1939,7 @@ static void load_GL_VERSION_3_0(GLADloadproc load) {
|
|||||||
glad_glFramebufferTexture3D = (PFNGLFRAMEBUFFERTEXTURE3DPROC)load("glFramebufferTexture3D");
|
glad_glFramebufferTexture3D = (PFNGLFRAMEBUFFERTEXTURE3DPROC)load("glFramebufferTexture3D");
|
||||||
glad_glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC)load("glFramebufferRenderbuffer");
|
glad_glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC)load("glFramebufferRenderbuffer");
|
||||||
glad_glGetFramebufferAttachmentParameteriv = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)load("glGetFramebufferAttachmentParameteriv");
|
glad_glGetFramebufferAttachmentParameteriv = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)load("glGetFramebufferAttachmentParameteriv");
|
||||||
|
|
||||||
glad_glBlitFramebuffer = (PFNGLBLITFRAMEBUFFERPROC)load("glBlitFramebuffer");
|
glad_glBlitFramebuffer = (PFNGLBLITFRAMEBUFFERPROC)load("glBlitFramebuffer");
|
||||||
glad_glRenderbufferStorageMultisample = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC)load("glRenderbufferStorageMultisample");
|
glad_glRenderbufferStorageMultisample = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC)load("glRenderbufferStorageMultisample");
|
||||||
glad_glFramebufferTextureLayer = (PFNGLFRAMEBUFFERTEXTURELAYERPROC)load("glFramebufferTextureLayer");
|
glad_glFramebufferTextureLayer = (PFNGLFRAMEBUFFERTEXTURELAYERPROC)load("glFramebufferTextureLayer");
|
||||||
@@ -1991,7 +1991,7 @@ static void load_GL_VERSION_3_2(GLADloadproc load) {
|
|||||||
glad_glSampleMaski = (PFNGLSAMPLEMASKIPROC)load("glSampleMaski");
|
glad_glSampleMaski = (PFNGLSAMPLEMASKIPROC)load("glSampleMaski");
|
||||||
}
|
}
|
||||||
static void load_GL_VERSION_3_3(GLADloadproc load) {
|
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_glBindFragDataLocationIndexed = (PFNGLBINDFRAGDATALOCATIONINDEXEDPROC)load("glBindFragDataLocationIndexed");
|
||||||
glad_glGetFragDataIndex = (PFNGLGETFRAGDATAINDEXPROC)load("glGetFragDataIndex");
|
glad_glGetFragDataIndex = (PFNGLGETFRAGDATAINDEXPROC)load("glGetFragDataIndex");
|
||||||
glad_glGenSamplers = (PFNGLGENSAMPLERSPROC)load("glGenSamplers");
|
glad_glGenSamplers = (PFNGLGENSAMPLERSPROC)load("glGenSamplers");
|
||||||
|
|||||||
@@ -355,9 +355,8 @@ int main()
|
|||||||
#ifndef __APPLE__
|
#ifndef __APPLE__
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
//we need glewExperimental on Linux
|
//we need glewExperimental on Linux
|
||||||
glewExperimental = GL_TRUE;
|
|
||||||
#endif // _WIN32
|
#endif // _WIN32
|
||||||
glewInit();
|
gladLoadGL();
|
||||||
#endif
|
#endif
|
||||||
#endif //B3_USE_GLFW
|
#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
|
||||||
|
|||||||
Reference in New Issue
Block a user