Mercurial > fife-parpg
diff engine/core/video/opengl/renderbackendopengl.cpp @ 579:b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
* Improved the most renderers with setColor() function.
* Fixed the genericrenderer, is now tested whether the images are in the viewport.
* Fixed the gridrenderer, the grid is now drawn only up to the viewport.
* Changed the vertex functions in opengl/renderbackendopengl.cpp from vertex3f() to vertex2f().
* Improved the Editor, now you can use blocking, grid and coordinate renderer over gui or keys. Additionally, the colors can be changed with the settings.xml.
author | helios2000@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Sat, 31 Jul 2010 17:46:19 +0000 |
parents | ad1f09d954f9 |
children | 47b49b9b0c0a |
line wrap: on
line diff
--- a/engine/core/video/opengl/renderbackendopengl.cpp Fri Jul 30 23:48:26 2010 +0000 +++ b/engine/core/video/opengl/renderbackendopengl.cpp Sat Jul 31 17:46:19 2010 +0000 @@ -43,6 +43,7 @@ m_rgba_format = *(testsurface->format); SDL_FreeSurface(testsurface); + m_clear = true; } const std::string& RenderBackendOpenGL::getName() const { @@ -132,9 +133,11 @@ } void RenderBackendOpenGL::startFrame() { - glDisable(GL_SCISSOR_TEST); - glClear(GL_COLOR_BUFFER_BIT); - glEnable(GL_SCISSOR_TEST); + if(m_clear) { + glDisable(GL_SCISSOR_TEST); + glClear(GL_COLOR_BUFFER_BIT); + glEnable(GL_SCISSOR_TEST); + } } void RenderBackendOpenGL::endFrame() { @@ -176,11 +179,15 @@ return new GLImage(data, width, height); } + void RenderBackendOpenGL::isClearNeeded(bool clear) { + m_clear = clear; + } + bool RenderBackendOpenGL::putPixel(int x, int y, int r, int g, int b) { if ((x < 0) || (x >= (int)getWidth()) || (y < 0) || (y >= (int)getHeight())) { return false; } - glColor4ub(r, g, b, 255); + glColor3ub(r, g, b); glBegin(GL_POINTS); glVertex2i(x, y); glEnd(); @@ -188,42 +195,38 @@ } void RenderBackendOpenGL::drawLine(const Point& p1, const Point& p2, int r, int g, int b) { - glColor4ub(r, g, b, 255); + glColor3ub(r, g, b); glBegin(GL_LINES); - glVertex3f(p1.x+0.5f, p1.y+0.5f, 0); - glVertex3f(p2.x+0.5f, p2.y+0.5f, 0); + glVertex2f(p1.x+0.5f, p1.y+0.5f); + glVertex2f(p2.x+0.5f, p2.y+0.5f); glEnd(); glBegin(GL_POINTS); - glVertex3f(p2.x+0.5f, p2.y+0.5f, 0); + glVertex2f(p2.x+0.5f, p2.y+0.5f); glEnd(); } void RenderBackendOpenGL::drawQuad(const Point& p1, const Point& p2, const Point& p3, const Point& p4, int r, int g, int b) { glColor4ub(r, g, b, 165); glBegin(GL_QUADS); - glVertex3f(p1.x, p1.y, 0); - glVertex3f(p2.x, p2.y, 0); - glVertex3f(p3.x, p3.y, 0); - glVertex3f(p4.x, p4.y, 0); + glVertex2f(p1.x, p1.y); + glVertex2f(p2.x, p2.y); + glVertex2f(p3.x, p3.y); + glVertex2f(p4.x, p4.y); glEnd(); } void RenderBackendOpenGL::drawVertex(const Point& p, const uint8_t size, int r, int g, int b){ - GLfloat width; - glGetFloatv(GL_LINE_WIDTH, &width); glLineWidth(1.0); + glColor3ub(r, g, b); glBegin(GL_LINE_LOOP); - glColor4ub(r, g, b, 255); - - glVertex3f(p.x-size, p.y+size, 0); - glVertex3f(p.x+size, p.y+size, 0); - glVertex3f(p.x+size, p.y-size, 0); - glVertex3f(p.x-size, p.y-size, 0); - + glVertex2f(p.x-size, p.y+size); + glVertex2f(p.x+size, p.y+size); + glVertex2f(p.x+size, p.y-size); + glVertex2f(p.x-size, p.y-size); glEnd(); glLineWidth(width);