summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpixel <pixel>2007-07-17 02:48:00 +0000
committerpixel <pixel>2007-07-17 02:48:00 +0000
commite50632000d629de08fa3dae2e0d41fb67f8b2892 (patch)
treeccebd64710d42cec2cc0ac37989d49990a11d8a0
parentcbc9950e48dc30900aba94ff9d079d8f3bdc7d32 (diff)
Adding constructor using an already-generated OpenGL texture.
-rw-r--r--include/texture.h7
-rw-r--r--lib/texture.cc28
2 files changed, 31 insertions, 4 deletions
diff --git a/include/texture.h b/include/texture.h
index e49e48f..9c96ca6 100644
--- a/include/texture.h
+++ b/include/texture.h
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-/* $Id: texture.h,v 1.12 2006-10-28 16:50:46 pixel Exp $ */
+/* $Id: texture.h,v 1.13 2007-07-17 02:48:00 pixel Exp $ */
#ifndef __TEXTURE_H__
#define __TEXTURE_H__
@@ -31,9 +31,10 @@
namespace mogltk {
class Texture : public Base {
public:
- Texture(int, int, bool = false) throw (GeneralException);
+ Texture(int x, int y, bool = false) throw (GeneralException);
Texture(Handle *, bool = false) throw (GeneralException);
- Texture(int, int, int, int);
+ Texture(int x, int y, int w, int h);
+ Texture(int w, int h, int t) throw (GeneralException);
Texture(SDL_Surface *, bool = false) throw (GeneralException);
virtual ~Texture();
SDL_Surface * GetSurface();
diff --git a/lib/texture.cc b/lib/texture.cc
index 4ba5572..edcc303 100644
--- a/lib/texture.cc
+++ b/lib/texture.cc
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-/* $Id: texture.cc,v 1.15 2006-10-28 16:50:47 pixel Exp $ */
+/* $Id: texture.cc,v 1.16 2007-07-17 02:48:00 pixel Exp $ */
#include <sys/types.h>
#include <SDL.h>
@@ -213,6 +213,32 @@ mogltk::Texture::Texture(int x, int y, int w, int h) : width(nextpower(w)), heig
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, x, y, w, h);
+
+ next = 0;
+ prev = footer;
+ footer = this;
+ if (!header) {
+ header = this;
+ }
+ if (prev) {
+ prev->next = this;
+ }
+}
+
+mogltk::Texture::Texture(int w, int h, int t) throw (GeneralException) : width(w), height(h),
+ tex(t), texture_allocated(true), planar(false), tainted(false), taintable(false) {
+ if ((!ISPOT(w)) || (!ISPOT(h)))
+ throw GeneralException(_("Size of the Texture not a power of 2!"));
+
+ next = 0;
+ prev = footer;
+ footer = this;
+ if (!header) {
+ header = this;
+ }
+ if (prev) {
+ prev->next = this;
+ }
}
mogltk::Texture::~Texture() {