Eigene Dateien/uni/visualisierung/vislu/bsp1/VisLu/VTexture.cpp

Go to the documentation of this file.
00001 #include "VTexture.h"
00002 #include "corona.h"
00003 
00004 #include <GL/glew.h>
00005 #include <GL/glut.h>
00006 
00007 #include <string>
00008 #include <iostream>
00009 
00010 using namespace corona;
00011 using namespace std;
00012 
00013 VTexture::VTexture(string _filename)
00014 {
00015         this->filename = "data/"+_filename;
00016         Image* image = OpenImage(this->filename.c_str(),PF_R8G8B8A8 );
00017         if (!image) {
00018                 cout << "Couldn't open image " << this->filename << endl;
00019         } else {
00020                 this->width = image->getWidth();
00021                 this->height = image->getHeight();
00022                 this->pixels = (GLbyte*)image->getPixels();
00023                 glGenTextures(1,&(this->tex));
00024                 glBindTexture(GL_TEXTURE_2D, this->tex);
00025                 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); 
00026                 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); 
00027                 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 
00028                 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
00029                 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, this->width, this->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, this->pixels);
00030         }
00031         delete image;
00032         image = 0;
00033 }
00034 void VTexture::bind() {
00035         glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE, GL_MODULATE);
00036         glBindTexture(GL_TEXTURE_2D, this->tex);
00037 }
00038 
00039 VTexture::~VTexture(void){
00040         delete[] this->pixels;
00041 }

Generated on Wed Dec 6 11:08:00 2006 for VisLU by  doxygen 1.5.1-p1