diff --git a/root.cpp b/root.cpp index 7164f69..767927a 100755 --- a/root.cpp +++ b/root.cpp @@ -59,7 +59,7 @@ namespace vb01{ glGenFramebuffers(1,&FBO); glBindFramebuffer(GL_FRAMEBUFFER,FBO); - Texture *texture=new Texture(); + Texture *texture=new Texture(width,height,false); glFramebufferTexture2D(GL_FRAMEBUFFER,GL_COLOR_ATTACHMENT0,GL_TEXTURE_2D,*(texture->getTexture()),0); /* diff --git a/tags b/tags index fb4ba54..9b0711d 100755 --- a/tags +++ b/tags @@ -136,9 +136,8 @@ TEXTURE_H texture.h /^#define TEXTURE_H$/;" d TEXT_H text.h /^#define TEXT_H$/;" d Text text.cpp /^ Text::Text(string fontPath,string entry){$/;" f class:vb01::Text Text text.h /^ class Text{$/;" c namespace:vb01 -Texture texture.cpp /^ Texture::Texture(){$/;" f class:vb01::Texture Texture texture.cpp /^ Texture::Texture(FT_Face &face, char ch){$/;" f class:vb01::Texture -Texture texture.cpp /^ Texture::Texture(int width, int height){$/;" f class:vb01::Texture +Texture texture.cpp /^ Texture::Texture(int width, int height, bool shadowMap){$/;" f class:vb01::Texture Texture texture.cpp /^ Texture::Texture(string path){$/;" f class:vb01::Texture Texture texture.cpp /^ Texture::Texture(string paths[6]){$/;" f class:vb01::Texture Texture texture.h /^ class Texture{$/;" c namespace:vb01 diff --git a/texture.cpp b/texture.cpp index cfe0c17..6a36e4b 100755 --- a/texture.cpp +++ b/texture.cpp @@ -8,31 +8,29 @@ using namespace std; namespace vb01{ - Texture::Texture(){ - width=800,height=600; - glGenTextures(1,&texture); - glBindTexture(GL_TEXTURE_2D,texture); - glTexImage2D(GL_TEXTURE_2D,0,GL_RGB,width,height,0,GL_RGB,GL_UNSIGNED_BYTE,NULL); - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT); - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT); - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); - } - - Texture::Texture(int width, int height){ + Texture::Texture(int width, int height, bool shadowMap){ this->width=width; this->height=height; glGenTextures(1,&texture); glBindTexture(GL_TEXTURE_2D,texture); - glTexImage2D(GL_TEXTURE_2D,0,GL_DEPTH_COMPONENT,width,height,0,GL_DEPTH_COMPONENT,GL_FLOAT,NULL); - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP_TO_BORDER); - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP_TO_BORDER); - float borderColor[]={1,1,1,1}; - glTexParameterfv(GL_TEXTURE_2D,GL_TEXTURE_BORDER_COLOR,borderColor); + if(shadowMap){ + glTexImage2D(GL_TEXTURE_2D,0,GL_DEPTH_COMPONENT,width,height,0,GL_DEPTH_COMPONENT,GL_FLOAT,NULL); + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP_TO_BORDER); + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP_TO_BORDER); + float borderColor[]={1,1,1,1}; + glTexParameterfv(GL_TEXTURE_2D,GL_TEXTURE_BORDER_COLOR,borderColor); + } + else{ + glTexImage2D(GL_TEXTURE_2D,0,GL_RGB,width,height,0,GL_RGB,GL_UNSIGNED_BYTE,NULL); + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); + } } Texture::Texture(FT_Face &face, char ch){ diff --git a/texture.h b/texture.h index e20551e..4fbe853 100755 --- a/texture.h +++ b/texture.h @@ -10,9 +10,8 @@ namespace vb01{ public: enum TextureType{TEXTURE_2D,TEXTURE_CUBEMAP}; - Texture(); ~Texture(); - Texture(int,int); + Texture(int,int,bool=true); Texture(FT_Face&,char); Texture(std::string); Texture(std::string[6]);