Mercurial > fife-parpg
comparison engine/core/video/opengl/renderbackendopengl.cpp @ 634:5f381fa34769
* Added the clearBackBuffer() function to the renderbackends.
* Renamed setClearScreen() to setClearBackBuffer()
* The SDL render backend now honors what was set with setClearBackBuffer()
* Documented testRenderedViewPort()
* The OpenGL backend no longer clears the screen every frame by default. testRenderedViewPort() takes care of clearing the screen for now. Note: if the user overrides the default and enables clearing of the backbuffer that it may be cleared twice in one frame (OpenGL only)!
author | prock@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Wed, 06 Oct 2010 15:49:53 +0000 |
parents | 46b95d06c8c2 |
children | 855ad500f991 |
comparison
equal
deleted
inserted
replaced
633:46b95d06c8c2 | 634:5f381fa34769 |
---|---|
41 SDL_Surface* testsurface = SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_SRCALPHA, 1, 1, 32, | 41 SDL_Surface* testsurface = SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_SRCALPHA, 1, 1, 32, |
42 RMASK, GMASK, BMASK ,AMASK); | 42 RMASK, GMASK, BMASK ,AMASK); |
43 | 43 |
44 m_rgba_format = *(testsurface->format); | 44 m_rgba_format = *(testsurface->format); |
45 SDL_FreeSurface(testsurface); | 45 SDL_FreeSurface(testsurface); |
46 m_clear = true; | 46 m_clear = false; |
47 } | 47 } |
48 | 48 |
49 const std::string& RenderBackendOpenGL::getName() const { | 49 const std::string& RenderBackendOpenGL::getName() const { |
50 static std::string backend_name = "OpenGL"; | 50 static std::string backend_name = "OpenGL"; |
51 return backend_name; | 51 return backend_name; |
60 if (SDL_InitSubSystem(flags) < 0) | 60 if (SDL_InitSubSystem(flags) < 0) |
61 throw SDLException(SDL_GetError()); | 61 throw SDLException(SDL_GetError()); |
62 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); | 62 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); |
63 | 63 |
64 SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); // temporary hack | 64 SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); // temporary hack |
65 } | |
66 | |
67 void RenderBackendOpenGL::clearBackBuffer() { | |
68 GLDisable flag(GL_SCISSOR_TEST); | |
69 glClear(GL_COLOR_BUFFER_BIT); | |
65 } | 70 } |
66 | 71 |
67 Image* RenderBackendOpenGL::createMainScreen(unsigned int width, unsigned int height, unsigned char bitsPerPixel, bool fs, const std::string& title, const std::string& icon) { | 72 Image* RenderBackendOpenGL::createMainScreen(unsigned int width, unsigned int height, unsigned char bitsPerPixel, bool fs, const std::string& title, const std::string& icon) { |
68 delete m_screen; | 73 delete m_screen; |
69 m_screen = 0; | 74 m_screen = 0; |
132 return m_screen; | 137 return m_screen; |
133 } | 138 } |
134 | 139 |
135 void RenderBackendOpenGL::startFrame() { | 140 void RenderBackendOpenGL::startFrame() { |
136 if(m_clear) { | 141 if(m_clear) { |
137 GLDisable flag(GL_SCISSOR_TEST); | 142 clearBackBuffer(); |
138 glClear(GL_COLOR_BUFFER_BIT); | |
139 } | 143 } |
140 } | 144 } |
141 | 145 |
142 void RenderBackendOpenGL::endFrame() { | 146 void RenderBackendOpenGL::endFrame() { |
143 SDL_GL_SwapBuffers(); | 147 SDL_GL_SwapBuffers(); |