Fixed buffer corruption bugs ! (Yeah !)

Former-commit-id: 3e2c82a786810a160d324f8ccf284f8e505613a0
This commit is contained in:
Lynix
2013-08-23 12:52:52 +02:00
parent 74d396a376
commit fe6816b089
5 changed files with 124 additions and 24 deletions

View File

@@ -342,13 +342,22 @@ void NzOpenGL::BindTexture(unsigned int textureUnit, nzImageType type, GLuint id
if (s_contextStates->texturesBinding[textureUnit] != id)
{
SetTextureUnit(textureUnit);
BindTextureUnit(textureUnit);
glBindTexture(TextureTarget[type], id);
s_contextStates->texturesBinding[textureUnit] = id;
}
}
void NzOpenGL::BindTextureUnit(unsigned int textureUnit)
{
if (s_contextStates->textureUnit != textureUnit)
{
glActiveTexture(GL_TEXTURE0 + textureUnit);
s_contextStates->textureUnit = textureUnit;
}
}
void NzOpenGL::DeleteBuffer(nzBufferType type, GLuint id)
{
#ifdef NAZARA_DEBUG
@@ -424,6 +433,32 @@ GLuint NzOpenGL::GetCurrentProgram()
return s_contextStates->currentProgram;
}
GLuint NzOpenGL::GetCurrentTexture()
{
#ifdef NAZARA_DEBUG
if (!s_contextStates)
{
NazaraError("No context activated");
return 0;
}
#endif
return s_contextStates->texturesBinding[s_contextStates->textureUnit];
}
GLuint NzOpenGL::GetCurrentTexture(unsigned int textureUnit)
{
#ifdef NAZARA_DEBUG
if (!s_contextStates)
{
NazaraError("No context activated");
return 0;
}
#endif
return s_contextStates->texturesBinding[textureUnit];
}
NzOpenGLFunc NzOpenGL::GetEntry(const NzString& entryPoint)
{
return LoadEntry(entryPoint.GetConstBuffer(), false);
@@ -1046,13 +1081,69 @@ bool NzOpenGL::IsSupported(const NzString& string)
return s_openGLextensionSet.find(string) != s_openGLextensionSet.end();
}
void NzOpenGL::SetBuffer(nzBufferType type, GLuint id)
{
#ifdef NAZARA_DEBUG
if (!s_contextStates)
{
NazaraError("No context activated");
return;
}
#endif
s_contextStates->buffersBinding[type] = id;
}
void NzOpenGL::SetProgram(GLuint id)
{
#ifdef NAZARA_DEBUG
if (!s_contextStates)
{
NazaraError("No context activated");
return;
}
#endif
s_contextStates->currentProgram = id;
}
void NzOpenGL::SetTexture(GLuint id)
{
#ifdef NAZARA_DEBUG
if (!s_contextStates)
{
NazaraError("No context activated");
return;
}
#endif
s_contextStates->texturesBinding[s_contextStates->textureUnit] = id;
}
void NzOpenGL::SetTexture(unsigned int textureUnit, GLuint id)
{
#ifdef NAZARA_DEBUG
if (!s_contextStates)
{
NazaraError("No context activated");
return;
}
#endif
s_contextStates->texturesBinding[textureUnit] = id;
}
void NzOpenGL::SetTextureUnit(unsigned int textureUnit)
{
if (s_contextStates->textureUnit != textureUnit)
#ifdef NAZARA_DEBUG
if (!s_contextStates)
{
glActiveTexture(GL_TEXTURE0 + textureUnit);
s_contextStates->textureUnit = textureUnit;
NazaraError("No context activated");
return;
}
#endif
s_contextStates->textureUnit = textureUnit;
}
bool NzOpenGL::TranslateFormat(nzPixelFormat pixelFormat, Format* format, FormatType type)