Browse Source

- Adding a few stuff to Texture
- Adding code to UiPainterDevice

Panagiotis Christopoulos Charitos 14 years ago
parent
commit
1bcac6e116

File diff suppressed because it is too large
+ 0 - 1
build/debug/Makefile


+ 3 - 0
src/Resources/Texture/Texture.cpp

@@ -147,6 +147,9 @@ void Texture::create(const Initializer& init_)
 	glGenTextures(1, &glId);
 	bind(LAST_TEX_UNIT);
 	target = GL_TEXTURE_2D;
+	internalFormat = init.internalFormat;
+	format = init.format;
+	type = init.type;
 
 	if(init.data == NULL)
 	{

+ 35 - 0
src/Resources/Texture/Texture.h

@@ -54,9 +54,20 @@ class Texture
 			size_t dataSize; ///< For compressed textures
 		};
 
+		/// Default constructor
 		Texture();
+
+		/// Desrcuctor
 		~Texture();
+
+
+		/// @name Accessors
+		/// @{
 		uint getGlId() const;
+		uint getInternalFormat() const;
+		uint getFormat() const;
+		uint getType() const;
+		/// @}
 
 		/// @name Create tex funcs
 		/// @{
@@ -88,6 +99,9 @@ class Texture
 	private:
 		uint glId; ///< Identification for OGL
 		uint target; ///< GL_TEXTURE_2D, GL_TEXTURE_3D... etc
+		uint internalFormat; ///< GL_COMPRESSED_RED, GL_RGB16 etc
+		uint format; ///< GL_RED, GL_RG, GL_RGB etc
+		uint type; ///< GL_UNSIGNED_BYTE, GL_BYTE etc
 
 		/// @name Variables set by the renderer
 		/// Set upon OpenGL initialization
@@ -112,6 +126,27 @@ inline uint Texture::getGlId() const
 }
 
 
+inline uint Texture::getInternalFormat() const
+{
+	ASSERT(isLoaded());
+	return internalFormat;
+}
+
+
+inline uint Texture::getFormat() const
+{
+	ASSERT(isLoaded());
+	return format;
+}
+
+
+inline uint Texture::getType() const
+{
+	ASSERT(isLoaded());
+	return type;
+}
+
+
 inline bool Texture::isLoaded() const
 {
 	return glId != std::numeric_limits<uint>::max();

+ 40 - 0
src/Ui/UiPainterDevice.cpp

@@ -0,0 +1,40 @@
+#include "UiPainterDevice.h"
+#include "Texture.h"
+
+
+namespace Ui {
+
+
+//======================================================================================================================
+// Constructor                                                                                                         =
+//======================================================================================================================
+PainterDevice::PainterDevice(Texture& colorFai_):
+	colorFai(colorFai_)
+{}
+
+
+//======================================================================================================================
+// getSize                                                                                                             =
+//======================================================================================================================
+Vec2 PainterDevice::getSize() const
+{
+	return Vec2(colorFai.getWidth(), colorFai.getHeight());
+}
+
+
+//======================================================================================================================
+// create                                                                                                              =
+//======================================================================================================================
+void PainterDevice::create()
+{
+	Fbo::create();
+	bind();
+
+	setNumOfColorAttachements(1);
+	glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorFai.getGlId(), 0);
+
+	unbind();
+}
+
+
+} // end namespace

+ 15 - 3
src/Ui/UiPainterDevice.h

@@ -3,6 +3,7 @@
 
 #include "Fbo.h"
 #include "Math.h"
+#include "Accessors.h"
 
 
 class Texture;
@@ -11,15 +12,26 @@ class Texture;
 namespace Ui {
 
 
-/// @todo
+/// This actually and FBO but with size info
 class PainterDevice: public Fbo
 {
 	public:
-		PainterDevice(const Vec2& size, Texture& colorFai);
+		/// Constructor
+		PainterDevice(Texture& colorFai);
+
+		/// @name Accessors
+		/// @{
+		Vec2 getSize() const;
+		/// @}
+
+	private:
+		Texture& colorFai;
+
+		void create();
 };
 
 
-} // end namesapce
+} // end namespace
 
 
 #endif

Some files were not shown because too many files changed in this diff