comparison engine/core/gui/base/opengl/opengl_gui_graphics.cpp @ 620:853d25234671

* Moved the GLEnable and GLDisable structures from opengl_gui_graphics.cpp to fife_opengl.h as they may prove to be useful elsewhere. * Fixed the color mask definitions in fife_stdint.h * Added the nextPow2() function to calculate the nearest (greater) power of 2 * Removed a bunch of re-definitions of RGB masks * Modified GLImage to only generate one "texture chunk". I hope this makes better use of memory and speeds things up a hair * Made use of the GLEnable structure when clearing the screen
author prock@33b003aa-7bff-0310-803a-e67f0ece8222
date Thu, 30 Sep 2010 21:24:55 +0000
parents 90005975cdbb
children
comparison
equal deleted inserted replaced
619:f648bfbae5fe 620:853d25234671
31 // These includes are split up in two parts, separated by one empty line 31 // These includes are split up in two parts, separated by one empty line
32 // First block: files included from the FIFE root src dir 32 // First block: files included from the FIFE root src dir
33 #include "video/image.h" 33 #include "video/image.h"
34 #include "gui/base/gui_image.h" 34 #include "gui/base/gui_image.h"
35 #include "util/structures/rect.h" 35 #include "util/structures/rect.h"
36 #include "video/opengl/fife_opengl.h"
36 37
37 #include "opengl_gui_graphics.h" 38 #include "opengl_gui_graphics.h"
38 39
39 namespace FIFE { 40 namespace FIFE {
40 struct GLEnable {
41 GLenum m_flag;
42 GLboolean m_oldval;
43 GLEnable(GLenum flag) : m_flag(flag) {
44 glGetBooleanv(flag, &m_oldval);
45 if (!m_oldval) {
46 glEnable(flag);
47 }
48 }
49 ~GLEnable() {
50 if (!m_oldval) {
51 glDisable(m_flag);
52 }
53 }
54 };
55
56 struct GLDisable {
57 GLenum m_flag;
58 GLboolean m_oldval;
59 GLDisable(GLenum flag) : m_flag(flag) {
60 glGetBooleanv(flag, &m_oldval);
61 if (m_oldval) {
62 glDisable(flag);
63 }
64 }
65 ~GLDisable() {
66 if (m_oldval) {
67 glEnable(m_flag);
68 }
69 }
70 };
71
72 OpenGLGuiGraphics::OpenGLGuiGraphics(ImagePool& pool): m_pool(pool) { 41 OpenGLGuiGraphics::OpenGLGuiGraphics(ImagePool& pool): m_pool(pool) {
73 mTarget = SDL_GetVideoSurface(); 42 mTarget = SDL_GetVideoSurface();
74 assert(mTarget); 43 assert(mTarget);
75 setTargetPlane(mTarget->w, mTarget->h); 44 setTargetPlane(mTarget->w, mTarget->h);
76 45
77 } 46 }
78 47
79 void OpenGLGuiGraphics::drawImage(const gcn::Image* image, int srcX, int srcY, int dstX, int dstY, int width, int height) { 48 void OpenGLGuiGraphics::drawImage(const gcn::Image* image, int srcX, int srcY, int dstX, int dstY, int width, int height) {
80 const GuiImage* g_img = dynamic_cast<const GuiImage*>(image); 49 const GuiImage* g_img = dynamic_cast<const GuiImage*>(image);
81 assert(g_img); 50 assert(g_img);