supported .png files

flipped quad coordinates
This commit is contained in:
devZoGok
2021-10-18 19:07:50 +03:00
parent 1fb25e858c
commit 3d666aa3a1
4 changed files with 14 additions and 9 deletions
+6 -6
View File
@@ -36,22 +36,22 @@ namespace vb01{
v6.pos=Vector3(size.x,0,0);
}
v1.norm=Vector3(0,0,-1);
v1.texCoords=Vector2(1,1);
v1.texCoords=Vector2(1,0);
v2.norm=Vector3(0,0,-1);
v2.texCoords=Vector2(0,1);
v2.texCoords=Vector2(0,0);
v3.norm=Vector3(0,0,-1);
v3.texCoords=Vector2(0,0);
v3.texCoords=Vector2(0,1);
v4.norm=Vector3(0,0,-1);
v4.texCoords=Vector2(0,0);
v4.texCoords=Vector2(0,1);
v5.norm=Vector3(0,0,-1);
v5.texCoords=Vector2(1,0);
v5.texCoords=Vector2(1,1);
v6.norm=Vector3(0,0,-1);
v6.texCoords=Vector2(1,1);
v6.texCoords=Vector2(1,0);
indices[0]=0;
indices[1]=1;
+1 -1
View File
@@ -242,7 +242,7 @@ buflen stb_image.h /^ int buflen;$/;" m struct:__anon84e4e8860308 typeref:type
camera root.h /^ Camera *camera;$/;" m class:vb01::Root typeref:typename:Camera *
castShadow mesh.h /^ bool staticVerts=true,castShadow=false;$/;" m class:vb01::Mesh typeref:typename:bool
castShadow model.h /^ bool castShadow=false;$/;" m class:vb01::Model typeref:typename:bool
ch text.h /^ int ch;$/;" m struct:vb01::Text::Glyph typeref:typename:int
ch text.h /^ u32 ch;$/;" m struct:vb01::Text::Glyph typeref:typename:u32
channel stb_image.h /^ stbi_uc size,type,channel;$/;" m struct:__anon84e4e8861108 typeref:typename:stbi_uc
channel_order stb_image.h /^ int channel_order;$/;" m struct:__anon84e4e8860508 typeref:typename:int
characters text.h /^ std::vector<Glyph> characters;$/;" m class:vb01::Text typeref:typename:std::vector<Glyph>
+1 -1
View File
@@ -14,7 +14,7 @@ namespace vb01{
class Text{
public:
struct Glyph{
int ch;
u32 ch;
Texture *texture=nullptr;
unsigned int advance;
Vector2 size,bearing;
+6 -1
View File
@@ -59,6 +59,11 @@ namespace vb01{
}
Texture::Texture(string path){
bool png=false;
int length=path.length();
if(path.substr(length-4,string::npos)==".png")
png=true;
glGenTextures(1,&texture);
glBindTexture(GL_TEXTURE_2D,texture);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
@@ -70,7 +75,7 @@ namespace vb01{
data=stbi_load(path.c_str(),&width,&height,&numChannels,0);
glTexImage2D(GL_TEXTURE_2D,0,GL_RGB,width,height,0,GL_RGB,GL_UNSIGNED_BYTE,data);
glTexImage2D(GL_TEXTURE_2D,0,png?GL_RGBA:GL_RGB,width,height,0,png?GL_RGBA:GL_RGB,GL_UNSIGNED_BYTE,data);
//glGenerateMipmap(GL_TEXTURE_2D);
stbi_image_free(data);
}