diff --git a/CMakeLists.txt b/CMakeLists.txt index b9ce738..440aca3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,15 +5,18 @@ include_directories(/usr/include/GLFW) include_directories(/usr/include/glad) include_directories(/usr/include/glm) include_directories(/usr/include/assimp) +include_directories(/usr/include/freetype2) link_directories(/usr/lib/) set(CMAKE_BUILD_TYPE Debug) +set(gui text.cpp rectangle.cpp) set(utils util.cpp) set(math quaternion.cpp vector.cpp) set(render waterPlane.cpp particleEmitter.cpp camera.cpp light.cpp material.cpp mesh.cpp model.cpp node.cpp quad.cpp box.cpp root.cpp shader.cpp texture.cpp) -add_executable(vb01 main.cpp ${render} ${math} ${utils}) +add_executable(vb01 main.cpp ${render} ${math} ${utils} ${gui}) target_link_libraries(vb01 glfw) target_link_libraries(vb01 glad) target_link_libraries(vb01 assimp) +target_link_libraries(vb01 freetype) diff --git a/box.cpp b/box.cpp index d805d39..de7bd1c 100644 --- a/box.cpp +++ b/box.cpp @@ -2,6 +2,19 @@ namespace vb01{ Box::Box(Vector3 size){ + this->staticVerts=false; + + numTris=12; + indices=new unsigned int[3*numTris]; + vertices=new Vertex[3*numTris]; + + setSize(size); + + construct(); + } + + void Box::setSize(Vector3 size){ + this->size=size; Vector3 pos[]={ Vector3(size.x/2,size.y/2,size.z/2), Vector3(-size.x/2,size.y/2,size.z/2), @@ -47,9 +60,6 @@ namespace vb01{ 4,4,3, 6,4,1, 5,4,2, 6,4,1, 4,4,3, 7,4,0 }; - numTris=12; - indices=new unsigned int[3*numTris]; - vertices=new Vertex[3*numTris]; for(int i=0;i<3*numTris;i++){ Vertex v; v.pos=pos[data[3*i]]; @@ -58,6 +68,5 @@ namespace vb01{ vertices[i]=v; indices[i]=i; } - construct(); } } diff --git a/box.h b/box.h index 88b8cad..e5abdda 100644 --- a/box.h +++ b/box.h @@ -7,6 +7,9 @@ namespace vb01{ class Box : public Mesh{ public: Box(Vector3); + void setSize(Vector3); + private: + Vector3 size; }; } diff --git a/gui.frag b/gui.frag new file mode 100644 index 0000000..19ca5d9 --- /dev/null +++ b/gui.frag @@ -0,0 +1,13 @@ +#version 330 core + +in vec2 texCoords; + +out vec4 FragColor; + +uniform bool texturingEnabled; +uniform vec4 diffuseColor; +uniform sampler2D tex; + +void main(){ + FragColor=texturingEnabled?texture(tex,texCoords):diffuseColor; +} diff --git a/gui.vert b/gui.vert new file mode 100644 index 0000000..b78ccb0 --- /dev/null +++ b/gui.vert @@ -0,0 +1,16 @@ +#version 330 core + +layout (location=0) in vec3 aVert; +layout (location=2) in vec2 aTexCoords; + +out vec2 texCoords; + +uniform vec2 screen; + +void main(){ + float x,y; + x=(aVert.x-screen.x*.5)/(screen.x*.5); + y=(screen.y*.5-aVert.y)/(screen.y*.5); + gl_Position=vec4(x,y,0,1); + texCoords=aTexCoords; +} diff --git a/main.cpp b/main.cpp index d9e9957..9b267f7 100644 --- a/main.cpp +++ b/main.cpp @@ -8,6 +8,7 @@ #include"material.h" #include"model.h" #include"light.h" +#include"text.h" #include #include"particleEmitter.h" @@ -17,9 +18,11 @@ using namespace std; int main(){ Root *root=Root::getSingleton(); root->start(800,600); + Node *rootNode=root->getRootNode(),*guiNode=root->getGuiNode(); Vector3 v1[]={Vector3(.2,.2,.2),Vector3(1,1,1)}; Vector3 v2[]={Vector3(2,0,0),Vector3(-1,0,0)}; + string tex[]={"defaultTexture.jpg","woodChips.jpg"}; string t[]={ "/home/dominykas/c++/FSim/left.jpg", @@ -35,20 +38,38 @@ int main(){ Box *box=new Box(Vector3(1,1,1)); Node *node=new Node(v2[i]); Material *mat=new Material(); - mat->addDiffuseMap("/home/dominykas/c++/FSim/defaultTexture.jpg"); + mat->addDiffuseMap("/home/dominykas/c++/FSim/"+tex[i]); mat->setLightingEnabled(false); + mat->setTexturingEnabled(true); + mat->setDiffuseColor(Vector4(0,0,1,1)); box->setMaterial(mat); node->attachMesh(box); - //root->getRootNode()->attachChild(node); + rootNode->attachChild(node); } + Text *text =new Text("/home/dominykas/c++/FSim/batang.ttf","HI"); + text->setText("IH"); + Node *textNode=new Node(Vector3(400,100,0)); + textNode->addText(text); + guiNode->attachChild(textNode); + + Quad *quad=new Quad(Vector3(400,200,0),false); + Node *quadNode=new Node(Vector3(0,0,0)); + Material *mat3=new Material(Material::MATERIAL_GUI); + mat3->addDiffuseMap("/home/dominykas/c++/FSim/defaultTexture.jpg"); + mat3->setTexturingEnabled(true); + mat3->setDiffuseColor(Vector4(1,0,0,.1)); + quad->setMaterial(mat3); + quadNode->attachMesh(quad); + guiNode->attachChild(quadNode); + ParticleEmitter *pe=new ParticleEmitter(100); - Node *node2=new Node(Vector3(0,0,0)); - Material *mat2=new Material(Material::MATERIAL_PARTICLE); - mat2->addDiffuseMap("/home/dominykas/c++/FSim/stern.jpg"); - pe->setMaterial(mat2); - node2->attachParticleEmitter(pe); - root->getRootNode()->attachChild(node2); + Node *peNode=new Node(Vector3::VEC_ZERO); + Material *peMat=new Material(Material::MATERIAL_PARTICLE); + peMat->addDiffuseMap("/home/dominykas/c++/FSim/stern.jpg"); + pe->setMaterial(peMat); + peNode->attachParticleEmitter(pe); + rootNode->attachChild(peNode); Camera *cam=Root::getSingleton()->getCamera(); cam->setPosition(Vector3(0,0,-5)); @@ -60,7 +81,7 @@ int main(){ l1->setInnerAngle(glm::radians(40.)); l1->setOuterAngle(glm::radians(60.)); l1->setType(Light::POINT); - //root->getRootNode()->addLight(l1); + //rootNode->addLight(l1); while(true){ root->update(); } diff --git a/material.cpp b/material.cpp index ba86ae2..5c8a03a 100644 --- a/material.cpp +++ b/material.cpp @@ -18,6 +18,12 @@ namespace vb01{ case MATERIAL_SKYBOX: shaderName="skybox."; break; + case MATERIAL_GUI: + shaderName="gui."; + break; + case MATERIAL_TEXT: + shaderName="text."; + break; } shader=new Shader(basePath+shaderName+"vert",basePath+shaderName+"frag"); } @@ -26,12 +32,19 @@ namespace vb01{ void Material::update(){ shader->use(); - if(type==MATERIAL_2D)shader->setBool(lightingEnabled,"lightingEnabled"); - for(Texture *t : diffuseMapTextures) - t->select(); - for(Texture *t : normalMapTextures) - t->select(); - for(Texture *t : specularMapTextures) - t->select(); + if(type==MATERIAL_2D) + shader->setBool(lightingEnabled,"lightingEnabled"); + shader->setBool(texturingEnabled,"texturingEnabled"); + if(texturingEnabled){ + for(Texture *t : diffuseMapTextures) + t->select(); + for(Texture *t : normalMapTextures) + t->select(); + for(Texture *t : specularMapTextures) + t->select(); + } + else{ + shader->setVec4(diffuseColor,"diffuseColor"); + } } } diff --git a/material.h b/material.h index 49ca47c..9669afe 100644 --- a/material.h +++ b/material.h @@ -3,27 +3,36 @@ #include"shader.h" #include"texture.h" +#include"vector.h" #include namespace vb01{ class Material{ public: - enum Type{MATERIAL_2D,MATERIAL_PARTICLE,MATERIAL_SKYBOX}; + enum Type{MATERIAL_2D,MATERIAL_PARTICLE,MATERIAL_SKYBOX,MATERIAL_GUI,MATERIAL_TEXT}; Material(Type=MATERIAL_2D); ~Material(); void update(); void addDiffuseMap(std::string diffuseMap){diffuseMapTextures.push_back(new Texture(diffuseMap));} void addDiffuseMap(std::string diffuseMap[6]){diffuseMapTextures.push_back(new Texture(diffuseMap));} + void addDiffuseMap(Texture *texture){diffuseMapTextures.push_back(texture);} void addNormalMap(std::string normalMap){normalMapTextures.push_back(new Texture(normalMap));} void addSpecularMap(std::string specularMap){specularMapTextures.push_back(new Texture(specularMap));} + inline void setDiffuseColor(Vector4 diffuse){this->diffuseColor=diffuse;} + inline void setSpecularColor(Vector4 specular){this->specularColor=specular;} inline void setLightingEnabled(bool lighting){this->lightingEnabled=lighting;} - inline Shader* getShader(){return shader;} + inline void setTexturingEnabled(bool texturing){this->texturingEnabled=texturing;} inline bool isLightingEnabled(){return lightingEnabled;} + inline bool isTexturingEnabled(){return texturingEnabled;} + inline Shader* getShader(){return shader;} + inline Texture* getDiffuseMap(int i){return diffuseMapTextures[i];} + inline Type getType(){return type;} private: Type type; - bool lightingEnabled=false; + bool lightingEnabled=false,texturingEnabled=true; std::vector diffuseMapTextures,normalMapTextures,specularMapTextures; + Vector4 diffuseColor=Vector4::VEC_IJKL,specularColor=Vector4::VEC_IJKL; Shader *shader=nullptr; }; } diff --git a/mesh.cpp b/mesh.cpp index 2095230..663dadc 100644 --- a/mesh.cpp +++ b/mesh.cpp @@ -31,9 +31,9 @@ namespace vb01{ glBindVertexArray(VAO); glBindBuffer(GL_ARRAY_BUFFER,VBO); - glBufferData(GL_ARRAY_BUFFER, 3*numTris*sizeof(Vertex), vertices, GL_STATIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, 3*numTris*sizeof(Vertex),staticVerts?vertices:NULL, staticVerts?GL_STATIC_DRAW:GL_DYNAMIC_DRAW); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,EBO); - glBufferData(GL_ELEMENT_ARRAY_BUFFER,3*numTris*sizeof(unsigned int),indices,GL_STATIC_DRAW); + glBufferData(GL_ELEMENT_ARRAY_BUFFER,3*numTris*sizeof(unsigned int),staticVerts?indices:NULL,staticVerts?GL_STATIC_DRAW:GL_DYNAMIC_DRAW); glVertexAttribPointer(0,3,GL_FLOAT,GL_FALSE,sizeof(Vertex),(void*)0); glEnableVertexAttribArray(0); @@ -41,10 +41,13 @@ namespace vb01{ glEnableVertexAttribArray(1); glVertexAttribPointer(2,2,GL_FLOAT,GL_FALSE,sizeof(Vertex),(void*)(offsetof(Vertex,texCoords))); glEnableVertexAttribArray(2); - } void Mesh::update(){ + mat4 model=mat4(1.f); + mat4 view=mat4(1.f); + mat4 proj=mat4(1.f); + Root *root=Root::getSingleton(); Camera *cam=root->getCamera(); float fov=cam->getFov(),width=root->getWidth(),height=root->getHeight(); @@ -52,19 +55,29 @@ namespace vb01{ Vector3 pos=(node?node->getPosition():Vector3::VEC_ZERO); Vector3 dir=cam->getDirection(),up=cam->getUp(),camPos=cam->getPosition(); - mat4 model=translate(mat4(1.),vec3(pos.x,pos.y,pos.z)); + model=translate(mat4(1.),vec3(pos.x,pos.y,pos.z)); model=rotate(model,radians(0.f),vec3(1,1,1)); - mat4 view=lookAt(vec3(camPos.x,camPos.y,camPos.z),vec3(camPos.x+dir.x,camPos.y+dir.y,camPos.z+dir.z),vec3(up.x,up.y,up.z)); - mat4 proj=perspective(radians(fov),width/height,nearPlane,farPlane); - //proj=ortho(0.f,800.f,0.f,-600.f,nearPlane,farPlane); + view=lookAt(vec3(camPos.x,camPos.y,camPos.z),vec3(camPos.x+dir.x,camPos.y+dir.y,camPos.z+dir.z),vec3(up.x,up.y,up.z)); + proj=perspective(radians(fov),width/height,nearPlane,farPlane); material->update(); - material->getShader()->setVec3(camPos,"camPos"); - material->getShader()->setMat4(model,"model"); - material->getShader()->setMat4(view,"view"); - material->getShader()->setMat4(proj,"proj"); + Shader *shader=material->getShader(); + shader->setVec3(camPos,"camPos"); + shader->setMat4(model,"model"); + shader->setMat4(view,"view"); + shader->setMat4(proj,"proj"); + if(material->getType()==Material::MATERIAL_GUI) + shader->setVec2(Vector2((float)width,(float)height),"screen"); + //proj=ortho(0.f,800.f,0.f,-600.f,nearPlane,farPlane); glBindVertexArray(VAO); + + if(!staticVerts){ + glBindBuffer(GL_ARRAY_BUFFER,VBO); + glBufferSubData(GL_ARRAY_BUFFER, 0, 3*numTris*sizeof(Vertex),vertices); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,EBO); + glBufferSubData(GL_ELEMENT_ARRAY_BUFFER,0,3*numTris*sizeof(unsigned int),indices); + } glDrawElements(GL_TRIANGLES,3*numTris,GL_UNSIGNED_INT,0); } } diff --git a/mesh.h b/mesh.h index ad645c0..118bc45 100644 --- a/mesh.h +++ b/mesh.h @@ -32,6 +32,8 @@ namespace vb01{ protected: Mesh(); void construct(); + + bool staticVerts=true; Vertex *vertices; unsigned int *indices,VAO,VBO,EBO; int numTris; diff --git a/node.cpp b/node.cpp index 4983a0b..834432e 100644 --- a/node.cpp +++ b/node.cpp @@ -3,6 +3,7 @@ #include"mesh.h" #include"particleEmitter.h" #include"light.h" +#include"text.h" #include"material.h" using namespace std; @@ -21,6 +22,8 @@ namespace vb01{ l->update(); for(ParticleEmitter *p : emitters) p->update(); + for(Text *t : texts) + t->update(); for(Node *c : children) c->update(); } @@ -64,4 +67,9 @@ namespace vb01{ } } } + + void Node::addText(Text *text){ + texts.push_back(text); + text->setNode(this); + } } diff --git a/node.h b/node.h index 5049c0b..9482ba1 100644 --- a/node.h +++ b/node.h @@ -10,6 +10,7 @@ namespace vb01{ class Model; class Light; class ParticleEmitter; + class Text; class Node{ public: @@ -20,6 +21,7 @@ namespace vb01{ virtual void update(); void attachChild(Node*); void addLight(Light*); + void addText(Text*); inline std::vector& getMeshes(){return meshes;} inline Node* getParent(){return parent;} inline Vector3 getPosition(){return pos;} @@ -34,6 +36,7 @@ namespace vb01{ std::vector emitters; std::vector children,descendants; std::vector lights; + std::vector texts; Node *parent=nullptr; }; } diff --git a/quad.cpp b/quad.cpp index d4dfbd4..27e86f6 100644 --- a/quad.cpp +++ b/quad.cpp @@ -1,35 +1,58 @@ #include"quad.h" namespace vb01{ - Quad::Quad(Vector3 size) : Mesh(){ - Vertex v1,v2,v3,v4,v5,v6; - v1.pos=Vector3(size.x/2,size.y/2,0); - v1.norm=Vector3(0,0,-1); - v1.texCoords=Vector2(1,1); - - v2.pos=Vector3(-size.x/2,size.y/2,0); - v2.norm=Vector3(0,0,-1); - v2.texCoords=Vector2(0,1); - - v3.pos=Vector3(-size.x/2,-size.y/2,0); - v3.norm=Vector3(0,0,-1); - v3.texCoords=Vector2(0,0); - - v4.pos=Vector3(-size.x/2,-size.y/2,0); - v4.norm=Vector3(0,0,-1); - v4.texCoords=Vector2(0,0); - - v5.pos=Vector3(size.x/2,-size.y/2,0); - v5.norm=Vector3(0,0,-1); - v5.texCoords=Vector2(1,0); - - v6.pos=Vector3(size.x/2,size.y/2,0); - v6.norm=Vector3(0,0,-1); - v6.texCoords=Vector2(1,1); + Quad::Quad(Vector3 size,bool spatial) : Mesh(){ + this->spatial=spatial; + this->staticVerts=false; int numPolyVerts=3; numTris=2; indices=new unsigned int[numTris*numPolyVerts]; + vertices=new Vertex[numTris*numPolyVerts]; + + setSize(size); + + Mesh::construct(); + } + + void Quad::setSize(Vector3 size){ + this->size=size; + + Vertex v1,v2,v3,v4,v5,v6; + if(spatial){ + v1.pos=Vector3(size.x/2,size.y/2,0); + v2.pos=Vector3(-size.x/2,size.y/2,0); + v3.pos=Vector3(-size.x/2,-size.y/2,0); + v4.pos=Vector3(-size.x/2,-size.y/2,0); + v5.pos=Vector3(size.x/2,-size.y/2,0); + v6.pos=Vector3(size.x/2,size.y/2,0); + } + else{ + v1.pos=Vector3(size.x,0,0); + v2.pos=Vector3(0,0,0); + v3.pos=Vector3(0,size.y,0); + v4.pos=Vector3(0,size.y,0); + v5.pos=Vector3(size.x,size.y,0); + v6.pos=Vector3(size.x,0,0); + } + v1.norm=Vector3(0,0,-1); + v1.texCoords=Vector2(1,1); + + v2.norm=Vector3(0,0,-1); + v2.texCoords=Vector2(0,1); + + v3.norm=Vector3(0,0,-1); + v3.texCoords=Vector2(0,0); + + v4.norm=Vector3(0,0,-1); + v4.texCoords=Vector2(0,0); + + v5.norm=Vector3(0,0,-1); + v5.texCoords=Vector2(1,0); + + v6.norm=Vector3(0,0,-1); + v6.texCoords=Vector2(1,1); + indices[0]=0; indices[1]=1; indices[2]=2; @@ -37,13 +60,12 @@ namespace vb01{ indices[4]=4; indices[5]=5; - vertices=new Vertex[numTris*numPolyVerts]; vertices[0]=v1; vertices[1]=v2; vertices[2]=v3; vertices[3]=v4; vertices[4]=v5; vertices[5]=v6; - Mesh::construct(); } + } diff --git a/quad.h b/quad.h index db82543..917c5e4 100644 --- a/quad.h +++ b/quad.h @@ -7,8 +7,11 @@ namespace vb01{ class Quad : public Mesh{ public: - Quad(Vector3); + Quad(Vector3,bool=true); + void setSize(Vector3); private: + Vector3 size; + bool spatial; }; } diff --git a/rectangle.cpp b/rectangle.cpp new file mode 100644 index 0000000..1530d34 --- /dev/null +++ b/rectangle.cpp @@ -0,0 +1,7 @@ +#include"rectangle.h" + +namespace vb01{ + Rectangle::Rectangle(Vector3 size){ + + } +} diff --git a/rectangle.h b/rectangle.h new file mode 100644 index 0000000..a4a7980 --- /dev/null +++ b/rectangle.h @@ -0,0 +1,16 @@ +#ifndef RECTANGLE_H +#define RECTANGLE_H + +#include"vector.h" + +namespace vb01{ + class Rectangle{ + public: + Rectangle(Vector3); + ~Rectangle(); + void update(); + private: + }; +} + +#endif diff --git a/root.cpp b/root.cpp index ed68de5..27bf304 100644 --- a/root.cpp +++ b/root.cpp @@ -6,6 +6,7 @@ #include #include"shader.h" #include"box.h" +#include"quad.h" using namespace std; @@ -20,6 +21,8 @@ namespace vb01{ Root::Root(){ rootNode=new Node(Vector3::VEC_ZERO); + guiNode=new Node(Vector3::VEC_ZERO); + camera=new Camera(); } @@ -46,14 +49,36 @@ namespace vb01{ glEnable(GL_DEPTH_TEST); glEnable(GL_STENCIL_TEST); glEnable(GL_CULL_FACE); + glCullFace(GL_FRONT); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); + + glGenFramebuffers(1,&guiFBO); + glBindFramebuffer(GL_FRAMEBUFFER,guiFBO); + Texture *texture=new Texture(); + glFramebufferTexture2D(GL_FRAMEBUFFER,GL_COLOR_ATTACHMENT0,GL_TEXTURE_2D,*(texture->getTexture()),0); + + glGenRenderbuffers(1,&guiRBO); + glBindRenderbuffer(GL_RENDERBUFFER,guiRBO); + glRenderbufferStorage(GL_RENDERBUFFER,GL_DEPTH24_STENCIL8,width,height); + glFramebufferRenderbuffer(GL_FRAMEBUFFER,GL_DEPTH_STENCIL_ATTACHMENT,GL_RENDERBUFFER,guiRBO); + if(glCheckFramebufferStatus(GL_FRAMEBUFFER)!=GL_FRAMEBUFFER_COMPLETE) + cout<<"Not complete\n"; + else + cout<<"Complete\n"; + glBindFramebuffer(GL_FRAMEBUFFER,0); + + guiPlane=new Quad(Vector3::VEC_IJK); + Material *mat=new Material(Material::MATERIAL_GUI); + mat->addDiffuseMap(texture); + guiPlane->setMaterial(mat); } void Root::update(){ if(running){ - glClearColor(0,0,0,1); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + glEnable(GL_DEPTH_TEST); + glEnable(GL_CULL_FACE); if(skybox){ glDepthMask(GL_FALSE); @@ -62,7 +87,19 @@ namespace vb01{ glDepthMask(GL_TRUE); glCullFace(GL_FRONT); } + rootNode->update(); + glDisable(GL_CULL_FACE); + + guiNode->update(); + glBindFramebuffer(GL_FRAMEBUFFER,guiFBO); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + glBindFramebuffer(GL_FRAMEBUFFER,0); + + //glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + + //guiPlane->update(); + glDisable(GL_DEPTH_TEST); glfwSwapBuffers(window); } diff --git a/root.h b/root.h index fab5c4f..1d0a667 100644 --- a/root.h +++ b/root.h @@ -12,6 +12,7 @@ namespace vb01{ class Mesh; class Box; + class Quad; class Shader; class Root{ @@ -21,16 +22,19 @@ namespace vb01{ void start(int,int); inline Camera* getCamera(){return camera;} inline Node* getRootNode(){return rootNode;} + inline Node* getGuiNode(){return guiNode;} inline int getWidth(){return width;} inline int getHeight(){return height;} void createSkybox(std::string[6]); static Root* getSingleton(); private: Box *skybox=nullptr; + Quad *guiPlane=nullptr; bool running=false; int width,height; + unsigned int guiFBO,guiRBO; GLFWwindow *window; - Node *rootNode; + Node *rootNode,*guiNode; Camera *camera; std::vector meshes; void framebuffer_size_callback(GLFWwindow*,int,int); diff --git a/tags b/tags index ecc8bfa..5fcb02f 100644 --- a/tags +++ b/tags @@ -18,13 +18,16 @@ EBO particleEmitter.h /^ unsigned int instanceVBO,VAO,VBO,EBO;$/;" m class:vb0 ErrorType shader.h /^ enum ErrorType{VERTEX,FRAGMENT,PROGRAM};$/;" g class:vb01::Shader FAST_BITS stb_image.h /^#define FAST_BITS /;" d FRAGMENT shader.h /^ enum ErrorType{VERTEX,FRAGMENT,PROGRAM};$/;" e enum:vb01::Shader::ErrorType +Glyph text.h /^ struct Glyph{$/;" s class:vb01::Text LIGHT_H light.h /^#define LIGHT_H$/;" d Light light.cpp /^ Light::Light(){$/;" f class:vb01::Light Light light.h /^ class Light{$/;" c namespace:vb01 -MATERIAL_2D material.h /^ enum Type{MATERIAL_2D,MATERIAL_PARTICLE,MATERIAL_SKYBOX};$/;" e enum:vb01::Material::Type +MATERIAL_2D material.h /^ enum Type{MATERIAL_2D,MATERIAL_PARTICLE,MATERIAL_SKYBOX,MATERIAL_GUI,MATERIAL_TEXT};$/;" e enum:vb01::Material::Type +MATERIAL_GUI material.h /^ enum Type{MATERIAL_2D,MATERIAL_PARTICLE,MATERIAL_SKYBOX,MATERIAL_GUI,MATERIAL_TEXT};$/;" e enum:vb01::Material::Type MATERIAL_H material.h /^#define MATERIAL_H$/;" d -MATERIAL_PARTICLE material.h /^ enum Type{MATERIAL_2D,MATERIAL_PARTICLE,MATERIAL_SKYBOX};$/;" e enum:vb01::Material::Type -MATERIAL_SKYBOX material.h /^ enum Type{MATERIAL_2D,MATERIAL_PARTICLE,MATERIAL_SKYBOX};$/;" e enum:vb01::Material::Type +MATERIAL_PARTICLE material.h /^ enum Type{MATERIAL_2D,MATERIAL_PARTICLE,MATERIAL_SKYBOX,MATERIAL_GUI,MATERIAL_TEXT};$/;" e enum:vb01::Material::Type +MATERIAL_SKYBOX material.h /^ enum Type{MATERIAL_2D,MATERIAL_PARTICLE,MATERIAL_SKYBOX,MATERIAL_GUI,MATERIAL_TEXT};$/;" e enum:vb01::Material::Type +MATERIAL_TEXT material.h /^ enum Type{MATERIAL_2D,MATERIAL_PARTICLE,MATERIAL_SKYBOX,MATERIAL_GUI,MATERIAL_TEXT};$/;" e enum:vb01::Material::Type MESH_H mesh.h /^#define MESH_H$/;" d MODEL_H model.h /^#define MODEL_H$/;" d Material material.cpp /^ Material::Material(Type type){$/;" f class:vb01::Material @@ -52,9 +55,12 @@ QUAT_J quaternion.cpp /^ const quaternion quaternion::QUAT_J(0,0,1,0);$/;" m cla QUAT_J quaternion.h /^ const static quaternion QUAT_I,QUAT_J,QUAT_K;$/;" m class:vb01::quaternion typeref:typename:const quaternion QUAT_K quaternion.cpp /^ const quaternion quaternion::QUAT_K(0,0,0,1);$/;" m class:vb01::quaternion typeref:typename:const quaternion QUAT_K quaternion.h /^ const static quaternion QUAT_I,QUAT_J,QUAT_K;$/;" m class:vb01::quaternion typeref:typename:const quaternion -Quad quad.cpp /^ Quad::Quad(Vector3 size) : Mesh(){$/;" f class:vb01::Quad +Quad quad.cpp /^ Quad::Quad(Vector3 size,bool spatial) : Mesh(){$/;" f class:vb01::Quad Quad quad.h /^ class Quad : public Mesh{$/;" c namespace:vb01 +RECTANGLE_H rectangle.h /^#define RECTANGLE_H$/;" d ROOT_H root.h /^#define ROOT_H$/;" d +Rectangle rectangle.cpp /^ Rectangle::Rectangle(Vector3 size){$/;" f class:vb01::Rectangle +Rectangle rectangle.h /^ class Rectangle{$/;" c namespace:vb01 Root root.cpp /^ Root::Root(){$/;" f class:vb01::Root Root root.h /^ class Root{$/;" c namespace:vb01 SHADER_H shader.h /^#define SHADER_H$/;" d @@ -119,17 +125,24 @@ Shader shader.h /^ class Shader{$/;" c namespace:vb01 TEXTURE_2D texture.h /^ enum TextureType{TEXTURE_2D,TEXTURE_CUBEMAP};$/;" e enum:vb01::Texture::TextureType TEXTURE_CUBEMAP texture.h /^ enum TextureType{TEXTURE_2D,TEXTURE_CUBEMAP};$/;" e enum:vb01::Texture::TextureType 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(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 TextureType texture.h /^ enum TextureType{TEXTURE_2D,TEXTURE_CUBEMAP};$/;" g class:vb01::Texture Type light.h /^ enum Type{POINT,DIRECTIONAL,SPOT,AMBIENT};$/;" g class:vb01::Light -Type material.h /^ enum Type{MATERIAL_2D,MATERIAL_PARTICLE,MATERIAL_SKYBOX};$/;" g class:vb01::Material +Type material.h /^ enum Type{MATERIAL_2D,MATERIAL_PARTICLE,MATERIAL_SKYBOX,MATERIAL_GUI,MATERIAL_TEXT};$/;" g class:vb01::Material UTIL_H util.h /^#define UTIL_H$/;" d VAO mesh.h /^ unsigned int *indices,VAO,VBO,EBO;$/;" m class:vb01::Mesh typeref:typename:unsigned int * VAO particleEmitter.h /^ unsigned int instanceVBO,VAO,VBO,EBO;$/;" m class:vb01::ParticleEmitter typeref:typename:unsigned int +VAO text.h /^ unsigned int VAO, VBO;$/;" m class:vb01::Text typeref:typename:unsigned int VBO mesh.h /^ unsigned int *indices,VAO,VBO,EBO;$/;" m class:vb01::Mesh typeref:typename:unsigned int * VBO particleEmitter.h /^ unsigned int instanceVBO,VAO,VBO,EBO;$/;" m class:vb01::ParticleEmitter typeref:typename:unsigned int +VBO text.h /^ unsigned int VAO, VBO;$/;" m class:vb01::Text typeref:typename:unsigned int VECTOR_H vector.h /^#define VECTOR_H$/;" d VEC_I vector.cpp /^ const Vector2 Vector2::VEC_I(1,0); $/;" m class:vb01::Vector2 typeref:typename:const Vector2 VEC_I vector.cpp /^ const Vector3 Vector3::VEC_I(1,0,0); $/;" m class:vb01::Vector3 typeref:typename:const Vector3 @@ -196,11 +209,14 @@ __anon84e4e8861008 stb_image.h /^{$/;" s __anon84e4e8861108 stb_image.h /^{$/;" s __anon84e4e8861208 stb_image.h /^{$/;" s __anon84e4e8861308 stb_image.h /^{$/;" s +addDiffuseMap material.h /^ void addDiffuseMap(Texture *texture){diffuseMapTextures.push_back(texture);}$/;" f class:vb01::Material typeref:typename:void addDiffuseMap material.h /^ void addDiffuseMap(std::string diffuseMap){diffuseMapTextures.push_back(new Texture(diffuseMa/;" f class:vb01::Material typeref:typename:void addDiffuseMap material.h /^ void addDiffuseMap(std::string diffuseMap[6]){diffuseMapTextures.push_back(new Texture(diffus/;" f class:vb01::Material typeref:typename:void addLight node.cpp /^ void Node::addLight(Light *light){$/;" f class:vb01::Node typeref:typename:void addNormalMap material.h /^ void addNormalMap(std::string normalMap){normalMapTextures.push_back(new Texture(normalMap));/;" f class:vb01::Material typeref:typename:void addSpecularMap material.h /^ void addSpecularMap(std::string specularMap){specularMapTextures.push_back(new Texture(specul/;" f class:vb01::Material typeref:typename:void +addText node.cpp /^ void Node::addText(Text *text){$/;" f class:vb01::Node typeref:typename:void +advance text.h /^ unsigned int advance;$/;" m struct:vb01::Text::Glyph typeref:typename:unsigned int all_a stb_image.h /^ unsigned int mr,mg,mb,ma, all_a;$/;" m struct:__anon84e4e8861008 typeref:typename:unsigned int app14_color_transform stb_image.h /^ int app14_color_transform; \/\/ Adobe APP14 tag$/;" m struct:__anon84e4e8860808 typeref:typename:int attachChild node.cpp /^ void Node::attachChild(Node *child){$/;" f class:vb01::Node typeref:typename:void @@ -208,14 +224,17 @@ attachMesh node.cpp /^ void Node::attachMesh(Mesh *mesh){$/;" f class:vb01::Node attachParticleEmitter node.cpp /^ void Node::attachParticleEmitter(ParticleEmitter *emitter){$/;" f class:vb01::Node typeref:typename:void attenuationValues light.h /^ Vector3 pos,color,attenuationValues=Vector3(1.8,.7,1),direction;$/;" m class:vb01::Light typeref:typename:Vector3 background stb_image.h /^ stbi_uc *background; \/\/ The current "background" as far as a gif is concerned$/;" m struct:__anon84e4e8861308 typeref:typename:stbi_uc * +bearing text.h /^ Vector2 size,bearing;$/;" m struct:vb01::Text::Glyph typeref:typename:Vector2 bgindex stb_image.h /^ int flags, bgindex, ratio, transparent, eflags;$/;" m struct:__anon84e4e8861308 typeref:typename:int bits_per_channel stb_image.h /^ int bits_per_channel;$/;" m struct:__anon84e4e8860508 typeref:typename:int bpp stb_image.h /^ int bpp, offset, hsz;$/;" m struct:__anon84e4e8861008 typeref:typename:int buffer_start stb_image.h /^ stbi_uc buffer_start[128];$/;" m struct:__anon84e4e8860308 typeref:typename:stbi_uc[128] buflen stb_image.h /^ int buflen;$/;" m struct:__anon84e4e8860308 typeref:typename:int camera root.h /^ Camera *camera;$/;" m class:vb01::Root typeref:typename:Camera * +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 characters;$/;" m class:vb01::Text typeref:typename:std::vector checkCompileErrors shader.cpp /^ void Shader::checkCompileErrors(unsigned int shader, ErrorType type){$/;" f class:vb01::Shader typeref:typename:void children node.h /^ std::vector children,descendants;$/;" m class:vb01::Node typeref:typename:std::vector code stb_image.h /^ stbi__uint16 code[256];$/;" m struct:__anon84e4e8860708 typeref:typename:stbi__uint16[256] @@ -228,6 +247,7 @@ coeff_h stb_image.h /^ int coeff_w, coeff_h; \/\/ number of 8x8 coeffi coeff_w stb_image.h /^ int coeff_w, coeff_h; \/\/ number of 8x8 coefficient blocks$/;" m struct:__anon84e4e8860808::__anon84e4e8860908 typeref:typename:int color light.h /^ Vector3 pos,color,attenuationValues=Vector3(1.8,.7,1),direction;$/;" m class:vb01::Light typeref:typename:Vector3 color particleEmitter.h /^ Vector4 color;$/;" m struct:vb01::ParticleEmitter::Particle typeref:typename:Vector4 +color text.h /^ Vector4 color=Vector4::VEC_IJKL;$/;" m class:vb01::Text typeref:typename:Vector4 color_table stb_image.h /^ stbi_uc *color_table;$/;" m struct:__anon84e4e8861308 typeref:typename:stbi_uc * conj quaternion.h /^ inline vb01::quaternion conj(){return (*this+vb01::quaternion(0,1,0,0)*(*this)*vb01::quaterni/;" f class:vb01::quaternion typeref:typename:vb01::quaternion construct mesh.cpp /^ void Mesh::construct(){$/;" f class:vb01::Mesh typeref:typename:void @@ -265,6 +285,7 @@ delta stb_image.h /^ int delta[17]; \/\/ old 'firstsymbol' - old 'firstco depth stb_image.h /^ int depth;$/;" m struct:__anon84e4e8860e08 typeref:typename:int dequant stb_image.h /^ stbi__uint16 dequant[4][64];$/;" m struct:__anon84e4e8860808 typeref:typename:stbi__uint16[4][64] descendants node.h /^ std::vector children,descendants;$/;" m class:vb01::Node typeref:typename:std::vector +diffuseColor material.h /^ Vector4 diffuseColor=Vector4::VEC_IJKL,specularColor=Vector4::VEC_IJKL;$/;" m class:vb01::Material typeref:typename:Vector4 diffuseMapTextures material.h /^ std::vector diffuseMapTextures,normalMapTextures,specularMapTextures;$/;" m class:vb01::Material typeref:typename:std::vector dir particleEmitter.h /^ Vector3 dir;$/;" m struct:vb01::ParticleEmitter::Particle typeref:typename:Vector3 direction camera.h /^ Vector3 position=Vector3(0,0,0),direction=Vector3(0,0,1),left=Vector3(1,0,0),up=Vector3(0,1,0/;" m class:vb01::Camera typeref:typename:Vector3 @@ -277,6 +298,7 @@ eflags stb_image.h /^ int flags, bgindex, ratio, transparent, eflags;$/;" m st emitters node.h /^ std::vector emitters;$/;" m class:vb01::Node typeref:typename:std::vector endColor particleEmitter.h /^ Vector4 startColor,endColor;$/;" m class:vb01::ParticleEmitter typeref:typename:Vector4 endSize particleEmitter.h /^ Vector2 startSize=Vector2::VEC_IJ,endSize=Vector2::VEC_IJ;$/;" m class:vb01::ParticleEmitter typeref:typename:Vector2 +entry text.h /^ std::string entry;$/;" m class:vb01::Text typeref:typename:std::string eob_run stb_image.h /^ int eob_run;$/;" m struct:__anon84e4e8860808 typeref:typename:int eof stb_image.h /^ int (*eof) (void *user); \/\/ returns nonzero if we are at end o/;" m struct:__anon84e4e8860208 typeref:typename:int (*)(void * user) expanded stb_image.h /^ stbi_uc *idata, *expanded, *out;$/;" m struct:__anon84e4e8860e08 typeref:typename:stbi_uc ** @@ -298,11 +320,13 @@ getAttenuationValues light.h /^ inline Vector3 getAttenuationValues(){return a getCamera root.h /^ inline Camera* getCamera(){return camera;}$/;" f class:vb01::Root typeref:typename:Camera * getChildren node.h /^ inline std::vector& getChildren(){return children;}$/;" f class:vb01::Node typeref:typename:std::vector & getDescendants node.h /^ inline std::vector& getDescendants(){return descendants;}$/;" f class:vb01::Node typeref:typename:std::vector & +getDiffuseMap material.h /^ inline Texture* getDiffuseMap(int i){return diffuseMapTextures[i];}$/;" f class:vb01::Material typeref:typename:Texture * getDirection camera.h /^ inline Vector3 getDirection(){return direction;}$/;" f class:vb01::Camera typeref:typename:Vector3 getDirection light.h /^ inline Vector3 getDirection(){return direction;}$/;" f class:vb01::Light typeref:typename:Vector3 getDistanceFrom vector.h /^ float getDistanceFrom(Vector3 v){return (v-*this).getLengthSq();}$/;" f struct:vb01::Vector3 typeref:typename:float getFarPlane camera.h /^ inline float getFarPlane(){return farPlane;}$/;" f class:vb01::Camera typeref:typename:float getFov camera.h /^ inline float getFov(){return fov;}$/;" f class:vb01::Camera typeref:typename:float +getGuiNode root.h /^ inline Node* getGuiNode(){return guiNode;}$/;" f class:vb01::Root typeref:typename:Node * getHeight root.h /^ inline int getHeight(){return height;}$/;" f class:vb01::Root typeref:typename:int getInnerAngle light.h /^ inline float getInnerAngle(){return innerAngle;}$/;" f class:vb01::Light typeref:typename:float getLeft camera.h /^ inline Vector3 getLeft(){return left;}$/;" f class:vb01::Camera typeref:typename:Vector3 @@ -327,9 +351,15 @@ getPosition node.h /^ inline Vector3 getPosition(){return pos;}$/;" f class:vb getRootNode root.h /^ inline Node* getRootNode(){return rootNode;}$/;" f class:vb01::Root typeref:typename:Node * getShader material.h /^ inline Shader* getShader(){return shader;}$/;" f class:vb01::Material typeref:typename:Shader * getSingleton root.cpp /^ Root* Root::getSingleton(){return root;}$/;" f class:vb01::Root typeref:typename:Root * +getTexture texture.h /^ inline unsigned int* getTexture(){return &texture;}$/;" f class:vb01::Texture typeref:typename:unsigned int * getTime util.h /^ inline s64 getTime(){return s64(std::chrono::system_clock::now().time_since_epoch()\/std::chron/;" f namespace:vb01 typeref:typename:s64 +getType material.h /^ inline Type getType(){return type;}$/;" f class:vb01::Material typeref:typename:Type getUp camera.h /^ inline Vector3 getUp(){return up;}$/;" f class:vb01::Camera typeref:typename:Vector3 getWidth root.h /^ inline int getWidth(){return width;}$/;" f class:vb01::Root typeref:typename:int +guiFBO root.h /^ unsigned int guiFBO,guiRBO;$/;" m class:vb01::Root typeref:typename:unsigned int +guiNode root.h /^ Node *rootNode,*guiNode;$/;" m class:vb01::Root typeref:typename:Node ** +guiPlane root.h /^ Quad *guiPlane=nullptr;$/;" m class:vb01::Root typeref:typename:Quad * +guiRBO root.h /^ unsigned int guiFBO,guiRBO;$/;" m class:vb01::Root typeref:typename:unsigned int h stb_image.h /^ int h,v;$/;" m struct:__anon84e4e8860808::__anon84e4e8860908 typeref:typename:int h stb_image.h /^ int w,h;$/;" m struct:__anon84e4e8861308 typeref:typename:int h2 stb_image.h /^ int x,y,w2,h2;$/;" m struct:__anon84e4e8860808::__anon84e4e8860908 typeref:typename:int @@ -368,11 +398,12 @@ instanceVBO particleEmitter.h /^ unsigned int instanceVBO,VAO,VBO,EBO;$/;" m c io stb_image.h /^ stbi_io_callbacks io;$/;" m struct:__anon84e4e8860308 typeref:typename:stbi_io_callbacks io_user_data stb_image.h /^ void *io_user_data;$/;" m struct:__anon84e4e8860308 typeref:typename:void * isLightingEnabled material.h /^ inline bool isLightingEnabled(){return lightingEnabled;}$/;" f class:vb01::Material typeref:typename:bool +isTexturingEnabled material.h /^ inline bool isTexturingEnabled(){return texturingEnabled;}$/;" f class:vb01::Material typeref:typename:bool jfif stb_image.h /^ int jfif;$/;" m struct:__anon84e4e8860808 typeref:typename:int left camera.h /^ Vector3 position=Vector3(0,0,0),direction=Vector3(0,0,1),left=Vector3(1,0,0),up=Vector3(0,1,0/;" m class:vb01::Camera typeref:typename:Vector3 length stb_image.h /^ stbi__uint32 length;$/;" m struct:__anon84e4e8860d08 typeref:typename:stbi__uint32 lflags stb_image.h /^ int lflags;$/;" m struct:__anon84e4e8861308 typeref:typename:int -lightingEnabled material.h /^ bool lightingEnabled=false;$/;" m class:vb01::Material typeref:typename:bool +lightingEnabled material.h /^ bool lightingEnabled=false,texturingEnabled=true;$/;" m class:vb01::Material typeref:typename:bool lights node.h /^ std::vector lights;$/;" m class:vb01::Node typeref:typename:std::vector line0 stb_image.h /^ stbi_uc *line0,*line1;$/;" m struct:__anon84e4e8860a08 typeref:typename:stbi_uc * line1 stb_image.h /^ stbi_uc *line0,*line1;$/;" m struct:__anon84e4e8860a08 typeref:typename:stbi_uc ** @@ -405,6 +436,7 @@ nearPlane camera.h /^ float fov=45,nearPlane=.1,farPlane=100;$/;" m class:vb01 node light.h /^ Node *node=nullptr;$/;" m class:vb01::Light typeref:typename:Node * node mesh.h /^ Node *node=nullptr;$/;" m class:vb01::Mesh typeref:typename:Node * node particleEmitter.h /^ Node *node=nullptr;$/;" m class:vb01::ParticleEmitter typeref:typename:Node * +node text.h /^ Node *node=nullptr;$/;" m class:vb01::Text typeref:typename:Node * nomore stb_image.h /^ int nomore; \/\/ flag if we saw a marker so must stop$/;" m struct:__anon84e4e8860808 typeref:typename:int norm mesh.h /^ Vector3 pos,norm;$/;" m struct:vb01::Mesh::Vertex typeref:typename:Vector3 norm quaternion.h /^ inline vb01::quaternion norm(){return *this\/getLength();}$/;" f class:vb01::quaternion typeref:typename:vb01::quaternion @@ -472,7 +504,7 @@ resample_row_hv_2_kernel stb_image.h /^ stbi_uc *(*resample_row_hv_2_kernel)(s restart_interval stb_image.h /^ int restart_interval, todo;$/;" m struct:__anon84e4e8860808 typeref:typename:int rgb stb_image.h /^ int rgb;$/;" m struct:__anon84e4e8860808 typeref:typename:int root root.cpp /^ static Root *root=new Root();$/;" v namespace:vb01 typeref:typename:Root * file: -rootNode root.h /^ Node *rootNode;$/;" m class:vb01::Root typeref:typename:Node * +rootNode root.h /^ Node *rootNode,*guiNode;$/;" m class:vb01::Root typeref:typename:Node * running root.h /^ bool running=false;$/;" m class:vb01::Root typeref:typename:bool s stb_image.h /^ stbi__context *s;$/;" m struct:__anon84e4e8860808 typeref:typename:stbi__context * s stb_image.h /^ stbi__context *s;$/;" m struct:__anon84e4e8860e08 typeref:typename:stbi__context * @@ -480,11 +512,13 @@ s16 util.h /^ typedef short s16;$/;" t namespace:vb01 typeref:typename:short s32 util.h /^ typedef int s32;$/;" t namespace:vb01 typeref:typename:int s64 util.h /^ typedef long long s64;$/;" t namespace:vb01 typeref:typename:long long s8 util.h /^ typedef char s8;$/;" t namespace:vb01 typeref:typename:char +scale text.h /^ float scale=1;$/;" m class:vb01::Text typeref:typename:float scan_n stb_image.h /^ int scan_n, order[4];$/;" m struct:__anon84e4e8860808 typeref:typename:int select texture.cpp /^ void Texture::select(){$/;" f class:vb01::Texture typeref:typename:void setAttenuationValues light.h /^ inline void setAttenuationValues(float a, float b, float c){$/;" f class:vb01::Light typeref:typename:void setBool shader.cpp /^ void Shader::setBool(bool b, string var){$/;" f class:vb01::Shader typeref:typename:void setColor light.h /^ inline void setColor(Vector3 color){this->color=color;}$/;" f class:vb01::Light typeref:typename:void +setDiffuseColor material.h /^ inline void setDiffuseColor(Vector4 diffuse){this->diffuseColor=diffuse;}$/;" f class:vb01::Material typeref:typename:void setDirection light.h /^ inline void setDirection(Vector3 dir){this->direction=dir;}$/;" f class:vb01::Light typeref:typename:void setFloat shader.cpp /^ void Shader::setFloat(float fl, string var){$/;" f class:vb01::Shader typeref:typename:void setInnerAngle light.h /^ inline void setInnerAngle(float innerAngle){this->innerAngle=innerAngle;}$/;" f class:vb01::Light typeref:typename:void @@ -497,22 +531,34 @@ setMaterial particleEmitter.h /^ inline void setMaterial(Material *mat){this-> setNode light.h /^ inline void setNode(Node *node){this->node=node;}$/;" f class:vb01::Light typeref:typename:void setNode mesh.h /^ inline void setNode(Node *node){this->node=node;}$/;" f class:vb01::Mesh typeref:typename:void setNode particleEmitter.h /^ inline void setNode(Node *node){this->node=node;}$/;" f class:vb01::ParticleEmitter typeref:typename:void +setNode text.h /^ inline void setNode(Node *node){this->node=node;}$/;" f class:vb01::Text typeref:typename:void setOuterAngle light.h /^ inline void setOuterAngle(float outerAngle){this->outerAngle=outerAngle;}$/;" f class:vb01::Light typeref:typename:void setPosition camera.h /^ void setPosition(Vector3 position){this->position=position;}$/;" f class:vb01::Camera typeref:typename:void setPosition light.h /^ inline void setPosition(Vector3 pos){this->pos=pos;}$/;" f class:vb01::Light typeref:typename:void +setSize box.cpp /^ void Box::setSize(Vector3 size){$/;" f class:vb01::Box typeref:typename:void +setSize quad.cpp /^ void Quad::setSize(Vector3 size){$/;" f class:vb01::Quad typeref:typename:void +setSpecularColor material.h /^ inline void setSpecularColor(Vector4 specular){this->specularColor=specular;}$/;" f class:vb01::Material typeref:typename:void +setText text.cpp /^ void Text::setText(string text){$/;" f class:vb01::Text typeref:typename:void +setTexturingEnabled material.h /^ inline void setTexturingEnabled(bool texturing){this->texturingEnabled=texturing;}$/;" f class:vb01::Material typeref:typename:void setType light.h /^ inline void setType(Type t){this->type=t;}$/;" f class:vb01::Light typeref:typename:void setVec2 shader.cpp /^ void Shader::setVec2(Vector2 vec, string var){$/;" f class:vb01::Shader typeref:typename:void setVec3 shader.cpp /^ void Shader::setVec3(Vector3 vec, string var){$/;" f class:vb01::Shader typeref:typename:void setVec4 shader.cpp /^ void Shader::setVec4(Vector4 vec, string var){$/;" f class:vb01::Shader typeref:typename:void shader material.h /^ Shader *shader=nullptr;$/;" m class:vb01::Material typeref:typename:Shader * +shader text.h /^ Shader *shader=nullptr;$/;" m class:vb01::Text typeref:typename:Shader * +size box.h /^ Vector3 size;$/;" m class:vb01::Box typeref:typename:Vector3 size particleEmitter.h /^ Vector2 size;$/;" m struct:vb01::ParticleEmitter::Particle typeref:typename:Vector2 +size quad.h /^ Vector3 size;$/;" m class:vb01::Quad typeref:typename:Vector3 size stb_image.h /^ stbi_uc size[257];$/;" m struct:__anon84e4e8860708 typeref:typename:stbi_uc[257] size stb_image.h /^ stbi_uc size[288];$/;" m struct:__anon84e4e8860b08 typeref:typename:stbi_uc[288] size stb_image.h /^ stbi_uc size,type,channel;$/;" m struct:__anon84e4e8861108 typeref:typename:stbi_uc +size text.h /^ Vector2 size,bearing;$/;" m struct:vb01::Text::Glyph typeref:typename:Vector2 skip stb_image.h /^ void (*skip) (void *user,int n); \/\/ skip the next 'n' bytes, or 'unget/;" m struct:__anon84e4e8860208 typeref:typename:void (*)(void * user,int n) skybox root.h /^ Box *skybox=nullptr;$/;" m class:vb01::Root typeref:typename:Box * +spatial quad.h /^ bool spatial;$/;" m class:vb01::Quad typeref:typename:bool spec_end stb_image.h /^ int spec_end;$/;" m struct:__anon84e4e8860808 typeref:typename:int spec_start stb_image.h /^ int spec_start;$/;" m struct:__anon84e4e8860808 typeref:typename:int +specularColor material.h /^ Vector4 diffuseColor=Vector4::VEC_IJKL,specularColor=Vector4::VEC_IJKL;$/;" m class:vb01::Material typeref:typename:Vector4 specularMapTextures material.h /^ std::vector diffuseMapTextures,normalMapTextures,specularMapTextures;$/;" m class:vb01::Material typeref:typename:std::vector spread particleEmitter.h /^ float spread=0,lowLife=1,highLife=2;$/;" m class:vb01::ParticleEmitter typeref:typename:float start root.cpp /^ void Root::start(int width,int height){$/;" f class:vb01::Root typeref:typename:void @@ -520,6 +566,7 @@ startColor particleEmitter.h /^ Vector4 startColor,endColor;$/;" m class:vb01: startSize particleEmitter.h /^ Vector2 startSize=Vector2::VEC_IJ,endSize=Vector2::VEC_IJ;$/;" m class:vb01::ParticleEmitter typeref:typename:Vector2 start_x stb_image.h /^ int start_x, start_y;$/;" m struct:__anon84e4e8861308 typeref:typename:int start_y stb_image.h /^ int start_x, start_y;$/;" m struct:__anon84e4e8861308 typeref:typename:int +staticVerts mesh.h /^ bool staticVerts=true;$/;" m class:vb01::Mesh typeref:typename:bool stbi__DNL stb_image.h /^#define stbi__DNL(/;" d stbi__EOI stb_image.h /^#define stbi__EOI(/;" d stbi__SOF stb_image.h /^#define stbi__SOF(/;" d @@ -793,7 +840,10 @@ succ_low stb_image.h /^ int succ_low;$/;" m struct:__anon84e4e88608 suffix stb_image.h /^ stbi_uc suffix;$/;" m struct:__anon84e4e8861208 typeref:typename:stbi_uc texCoords mesh.h /^ Vector2 texCoords; $/;" m struct:vb01::Mesh::Vertex typeref:typename:Vector2 texCoords particleEmitter.h /^ Vector2 texCoords;$/;" m struct:vb01::ParticleEmitter::Vertex typeref:typename:Vector2 +texts node.h /^ std::vector texts;$/;" m class:vb01::Node typeref:typename:std::vector +texture text.h /^ Texture *texture=nullptr;$/;" m struct:vb01::Text::Glyph typeref:typename:Texture * texture texture.h /^ unsigned int texture;$/;" m class:vb01::Texture typeref:typename:unsigned int +texturingEnabled material.h /^ bool lightingEnabled=false,texturingEnabled=true;$/;" m class:vb01::Material typeref:typename:bool time particleEmitter.h /^ s64 time=0,timeToLive=0;$/;" m struct:vb01::ParticleEmitter::Particle typeref:typename:s64 timeToLive particleEmitter.h /^ s64 time=0,timeToLive=0;$/;" m struct:vb01::ParticleEmitter::Particle typeref:typename:s64 todo stb_image.h /^ int restart_interval, todo;$/;" m struct:__anon84e4e8860808 typeref:typename:int @@ -817,6 +867,7 @@ update model.cpp /^ void Model::update(){$/;" f class:vb01::Model typeref:typena update node.cpp /^ void Node::update(){$/;" f class:vb01::Node typeref:typename:void update particleEmitter.cpp /^ void ParticleEmitter::update(){$/;" f class:vb01::ParticleEmitter typeref:typename:void update root.cpp /^ void Root::update(){$/;" f class:vb01::Root typeref:typename:void +update text.cpp /^ void Text::update(){$/;" f class:vb01::Text typeref:typename:void use shader.cpp /^ void Shader::use(){glUseProgram(id);}$/;" f class:vb01::Shader typeref:typename:void v stb_image.h /^ int h,v;$/;" m struct:__anon84e4e8860808::__anon84e4e8860908 typeref:typename:int vString shader.h /^ std::string vString,fString;$/;" m class:vb01::Shader typeref:typename:std::string @@ -843,10 +894,14 @@ vb01 quad.cpp /^namespace vb01{$/;" n file: vb01 quad.h /^namespace vb01{$/;" n vb01 quaternion.cpp /^namespace vb01{$/;" n file: vb01 quaternion.h /^namespace vb01{$/;" n +vb01 rectangle.cpp /^namespace vb01{$/;" n file: +vb01 rectangle.h /^namespace vb01{$/;" n vb01 root.cpp /^namespace vb01{$/;" n file: vb01 root.h /^namespace vb01{$/;" n vb01 shader.cpp /^namespace vb01{$/;" n file: vb01 shader.h /^namespace vb01{$/;" n +vb01 text.cpp /^namespace vb01{$/;" n file: +vb01 text.h /^namespace vb01{$/;" n vb01 texture.cpp /^namespace vb01{$/;" n file: vb01 texture.h /^namespace vb01{$/;" n vb01 util.cpp /^namespace vb01{$/;" n file: @@ -896,3 +951,4 @@ zout_start stb_image.h /^ char *zout_start;$/;" m struct:__anon84e4e8860c08 ty ~Model model.cpp /^ Model::~Model(){}$/;" f class:vb01::Model ~Node node.cpp /^ Node::~Node(){}$/;" f class:vb01::Node ~ParticleEmitter particleEmitter.cpp /^ ParticleEmitter::~ParticleEmitter(){}$/;" f class:vb01::ParticleEmitter +~Text text.cpp /^ Text::~Text(){}$/;" f class:vb01::Text diff --git a/text.cpp b/text.cpp new file mode 100644 index 0000000..4cc1dc8 --- /dev/null +++ b/text.cpp @@ -0,0 +1,102 @@ +#include"root.h" +#include"text.h" +#include"shader.h" +#include"texture.h" +#include"node.h" +#include +#include +#include +#include +#include FT_FREETYPE_H + +using namespace std; + +namespace vb01{ + Text::Text(string fontPath,string entry){ + string basePath="/home/dominykas/c++/FSim/text."; + shader=new Shader(basePath+"vert",basePath+"frag"); + + FT_Library ft; + FT_Face face; + if(FT_Init_FreeType(&ft)) + cout<<"Couldn't init Freetype\n"; + if(FT_New_Face(ft,fontPath.c_str(),0,&face)) + cout<<"Could not load font\n"; + + FT_Set_Pixel_Sizes(face,0,96); + + glPixelStorei(GL_UNPACK_ALIGNMENT,1); + + for(u32 i=0;i<128;i++){ + if(FT_Load_Char(face,i,FT_LOAD_RENDER)){ + cout<<"Could not load glyph\n"; + continue; + } + Glyph c; + c.ch=i; + c.texture=new Texture(face,i); + c.size=Vector2(face->glyph->bitmap.width,face->glyph->bitmap.rows); + c.bearing=Vector2(face->glyph->bitmap_left,face->glyph->bitmap_top); + c.advance=face->glyph->advance.x; + characters.push_back(c); + } + + FT_Done_Face(face); + FT_Done_FreeType(ft); + + setText(entry); + } + + Text::~Text(){} + + void Text::update(){ + Root *root=Root::getSingleton(); + int width=root->getWidth(),height=root->getHeight(); + + shader->use(); + shader->setVec4(color,"color"); + shader->setVec2(Vector2(width,height),"screen"); + + Vector3 origin=node->getPosition(); + for(int i=0;i>6)*scale; + glBindVertexArray(VAO); + glBindBuffer(GL_ARRAY_BUFFER,VBO); + glBufferSubData(GL_ARRAY_BUFFER,0,sizeof(data),data); + ch.texture->select(); + glDrawArrays(GL_TRIANGLES,0,6); + } + } + + void Text::setText(string text){ + this->entry=text; + + glGenVertexArrays(1,&VAO); + glGenBuffers(1,&VBO); + glBindVertexArray(VAO); + glBindBuffer(GL_ARRAY_BUFFER,VBO); + glBufferData(GL_ARRAY_BUFFER,sizeof(float)*6*4,NULL,GL_DYNAMIC_DRAW); + glEnableVertexAttribArray(0); + glVertexAttribPointer(0,4,GL_FLOAT,GL_FALSE,4*sizeof(float),(void*)0); + glBindBuffer(GL_ARRAY_BUFFER,0); + glBindVertexArray(0); + } +} diff --git a/text.frag b/text.frag new file mode 100644 index 0000000..b28ad39 --- /dev/null +++ b/text.frag @@ -0,0 +1,13 @@ +#version 330 core + +in vec2 texCoords; + +out vec4 FragColor; + +uniform sampler2D tex; +uniform vec4 color; + +void main(){ + //FragColor=vec4(1,0,1,1); + FragColor=vec4(color.xyz,texture(tex,texCoords).r); +} diff --git a/text.h b/text.h new file mode 100644 index 0000000..2a4f261 --- /dev/null +++ b/text.h @@ -0,0 +1,39 @@ +#ifndef TEXT_H +#define TEXT_H + +#include +#include +#include"vector.h" +#include"util.h" + +namespace vb01{ + class Node; + class Texture; + class Shader; + + class Text{ + public: + struct Glyph{ + u32 ch; + Texture *texture=nullptr; + unsigned int advance; + Vector2 size,bearing; + }; + + Text(std::string,std::string); + ~Text(); + void update(); + void setText(std::string); + inline void setNode(Node *node){this->node=node;} + private: + Node *node=nullptr; + std::string entry; + std::vector characters; + Shader *shader=nullptr; + unsigned int VAO, VBO; + float scale=1; + Vector4 color=Vector4::VEC_IJKL; + }; +} + +#endif diff --git a/text.vert b/text.vert new file mode 100644 index 0000000..d831870 --- /dev/null +++ b/text.vert @@ -0,0 +1,15 @@ +#version 330 core + +layout (location=0) in vec4 aVert; + +out vec2 texCoords; + +uniform vec2 screen; + +void main(){ + float x,y; + x=(aVert.x-screen.x*.5)/(screen.x*.5); + y=(screen.y*.5-aVert.y)/(screen.y*.5); + gl_Position=vec4(x,y,0,1); + texCoords=aVert.zw; +} diff --git a/texture.cpp b/texture.cpp index b38708c..6e7c534 100644 --- a/texture.cpp +++ b/texture.cpp @@ -8,6 +8,41 @@ 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,1,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){ + this->type=TextureType::TEXTURE_2D; + + glGenTextures(1,&texture); + glBindTexture(GL_TEXTURE_2D,texture); + glTexImage2D( + GL_TEXTURE_2D, + 0, + GL_RED, + face->glyph->bitmap.width, + face->glyph->bitmap.rows, + 0, + GL_RED, + GL_UNSIGNED_BYTE, + face->glyph->bitmap.buffer + ); + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); + glBindTexture(GL_TEXTURE_2D,0); + } + Texture::Texture(string path){ this->type=TextureType::TEXTURE_2D; @@ -15,6 +50,8 @@ namespace vb01{ glBindTexture(GL_TEXTURE_2D,texture); 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_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); diff --git a/texture.frag b/texture.frag index 40dde81..47ad70e 100644 --- a/texture.frag +++ b/texture.frag @@ -20,10 +20,12 @@ struct Light{ uniform Light light[numLights]; uniform sampler2D tex; uniform bool lightingEnabled; +uniform bool texturingEnabled; +uniform vec4 diffuseColor; uniform vec3 camPos; void main(){ - vec4 finalColor=texture(tex,texCoords); + vec4 finalColor=texturingEnabled?texture(tex,texCoords):diffuseColor; if(lightingEnabled){ vec3 diffuseColor=vec3(0),specularColor; for(int i=0;i +#include +#include FT_FREETYPE_H namespace vb01{ class Texture{ public: enum TextureType{TEXTURE_2D,TEXTURE_CUBEMAP}; + Texture(); + Texture(FT_Face&,char); Texture(std::string); Texture(std::string[6]); void select(); + inline unsigned int* getTexture(){return &texture;} private: TextureType type; unsigned int texture;