renderbuffers are usable for various resolutions

This commit is contained in:
devZoGok
2021-10-18 19:08:26 +03:00
parent 9e6b5a995a
commit e5ddfb5e47
4 changed files with 20 additions and 24 deletions
+1 -1
View File
@@ -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);
/*
+1 -2
View File
@@ -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
+17 -19
View File
@@ -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){
+1 -2
View File
@@ -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]);