[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [58096] branches/ge_dev/source/gameengine/ GamePlayer/common: BGE cleanup: removing unused banner code from GPC_Canvas .

Mitchell Stokes mogurijin at gmail.com
Tue Jul 9 03:04:49 CEST 2013


Revision: 58096
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=58096
Author:   moguri
Date:     2013-07-09 01:04:49 +0000 (Tue, 09 Jul 2013)
Log Message:
-----------
BGE cleanup: removing unused banner code from GPC_Canvas.

Modified Paths:
--------------
    branches/ge_dev/source/gameengine/GamePlayer/common/GPC_Canvas.cpp
    branches/ge_dev/source/gameengine/GamePlayer/common/GPC_Canvas.h

Modified: branches/ge_dev/source/gameengine/GamePlayer/common/GPC_Canvas.cpp
===================================================================
--- branches/ge_dev/source/gameengine/GamePlayer/common/GPC_Canvas.cpp	2013-07-09 01:01:25 UTC (rev 58095)
+++ branches/ge_dev/source/gameengine/GamePlayer/common/GPC_Canvas.cpp	2013-07-09 01:04:49 UTC (rev 58096)
@@ -56,16 +56,13 @@
 #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()
 {
-	DisposeAllBanners();
 }
 
 
@@ -115,8 +111,6 @@
 
 void GPC_Canvas::EndFrame()
 {
-	if (m_bannersEnabled)
-		DrawAllBanners();
 }
 
 
@@ -185,180 +179,6 @@
 	::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(

Modified: branches/ge_dev/source/gameengine/GamePlayer/common/GPC_Canvas.h
===================================================================
--- branches/ge_dev/source/gameengine/GamePlayer/common/GPC_Canvas.h	2013-07-09 01:01:25 UTC (rev 58095)
+++ branches/ge_dev/source/gameengine/GamePlayer/common/GPC_Canvas.h	2013-07-09 01:04:49 UTC (rev 58096)
@@ -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 @@
 
 	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,69 +141,8 @@
 
 	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;
 		int oldDepthTest;
@@ -270,8 +171,6 @@
 		void
 	SetOrthoProjection(
 	);
-	
-	static TBannerId s_bannerId;
 };
 
 #endif  /* __GPC_CANVAS_H__ */




More information about the Bf-blender-cvs mailing list