explicitly remove textures during resetSimulation

move glViewport to Win32Window
This commit is contained in:
erwincoumans
2018-02-21 23:22:16 -08:00
parent 15c46a0237
commit 73a4334e30
16 changed files with 102 additions and 5 deletions

View File

@@ -944,9 +944,18 @@ int GLInstancingRenderer::registerGraphicsInstance(int shapeIndex, const float*
return newUid;
}
void GLInstancingRenderer::removeTexture(int textureIndex)
{
if ((textureIndex >= 0) && (textureIndex < m_data->m_textureHandles.size()))
{
InternalTextureHandle& h = m_data->m_textureHandles[textureIndex];
glDeleteTextures(1, &h.m_glTexture);
}
}
int GLInstancingRenderer::registerTexture(const unsigned char* texels, int width, int height, bool flipPixelsY)
{
B3_PROFILE("GLInstancingRenderer::registerTexture");
b3Assert(glGetError() ==GL_NO_ERROR);
glActiveTexture(GL_TEXTURE0);

View File

@@ -69,6 +69,7 @@ public:
virtual void activateTexture(int textureIndex);
virtual void replaceTexture(int shapeIndex, int textureId);
virtual int getShapeIndexFromInstance(int srcIndex);
virtual void removeTexture(int textureIndex);
///position x,y,z, quaternion x,y,z,w, color r,g,b,a, scaling x,y,z
virtual int registerGraphicsInstance(int shapeIndex, const float* position, const float* quaternion, const float* color, const float* scaling);

View File

@@ -44,7 +44,7 @@ static SimpleOpenGL2App* gApp2=0;
static void Simple2ResizeCallback( float widthf, float heightf)
{
glViewport(0, 0, widthf, heightf);
int width = (int)widthf;
int height = (int)heightf;

View File

@@ -460,6 +460,14 @@ void SimpleOpenGL2Renderer::updateTexture(int textureIndex, const unsigned ch
}
}
void SimpleOpenGL2Renderer::removeTexture(int textureIndex)
{
if ((textureIndex >= 0) && (textureIndex < m_data->m_textureHandles.size()))
{
glDeleteTextures(1, &m_data->m_textureHandles[textureIndex].m_glTexture);
}
}
void SimpleOpenGL2Renderer::activateTexture(int textureIndex)
{
glActiveTexture(GL_TEXTURE0);

View File

@@ -55,7 +55,7 @@ public:
virtual int registerTexture(const unsigned char* texels, int width, int height, bool flipTexelsY);
virtual void updateTexture(int textureIndex, const unsigned char* texels, bool flipTexelsY);
virtual void activateTexture(int textureIndex);
virtual void removeTexture(int textureIndex);
virtual int registerGraphicsInstance(int shapeIndex, const double* position, const double* quaternion, const double* color, const double* scaling);

View File

@@ -413,10 +413,13 @@ 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);
if (sData->m_resizeCallback)
(*sData->m_resizeCallback)(sData->m_openglViewportWidth,sData->m_openglViewportHeight);
{
glViewport(0, 0, sData->m_openglViewportWidth, sData->m_openglViewportHeight);
(*sData->m_resizeCallback)(sData->m_openglViewportWidth, sData->m_openglViewportHeight);
}
//if (sOpenGLInitialized)
//{
// //gDemoApplication->reshape(sWidth,sHeight);