Small graphics code cleanup

--HG--
branch : minor
This commit is contained in:
Alex Szpakowski
2017-09-30 16:42:11 -03:00
parent 8fa511aea8
commit 050be14547
4 changed files with 34 additions and 40 deletions
+1 -1
View File
@@ -94,7 +94,7 @@ void Image::init(PixelFormat fmt, int w, int h, const Settings &settings)
if (getMipmapCount() > 1)
filter.mipmap = defaultMipmapFilter;
initQuad();
}
+1 -2
View File
@@ -186,8 +186,7 @@ bool Canvas::loadVolatile()
// getMaxRenderbufferSamples will be 0 on systems that don't support
// multisampled renderbuffers / don't export FBO multisample extensions.
actualSamples = getRequestedMSAA();
actualSamples = std::min(actualSamples, gl.getMaxRenderbufferSamples());
actualSamples = std::min(getRequestedMSAA(), gl.getMaxRenderbufferSamples());
actualSamples = std::max(actualSamples, 0);
actualSamples = actualSamples == 1 ? 0 : actualSamples;
+32 -32
View File
@@ -81,9 +81,22 @@ int Mesh::bindAttributeToShaderInput(int attributeindex, const std::string &inpu
vbo->unmap();
gl.bindBuffer(BUFFER_VERTEX, (GLuint) vbo->getHandle());
GLenum datatype = 0;
switch (format.type)
{
case DATA_BYTE:
datatype = GL_UNSIGNED_BYTE;
break;
case DATA_FLOAT:
datatype = GL_FLOAT;
break;
default:
datatype = 0;
break;
}
const void *gloffset = BUFFER_OFFSET(getAttributeOffset(attributeindex));
GLenum datatype = getGLDataType(format.type);
GLboolean normalized = (datatype == GL_UNSIGNED_BYTE);
glVertexAttribPointer(attriblocation, format.components, datatype, normalized, (GLsizei) vertexStride, gloffset);
@@ -98,8 +111,24 @@ void Mesh::drawInternal(int start, int count, int instancecount, bool useindexbu
gl.useVertexAttribArrays(attribflags, instancedattribflags);
gl.bindTextureToUnit(texture, 0, false);
gl.prepareDraw();
GLenum gldrawmode = getGLDrawMode(drawMode);
GLenum gldrawmode = GL_TRIANGLES;
switch (drawMode)
{
case DRAWMODE_FAN:
gldrawmode = GL_TRIANGLE_FAN;
break;
case DRAWMODE_STRIP:
gldrawmode = GL_TRIANGLE_STRIP;
break;
case DRAWMODE_TRIANGLES:
default:
gldrawmode = GL_TRIANGLES;
break;
case DRAWMODE_POINTS:
gldrawmode = GL_POINTS;
break;
}
if (useindexbuffer)
{
@@ -116,35 +145,6 @@ void Mesh::drawInternal(int start, int count, int instancecount, bool useindexbu
}
}
GLenum Mesh::getGLDrawMode(DrawMode mode)
{
switch (mode)
{
case DRAWMODE_FAN:
return GL_TRIANGLE_FAN;
case DRAWMODE_STRIP:
return GL_TRIANGLE_STRIP;
case DRAWMODE_TRIANGLES:
default:
return GL_TRIANGLES;
case DRAWMODE_POINTS:
return GL_POINTS;
}
}
GLenum Mesh::getGLDataType(DataType type)
{
switch (type)
{
case DATA_BYTE:
return GL_UNSIGNED_BYTE;
case DATA_FLOAT:
return GL_FLOAT;
default:
return 0;
}
}
} // opengl
} // graphics
} // love
-5
View File
@@ -49,11 +49,6 @@ protected:
void drawInternal(int start, int count, int instancecount, bool useindexbuffer, uint32 attribflags, uint32 instancedattribflags) const override;
private:
static GLenum getGLDrawMode(DrawMode mode);
static GLenum getGLDataType(DataType type);
}; // Mesh
} // opengl