mirror of
https://github.com/love2d/love.git
synced 2026-08-15 15:51:12 +02:00
Updated love.graphics.polygon and love.graphics.point to work with OpenGL ES.
--HG-- branch : minor
This commit is contained in:
@@ -1025,13 +1025,14 @@ void Graphics::printf(const std::string &str, float x, float y, float wrap, Alig
|
||||
|
||||
void Graphics::point(float x, float y)
|
||||
{
|
||||
GLfloat coord[] = {x, y};
|
||||
|
||||
gl.prepareDraw();
|
||||
gl.bindTexture(gl.getDefaultTexture());
|
||||
glBegin(GL_POINTS);
|
||||
glVertex2f(x, y);
|
||||
glEnd();
|
||||
|
||||
++gl.stats.drawCalls;
|
||||
glEnableVertexAttribArray(ATTRIB_POS);
|
||||
glVertexAttribPointer(ATTRIB_POS, 2, GL_FLOAT, GL_FALSE, 0, coord);
|
||||
gl.drawArrays(GL_POINTS, 0, 1);
|
||||
glDisableVertexAttribArray(ATTRIB_POS);
|
||||
}
|
||||
|
||||
void Graphics::polyline(const float *coords, size_t count)
|
||||
@@ -1151,7 +1152,7 @@ void Graphics::polygon(DrawMode mode, const float *coords, size_t count)
|
||||
gl.bindTexture(gl.getDefaultTexture());
|
||||
glEnableVertexAttribArray(ATTRIB_POS);
|
||||
glVertexAttribPointer(ATTRIB_POS, 2, GL_FLOAT, GL_FALSE, 0, coords);
|
||||
gl.drawArrays(GL_POLYGON, 0, count/2-1); // opengl will close the polygon for us
|
||||
gl.drawArrays(GL_TRIANGLE_FAN, 0, count/2-1); // opengl will close the polygon for us
|
||||
glDisableVertexAttribArray(ATTRIB_POS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -431,6 +431,8 @@ bool Window::setContext(int msaa, bool vsync, bool sRGB)
|
||||
std::string title = "Unable to initialize OpenGL";
|
||||
std::string message = "This program requires a graphics card and video drivers which support OpenGL 2.1 or OpenGL ES 2.";
|
||||
|
||||
std::cerr << title << std::endl << message << std::endl;
|
||||
|
||||
// Display a message box with the error, but only once.
|
||||
if (!displayedContextError)
|
||||
{
|
||||
@@ -438,7 +440,6 @@ bool Window::setContext(int msaa, bool vsync, bool sRGB)
|
||||
displayedContextError = true;
|
||||
}
|
||||
|
||||
std::cerr << title << std::endl << message << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user