remove a few warnings, fix GLInstancingRenderer::drawLines
This commit is contained in:
@@ -92,7 +92,7 @@ struct b3GraphicsInstance
|
||||
int m_vertexArrayOffset;
|
||||
int m_primitiveType;
|
||||
|
||||
b3GraphicsInstance()
|
||||
b3GraphicsInstance()
|
||||
:m_cube_vao(-1),
|
||||
m_index_vbo(-1),
|
||||
m_texturehandle(0),
|
||||
@@ -158,7 +158,7 @@ struct InternalDataRenderer : public GLInstanceRendererInternalData
|
||||
int m_rightMouseButton;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
GLuint m_defaultTexturehandle;
|
||||
b3AlignedObjectArray<GLuint> m_textureHandles;
|
||||
@@ -509,7 +509,7 @@ void GLInstancingRenderer::writeSingleInstanceTransformToGPU(float* position, fl
|
||||
|
||||
void GLInstancingRenderer::writeTransforms()
|
||||
{
|
||||
|
||||
|
||||
b3Assert(glGetError() ==GL_NO_ERROR);
|
||||
|
||||
|
||||
@@ -517,7 +517,7 @@ void GLInstancingRenderer::writeTransforms()
|
||||
glFlush();
|
||||
|
||||
b3Assert(glGetError() ==GL_NO_ERROR);
|
||||
|
||||
|
||||
|
||||
char* orgBase = (char*)glMapBuffer( GL_ARRAY_BUFFER,GL_READ_WRITE);
|
||||
if (orgBase)
|
||||
@@ -661,7 +661,7 @@ int GLInstancingRenderer::registerTexture(const unsigned char* texels, int width
|
||||
glBindTexture(GL_TEXTURE_2D,textureHandle);
|
||||
|
||||
b3Assert(glGetError() ==GL_NO_ERROR);
|
||||
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width,height,0,GL_RGB,GL_UNSIGNED_BYTE,image);
|
||||
|
||||
|
||||
@@ -863,7 +863,7 @@ void GLInstancingRenderer::init()
|
||||
{
|
||||
b3Assert(glGetError() ==GL_NO_ERROR);
|
||||
|
||||
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDepthFunc(GL_LESS);
|
||||
|
||||
@@ -919,7 +919,7 @@ void GLInstancingRenderer::init()
|
||||
glGenTextures(1,(GLuint*)&m_data->m_defaultTexturehandle);
|
||||
glBindTexture(GL_TEXTURE_2D,m_data->m_defaultTexturehandle);
|
||||
b3Assert(glGetError() ==GL_NO_ERROR);
|
||||
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 256,256,0,GL_RGB,GL_UNSIGNED_BYTE,image);
|
||||
glGenerateMipmap(GL_TEXTURE_2D);
|
||||
|
||||
@@ -1084,7 +1084,7 @@ void GLInstancingRenderer::updateCamera(int upAxis)
|
||||
default:
|
||||
b3Assert(0);
|
||||
};
|
||||
|
||||
|
||||
|
||||
float m_frustumZNear=1;
|
||||
float m_frustumZFar=10000.f;
|
||||
@@ -1246,7 +1246,7 @@ void GLInstancingRenderer::getMouseDirection(float* dir, int x, int y)
|
||||
#include "OpenGLTrueTypeFont/stb_image_write.h"
|
||||
void writeTextureToPng(int textureWidth, int textureHeight, const char* fileName, int numComponents)
|
||||
{
|
||||
|
||||
|
||||
b3Assert(glGetError() ==GL_NO_ERROR);
|
||||
glPixelStorei(GL_PACK_ALIGNMENT,4);
|
||||
|
||||
@@ -1314,7 +1314,7 @@ void GLInstancingRenderer::renderScene()
|
||||
|
||||
if (useShadowMap)
|
||||
{
|
||||
|
||||
|
||||
renderSceneInternal(B3_CREATE_SHADOWMAP_RENDERMODE);
|
||||
// glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
|
||||
renderSceneInternal(B3_USE_SHADOWMAP_RENDERMODE);
|
||||
@@ -1335,7 +1335,7 @@ void GLInstancingRenderer::drawPoints(const float* positions, const float color[
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D,0);
|
||||
|
||||
|
||||
b3Assert(glGetError() ==GL_NO_ERROR);glUseProgram(linesShader);
|
||||
glUniformMatrix4fv(lines_ProjectionMatrix, 1, false, &projectionMatrix[0]);
|
||||
glUniformMatrix4fv(lines_ModelViewMatrix, 1, false, &modelviewMatrix[0]);
|
||||
@@ -1383,7 +1383,7 @@ void GLInstancingRenderer::drawLines(const float* positions, const float color[4
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D,0);
|
||||
|
||||
|
||||
b3Assert(glGetError() ==GL_NO_ERROR);glUseProgram(linesShader);
|
||||
glUniformMatrix4fv(lines_ProjectionMatrix, 1, false, &projectionMatrix[0]);
|
||||
glUniformMatrix4fv(lines_ModelViewMatrix, 1, false, &modelviewMatrix[0]);
|
||||
@@ -1406,8 +1406,8 @@ void GLInstancingRenderer::drawLines(const float* positions, const float color[4
|
||||
glEnableVertexAttribArray(0);
|
||||
|
||||
b3Assert(glGetError() ==GL_NO_ERROR);
|
||||
int numFloats = pointStrideInBytes / sizeof(float);
|
||||
glVertexAttribPointer(0, numFloats, GL_FLOAT, GL_FALSE, 0, 0);
|
||||
int numFloats = 3;
|
||||
glVertexAttribPointer(0, numFloats, GL_FLOAT, GL_FALSE, pointStrideInBytes, 0);
|
||||
b3Assert(glGetError() ==GL_NO_ERROR);
|
||||
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, linesIndexVbo);
|
||||
@@ -1427,7 +1427,7 @@ void GLInstancingRenderer::drawLines(const float* positions, const float color[4
|
||||
glBindVertexArray(0);
|
||||
b3Assert(glGetError() ==GL_NO_ERROR);
|
||||
glPointSize(1);
|
||||
b3Assert(glGetError() ==GL_NO_ERROR);
|
||||
b3Assert(glGetError() ==GL_NO_ERROR);
|
||||
|
||||
}
|
||||
|
||||
@@ -1439,7 +1439,7 @@ void GLInstancingRenderer::drawLine(const float from[4], const float to[4], cons
|
||||
glBindTexture(GL_TEXTURE_2D,0);
|
||||
b3Assert(glGetError() ==GL_NO_ERROR);
|
||||
|
||||
|
||||
|
||||
|
||||
glUseProgram(linesShader);
|
||||
|
||||
@@ -1505,13 +1505,13 @@ struct PointerCaster
|
||||
int m_baseIndex;
|
||||
GLvoid* m_pointer;
|
||||
};
|
||||
|
||||
|
||||
PointerCaster()
|
||||
:m_pointer(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
void GLInstancingRenderer::renderSceneInternal(int renderMode)
|
||||
{
|
||||
@@ -1593,7 +1593,7 @@ void GLInstancingRenderer::renderSceneInternal(int renderMode)
|
||||
//glCullFace(GL_BACK);
|
||||
|
||||
}
|
||||
|
||||
|
||||
b3CreateOrtho(-shadowMapWorldSize,shadowMapWorldSize,-shadowMapWorldSize,shadowMapWorldSize,1,300,depthProjectionMatrix);//-14,14,-14,14,1,200, depthProjectionMatrix);
|
||||
float depthViewMatrix[4][4];
|
||||
b3Vector3 center = b3MakeVector3(0,0,0);
|
||||
@@ -1692,12 +1692,12 @@ b3Assert(glGetError() ==GL_NO_ERROR);
|
||||
int vertexStride = 9*sizeof(float);
|
||||
PointerCaster vertex;
|
||||
vertex.m_baseIndex = gfxObj->m_vertexArrayOffset*vertexStride;
|
||||
|
||||
|
||||
|
||||
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 9*sizeof(float), vertex.m_pointer);
|
||||
glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, 0, (GLvoid *)(curOffset*4*sizeof(float)+m_maxShapeCapacityInBytes));
|
||||
glVertexAttribPointer(2, 4, GL_FLOAT, GL_FALSE, 0, (GLvoid *)(curOffset*4*sizeof(float)+m_maxShapeCapacityInBytes+POSITION_BUFFER_SIZE));
|
||||
|
||||
|
||||
PointerCaster uv;
|
||||
uv.m_baseIndex = 7*sizeof(float)+vertex.m_baseIndex;
|
||||
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
#include "Bullet3Common/b3Vector3.h"
|
||||
#include "Bullet3Common/b3Logging.h"
|
||||
|
||||
#include "../btgui/OpenGLTrueTypeFont/fontstash.h"
|
||||
#include "../btgui/OpenGLWindow/TwFonts.h"
|
||||
#include "OpenGLTrueTypeFont/fontstash.h"
|
||||
#include "OpenGLWindow/TwFonts.h"
|
||||
#include "OpenGLTrueTypeFont/opengl_fontstashcallbacks.h"
|
||||
#include <assert.h>
|
||||
|
||||
@@ -81,7 +81,7 @@ SimpleOpenGL3App::SimpleOpenGL3App( const char* title, int width,int height)
|
||||
|
||||
b3Assert(glGetError() ==GL_NO_ERROR);
|
||||
|
||||
glClearColor(1,1,1,1);
|
||||
glClearColor(0.9,0.9,1,1);
|
||||
m_window->startRendering();
|
||||
b3Assert(glGetError() ==GL_NO_ERROR);
|
||||
|
||||
@@ -91,7 +91,7 @@ SimpleOpenGL3App::SimpleOpenGL3App( const char* title, int width,int height)
|
||||
glewExperimental = GL_TRUE;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
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.
|
||||
@@ -99,7 +99,7 @@ SimpleOpenGL3App::SimpleOpenGL3App( const char* title, int width,int height)
|
||||
|
||||
#endif
|
||||
glGetError();//don't remove this call, it is needed for Ubuntu
|
||||
|
||||
|
||||
b3Assert(glGetError() ==GL_NO_ERROR);
|
||||
|
||||
m_primRenderer = new GLPrimitiveRenderer(width,height);
|
||||
@@ -125,9 +125,9 @@ SimpleOpenGL3App::SimpleOpenGL3App( const char* title, int width,int height)
|
||||
|
||||
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
m_data->m_renderCallbacks = new OpenGL2RenderCallbacks(m_primRenderer);
|
||||
m_data->m_fontStash = sth_create(512,512,m_data->m_renderCallbacks);//256,256);//,1024);//512,512);
|
||||
b3Assert(glGetError() ==GL_NO_ERROR);
|
||||
@@ -137,7 +137,7 @@ SimpleOpenGL3App::SimpleOpenGL3App( const char* title, int width,int height)
|
||||
b3Warning("Could not create stash");
|
||||
//fprintf(stderr, "Could not create stash.\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
char* data2 = OpenSansData;
|
||||
unsigned char* data = (unsigned char*) data2;
|
||||
@@ -302,11 +302,20 @@ int SimpleOpenGL3App::registerGraphicsSphereShape(float radius, bool usePointSpr
|
||||
return graphicsShapeIndex;
|
||||
}
|
||||
|
||||
void SimpleOpenGL3App::drawGrid(int gridSize, float upOffset, int upAxis)
|
||||
void SimpleOpenGL3App::drawGrid(DrawGridData data)
|
||||
{
|
||||
int gridSize = data.gridSize;
|
||||
float upOffset = data.upOffset;
|
||||
int upAxis = data.upAxis;
|
||||
float gridColor[4];
|
||||
gridColor[0] = data.gridColor[0];
|
||||
gridColor[1] = data.gridColor[1];
|
||||
gridColor[2] = data.gridColor[2];
|
||||
gridColor[3] = data.gridColor[3];
|
||||
|
||||
int sideAxis=-1;
|
||||
int forwardAxis=-1;
|
||||
|
||||
|
||||
switch (upAxis)
|
||||
{
|
||||
case 1:
|
||||
@@ -320,8 +329,8 @@ void SimpleOpenGL3App::drawGrid(int gridSize, float upOffset, int upAxis)
|
||||
default:
|
||||
b3Assert(0);
|
||||
};
|
||||
b3Vector3 gridColor = b3MakeVector3(0.5,0.5,0.5);
|
||||
|
||||
//b3Vector3 gridColor = b3MakeVector3(0.5,0.5,0.5);
|
||||
|
||||
b3AlignedObjectArray<unsigned int> indices;
|
||||
b3AlignedObjectArray<b3Vector3> vertices;
|
||||
int lineIndex=0;
|
||||
@@ -346,7 +355,7 @@ void SimpleOpenGL3App::drawGrid(int gridSize, float upOffset, int upAxis)
|
||||
|
||||
b3Assert(glGetError() ==GL_NO_ERROR);
|
||||
{
|
||||
|
||||
|
||||
b3Assert(glGetError() ==GL_NO_ERROR);
|
||||
b3Vector3 from=b3MakeVector3(0,0,0);
|
||||
from[sideAxis] = float(-gridSize);
|
||||
@@ -360,12 +369,12 @@ void SimpleOpenGL3App::drawGrid(int gridSize, float upOffset, int upAxis)
|
||||
indices.push_back(lineIndex++);
|
||||
vertices.push_back(to);
|
||||
indices.push_back(lineIndex++);
|
||||
m_instancingRenderer->drawLine(from,to,gridColor);
|
||||
m_instancingRenderer->drawLine(from,to,gridColor);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*m_instancingRenderer->drawLines(&vertices[0].x,
|
||||
gridColor,
|
||||
vertices.size(),sizeof(b3Vector3),&indices[0],indices.size(),1);
|
||||
|
||||
@@ -5,6 +5,25 @@
|
||||
#include "OpenGLWindow/GLPrimitiveRenderer.h"
|
||||
#include "OpenGLWindow/b3gWindowInterface.h"
|
||||
|
||||
struct DrawGridData
|
||||
{
|
||||
int gridSize;
|
||||
float upOffset;
|
||||
int upAxis;
|
||||
float gridColor[4];
|
||||
|
||||
DrawGridData()
|
||||
:gridSize(10),
|
||||
upOffset(0.001f),
|
||||
upAxis(1)
|
||||
{
|
||||
gridColor[0] = 0.6f;
|
||||
gridColor[1] = 0.6f;
|
||||
gridColor[2] = 0.6f;
|
||||
gridColor[3] = 1.f;
|
||||
}
|
||||
};
|
||||
|
||||
struct SimpleOpenGL3App
|
||||
{
|
||||
struct SimpleInternalData* m_data;
|
||||
@@ -15,11 +34,11 @@ struct SimpleOpenGL3App
|
||||
|
||||
SimpleOpenGL3App(const char* title, int width,int height);
|
||||
virtual ~SimpleOpenGL3App();
|
||||
|
||||
|
||||
int registerCubeShape(float halfExtentsX=1.f,float halfExtentsY=1.f, float halfExtentsZ = 1.f);
|
||||
int registerGraphicsSphereShape(float radius, bool usePointSprites=true, int largeSphereThreshold=100, int mediumSphereThreshold=10);
|
||||
|
||||
void drawGrid(int gridSize=10, float upOffset=0.001, int upAxis=1);
|
||||
void drawGrid(DrawGridData data=DrawGridData());
|
||||
void swapBuffer();
|
||||
void drawText( const char* txt, int posX, int posY);
|
||||
struct sth_stash* getFontStash();
|
||||
|
||||
@@ -819,6 +819,9 @@ void btMultiBody::stepVelocitiesMultiDof(btScalar dt,
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1329,6 +1332,10 @@ void btMultiBody::stepVelocitiesMultiDof(btScalar dt,
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//determine h*D^{-1}
|
||||
@@ -2589,6 +2596,10 @@ void btMultiBody::stepPositionsMultiDof(btScalar dt, btScalar *pq, btScalar *pqd
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
m_links[i].updateCacheMultiDof(pq);
|
||||
@@ -2709,6 +2720,9 @@ void btMultiBody::filConstraintJacobianMultiDof(int link,
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -507,6 +507,11 @@ struct btMultibodyLink
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
{
|
||||
//invalid type
|
||||
btAssert(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user