diff options
author | Mitchell Stokes <mogurijin@gmail.com> | 2013-07-09 05:04:49 +0400 |
---|---|---|
committer | Mitchell Stokes <mogurijin@gmail.com> | 2013-07-09 05:04:49 +0400 |
commit | 5b3106b89de68868fa6e9827b4b251e73a664b01 (patch) | |
tree | 1bb7b1585f3892f74a29d695c9f66a5c470726a4 /source/gameengine | |
parent | abdb983a46ffa5e9f7e9d0fe13ae3d60b0e74365 (diff) |
BGE cleanup: removing unused banner code from GPC_Canvas.
Diffstat (limited to 'source/gameengine')
-rw-r--r-- | source/gameengine/GamePlayer/common/GPC_Canvas.cpp | 182 | ||||
-rw-r--r-- | source/gameengine/GamePlayer/common/GPC_Canvas.h | 101 |
2 files changed, 1 insertions, 282 deletions
diff --git a/source/gameengine/GamePlayer/common/GPC_Canvas.cpp b/source/gameengine/GamePlayer/common/GPC_Canvas.cpp index dd914cd6e7d..af756ce2d63 100644 --- a/source/gameengine/GamePlayer/common/GPC_Canvas.cpp +++ b/source/gameengine/GamePlayer/common/GPC_Canvas.cpp @@ -56,16 +56,13 @@ extern "C" { #include "IMB_imbuf_types.h" } -GPC_Canvas::TBannerId GPC_Canvas::s_bannerId = 0; - GPC_Canvas::GPC_Canvas( int width, int height ) : m_width(width), - m_height(height), - m_bannersEnabled(false) + m_height(height) { // initialize area so that it's available for game logic on frame 1 (ImageViewport) m_displayarea.m_x1 = 0; @@ -79,7 +76,6 @@ GPC_Canvas::GPC_Canvas( GPC_Canvas::~GPC_Canvas() { - DisposeAllBanners(); } @@ -115,8 +111,6 @@ void GPC_Canvas::Resize(int width, int height) void GPC_Canvas::EndFrame() { - if (m_bannersEnabled) - DrawAllBanners(); } @@ -185,180 +179,6 @@ void GPC_Canvas::ClearBuffer( ::glClear(ogltype); } - -GPC_Canvas::TBannerId GPC_Canvas::AddBanner( - unsigned int bannerWidth, unsigned int bannerHeight, - unsigned int imageWidth, unsigned int imageHeight, - unsigned char* imageData, - TBannerAlignment alignment, bool enabled) -{ - TBannerData banner; - - banner.alignment = alignment; - banner.enabled = enabled; - banner.displayWidth = bannerWidth; - banner.displayHeight = bannerHeight; - banner.imageWidth = imageWidth; - banner.imageHeight = imageHeight; - unsigned int bannerDataSize = imageWidth*imageHeight*4; - banner.imageData = new unsigned char [bannerDataSize]; - ::memcpy(banner.imageData, imageData, bannerDataSize); - banner.textureName = 0; - - m_banners.insert(TBannerMap::value_type(++s_bannerId, banner)); - return s_bannerId; -} - - -void GPC_Canvas::DisposeBanner(TBannerId id) -{ - TBannerMap::iterator it = m_banners.find(id); - if (it != m_banners.end()) { - DisposeBanner(it->second); - m_banners.erase(it); - } -} - -void GPC_Canvas::DisposeAllBanners() -{ - TBannerMap::iterator it = m_banners.begin(); - while (it != m_banners.end()) { - DisposeBanner(it->second); - it++; - } -} - -void GPC_Canvas::SetBannerEnabled(TBannerId id, bool enabled) -{ - TBannerMap::iterator it = m_banners.find(id); - if (it != m_banners.end()) { - it->second.enabled = enabled; - } -} - - -void GPC_Canvas::SetBannerDisplayEnabled(bool enabled) -{ - m_bannersEnabled = enabled; -} - - -void GPC_Canvas::DisposeBanner(TBannerData& banner) -{ - if (banner.imageData) { - delete [] banner.imageData; - banner.imageData = 0; - } - if (banner.textureName) { - ::glDeleteTextures(1, (GLuint*)&banner.textureName); - } -} - -void GPC_Canvas::DrawAllBanners(void) -{ - if (!m_bannersEnabled || (m_banners.size() < 1)) - return; - - // Save the old rendering parameters. - - CanvasRenderState render_state; - PushRenderState(render_state); - - // Set up everything for banner display. - - // Set up OpenGL matrices - SetOrthoProjection(); - // Activate OpenGL settings needed for display of the texture - ::glDisable(GL_LIGHTING); - ::glDisable(GL_DEPTH_TEST); - ::glDisable(GL_FOG); - ::glEnable(GL_TEXTURE_2D); - ::glEnable(GL_BLEND); - ::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - TBannerMap::iterator it = m_banners.begin(); - while (it != m_banners.end()) { - if (it->second.enabled) { - DrawBanner(it->second); - } - it++; - } - - PopRenderState(render_state); -} - - -void GPC_Canvas::DrawBanner(TBannerData& banner) -{ - if (!banner.enabled) - return; - - // Set up coordinates - int coords[4][2]; - if (banner.alignment == alignTopLeft) { - // Upper left - coords[0][0] = 0; - coords[0][1] = ((int)m_height)-banner.displayHeight; - coords[1][0] = banner.displayWidth; - coords[1][1] = ((int)m_height)-banner.displayHeight; - coords[2][0] = banner.displayWidth; - coords[2][1] = ((int)m_height); - coords[3][0] = 0; - coords[3][1] = ((int)m_height); - } - else { - // Lower right - coords[0][0] = (int)m_width - banner.displayWidth; - coords[0][1] = 0; - coords[1][0] = m_width; - coords[1][1] = 0; - coords[2][0] = m_width; - coords[2][1] = banner.displayHeight; - coords[3][0] = (int)m_width - banner.displayWidth; - coords[3][1] = banner.displayHeight; - } - // Set up uvs - int uvs[4][2] = { - { 0, 1}, - { 1, 1}, - { 1, 0}, - { 0, 0} - }; - - if (!banner.textureName) { - ::glGenTextures(1, (GLuint*)&banner.textureName); - ::glBindTexture(GL_TEXTURE_2D, banner.textureName); - ::glTexImage2D( - GL_TEXTURE_2D, // target - 0, // level - 4, // components - banner.imageWidth, // width - banner.displayHeight, // height - 0, // border - GL_RGBA, // format - GL_UNSIGNED_BYTE, // type - banner.imageData); // image data - ::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - ::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - } - else { - ::glBindTexture(GL_TEXTURE_2D, banner.textureName); - } - - // Draw the rectangle with the texture on it - ::glBegin(GL_QUADS); - ::glColor4f(1.f, 1.f, 1.f, 1.f); - ::glTexCoord2iv((GLint*)uvs[0]); - ::glVertex2iv((GLint*)coords[0]); - ::glTexCoord2iv((GLint*)uvs[1]); - ::glVertex2iv((GLint*)coords[1]); - ::glTexCoord2iv((GLint*)uvs[2]); - ::glVertex2iv((GLint*)coords[2]); - ::glTexCoord2iv((GLint*)uvs[3]); - ::glVertex2iv((GLint*)coords[3]); - ::glEnd(); -} - void GPC_Canvas:: PushRenderState( diff --git a/source/gameengine/GamePlayer/common/GPC_Canvas.h b/source/gameengine/GamePlayer/common/GPC_Canvas.h index 07f96166ec2..4b03f76c6cc 100644 --- a/source/gameengine/GamePlayer/common/GPC_Canvas.h +++ b/source/gameengine/GamePlayer/common/GPC_Canvas.h @@ -47,40 +47,7 @@ class GPC_Canvas : public RAS_ICanvas { -public: - /** - * Used to position banners in the canvas. - */ - typedef enum { - alignTopLeft, - alignBottomRight - } TBannerAlignment; - - typedef int TBannerId; - protected: - /** - * Used to store info for banners drawn on top of the canvas. - */ - typedef struct { - /** Where the banner will be displayed. */ - TBannerAlignment alignment; - /** Banner display enabled. */ - bool enabled; - /** Banner display width. */ - unsigned int displayWidth; - /** Banner display height. */ - unsigned int displayHeight; - /** Banner image width. */ - unsigned int imageWidth; - /** Banner image height. */ - unsigned int imageHeight; - /** Banner image data. */ - unsigned char* imageData; - /** Banner OpenGL texture name. */ - unsigned int textureName; - } TBannerData; - typedef std::map<TBannerId, TBannerData> TBannerMap; /** Width of the context. */ int m_width; @@ -92,11 +59,6 @@ protected: int m_viewport[4]; - /** Storage for the banners to display. */ - TBannerMap m_banners; - /** State of banner display. */ - bool m_bannersEnabled; - public: GPC_Canvas(int width, int height); @@ -179,68 +141,7 @@ public: void ClearBuffer(int type); - /** - * \section Services provided by this class. - */ - - /** - * Enables display of a banner. - * The image data is copied inside. - * \param bannerWidth Display width of the banner. - * \param bannerHeight Display height of the banner. - * \param imageWidth Width of the banner image in pixels. - * \param imageHeight Height of the banner image in pixels. - * \param imageData Pointer to the pixels of the image to display. - * \param alignment Where the banner will be positioned on the canvas. - * \param enabled Whether the banner will be displayed initially. - * \return A banner id. - */ - TBannerId AddBanner( - unsigned int bannerWidth, unsigned int bannerHeight, - unsigned int imageWidth, unsigned int imageHeight, - unsigned char* imageData, TBannerAlignment alignment = alignTopLeft, - bool enabled = true); - - /** - * Disposes a banner. - * \param id Banner to be disposed. - */ - void DisposeBanner(TBannerId id); - - /** - * Disposes all the banners. - */ - void DisposeAllBanners(); - - /** - * Enables or disables display of a banner. - * \param id Banner id of the banner to be enabled/disabled. - * \param enabled New state of the banner. - */ - void SetBannerEnabled(TBannerId id, bool enabled = true); - - /** - * Enables or disables display of all banners. - * \param enabled New state of the banners. - */ - void SetBannerDisplayEnabled(bool enabled = true); - protected: - /** - * Disposes a banner. - * \param it Banner to be disposed. - */ - void DisposeBanner(TBannerData& banner); - - /** - * Draws all the banners enabled. - */ - void DrawAllBanners(void); - - /** - * Draws a banner. - */ - void DrawBanner(TBannerData& banner); struct CanvasRenderState { int oldLighting; @@ -270,8 +171,6 @@ protected: void SetOrthoProjection( ); - - static TBannerId s_bannerId; }; #endif /* __GPC_CANVAS_H__ */ |