Răsfoiți Sursa

Delete old GLES texture support

Daniele Bartolini 13 ani în urmă
părinte
comite
1c36bf2590

+ 0 - 183
src/renderers/gles/GLESTexture.cpp

@@ -1,183 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#include "GLESTexture.h"
-#include "Image.h"
-#include "Pixel.h"
-#include "Log.h"
-#include "GLESUtils.h"
-#include "GLESTextureManager.h"
-#include "ImageLoader.h"
-
-namespace crown
-{
-
-GLESTexture::GLESTexture() :
-	mTextureObject(0)
-{
-	glGenTextures(1, &mTextureObject);
-}
-
-GLESTexture::~GLESTexture()
-{
-	glDeleteTextures(1, &mTextureObject);
-}
-
-GLenum GLESTexture::GetGLTarget() const
-{
-	return GL_TEXTURE_2D;
-}
-
-GLuint GLESTexture::GetGLObject() const
-{
-	return mTextureObject;
-}
-
-GLenum GLESTexture::GetGLTextureFormat() const
-{
-//	int32_t value;
-//	glGetTexLevelParameteriv(GetGLTarget(), 0, GL_TEXTURE_INTERNAL_FORMAT, &value);
-//	return value;
-	return 0;
-}
-
-void GLESTexture::Load(const char* relativePath)
-{
-	LoadFromFile(relativePath);
-}
-
-void GLESTexture::LoadFromFile(const char* relativePath)
-{
-	Image* image;
-
-	image = ImageLoader::Load(relativePath);
-	// In case of fail, use the fallback image
-	if (!image)
-	{
-		Log::E("%s: Loading failed, using fallback.", relativePath);
-		LoadFromImage(GetTextureManager()->GetFallback());
-		return;
-	}
-
-	LoadFromImage(image);
-	delete image;
-}
-
-void GLESTexture::LoadFromFile(const char* relativePath, Color4 colorKey)
-{
-	Image* image;
-
-	image = ImageLoader::Load(relativePath);
-	// In case of fail, use the fallback image
-	if (!image)
-	{
-		Log::E("%s: Loading failed, using fallback.", relativePath);
-		LoadFromImage(GetTextureManager()->GetFallback());
-		return;
-	}
-
-	image->ApplyColorKeying(colorKey);
-	LoadFromImage(image);
-	delete image;
-}
-
-void GLESTexture::LoadFromFile(const char* relativePath, const char* alphaGreyscale)
-{
-	Image* image;
-
-	image = ImageLoader::Load(relativePath);
-	// In case of fail, use the fallback image
-	if (!image)
-	{
-		Log::E("%s: Loading failed, using fallback.", relativePath);
-		LoadFromImage(GetTextureManager()->GetFallback());
-		return;
-	}
-
-	Image* greyscaleImage;
-	greyscaleImage = ImageLoader::Load(alphaGreyscale);
-	if (!greyscaleImage)
-	{
-		Log::E("%s: Loading failed, no alpha map applied.", alphaGreyscale);
-	}
-	else
-	{
-		image->ApplyGreyscaleToAlpha(greyscaleImage);
-		delete greyscaleImage;
-	}
-
-	LoadFromImage(image);
-	delete image;
-}
-
-void GLESTexture::LoadFromImage(const Image* image)
-{
-	GLenum target = GetGLTarget();
-	glBindTexture(target, mTextureObject);
-
-	PixelFormat imageFormat = image->GetFormat();
-	GLint textureFormat = GLES::GetPixelFormat(imageFormat);
-
-	if (mGenerateMipMaps)
-	{
-		glTexParameteri(target, GL_GENERATE_MIPMAP, GL_TRUE);
-	}
-
-	glTexImage2D(target, 0, textureFormat, image->GetWidth(), image->GetHeight(), 0,
-		textureFormat, GL_UNSIGNED_BYTE, image->GetBuffer());
-
-	mWidth = image->GetWidth();
-	mHeight = image->GetHeight();
-}
-
-Image* GLESTexture::GetImage() const
-{
-//	glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
-
-//	GLenum target = GetGLTarget();
-//	glBindTexture(target, mTextureObject);
-
-//	
-
-//	GLenum glFormat = GetGLTextureFormat();
-//	PixelFormat format = GetTextureFormat();
-//	int32_t bytesPerPixel = Pixel::GetBytesPerPixel(format);
-
-//	char* texData = new char[GetWidth() * GetHeight() * bytesPerPixel];
-
-//	glGetTexImage(target, 0, glFormat, GL_UNSIGNED_BYTE, texData);
-
-//	Image* image = new Image(IT_2D, format, GetWidth(), GetHeight(), texData);
-//	return image;
-	return 0;
-}
-
-PixelFormat GLESTexture::GetTextureFormat() const
-{
-	return GLES::GetPixelFormatFromGLFormat(GetGLTextureFormat());
-}
-
-} // namespace crown
-

+ 0 - 71
src/renderers/gles/GLESTexture.h

@@ -1,71 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#pragma once
-
-#include <GLES/gl.h>
-#include "Types.h"
-#include "Texture.h"
-
-namespace crown
-{
-
-class GLESTexture : public Texture
-{
-
-public:
-
-	//! Constructor
-	GLESTexture();
-
-	//! Destructor
-	~GLESTexture();
-
-	//! Returns the OpenGL's texture target
-	GLenum GetGLTarget() const;
-
-	//! Returns the OpenGL's texture object
-	GLuint GetGLObject() const;
-
-	GLenum GetGLTextureFormat() const;
-
-	virtual void Load(const char* relativePath);
-
-	void LoadFromFile(const char* relativePath);
-	void LoadFromFile(const char* relativePath, Color4 colorKey);
-	void LoadFromFile(const char* relativePath, const char* alphaGreyscale);
-	void LoadFromImage(const Image* image);
-
-	Image* GetImage() const;
-
-	PixelFormat GetTextureFormat() const;
-
-private:
-
-	GLuint mTextureObject;
-};
-
-} // namespace crown
-

+ 0 - 99
src/renderers/gles/GLESTextureManager.cpp

@@ -1,99 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#include "GLESTextureManager.h"
-#include "GLESTexture.h"
-
-namespace crown
-{
-
-Texture* GLESTextureManager::Create(const char* name, bool& created)
-{
-	Texture* texture = static_cast<GLESTexture*>(ResourceManager::Create(name, created));
-
-	return texture;
-}
-
-Texture* GLESTextureManager::Load(const char* name, bool generateMipMaps)
-{
-	bool created;
-	Texture* texture = Create(name, created);
-
-	if (texture != NULL && created)
-	{
-		// Populate parameters
-		texture->SetGenerateMipMaps(generateMipMaps);
-
-		texture->Load(name);
-	}
-
-	return texture;
-}
-
-Texture* GLESTextureManager::Load(const char* name, bool generateMipMaps, Color4 colorKey)
-{
-	bool created;
-	Texture* texture = Create(name, created);
-
-	if (texture != NULL && created)
-	{
-		// Populate parameters
-		texture->SetGenerateMipMaps(generateMipMaps);
-
-		texture->LoadFromFile(name, colorKey);
-	}
-
-	return texture;
-}
-
-Texture* GLESTextureManager::Load(const char* name, const char* greyscaleAlpha, bool generateMipMaps)
-{
-	bool created;
-	Texture* texture = Create(name, created);
-
-	if (texture != NULL && created)
-	{
-		// Populate parameters
-		texture->SetGenerateMipMaps(generateMipMaps);
-
-		texture->LoadFromFile(name, greyscaleAlpha);
-	}
-
-	return texture;
-}
-
-GLESTexture* GLESTextureManager::CreateSpecific(const char* name)
-{
-	return new GLESTexture();
-}
-
-GLESTextureManager textureMgr;
-TextureManager* GetTextureManager()
-{
-	return &textureMgr;
-}
-
-} // namespace crown
-

+ 0 - 82
src/renderers/gles/GLESTextureManager.h

@@ -1,82 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#pragma once
-
-#include "TextureManager.h"
-#include "GLESTexture.h"
-
-namespace crown
-{
-
-class GLESTextureManager : public TextureManager
-{
-
-public:
-
-	GLESTextureManager() {}
-
-	/**
-	 * Creates a texture resource withe the given name.
-	 * If a resource with the same name already exists, the
-	 * already existent resource will be returned. In order
-	 * to distinguish between a newly created resource or a
-	 * point32_ter to an existing one, you have to check
-	 * at the value returned by 'created'.
-	 * @param name The name of the resource
-	 * @param created Returns true if newly created, false otherwise
-	 * @return A point32_ter to the created resource
-	 */
-	virtual Texture* Create(const char* name, bool& created);
-
-	/**
-	 * Loads a texture resource from file.
-	 * The name of the file determines the name of the resource and vice-versa.
-	 * @param name Tha name of the resource
-	 * @return A point32_ter to the loaded resource
-	 */
-	virtual Texture* Load(const char* name, bool generateMipMaps = true);
-
-	/**
-	 * Loads a texture resource from file using color keying.
-	 * The name of the file determines the name of the resource and vice-versa.
-	 * @param name The name of the resource
-	 * @param colorKey The color to use as transparent color
-	 * @return A point32_ter to the loaded resource
-	 */
-	virtual Texture* Load(const char* name, bool generateMipMaps, Color4 colorKey);
-
-	virtual Texture* Load(const char* name, const char* greyscaleAlpha, bool generateMipMaps);
-
-	virtual GLESTexture* CreateSpecific(const char* name);
-
-private:
-
-	GLESTextureManager(const GLESTextureManager&);
-	GLESTextureManager& operator=(const GLESTextureManager&);
-};
-
-} // namespace crown
-