[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Usata-commits] Changes to usata2/src/texture.cpp
From: |
David Lau |
Subject: |
[Usata-commits] Changes to usata2/src/texture.cpp |
Date: |
Sat, 15 Jan 2005 14:17:36 -0500 |
Index: usata2/src/texture.cpp
diff -u usata2/src/texture.cpp:1.5 usata2/src/texture.cpp:1.6
--- usata2/src/texture.cpp:1.5 Sun Dec 26 18:36:42 2004
+++ usata2/src/texture.cpp Sat Jan 15 19:17:35 2005
@@ -10,13 +10,14 @@
// included in the software distribution, or visit
// http://www.fsf.org/licenses/gpl.html.
//
-// $Id: texture.cpp,v 1.5 2004/12/26 18:36:42 Descender Exp $
+// $Id: texture.cpp,v 1.6 2005/01/15 19:17:35 skunix Exp $
#include <boost/scoped_array.hpp>
#include <GL/glew.h>
#include "texture.hpp"
#include "texture-meta.hpp"
+#include <boost/tuple/tuple.hpp>
#include <Magick++.h>
#include "log.hpp"
namespace usata
@@ -46,6 +47,7 @@
const std::string&
format() const {return Format;}
unsigned char*get_pixels(){ return pixels.get();}
+
};
}
@@ -64,19 +66,27 @@
{
}
+
+void
+Texture::allocate_gltex(void)
+{
+ glGenTextures(1,&tex_id);
+}
+
Texture::Texture (const TextureMeta* meta)
{
Magick::Image XI(meta->filepath.native_file_string());
log::BufferedStream logstream(log::Level::DEBUG);
- logstream << XI.columns() << "x" <<XI.rows() << log::commit;
Magick::ImageType image_type = XI.type();
unsigned Depth;
+ GLint format = 0;
std::string Type;
switch (image_type)
{
case Magick::TrueColorType:
case Magick::PaletteType:
{
+ format = GL_RGB;
Type="RGB";
Depth = 24;
break;
@@ -85,6 +95,7 @@
case Magick::TrueColorMatteType:
case Magick::PaletteMatteType:
{
+ format = GL_RGBA;
Type="RGBA";
Depth = 32;
break;
@@ -103,8 +114,10 @@
Pixmap pb(XI.columns(),XI.rows(),Depth,Type);
XI.write(0,0,pb.width(), pb.height(),
pb.format(),Magick::CharPixel,pb.get_pixels());
-
-
+ glBindTexture(GL_TEXTURE_2D, tex_id);
+ glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
+
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
+ gluBuild2DMipmaps(GL_TEXTURE_2D, format, pb.width(), pb.height(),
format, GL_UNSIGNED_BYTE,pb.get_pixels());
return;
}
- [Usata-commits] Changes to usata2/src/texture.cpp,
David Lau <=
- [Usata-commits] Changes to usata2/src/texture.cpp, David Lau, 2005/01/17
- [Usata-commits] Changes to usata2/src/texture.cpp, David Lau, 2005/01/19
- [Usata-commits] Changes to usata2/src/texture.cpp, David Lau, 2005/01/19
- [Usata-commits] Changes to usata2/src/texture.cpp, David Lau, 2005/01/19
- [Usata-commits] Changes to usata2/src/texture.cpp, David Lau, 2005/01/20
- [Usata-commits] Changes to usata2/src/texture.cpp, David Lau, 2005/01/25
- [Usata-commits] Changes to usata2/src/texture.cpp, David Lau, 2005/01/25