forked from Mirrorlandia_minetest/irrlicht
OpenGL3: Replace direct calls into libGL with mt_opengl
This commit is contained in:
parent
063079b372
commit
d4735ebc76
@ -192,19 +192,19 @@ COpenGL3DriverBase::~COpenGL3DriverBase()
|
|||||||
QuadsIndices.push_back(4 * k + 2);
|
QuadsIndices.push_back(4 * k + 2);
|
||||||
QuadsIndices.push_back(4 * k + 3);
|
QuadsIndices.push_back(4 * k + 3);
|
||||||
}
|
}
|
||||||
glGenBuffers(1, &QuadIndexBuffer);
|
GL.GenBuffers(1, &QuadIndexBuffer);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, QuadIndexBuffer);
|
GL.BindBuffer(GL_ARRAY_BUFFER, QuadIndexBuffer);
|
||||||
glBufferData(GL_ARRAY_BUFFER, sizeof(QuadsIndices[0]) * QuadsIndices.size(), QuadsIndices.data(), GL_STATIC_DRAW);
|
GL.BufferData(GL_ARRAY_BUFFER, sizeof(QuadsIndices[0]) * QuadsIndices.size(), QuadsIndices.data(), GL_STATIC_DRAW);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
GL.BindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
QuadIndexCount = QuadsIndices.size();
|
QuadIndexCount = QuadsIndices.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
void COpenGL3DriverBase::initVersion() {
|
void COpenGL3DriverBase::initVersion() {
|
||||||
Name = glGetString(GL_VERSION);
|
Name = GL.GetString(GL_VERSION);
|
||||||
printVersion();
|
printVersion();
|
||||||
|
|
||||||
// print renderer information
|
// print renderer information
|
||||||
VendorName = glGetString(GL_VENDOR);
|
VendorName = GL.GetString(GL_VENDOR);
|
||||||
os::Printer::log(VendorName.c_str(), ELL_INFORMATION);
|
os::Printer::log(VendorName.c_str(), ELL_INFORMATION);
|
||||||
|
|
||||||
Version = getVersionFromOpenGL();
|
Version = getVersionFromOpenGL();
|
||||||
@ -242,7 +242,7 @@ COpenGL3DriverBase::~COpenGL3DriverBase()
|
|||||||
DriverAttributes->setAttribute("Version", 100 * Version.Major + Version.Minor);
|
DriverAttributes->setAttribute("Version", 100 * Version.Major + Version.Minor);
|
||||||
DriverAttributes->setAttribute("AntiAlias", AntiAlias);
|
DriverAttributes->setAttribute("AntiAlias", AntiAlias);
|
||||||
|
|
||||||
glPixelStorei(GL_PACK_ALIGNMENT, 1);
|
GL.PixelStorei(GL_PACK_ALIGNMENT, 1);
|
||||||
|
|
||||||
UserClipPlane.reallocate(0);
|
UserClipPlane.reallocate(0);
|
||||||
|
|
||||||
@ -250,10 +250,10 @@ COpenGL3DriverBase::~COpenGL3DriverBase()
|
|||||||
setTransform(static_cast<E_TRANSFORMATION_STATE>(i), core::IdentityMatrix);
|
setTransform(static_cast<E_TRANSFORMATION_STATE>(i), core::IdentityMatrix);
|
||||||
|
|
||||||
setAmbientLight(SColorf(0.0f, 0.0f, 0.0f, 0.0f));
|
setAmbientLight(SColorf(0.0f, 0.0f, 0.0f, 0.0f));
|
||||||
glClearDepthf(1.0f);
|
GL.ClearDepthf(1.0f);
|
||||||
|
|
||||||
glHint(GL_GENERATE_MIPMAP_HINT, GL_NICEST);
|
GL.Hint(GL_GENERATE_MIPMAP_HINT, GL_NICEST);
|
||||||
glFrontFace(GL_CW);
|
GL.FrontFace(GL_CW);
|
||||||
|
|
||||||
// create material renderers
|
// create material renderers
|
||||||
createMaterialRenderers();
|
createMaterialRenderers();
|
||||||
@ -418,7 +418,7 @@ COpenGL3DriverBase::~COpenGL3DriverBase()
|
|||||||
{
|
{
|
||||||
CNullDriver::endScene();
|
CNullDriver::endScene();
|
||||||
|
|
||||||
glFlush();
|
GL.Flush();
|
||||||
|
|
||||||
if (ContextManager)
|
if (ContextManager)
|
||||||
return ContextManager->swapBuffers();
|
return ContextManager->swapBuffers();
|
||||||
@ -460,7 +460,7 @@ COpenGL3DriverBase::~COpenGL3DriverBase()
|
|||||||
bool newBuffer = false;
|
bool newBuffer = false;
|
||||||
if (!HWBuffer->vbo_verticesID)
|
if (!HWBuffer->vbo_verticesID)
|
||||||
{
|
{
|
||||||
glGenBuffers(1, &HWBuffer->vbo_verticesID);
|
GL.GenBuffers(1, &HWBuffer->vbo_verticesID);
|
||||||
if (!HWBuffer->vbo_verticesID) return false;
|
if (!HWBuffer->vbo_verticesID) return false;
|
||||||
newBuffer = true;
|
newBuffer = true;
|
||||||
}
|
}
|
||||||
@ -469,22 +469,22 @@ COpenGL3DriverBase::~COpenGL3DriverBase()
|
|||||||
newBuffer = true;
|
newBuffer = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, HWBuffer->vbo_verticesID);
|
GL.BindBuffer(GL_ARRAY_BUFFER, HWBuffer->vbo_verticesID);
|
||||||
|
|
||||||
// copy data to graphics card
|
// copy data to graphics card
|
||||||
if (!newBuffer)
|
if (!newBuffer)
|
||||||
glBufferSubData(GL_ARRAY_BUFFER, 0, bufferSize, buffer);
|
GL.BufferSubData(GL_ARRAY_BUFFER, 0, bufferSize, buffer);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
HWBuffer->vbo_verticesSize = bufferSize;
|
HWBuffer->vbo_verticesSize = bufferSize;
|
||||||
|
|
||||||
if (HWBuffer->Mapped_Vertex == scene::EHM_STATIC)
|
if (HWBuffer->Mapped_Vertex == scene::EHM_STATIC)
|
||||||
glBufferData(GL_ARRAY_BUFFER, bufferSize, buffer, GL_STATIC_DRAW);
|
GL.BufferData(GL_ARRAY_BUFFER, bufferSize, buffer, GL_STATIC_DRAW);
|
||||||
else
|
else
|
||||||
glBufferData(GL_ARRAY_BUFFER, bufferSize, buffer, GL_DYNAMIC_DRAW);
|
GL.BufferData(GL_ARRAY_BUFFER, bufferSize, buffer, GL_DYNAMIC_DRAW);
|
||||||
}
|
}
|
||||||
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
GL.BindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
|
|
||||||
return (!testGLError(__LINE__));
|
return (!testGLError(__LINE__));
|
||||||
}
|
}
|
||||||
@ -523,7 +523,7 @@ COpenGL3DriverBase::~COpenGL3DriverBase()
|
|||||||
bool newBuffer = false;
|
bool newBuffer = false;
|
||||||
if (!HWBuffer->vbo_indicesID)
|
if (!HWBuffer->vbo_indicesID)
|
||||||
{
|
{
|
||||||
glGenBuffers(1, &HWBuffer->vbo_indicesID);
|
GL.GenBuffers(1, &HWBuffer->vbo_indicesID);
|
||||||
if (!HWBuffer->vbo_indicesID) return false;
|
if (!HWBuffer->vbo_indicesID) return false;
|
||||||
newBuffer = true;
|
newBuffer = true;
|
||||||
}
|
}
|
||||||
@ -532,22 +532,22 @@ COpenGL3DriverBase::~COpenGL3DriverBase()
|
|||||||
newBuffer = true;
|
newBuffer = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, HWBuffer->vbo_indicesID);
|
GL.BindBuffer(GL_ELEMENT_ARRAY_BUFFER, HWBuffer->vbo_indicesID);
|
||||||
|
|
||||||
// copy data to graphics card
|
// copy data to graphics card
|
||||||
if (!newBuffer)
|
if (!newBuffer)
|
||||||
glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, indexCount * indexSize, indices);
|
GL.BufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, indexCount * indexSize, indices);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
HWBuffer->vbo_indicesSize = indexCount * indexSize;
|
HWBuffer->vbo_indicesSize = indexCount * indexSize;
|
||||||
|
|
||||||
if (HWBuffer->Mapped_Index == scene::EHM_STATIC)
|
if (HWBuffer->Mapped_Index == scene::EHM_STATIC)
|
||||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, indexCount * indexSize, indices, GL_STATIC_DRAW);
|
GL.BufferData(GL_ELEMENT_ARRAY_BUFFER, indexCount * indexSize, indices, GL_STATIC_DRAW);
|
||||||
else
|
else
|
||||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, indexCount * indexSize, indices, GL_DYNAMIC_DRAW);
|
GL.BufferData(GL_ELEMENT_ARRAY_BUFFER, indexCount * indexSize, indices, GL_DYNAMIC_DRAW);
|
||||||
}
|
}
|
||||||
|
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
GL.BindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||||
|
|
||||||
return (!testGLError(__LINE__));
|
return (!testGLError(__LINE__));
|
||||||
}
|
}
|
||||||
@ -627,12 +627,12 @@ COpenGL3DriverBase::~COpenGL3DriverBase()
|
|||||||
SHWBufferLink_opengl *HWBuffer = static_cast<SHWBufferLink_opengl*>(_HWBuffer);
|
SHWBufferLink_opengl *HWBuffer = static_cast<SHWBufferLink_opengl*>(_HWBuffer);
|
||||||
if (HWBuffer->vbo_verticesID)
|
if (HWBuffer->vbo_verticesID)
|
||||||
{
|
{
|
||||||
glDeleteBuffers(1, &HWBuffer->vbo_verticesID);
|
GL.DeleteBuffers(1, &HWBuffer->vbo_verticesID);
|
||||||
HWBuffer->vbo_verticesID = 0;
|
HWBuffer->vbo_verticesID = 0;
|
||||||
}
|
}
|
||||||
if (HWBuffer->vbo_indicesID)
|
if (HWBuffer->vbo_indicesID)
|
||||||
{
|
{
|
||||||
glDeleteBuffers(1, &HWBuffer->vbo_indicesID);
|
GL.DeleteBuffers(1, &HWBuffer->vbo_indicesID);
|
||||||
HWBuffer->vbo_indicesID = 0;
|
HWBuffer->vbo_indicesID = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -656,13 +656,13 @@ COpenGL3DriverBase::~COpenGL3DriverBase()
|
|||||||
|
|
||||||
if (HWBuffer->Mapped_Vertex != scene::EHM_NEVER)
|
if (HWBuffer->Mapped_Vertex != scene::EHM_NEVER)
|
||||||
{
|
{
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, HWBuffer->vbo_verticesID);
|
GL.BindBuffer(GL_ARRAY_BUFFER, HWBuffer->vbo_verticesID);
|
||||||
vertices = 0;
|
vertices = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (HWBuffer->Mapped_Index != scene::EHM_NEVER)
|
if (HWBuffer->Mapped_Index != scene::EHM_NEVER)
|
||||||
{
|
{
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, HWBuffer->vbo_indicesID);
|
GL.BindBuffer(GL_ELEMENT_ARRAY_BUFFER, HWBuffer->vbo_indicesID);
|
||||||
indexList = 0;
|
indexList = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -673,10 +673,10 @@ COpenGL3DriverBase::~COpenGL3DriverBase()
|
|||||||
mb->getIndexType());
|
mb->getIndexType());
|
||||||
|
|
||||||
if (HWBuffer->Mapped_Vertex != scene::EHM_NEVER)
|
if (HWBuffer->Mapped_Vertex != scene::EHM_NEVER)
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
GL.BindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
|
|
||||||
if (HWBuffer->Mapped_Index != scene::EHM_NEVER)
|
if (HWBuffer->Mapped_Index != scene::EHM_NEVER)
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
GL.BindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -741,25 +741,25 @@ COpenGL3DriverBase::~COpenGL3DriverBase()
|
|||||||
{
|
{
|
||||||
case scene::EPT_POINTS:
|
case scene::EPT_POINTS:
|
||||||
case scene::EPT_POINT_SPRITES:
|
case scene::EPT_POINT_SPRITES:
|
||||||
glDrawArrays(GL_POINTS, 0, primitiveCount);
|
GL.DrawArrays(GL_POINTS, 0, primitiveCount);
|
||||||
break;
|
break;
|
||||||
case scene::EPT_LINE_STRIP:
|
case scene::EPT_LINE_STRIP:
|
||||||
glDrawElements(GL_LINE_STRIP, primitiveCount + 1, indexSize, indexList);
|
GL.DrawElements(GL_LINE_STRIP, primitiveCount + 1, indexSize, indexList);
|
||||||
break;
|
break;
|
||||||
case scene::EPT_LINE_LOOP:
|
case scene::EPT_LINE_LOOP:
|
||||||
glDrawElements(GL_LINE_LOOP, primitiveCount, indexSize, indexList);
|
GL.DrawElements(GL_LINE_LOOP, primitiveCount, indexSize, indexList);
|
||||||
break;
|
break;
|
||||||
case scene::EPT_LINES:
|
case scene::EPT_LINES:
|
||||||
glDrawElements(GL_LINES, primitiveCount*2, indexSize, indexList);
|
GL.DrawElements(GL_LINES, primitiveCount*2, indexSize, indexList);
|
||||||
break;
|
break;
|
||||||
case scene::EPT_TRIANGLE_STRIP:
|
case scene::EPT_TRIANGLE_STRIP:
|
||||||
glDrawElements(GL_TRIANGLE_STRIP, primitiveCount + 2, indexSize, indexList);
|
GL.DrawElements(GL_TRIANGLE_STRIP, primitiveCount + 2, indexSize, indexList);
|
||||||
break;
|
break;
|
||||||
case scene::EPT_TRIANGLE_FAN:
|
case scene::EPT_TRIANGLE_FAN:
|
||||||
glDrawElements(GL_TRIANGLE_FAN, primitiveCount + 2, indexSize, indexList);
|
GL.DrawElements(GL_TRIANGLE_FAN, primitiveCount + 2, indexSize, indexList);
|
||||||
break;
|
break;
|
||||||
case scene::EPT_TRIANGLES:
|
case scene::EPT_TRIANGLES:
|
||||||
glDrawElements((LastMaterial.Wireframe) ? GL_LINES : (LastMaterial.PointCloud) ? GL_POINTS : GL_TRIANGLES, primitiveCount*3, indexSize, indexList);
|
GL.DrawElements((LastMaterial.Wireframe) ? GL_LINES : (LastMaterial.PointCloud) ? GL_POINTS : GL_TRIANGLES, primitiveCount*3, indexSize, indexList);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -827,8 +827,8 @@ COpenGL3DriverBase::~COpenGL3DriverBase()
|
|||||||
if (!clipRect->isValid())
|
if (!clipRect->isValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
glEnable(GL_SCISSOR_TEST);
|
GL.Enable(GL_SCISSOR_TEST);
|
||||||
glScissor(clipRect->UpperLeftCorner.X, renderTargetSize.Height - clipRect->LowerRightCorner.Y,
|
GL.Scissor(clipRect->UpperLeftCorner.X, renderTargetSize.Height - clipRect->LowerRightCorner.Y,
|
||||||
clipRect->getWidth(), clipRect->getHeight());
|
clipRect->getWidth(), clipRect->getHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -846,7 +846,7 @@ COpenGL3DriverBase::~COpenGL3DriverBase()
|
|||||||
drawQuad(vt2DImage, vertices);
|
drawQuad(vt2DImage, vertices);
|
||||||
|
|
||||||
if (clipRect)
|
if (clipRect)
|
||||||
glDisable(GL_SCISSOR_TEST);
|
GL.Disable(GL_SCISSOR_TEST);
|
||||||
|
|
||||||
testGLError(__LINE__);
|
testGLError(__LINE__);
|
||||||
}
|
}
|
||||||
@ -906,8 +906,8 @@ COpenGL3DriverBase::~COpenGL3DriverBase()
|
|||||||
if (!clipRect->isValid())
|
if (!clipRect->isValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
glEnable(GL_SCISSOR_TEST);
|
GL.Enable(GL_SCISSOR_TEST);
|
||||||
glScissor(clipRect->UpperLeftCorner.X, renderTargetSize.Height - clipRect->LowerRightCorner.Y,
|
GL.Scissor(clipRect->UpperLeftCorner.X, renderTargetSize.Height - clipRect->LowerRightCorner.Y,
|
||||||
clipRect->getWidth(), clipRect->getHeight());
|
clipRect->getWidth(), clipRect->getHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -952,12 +952,12 @@ COpenGL3DriverBase::~COpenGL3DriverBase()
|
|||||||
tcoords.UpperLeftCorner.X, tcoords.LowerRightCorner.Y));
|
tcoords.UpperLeftCorner.X, tcoords.LowerRightCorner.Y));
|
||||||
}
|
}
|
||||||
|
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, QuadIndexBuffer);
|
GL.BindBuffer(GL_ELEMENT_ARRAY_BUFFER, QuadIndexBuffer);
|
||||||
drawElements(GL_TRIANGLES, vt2DImage, vtx.const_pointer(), vtx.size(), 0, 6 * drawCount);
|
drawElements(GL_TRIANGLES, vt2DImage, vtx.const_pointer(), vtx.size(), 0, 6 * drawCount);
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
GL.BindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||||
|
|
||||||
if (clipRect)
|
if (clipRect)
|
||||||
glDisable(GL_SCISSOR_TEST);
|
GL.Disable(GL_SCISSOR_TEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1093,25 +1093,25 @@ COpenGL3DriverBase::~COpenGL3DriverBase()
|
|||||||
void COpenGL3DriverBase::drawArrays(GLenum primitiveType, const VertexType &vertexType, const void *vertices, int vertexCount)
|
void COpenGL3DriverBase::drawArrays(GLenum primitiveType, const VertexType &vertexType, const void *vertices, int vertexCount)
|
||||||
{
|
{
|
||||||
beginDraw(vertexType, reinterpret_cast<uintptr_t>(vertices));
|
beginDraw(vertexType, reinterpret_cast<uintptr_t>(vertices));
|
||||||
glDrawArrays(primitiveType, 0, vertexCount);
|
GL.DrawArrays(primitiveType, 0, vertexCount);
|
||||||
endDraw(vertexType);
|
endDraw(vertexType);
|
||||||
}
|
}
|
||||||
|
|
||||||
void COpenGL3DriverBase::drawElements(GLenum primitiveType, const VertexType &vertexType, const void *vertices, int vertexCount, const u16 *indices, int indexCount)
|
void COpenGL3DriverBase::drawElements(GLenum primitiveType, const VertexType &vertexType, const void *vertices, int vertexCount, const u16 *indices, int indexCount)
|
||||||
{
|
{
|
||||||
beginDraw(vertexType, reinterpret_cast<uintptr_t>(vertices));
|
beginDraw(vertexType, reinterpret_cast<uintptr_t>(vertices));
|
||||||
glDrawRangeElements(primitiveType, 0, vertexCount - 1, indexCount, GL_UNSIGNED_SHORT, indices);
|
GL.DrawRangeElements(primitiveType, 0, vertexCount - 1, indexCount, GL_UNSIGNED_SHORT, indices);
|
||||||
endDraw(vertexType);
|
endDraw(vertexType);
|
||||||
}
|
}
|
||||||
|
|
||||||
void COpenGL3DriverBase::beginDraw(const VertexType &vertexType, uintptr_t verticesBase)
|
void COpenGL3DriverBase::beginDraw(const VertexType &vertexType, uintptr_t verticesBase)
|
||||||
{
|
{
|
||||||
for (auto attr: vertexType) {
|
for (auto attr: vertexType) {
|
||||||
glEnableVertexAttribArray(attr.Index);
|
GL.EnableVertexAttribArray(attr.Index);
|
||||||
switch (attr.mode) {
|
switch (attr.mode) {
|
||||||
case VertexAttribute::Mode::Regular: glVertexAttribPointer(attr.Index, attr.ComponentCount, attr.ComponentType, GL_FALSE, vertexType.VertexSize, reinterpret_cast<void *>(verticesBase + attr.Offset)); break;
|
case VertexAttribute::Mode::Regular: GL.VertexAttribPointer(attr.Index, attr.ComponentCount, attr.ComponentType, GL_FALSE, vertexType.VertexSize, reinterpret_cast<void *>(verticesBase + attr.Offset)); break;
|
||||||
case VertexAttribute::Mode::Normalized: glVertexAttribPointer(attr.Index, attr.ComponentCount, attr.ComponentType, GL_TRUE, vertexType.VertexSize, reinterpret_cast<void *>(verticesBase + attr.Offset)); break;
|
case VertexAttribute::Mode::Normalized: GL.VertexAttribPointer(attr.Index, attr.ComponentCount, attr.ComponentType, GL_TRUE, vertexType.VertexSize, reinterpret_cast<void *>(verticesBase + attr.Offset)); break;
|
||||||
case VertexAttribute::Mode::Integral: glVertexAttribIPointer(attr.Index, attr.ComponentCount, attr.ComponentType, vertexType.VertexSize, reinterpret_cast<void *>(verticesBase + attr.Offset)); break;
|
case VertexAttribute::Mode::Integral: GL.VertexAttribIPointer(attr.Index, attr.ComponentCount, attr.ComponentType, vertexType.VertexSize, reinterpret_cast<void *>(verticesBase + attr.Offset)); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1119,7 +1119,7 @@ COpenGL3DriverBase::~COpenGL3DriverBase()
|
|||||||
void COpenGL3DriverBase::endDraw(const VertexType &vertexType)
|
void COpenGL3DriverBase::endDraw(const VertexType &vertexType)
|
||||||
{
|
{
|
||||||
for (auto attr: vertexType)
|
for (auto attr: vertexType)
|
||||||
glDisableVertexAttribArray(attr.Index);
|
GL.DisableVertexAttribArray(attr.Index);
|
||||||
}
|
}
|
||||||
|
|
||||||
ITexture* COpenGL3DriverBase::createDeviceDependentTexture(const io::path& name, IImage* image)
|
ITexture* COpenGL3DriverBase::createDeviceDependentTexture(const io::path& name, IImage* image)
|
||||||
@ -1156,7 +1156,7 @@ COpenGL3DriverBase::~COpenGL3DriverBase()
|
|||||||
bool COpenGL3DriverBase::testGLError(int code)
|
bool COpenGL3DriverBase::testGLError(int code)
|
||||||
{
|
{
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
GLenum g = glGetError();
|
GLenum g = GL.GetError();
|
||||||
switch (g)
|
switch (g)
|
||||||
{
|
{
|
||||||
case GL_NO_ERROR:
|
case GL_NO_ERROR:
|
||||||
@ -1418,15 +1418,15 @@ COpenGL3DriverBase::~COpenGL3DriverBase()
|
|||||||
// TODO: Polygon Offset. Not sure if it was left out deliberately or if it won't work with this driver.
|
// TODO: Polygon Offset. Not sure if it was left out deliberately or if it won't work with this driver.
|
||||||
|
|
||||||
if (resetAllRenderStates || lastmaterial.Thickness != material.Thickness)
|
if (resetAllRenderStates || lastmaterial.Thickness != material.Thickness)
|
||||||
glLineWidth(core::clamp(static_cast<GLfloat>(material.Thickness), DimAliasedLine[0], DimAliasedLine[1]));
|
GL.LineWidth(core::clamp(static_cast<GLfloat>(material.Thickness), DimAliasedLine[0], DimAliasedLine[1]));
|
||||||
|
|
||||||
// Anti aliasing
|
// Anti aliasing
|
||||||
if (resetAllRenderStates || lastmaterial.AntiAliasing != material.AntiAliasing)
|
if (resetAllRenderStates || lastmaterial.AntiAliasing != material.AntiAliasing)
|
||||||
{
|
{
|
||||||
if (material.AntiAliasing & EAAM_ALPHA_TO_COVERAGE)
|
if (material.AntiAliasing & EAAM_ALPHA_TO_COVERAGE)
|
||||||
glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE);
|
GL.Enable(GL_SAMPLE_ALPHA_TO_COVERAGE);
|
||||||
else if (lastmaterial.AntiAliasing & EAAM_ALPHA_TO_COVERAGE)
|
else if (lastmaterial.AntiAliasing & EAAM_ALPHA_TO_COVERAGE)
|
||||||
glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);
|
GL.Disable(GL_SAMPLE_ALPHA_TO_COVERAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Texture parameters
|
// Texture parameters
|
||||||
@ -1455,7 +1455,7 @@ COpenGL3DriverBase::~COpenGL3DriverBase()
|
|||||||
if (!tmpTexture->getStatesCache().IsCached || material.TextureLayers[i].MagFilter != tmpTexture->getStatesCache().MagFilter)
|
if (!tmpTexture->getStatesCache().IsCached || material.TextureLayers[i].MagFilter != tmpTexture->getStatesCache().MagFilter)
|
||||||
{
|
{
|
||||||
E_TEXTURE_MAG_FILTER magFilter = material.TextureLayers[i].MagFilter;
|
E_TEXTURE_MAG_FILTER magFilter = material.TextureLayers[i].MagFilter;
|
||||||
glTexParameteri(tmpTextureType, GL_TEXTURE_MAG_FILTER,
|
GL.TexParameteri(tmpTextureType, GL_TEXTURE_MAG_FILTER,
|
||||||
magFilter == ETMAGF_NEAREST ? GL_NEAREST :
|
magFilter == ETMAGF_NEAREST ? GL_NEAREST :
|
||||||
(assert(magFilter == ETMAGF_LINEAR), GL_LINEAR));
|
(assert(magFilter == ETMAGF_LINEAR), GL_LINEAR));
|
||||||
|
|
||||||
@ -1468,7 +1468,7 @@ COpenGL3DriverBase::~COpenGL3DriverBase()
|
|||||||
!tmpTexture->getStatesCache().MipMapStatus)
|
!tmpTexture->getStatesCache().MipMapStatus)
|
||||||
{
|
{
|
||||||
E_TEXTURE_MIN_FILTER minFilter = material.TextureLayers[i].MinFilter;
|
E_TEXTURE_MIN_FILTER minFilter = material.TextureLayers[i].MinFilter;
|
||||||
glTexParameteri(tmpTextureType, GL_TEXTURE_MIN_FILTER,
|
GL.TexParameteri(tmpTextureType, GL_TEXTURE_MIN_FILTER,
|
||||||
minFilter == ETMINF_NEAREST_MIPMAP_NEAREST ? GL_NEAREST_MIPMAP_NEAREST :
|
minFilter == ETMINF_NEAREST_MIPMAP_NEAREST ? GL_NEAREST_MIPMAP_NEAREST :
|
||||||
minFilter == ETMINF_LINEAR_MIPMAP_NEAREST ? GL_LINEAR_MIPMAP_NEAREST :
|
minFilter == ETMINF_LINEAR_MIPMAP_NEAREST ? GL_LINEAR_MIPMAP_NEAREST :
|
||||||
minFilter == ETMINF_NEAREST_MIPMAP_LINEAR ? GL_NEAREST_MIPMAP_LINEAR :
|
minFilter == ETMINF_NEAREST_MIPMAP_LINEAR ? GL_NEAREST_MIPMAP_LINEAR :
|
||||||
@ -1484,7 +1484,7 @@ COpenGL3DriverBase::~COpenGL3DriverBase()
|
|||||||
tmpTexture->getStatesCache().MipMapStatus)
|
tmpTexture->getStatesCache().MipMapStatus)
|
||||||
{
|
{
|
||||||
E_TEXTURE_MIN_FILTER minFilter = material.TextureLayers[i].MinFilter;
|
E_TEXTURE_MIN_FILTER minFilter = material.TextureLayers[i].MinFilter;
|
||||||
glTexParameteri(tmpTextureType, GL_TEXTURE_MIN_FILTER,
|
GL.TexParameteri(tmpTextureType, GL_TEXTURE_MIN_FILTER,
|
||||||
(minFilter == ETMINF_NEAREST_MIPMAP_NEAREST || minFilter == ETMINF_NEAREST_MIPMAP_LINEAR) ? GL_NEAREST :
|
(minFilter == ETMINF_NEAREST_MIPMAP_NEAREST || minFilter == ETMINF_NEAREST_MIPMAP_LINEAR) ? GL_NEAREST :
|
||||||
(assert(minFilter == ETMINF_LINEAR_MIPMAP_NEAREST || minFilter == ETMINF_LINEAR_MIPMAP_LINEAR), GL_LINEAR));
|
(assert(minFilter == ETMINF_LINEAR_MIPMAP_NEAREST || minFilter == ETMINF_LINEAR_MIPMAP_LINEAR), GL_LINEAR));
|
||||||
|
|
||||||
@ -1496,7 +1496,7 @@ COpenGL3DriverBase::~COpenGL3DriverBase()
|
|||||||
if (AnisotropicFilterSupported &&
|
if (AnisotropicFilterSupported &&
|
||||||
(!tmpTexture->getStatesCache().IsCached || material.TextureLayers[i].AnisotropicFilter != tmpTexture->getStatesCache().AnisotropicFilter))
|
(!tmpTexture->getStatesCache().IsCached || material.TextureLayers[i].AnisotropicFilter != tmpTexture->getStatesCache().AnisotropicFilter))
|
||||||
{
|
{
|
||||||
glTexParameteri(tmpTextureType, GL.TEXTURE_MAX_ANISOTROPY,
|
GL.TexParameteri(tmpTextureType, GL.TEXTURE_MAX_ANISOTROPY,
|
||||||
material.TextureLayers[i].AnisotropicFilter>1 ? core::min_(MaxAnisotropy, material.TextureLayers[i].AnisotropicFilter) : 1);
|
material.TextureLayers[i].AnisotropicFilter>1 ? core::min_(MaxAnisotropy, material.TextureLayers[i].AnisotropicFilter) : 1);
|
||||||
|
|
||||||
tmpTexture->getStatesCache().AnisotropicFilter = material.TextureLayers[i].AnisotropicFilter;
|
tmpTexture->getStatesCache().AnisotropicFilter = material.TextureLayers[i].AnisotropicFilter;
|
||||||
@ -1504,13 +1504,13 @@ COpenGL3DriverBase::~COpenGL3DriverBase()
|
|||||||
|
|
||||||
if (!tmpTexture->getStatesCache().IsCached || material.TextureLayers[i].TextureWrapU != tmpTexture->getStatesCache().WrapU)
|
if (!tmpTexture->getStatesCache().IsCached || material.TextureLayers[i].TextureWrapU != tmpTexture->getStatesCache().WrapU)
|
||||||
{
|
{
|
||||||
glTexParameteri(tmpTextureType, GL_TEXTURE_WRAP_S, getTextureWrapMode(material.TextureLayers[i].TextureWrapU));
|
GL.TexParameteri(tmpTextureType, GL_TEXTURE_WRAP_S, getTextureWrapMode(material.TextureLayers[i].TextureWrapU));
|
||||||
tmpTexture->getStatesCache().WrapU = material.TextureLayers[i].TextureWrapU;
|
tmpTexture->getStatesCache().WrapU = material.TextureLayers[i].TextureWrapU;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tmpTexture->getStatesCache().IsCached || material.TextureLayers[i].TextureWrapV != tmpTexture->getStatesCache().WrapV)
|
if (!tmpTexture->getStatesCache().IsCached || material.TextureLayers[i].TextureWrapV != tmpTexture->getStatesCache().WrapV)
|
||||||
{
|
{
|
||||||
glTexParameteri(tmpTextureType, GL_TEXTURE_WRAP_T, getTextureWrapMode(material.TextureLayers[i].TextureWrapV));
|
GL.TexParameteri(tmpTextureType, GL_TEXTURE_WRAP_T, getTextureWrapMode(material.TextureLayers[i].TextureWrapV));
|
||||||
tmpTexture->getStatesCache().WrapV = material.TextureLayers[i].TextureWrapV;
|
tmpTexture->getStatesCache().WrapV = material.TextureLayers[i].TextureWrapV;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1902,7 +1902,7 @@ COpenGL3DriverBase::~COpenGL3DriverBase()
|
|||||||
CacheHandler->setColorMask(ECP_ALL);
|
CacheHandler->setColorMask(ECP_ALL);
|
||||||
|
|
||||||
const f32 inv = 1.0f / 255.0f;
|
const f32 inv = 1.0f / 255.0f;
|
||||||
glClearColor(color.getRed() * inv, color.getGreen() * inv,
|
GL.ClearColor(color.getRed() * inv, color.getGreen() * inv,
|
||||||
color.getBlue() * inv, color.getAlpha() * inv);
|
color.getBlue() * inv, color.getAlpha() * inv);
|
||||||
|
|
||||||
mask |= GL_COLOR_BUFFER_BIT;
|
mask |= GL_COLOR_BUFFER_BIT;
|
||||||
@ -1911,18 +1911,18 @@ COpenGL3DriverBase::~COpenGL3DriverBase()
|
|||||||
if (flag & ECBF_DEPTH)
|
if (flag & ECBF_DEPTH)
|
||||||
{
|
{
|
||||||
CacheHandler->setDepthMask(true);
|
CacheHandler->setDepthMask(true);
|
||||||
glClearDepthf(depth);
|
GL.ClearDepthf(depth);
|
||||||
mask |= GL_DEPTH_BUFFER_BIT;
|
mask |= GL_DEPTH_BUFFER_BIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flag & ECBF_STENCIL)
|
if (flag & ECBF_STENCIL)
|
||||||
{
|
{
|
||||||
glClearStencil(stencil);
|
GL.ClearStencil(stencil);
|
||||||
mask |= GL_STENCIL_BUFFER_BIT;
|
mask |= GL_STENCIL_BUFFER_BIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mask)
|
if (mask)
|
||||||
glClear(mask);
|
GL.Clear(mask);
|
||||||
|
|
||||||
CacheHandler->setColorMask(colorMask);
|
CacheHandler->setColorMask(colorMask);
|
||||||
CacheHandler->setDepthMask(depthMask);
|
CacheHandler->setDepthMask(depthMask);
|
||||||
@ -1941,8 +1941,8 @@ COpenGL3DriverBase::~COpenGL3DriverBase()
|
|||||||
GLint internalformat = GL_RGBA;
|
GLint internalformat = GL_RGBA;
|
||||||
GLint type = GL_UNSIGNED_BYTE;
|
GLint type = GL_UNSIGNED_BYTE;
|
||||||
{
|
{
|
||||||
// glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT, &internalformat);
|
// GL.GetIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT, &internalformat);
|
||||||
// glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_TYPE, &type);
|
// GL.GetIntegerv(GL_IMPLEMENTATION_COLOR_READ_TYPE, &type);
|
||||||
// there's a format we don't support ATM
|
// there's a format we don't support ATM
|
||||||
if (GL_UNSIGNED_SHORT_4_4_4_4 == type)
|
if (GL_UNSIGNED_SHORT_4_4_4_4 == type)
|
||||||
{
|
{
|
||||||
@ -1977,7 +1977,7 @@ COpenGL3DriverBase::~COpenGL3DriverBase()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
glReadPixels(0, 0, ScreenSize.Width, ScreenSize.Height, internalformat, type, pixels);
|
GL.ReadPixels(0, 0, ScreenSize.Width, ScreenSize.Height, internalformat, type, pixels);
|
||||||
testGLError(__LINE__);
|
testGLError(__LINE__);
|
||||||
|
|
||||||
// opengl images are horizontally flipped, so we have to fix that here.
|
// opengl images are horizontally flipped, so we have to fix that here.
|
||||||
|
@ -17,7 +17,7 @@ namespace video
|
|||||||
{
|
{
|
||||||
void COpenGL3ExtensionHandler::initExtensionsOld()
|
void COpenGL3ExtensionHandler::initExtensionsOld()
|
||||||
{
|
{
|
||||||
auto extensions_string = reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS));
|
auto extensions_string = reinterpret_cast<const char *>(GL.GetString(GL_EXTENSIONS));
|
||||||
const char *pos = extensions_string;
|
const char *pos = extensions_string;
|
||||||
while (const char *next = strchr(pos, ' ')) {
|
while (const char *next = strchr(pos, ' ')) {
|
||||||
addExtension(std::string{pos, next});
|
addExtension(std::string{pos, next});
|
||||||
|
@ -79,13 +79,13 @@ namespace video
|
|||||||
|
|
||||||
static GLint GetInteger(GLenum key) {
|
static GLint GetInteger(GLenum key) {
|
||||||
GLint val = 0;
|
GLint val = 0;
|
||||||
glGetIntegerv(key, &val);
|
GL.GetIntegerv(key, &val);
|
||||||
return val;
|
return val;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void irrGlActiveTexture(GLenum texture)
|
inline void irrGlActiveTexture(GLenum texture)
|
||||||
{
|
{
|
||||||
glActiveTexture(texture);
|
GL.ActiveTexture(texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void irrGlCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border,
|
inline void irrGlCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border,
|
||||||
@ -102,37 +102,37 @@ namespace video
|
|||||||
|
|
||||||
inline void irrGlUseProgram(GLuint prog)
|
inline void irrGlUseProgram(GLuint prog)
|
||||||
{
|
{
|
||||||
glUseProgram(prog);
|
GL.UseProgram(prog);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void irrGlBindFramebuffer(GLenum target, GLuint framebuffer)
|
inline void irrGlBindFramebuffer(GLenum target, GLuint framebuffer)
|
||||||
{
|
{
|
||||||
glBindFramebuffer(target, framebuffer);
|
GL.BindFramebuffer(target, framebuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void irrGlDeleteFramebuffers(GLsizei n, const GLuint *framebuffers)
|
inline void irrGlDeleteFramebuffers(GLsizei n, const GLuint *framebuffers)
|
||||||
{
|
{
|
||||||
glDeleteFramebuffers(n, framebuffers);
|
GL.DeleteFramebuffers(n, framebuffers);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void irrGlGenFramebuffers(GLsizei n, GLuint *framebuffers)
|
inline void irrGlGenFramebuffers(GLsizei n, GLuint *framebuffers)
|
||||||
{
|
{
|
||||||
glGenFramebuffers(n, framebuffers);
|
GL.GenFramebuffers(n, framebuffers);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline GLenum irrGlCheckFramebufferStatus(GLenum target)
|
inline GLenum irrGlCheckFramebufferStatus(GLenum target)
|
||||||
{
|
{
|
||||||
return glCheckFramebufferStatus(target);
|
return GL.CheckFramebufferStatus(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void irrGlFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
|
inline void irrGlFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
|
||||||
{
|
{
|
||||||
glFramebufferTexture2D(target, attachment, textarget, texture, level);
|
GL.FramebufferTexture2D(target, attachment, textarget, texture, level);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void irrGlGenerateMipmap(GLenum target)
|
inline void irrGlGenerateMipmap(GLenum target)
|
||||||
{
|
{
|
||||||
glGenerateMipmap(target);
|
GL.GenerateMipmap(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void irrGlDrawBuffer(GLenum mode)
|
inline void irrGlDrawBuffer(GLenum mode)
|
||||||
@ -147,12 +147,12 @@ namespace video
|
|||||||
|
|
||||||
inline void irrGlBlendFuncSeparate(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha)
|
inline void irrGlBlendFuncSeparate(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha)
|
||||||
{
|
{
|
||||||
glBlendFuncSeparate(sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha);
|
GL.BlendFuncSeparate(sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void irrGlBlendEquation(GLenum mode)
|
inline void irrGlBlendEquation(GLenum mode)
|
||||||
{
|
{
|
||||||
glBlendEquation(mode);
|
GL.BlendEquation(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AnisotropicFilterSupported = false;
|
bool AnisotropicFilterSupported = false;
|
||||||
|
@ -86,12 +86,12 @@ COpenGL3MaterialRenderer::~COpenGL3MaterialRenderer()
|
|||||||
{
|
{
|
||||||
GLuint shaders[8];
|
GLuint shaders[8];
|
||||||
GLint count;
|
GLint count;
|
||||||
glGetAttachedShaders(Program, 8, &count, shaders);
|
GL.GetAttachedShaders(Program, 8, &count, shaders);
|
||||||
|
|
||||||
count=core::min_(count,8);
|
count=core::min_(count,8);
|
||||||
for (GLint i=0; i<count; ++i)
|
for (GLint i=0; i<count; ++i)
|
||||||
glDeleteShader(shaders[i]);
|
GL.DeleteShader(shaders[i]);
|
||||||
glDeleteProgram(Program);
|
GL.DeleteProgram(Program);
|
||||||
Program = 0;
|
Program = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,7 +110,7 @@ void COpenGL3MaterialRenderer::init(s32& outMaterialTypeNr,
|
|||||||
{
|
{
|
||||||
outMaterialTypeNr = -1;
|
outMaterialTypeNr = -1;
|
||||||
|
|
||||||
Program = glCreateProgram();
|
Program = GL.CreateProgram();
|
||||||
|
|
||||||
if (!Program)
|
if (!Program)
|
||||||
return;
|
return;
|
||||||
@ -124,7 +124,7 @@ void COpenGL3MaterialRenderer::init(s32& outMaterialTypeNr,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
for ( size_t i = 0; i < EVA_COUNT; ++i )
|
for ( size_t i = 0; i < EVA_COUNT; ++i )
|
||||||
glBindAttribLocation( Program, i, sBuiltInVertexAttributeNames[i]);
|
GL.BindAttribLocation( Program, i, sBuiltInVertexAttributeNames[i]);
|
||||||
|
|
||||||
if (!linkProgram())
|
if (!linkProgram())
|
||||||
return;
|
return;
|
||||||
@ -198,13 +198,13 @@ bool COpenGL3MaterialRenderer::createShader(GLenum shaderType, const char* shade
|
|||||||
{
|
{
|
||||||
if (Program)
|
if (Program)
|
||||||
{
|
{
|
||||||
GLuint shaderHandle = glCreateShader(shaderType);
|
GLuint shaderHandle = GL.CreateShader(shaderType);
|
||||||
glShaderSource(shaderHandle, 1, &shader, NULL);
|
GL.ShaderSource(shaderHandle, 1, &shader, NULL);
|
||||||
glCompileShader(shaderHandle);
|
GL.CompileShader(shaderHandle);
|
||||||
|
|
||||||
GLint status = 0;
|
GLint status = 0;
|
||||||
|
|
||||||
glGetShaderiv(shaderHandle, GL_COMPILE_STATUS, &status);
|
GL.GetShaderiv(shaderHandle, GL_COMPILE_STATUS, &status);
|
||||||
|
|
||||||
if (status != GL_TRUE)
|
if (status != GL_TRUE)
|
||||||
{
|
{
|
||||||
@ -213,13 +213,13 @@ bool COpenGL3MaterialRenderer::createShader(GLenum shaderType, const char* shade
|
|||||||
GLint maxLength=0;
|
GLint maxLength=0;
|
||||||
GLint length;
|
GLint length;
|
||||||
|
|
||||||
glGetShaderiv(shaderHandle, GL_INFO_LOG_LENGTH,
|
GL.GetShaderiv(shaderHandle, GL_INFO_LOG_LENGTH,
|
||||||
&maxLength);
|
&maxLength);
|
||||||
|
|
||||||
if (maxLength)
|
if (maxLength)
|
||||||
{
|
{
|
||||||
GLchar *infoLog = new GLchar[maxLength];
|
GLchar *infoLog = new GLchar[maxLength];
|
||||||
glGetShaderInfoLog(shaderHandle, maxLength, &length, infoLog);
|
GL.GetShaderInfoLog(shaderHandle, maxLength, &length, infoLog);
|
||||||
os::Printer::log(reinterpret_cast<const c8*>(infoLog), ELL_ERROR);
|
os::Printer::log(reinterpret_cast<const c8*>(infoLog), ELL_ERROR);
|
||||||
delete [] infoLog;
|
delete [] infoLog;
|
||||||
}
|
}
|
||||||
@ -227,7 +227,7 @@ bool COpenGL3MaterialRenderer::createShader(GLenum shaderType, const char* shade
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
glAttachShader(Program, shaderHandle);
|
GL.AttachShader(Program, shaderHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -238,11 +238,11 @@ bool COpenGL3MaterialRenderer::linkProgram()
|
|||||||
{
|
{
|
||||||
if (Program)
|
if (Program)
|
||||||
{
|
{
|
||||||
glLinkProgram(Program);
|
GL.LinkProgram(Program);
|
||||||
|
|
||||||
GLint status = 0;
|
GLint status = 0;
|
||||||
|
|
||||||
glGetProgramiv(Program, GL_LINK_STATUS, &status);
|
GL.GetProgramiv(Program, GL_LINK_STATUS, &status);
|
||||||
|
|
||||||
if (!status)
|
if (!status)
|
||||||
{
|
{
|
||||||
@ -251,12 +251,12 @@ bool COpenGL3MaterialRenderer::linkProgram()
|
|||||||
GLint maxLength=0;
|
GLint maxLength=0;
|
||||||
GLsizei length;
|
GLsizei length;
|
||||||
|
|
||||||
glGetProgramiv(Program, GL_INFO_LOG_LENGTH, &maxLength);
|
GL.GetProgramiv(Program, GL_INFO_LOG_LENGTH, &maxLength);
|
||||||
|
|
||||||
if (maxLength)
|
if (maxLength)
|
||||||
{
|
{
|
||||||
GLchar *infoLog = new GLchar[maxLength];
|
GLchar *infoLog = new GLchar[maxLength];
|
||||||
glGetProgramInfoLog(Program, maxLength, &length, infoLog);
|
GL.GetProgramInfoLog(Program, maxLength, &length, infoLog);
|
||||||
os::Printer::log(reinterpret_cast<const c8*>(infoLog), ELL_ERROR);
|
os::Printer::log(reinterpret_cast<const c8*>(infoLog), ELL_ERROR);
|
||||||
delete [] infoLog;
|
delete [] infoLog;
|
||||||
}
|
}
|
||||||
@ -266,14 +266,14 @@ bool COpenGL3MaterialRenderer::linkProgram()
|
|||||||
|
|
||||||
GLint num = 0;
|
GLint num = 0;
|
||||||
|
|
||||||
glGetProgramiv(Program, GL_ACTIVE_UNIFORMS, &num);
|
GL.GetProgramiv(Program, GL_ACTIVE_UNIFORMS, &num);
|
||||||
|
|
||||||
if (num == 0)
|
if (num == 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
GLint maxlen = 0;
|
GLint maxlen = 0;
|
||||||
|
|
||||||
glGetProgramiv(Program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &maxlen);
|
GL.GetProgramiv(Program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &maxlen);
|
||||||
|
|
||||||
if (maxlen == 0)
|
if (maxlen == 0)
|
||||||
{
|
{
|
||||||
@ -294,7 +294,7 @@ bool COpenGL3MaterialRenderer::linkProgram()
|
|||||||
memset(buf, 0, maxlen);
|
memset(buf, 0, maxlen);
|
||||||
|
|
||||||
GLint size;
|
GLint size;
|
||||||
glGetActiveUniform(Program, i, maxlen, 0, &size, &ui.type, reinterpret_cast<GLchar*>(buf));
|
GL.GetActiveUniform(Program, i, maxlen, 0, &size, &ui.type, reinterpret_cast<GLchar*>(buf));
|
||||||
|
|
||||||
core::stringc name = "";
|
core::stringc name = "";
|
||||||
|
|
||||||
@ -308,7 +308,7 @@ bool COpenGL3MaterialRenderer::linkProgram()
|
|||||||
}
|
}
|
||||||
|
|
||||||
ui.name = name;
|
ui.name = name;
|
||||||
ui.location = glGetUniformLocation(Program, buf);
|
ui.location = GL.GetUniformLocation(Program, buf);
|
||||||
|
|
||||||
UniformInfo.push_back(ui);
|
UniformInfo.push_back(ui);
|
||||||
}
|
}
|
||||||
@ -378,25 +378,25 @@ bool COpenGL3MaterialRenderer::setPixelShaderConstant(s32 index, const f32* floa
|
|||||||
switch (UniformInfo[index].type)
|
switch (UniformInfo[index].type)
|
||||||
{
|
{
|
||||||
case GL_FLOAT:
|
case GL_FLOAT:
|
||||||
glUniform1fv(UniformInfo[index].location, count, floats);
|
GL.Uniform1fv(UniformInfo[index].location, count, floats);
|
||||||
break;
|
break;
|
||||||
case GL_FLOAT_VEC2:
|
case GL_FLOAT_VEC2:
|
||||||
glUniform2fv(UniformInfo[index].location, count/2, floats);
|
GL.Uniform2fv(UniformInfo[index].location, count/2, floats);
|
||||||
break;
|
break;
|
||||||
case GL_FLOAT_VEC3:
|
case GL_FLOAT_VEC3:
|
||||||
glUniform3fv(UniformInfo[index].location, count/3, floats);
|
GL.Uniform3fv(UniformInfo[index].location, count/3, floats);
|
||||||
break;
|
break;
|
||||||
case GL_FLOAT_VEC4:
|
case GL_FLOAT_VEC4:
|
||||||
glUniform4fv(UniformInfo[index].location, count/4, floats);
|
GL.Uniform4fv(UniformInfo[index].location, count/4, floats);
|
||||||
break;
|
break;
|
||||||
case GL_FLOAT_MAT2:
|
case GL_FLOAT_MAT2:
|
||||||
glUniformMatrix2fv(UniformInfo[index].location, count/4, false, floats);
|
GL.UniformMatrix2fv(UniformInfo[index].location, count/4, false, floats);
|
||||||
break;
|
break;
|
||||||
case GL_FLOAT_MAT3:
|
case GL_FLOAT_MAT3:
|
||||||
glUniformMatrix3fv(UniformInfo[index].location, count/9, false, floats);
|
GL.UniformMatrix3fv(UniformInfo[index].location, count/9, false, floats);
|
||||||
break;
|
break;
|
||||||
case GL_FLOAT_MAT4:
|
case GL_FLOAT_MAT4:
|
||||||
glUniformMatrix4fv(UniformInfo[index].location, count/16, false, floats);
|
GL.UniformMatrix4fv(UniformInfo[index].location, count/16, false, floats);
|
||||||
break;
|
break;
|
||||||
case GL_SAMPLER_2D:
|
case GL_SAMPLER_2D:
|
||||||
case GL_SAMPLER_CUBE:
|
case GL_SAMPLER_CUBE:
|
||||||
@ -404,7 +404,7 @@ bool COpenGL3MaterialRenderer::setPixelShaderConstant(s32 index, const f32* floa
|
|||||||
if(floats)
|
if(floats)
|
||||||
{
|
{
|
||||||
const GLint id = (GLint)(*floats);
|
const GLint id = (GLint)(*floats);
|
||||||
glUniform1iv(UniformInfo[index].location, 1, &id);
|
GL.Uniform1iv(UniformInfo[index].location, 1, &id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
status = false;
|
status = false;
|
||||||
@ -429,23 +429,23 @@ bool COpenGL3MaterialRenderer::setPixelShaderConstant(s32 index, const s32* ints
|
|||||||
{
|
{
|
||||||
case GL_INT:
|
case GL_INT:
|
||||||
case GL_BOOL:
|
case GL_BOOL:
|
||||||
glUniform1iv(UniformInfo[index].location, count, ints);
|
GL.Uniform1iv(UniformInfo[index].location, count, ints);
|
||||||
break;
|
break;
|
||||||
case GL_INT_VEC2:
|
case GL_INT_VEC2:
|
||||||
case GL_BOOL_VEC2:
|
case GL_BOOL_VEC2:
|
||||||
glUniform2iv(UniformInfo[index].location, count/2, ints);
|
GL.Uniform2iv(UniformInfo[index].location, count/2, ints);
|
||||||
break;
|
break;
|
||||||
case GL_INT_VEC3:
|
case GL_INT_VEC3:
|
||||||
case GL_BOOL_VEC3:
|
case GL_BOOL_VEC3:
|
||||||
glUniform3iv(UniformInfo[index].location, count/3, ints);
|
GL.Uniform3iv(UniformInfo[index].location, count/3, ints);
|
||||||
break;
|
break;
|
||||||
case GL_INT_VEC4:
|
case GL_INT_VEC4:
|
||||||
case GL_BOOL_VEC4:
|
case GL_BOOL_VEC4:
|
||||||
glUniform4iv(UniformInfo[index].location, count/4, ints);
|
GL.Uniform4iv(UniformInfo[index].location, count/4, ints);
|
||||||
break;
|
break;
|
||||||
case GL_SAMPLER_2D:
|
case GL_SAMPLER_2D:
|
||||||
case GL_SAMPLER_CUBE:
|
case GL_SAMPLER_CUBE:
|
||||||
glUniform1iv(UniformInfo[index].location, 1, ints);
|
GL.Uniform1iv(UniformInfo[index].location, 1, ints);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
status = false;
|
status = false;
|
||||||
|
@ -15,9 +15,9 @@ namespace video {
|
|||||||
|
|
||||||
OpenGLVersion COpenGL3Driver::getVersionFromOpenGL() const {
|
OpenGLVersion COpenGL3Driver::getVersionFromOpenGL() const {
|
||||||
GLint major, minor, profile;
|
GLint major, minor, profile;
|
||||||
glGetIntegerv(GL_MAJOR_VERSION, &major);
|
GL.GetIntegerv(GL_MAJOR_VERSION, &major);
|
||||||
glGetIntegerv(GL_MINOR_VERSION, &minor);
|
GL.GetIntegerv(GL_MINOR_VERSION, &minor);
|
||||||
glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &profile);
|
GL.GetIntegerv(GL_CONTEXT_PROFILE_MASK, &profile);
|
||||||
// The spec is clear a context can’t be both core and compatibility at the same time.
|
// The spec is clear a context can’t be both core and compatibility at the same time.
|
||||||
// However, the returned value is a mask. Ask Khronos why. -- numzero
|
// However, the returned value is a mask. Ask Khronos why. -- numzero
|
||||||
if (profile & GL_CONTEXT_COMPATIBILITY_PROFILE_BIT)
|
if (profile & GL_CONTEXT_COMPATIBILITY_PROFILE_BIT)
|
||||||
@ -66,8 +66,8 @@ namespace video {
|
|||||||
MaxAnisotropy = GetInteger(GL.MAX_TEXTURE_MAX_ANISOTROPY);
|
MaxAnisotropy = GetInteger(GL.MAX_TEXTURE_MAX_ANISOTROPY);
|
||||||
MaxIndices = GetInteger(GL_MAX_ELEMENTS_INDICES);
|
MaxIndices = GetInteger(GL_MAX_ELEMENTS_INDICES);
|
||||||
MaxTextureSize = GetInteger(GL_MAX_TEXTURE_SIZE);
|
MaxTextureSize = GetInteger(GL_MAX_TEXTURE_SIZE);
|
||||||
glGetFloatv(GL_MAX_TEXTURE_LOD_BIAS, &MaxTextureLODBias);
|
GL.GetFloatv(GL_MAX_TEXTURE_LOD_BIAS, &MaxTextureLODBias);
|
||||||
glGetFloatv(GL_ALIASED_LINE_WIDTH_RANGE, DimAliasedLine);
|
GL.GetFloatv(GL_ALIASED_LINE_WIDTH_RANGE, DimAliasedLine);
|
||||||
DimAliasedPoint[0] = 1.0f;
|
DimAliasedPoint[0] = 1.0f;
|
||||||
DimAliasedPoint[1] = 1.0f;
|
DimAliasedPoint[1] = 1.0f;
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ namespace video {
|
|||||||
}
|
}
|
||||||
|
|
||||||
OpenGLVersion COpenGLES2Driver::getVersionFromOpenGL() const {
|
OpenGLVersion COpenGLES2Driver::getVersionFromOpenGL() const {
|
||||||
auto version_string = reinterpret_cast<const char *>(glGetString(GL_VERSION));
|
auto version_string = reinterpret_cast<const char *>(GL.GetString(GL_VERSION));
|
||||||
int major, minor;
|
int major, minor;
|
||||||
if (sscanf(version_string, "OpenGL ES %d.%d", &major, &minor) != 2) {
|
if (sscanf(version_string, "OpenGL ES %d.%d", &major, &minor) != 2) {
|
||||||
os::Printer::log("Failed to parse OpenGL ES version string", version_string, ELL_ERROR);
|
os::Printer::log("Failed to parse OpenGL ES version string", version_string, ELL_ERROR);
|
||||||
@ -123,9 +123,9 @@ namespace video {
|
|||||||
MaxIndices = GetInteger(GL_MAX_ELEMENTS_INDICES);
|
MaxIndices = GetInteger(GL_MAX_ELEMENTS_INDICES);
|
||||||
MaxTextureSize = GetInteger(GL_MAX_TEXTURE_SIZE);
|
MaxTextureSize = GetInteger(GL_MAX_TEXTURE_SIZE);
|
||||||
if (TextureLODBiasSupported)
|
if (TextureLODBiasSupported)
|
||||||
glGetFloatv(GL_MAX_TEXTURE_LOD_BIAS, &MaxTextureLODBias);
|
GL.GetFloatv(GL_MAX_TEXTURE_LOD_BIAS, &MaxTextureLODBias);
|
||||||
glGetFloatv(GL_ALIASED_LINE_WIDTH_RANGE, DimAliasedLine); // NOTE: this is not in the OpenGL ES 2.0 spec...
|
GL.GetFloatv(GL_ALIASED_LINE_WIDTH_RANGE, DimAliasedLine); // NOTE: this is not in the OpenGL ES 2.0 spec...
|
||||||
glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE, DimAliasedPoint);
|
GL.GetFloatv(GL_ALIASED_POINT_SIZE_RANGE, DimAliasedPoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
IVideoDriver* createOGLES2Driver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, IContextManager* contextManager)
|
IVideoDriver* createOGLES2Driver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, IContextManager* contextManager)
|
||||||
|
Loading…
Reference in New Issue
Block a user