Преглед изворни кода

Disable texturing in GLRenderer

Daniele Bartolini пре 13 година
родитељ
комит
070b1a3467
3 измењених фајлова са 135 додато и 137 уклоњено
  1. 54 56
      src/Renderer.h
  2. 74 74
      src/renderers/gl/GLRenderer.cpp
  3. 7 7
      src/renderers/gl/GLRenderer.h

+ 54 - 56
src/Renderer.h

@@ -28,7 +28,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "Types.h"
 #include "Types.h"
 #include "Color4.h"
 #include "Color4.h"
 #include "Mat4.h"
 #include "Mat4.h"
-#include "Texture.h"
+#include "TextureResource.h"
 #include "Point2.h"
 #include "Point2.h"
 #include "Material.h"
 #include "Material.h"
 
 
@@ -36,12 +36,10 @@ namespace crown
 {
 {
 
 
 class Image;
 class Image;
-class Texture;
 class Rect;
 class Rect;
 class VertexBuffer;
 class VertexBuffer;
 class IndexBuffer;
 class IndexBuffer;
 class OcclusionQuery;
 class OcclusionQuery;
-class TextureManager;
 
 
 enum MatrixType
 enum MatrixType
 {
 {
@@ -147,57 +145,57 @@ public:
 	*/
 	*/
 	virtual void _SetAmbientLight(const Color4& color) = 0;
 	virtual void _SetAmbientLight(const Color4& color) = 0;
 
 
-	/**
-		Set whether the given texture unit is enabled.
-	@param unit
-		The texture unit
-	@param texturing
-		Whether texturing is enabled or not
-	*/
-	virtual void _SetTexturing(uint32_t unit, bool texturing) = 0;
-
-	/**
-		Sets a texture for the given texture unit.
-	@param unit
-		The texture unit
-	@param texture
-		The texture
-	*/
-	virtual void _SetTexture(uint32_t unit, Texture* texture) = 0;
-
-	/**
-		Sets the texture mode for the given texture unit.
-	@note
-		The texture mode specifies how the texture
-		values are int32_terpreted when a fragment is
-		textured.
-	@param unit
-		The texture unit
-	@param mode
-		The texture mode
-	@param
-		The blend color. This parameter means only when
-		mode == TM_BLEND
-	*/
-	virtual void _SetTextureMode(uint32_t unit, TextureMode mode, const Color4& blendColor) = 0;
-
-	/**
-		Sets the texture wrap parameter for the given texture unit.
-	@param unit
-		The texture unit
-	@param wrap
-		The wrap parameter
-	*/
-	virtual void _SetTextureWrap(uint32_t unit, TextureWrap wrap) = 0;
-
-	/**
-		Sets the filter for the given texture unit.
-	@param unit
-		The texture unit
-	@filter
-		The filter
-	*/
-	virtual void _SetTextureFilter(uint32_t unit, TextureFilter filter) = 0;
+//	/**
+//		Set whether the given texture unit is enabled.
+//	@param unit
+//		The texture unit
+//	@param texturing
+//		Whether texturing is enabled or not
+//	*/
+//	virtual void _SetTexturing(uint32_t unit, bool texturing) = 0;
+
+//	/**
+//		Sets a texture for the given texture unit.
+//	@param unit
+//		The texture unit
+//	@param texture
+//		The texture
+//	*/
+//	virtual void _SetTexture(uint32_t unit, Texture* texture) = 0;
+
+//	/**
+//		Sets the texture mode for the given texture unit.
+//	@note
+//		The texture mode specifies how the texture
+//		values are int32_terpreted when a fragment is
+//		textured.
+//	@param unit
+//		The texture unit
+//	@param mode
+//		The texture mode
+//	@param
+//		The blend color. This parameter means only when
+//		mode == TM_BLEND
+//	*/
+//	virtual void _SetTextureMode(uint32_t unit, TextureMode mode, const Color4& blendColor) = 0;
+
+//	/**
+//		Sets the texture wrap parameter for the given texture unit.
+//	@param unit
+//		The texture unit
+//	@param wrap
+//		The wrap parameter
+//	*/
+//	virtual void _SetTextureWrap(uint32_t unit, TextureWrap wrap) = 0;
+
+//	/**
+//		Sets the filter for the given texture unit.
+//	@param unit
+//		The texture unit
+//	@filter
+//		The filter
+//	*/
+//	virtual void _SetTextureFilter(uint32_t unit, TextureFilter filter) = 0;
 
 
 	virtual void				_SetLight(uint32_t light, bool active) = 0;
 	virtual void				_SetLight(uint32_t light, bool active) = 0;
 	virtual void				_SetLightParams(uint32_t light, LightType type, const Vec3& position) = 0;
 	virtual void				_SetLightParams(uint32_t light, LightType type, const Vec3& position) = 0;
@@ -326,8 +324,8 @@ public:
 	//! Creates an empty vertex buffer
 	//! Creates an empty vertex buffer
 	virtual IndexBuffer* CreateIndexBuffer() = 0;
 	virtual IndexBuffer* CreateIndexBuffer() = 0;
 
 
-	//! Sets the texture to use in the specified layer
-	virtual void SetTexture(uint32_t layer, Texture* texture) = 0;
+//	//! Sets the texture to use in the specified layer
+//	virtual void SetTexture(uint32_t layer, Texture* texture) = 0;
 
 
 	//! Returns the current matrix
 	//! Returns the current matrix
 	virtual Mat4 GetMatrix(MatrixType type) const = 0;
 	virtual Mat4 GetMatrix(MatrixType type) const = 0;

+ 74 - 74
src/renderers/gl/GLRenderer.cpp

@@ -30,7 +30,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "GLOcclusionQuery.h"
 #include "GLOcclusionQuery.h"
 #include "GLRenderer.h"
 #include "GLRenderer.h"
 #include "GLTexture.h"
 #include "GLTexture.h"
-#include "GLTextureManager.h"
+//#include "GLTextureManager.h"
 #include "GLUtils.h"
 #include "GLUtils.h"
 #include "GLVertexBuffer.h"
 #include "GLVertexBuffer.h"
 #include "Log.h"
 #include "Log.h"
@@ -78,7 +78,7 @@ GLRenderer::GLRenderer() :
 
 
 	for (uint32_t i = 0; i < MAX_TEXTURE_UNITS; i++)
 	for (uint32_t i = 0; i < MAX_TEXTURE_UNITS; i++)
 	{
 	{
-		mTextureUnit[i] = 0;
+//		mTextureUnit[i] = 0;
 		mTextureUnitTarget[i] = GL_TEXTURE_2D;
 		mTextureUnitTarget[i] = GL_TEXTURE_2D;
 	}
 	}
 
 
@@ -237,78 +237,78 @@ void GLRenderer::_SetLighting(bool lighting)
 	}
 	}
 }
 }
 
 
-//-----------------------------------------------------------------------------
-void GLRenderer::_SetTexturing(uint32_t unit, bool texturing)
-{
-	if (!ActivateTextureUnit(unit))
-		return;
+////-----------------------------------------------------------------------------
+//void GLRenderer::_SetTexturing(uint32_t unit, bool texturing)
+//{
+//	if (!ActivateTextureUnit(unit))
+//		return;
 
 
-	if (texturing)
-	{
-		glEnable(mTextureUnitTarget[unit]);
-	}
-	else
-	{
-		glDisable(mTextureUnitTarget[unit]);
-	}
-}
+//	if (texturing)
+//	{
+//		glEnable(mTextureUnitTarget[unit]);
+//	}
+//	else
+//	{
+//		glDisable(mTextureUnitTarget[unit]);
+//	}
+//}
 
 
-//-----------------------------------------------------------------------------
-void GLRenderer::_SetTexture(uint32_t unit, Texture* texture)
-{
-	if (!ActivateTextureUnit(unit))
-		return;
+////-----------------------------------------------------------------------------
+//void GLRenderer::_SetTexture(uint32_t unit, Texture* texture)
+//{
+//	if (!ActivateTextureUnit(unit))
+//		return;
 
 
-	if (texture != NULL)
-	{
-		mTextureUnit[unit] = texture;
-		mTextureUnitTarget[unit] = static_cast<const GLTexture*>(texture)->GetGLTarget();
+//	if (texture != NULL)
+//	{
+//		mTextureUnit[unit] = texture;
+//		mTextureUnitTarget[unit] = static_cast<const GLTexture*>(texture)->GetGLTarget();
 
 
-		glEnable(mTextureUnitTarget[unit]);
-		glBindTexture(mTextureUnitTarget[unit], static_cast<const GLTexture*>(texture)->GetGLObject());
-	}
-}
+//		glEnable(mTextureUnitTarget[unit]);
+//		glBindTexture(mTextureUnitTarget[unit], static_cast<const GLTexture*>(texture)->GetGLObject());
+//	}
+//}
 
 
-//-----------------------------------------------------------------------------
-void GLRenderer::_SetTextureMode(uint32_t unit, TextureMode mode, const Color4& blendColor)
-{
-	if (!ActivateTextureUnit(unit))
-		return;
+////-----------------------------------------------------------------------------
+//void GLRenderer::_SetTextureMode(uint32_t unit, TextureMode mode, const Color4& blendColor)
+//{
+//	if (!ActivateTextureUnit(unit))
+//		return;
 
 
-	GLint envMode = GL::GetTextureMode(mode);
+//	GLint envMode = GL::GetTextureMode(mode);
 
 
-	if (envMode == GL_BLEND)
-	{
-		glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, &blendColor.r);
-	}
+//	if (envMode == GL_BLEND)
+//	{
+//		glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, &blendColor.r);
+//	}
 
 
-	glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, envMode);
-}
+//	glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, envMode);
+//}
 
 
-//-----------------------------------------------------------------------------
-void GLRenderer::_SetTextureWrap(uint32_t unit, TextureWrap wrap)
-{
-	GLenum glWrap = GL::GetTextureWrap(wrap);
+////-----------------------------------------------------------------------------
+//void GLRenderer::_SetTextureWrap(uint32_t unit, TextureWrap wrap)
+//{
+//	GLenum glWrap = GL::GetTextureWrap(wrap);
 
 
-	glTexParameteri(mTextureUnitTarget[unit], GL_TEXTURE_WRAP_S, glWrap);
-	glTexParameteri(mTextureUnitTarget[unit], GL_TEXTURE_WRAP_T, glWrap);
-	glTexParameteri(mTextureUnitTarget[unit], GL_TEXTURE_WRAP_R, glWrap);
-}
+//	glTexParameteri(mTextureUnitTarget[unit], GL_TEXTURE_WRAP_S, glWrap);
+//	glTexParameteri(mTextureUnitTarget[unit], GL_TEXTURE_WRAP_T, glWrap);
+//	glTexParameteri(mTextureUnitTarget[unit], GL_TEXTURE_WRAP_R, glWrap);
+//}
 
 
-//-----------------------------------------------------------------------------
-void GLRenderer::_SetTextureFilter(uint32_t unit, TextureFilter filter)
-{
-	if (!ActivateTextureUnit(unit))
-		return;
+////-----------------------------------------------------------------------------
+//void GLRenderer::_SetTextureFilter(uint32_t unit, TextureFilter filter)
+//{
+//	if (!ActivateTextureUnit(unit))
+//		return;
 
 
-	GLint minFilter;
-	GLint magFilter;
+//	GLint minFilter;
+//	GLint magFilter;
 
 
-	GL::GetTextureFilter(filter, minFilter, magFilter);
+//	GL::GetTextureFilter(filter, minFilter, magFilter);
 
 
-	glTexParameteri(mTextureUnitTarget[unit], GL_TEXTURE_MIN_FILTER, minFilter);
-	glTexParameteri(mTextureUnitTarget[unit], GL_TEXTURE_MAG_FILTER, magFilter);
-}
+//	glTexParameteri(mTextureUnitTarget[unit], GL_TEXTURE_MIN_FILTER, minFilter);
+//	glTexParameteri(mTextureUnitTarget[unit], GL_TEXTURE_MAG_FILTER, magFilter);
+//}
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 void GLRenderer::_SetBackfaceCulling(bool culling)
 void GLRenderer::_SetBackfaceCulling(bool culling)
@@ -722,20 +722,20 @@ IndexBuffer*  GLRenderer::CreateIndexBuffer()
 	return ib;
 	return ib;
 }
 }
 
 
-//-----------------------------------------------------------------------------
-void GLRenderer::SetTexture(uint32_t layer, Texture* texture)
-{
-	if (texture == NULL)
-	{
-		return;
-	}
-
-	_SetTexturing(layer, true);
-	_SetTexture(layer, texture);
-	_SetTextureMode(layer, texture->GetMode(), texture->GetBlendColor());
-	_SetTextureWrap(layer, texture->GetWrap());
-	_SetTextureFilter(layer, texture->GetFilter());
-}
+////-----------------------------------------------------------------------------
+//void GLRenderer::SetTexture(uint32_t layer, Texture* texture)
+//{
+//	if (texture == NULL)
+//	{
+//		return;
+//	}
+
+//	_SetTexturing(layer, true);
+//	_SetTexture(layer, texture);
+//	_SetTextureMode(layer, texture->GetMode(), texture->GetBlendColor());
+//	_SetTextureWrap(layer, texture->GetWrap());
+//	_SetTextureFilter(layer, texture->GetFilter());
+//}
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 void GLRenderer::SetScissorBox(uint32_t x, uint32_t y, uint32_t width, uint32_t height)
 void GLRenderer::SetScissorBox(uint32_t x, uint32_t y, uint32_t width, uint32_t height)

+ 7 - 7
src/renderers/gl/GLRenderer.h

@@ -58,11 +58,11 @@ public:
 	void				_SetLighting(bool lighting);
 	void				_SetLighting(bool lighting);
 	void				_SetAmbientLight(const Color4& color);
 	void				_SetAmbientLight(const Color4& color);
 
 
-	void				_SetTexturing(uint32_t unit, bool texturing);
-	void				_SetTexture(uint32_t unit, Texture* texture);
-	void				_SetTextureMode(uint32_t unit, TextureMode mode, const Color4& blendColor);
-	void				_SetTextureWrap(uint32_t unit, TextureWrap wrap);
-	void				_SetTextureFilter(uint32_t unit, TextureFilter filter);
+//	void				_SetTexturing(uint32_t unit, bool texturing);
+//	void				_SetTexture(uint32_t unit, Texture* texture);
+//	void				_SetTextureMode(uint32_t unit, TextureMode mode, const Color4& blendColor);
+//	void				_SetTextureWrap(uint32_t unit, TextureWrap wrap);
+//	void				_SetTextureFilter(uint32_t unit, TextureFilter filter);
 
 
 	void				_SetLight(uint32_t light, bool active);
 	void				_SetLight(uint32_t light, bool active);
 	void				_SetLightParams(uint32_t light, LightType type, const Vec3& position);
 	void				_SetLightParams(uint32_t light, LightType type, const Vec3& position);
@@ -107,7 +107,7 @@ public:
 
 
 	OcclusionQuery*		CreateOcclusionQuery();
 	OcclusionQuery*		CreateOcclusionQuery();
 
 
-	void				SetTexture(uint32_t layer, Texture* texture);
+//	void				SetTexture(uint32_t layer, Texture* texture);
 
 
 	Mat4				GetMatrix(MatrixType type) const;
 	Mat4				GetMatrix(MatrixType type) const;
 	void				SetMatrix(MatrixType type, const Mat4& matrix);
 	void				SetMatrix(MatrixType type, const Mat4& matrix);
@@ -157,7 +157,7 @@ private:
 	IndexBufferList		mIndexBufferList;
 	IndexBufferList		mIndexBufferList;
 
 
 	int32_t				mActiveTextureUnit;
 	int32_t				mActiveTextureUnit;
-	Texture*			mTextureUnit[MAX_TEXTURE_UNITS];
+//	Texture*			mTextureUnit[MAX_TEXTURE_UNITS];
 	GLenum				mTextureUnitTarget[MAX_TEXTURE_UNITS];
 	GLenum				mTextureUnitTarget[MAX_TEXTURE_UNITS];
 
 
 	// Debug lines
 	// Debug lines