Commit f96665f2 authored by Mathieu Faverge's avatar Mathieu Faverge

Cleanup DOS files to unix files

parent 1c96b263

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libotf", "otflib\libotf_vs08.vcproj", "{6B9B49C9-75CD-400D-B736-5EACA04D0A82}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "otfaux", "tools\otfaux\otfaux_vs08.vcproj", "{24587836-ED5E-49DF-A7AD-419FDC208C08}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "otfcompress", "tools\otfcompress\otfcompress_vs08.vcproj", "{B6BBC220-1492-4BEA-A299-9D062133ABAA}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "otfdump", "tools\otfdump\otfdump_vs08.vcproj", "{508A823C-8EAB-4C56-9DFE-4D85B0D24491}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "otfmerge", "tools\otfmerge\otfmerge_vs08.vcproj", "{1B9223C8-DE20-4538-8214-776C6017D22B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release Static|Win32 = Release Static|Win32
Release Static|x64 = Release Static|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6B9B49C9-75CD-400D-B736-5EACA04D0A82}.Debug|Win32.ActiveCfg = Debug|Win32
{6B9B49C9-75CD-400D-B736-5EACA04D0A82}.Debug|Win32.Build.0 = Debug|Win32
{6B9B49C9-75CD-400D-B736-5EACA04D0A82}.Debug|x64.ActiveCfg = Debug|x64
{6B9B49C9-75CD-400D-B736-5EACA04D0A82}.Debug|x64.Build.0 = Debug|x64
{6B9B49C9-75CD-400D-B736-5EACA04D0A82}.Release Static|Win32.ActiveCfg = Release Static|Win32
{6B9B49C9-75CD-400D-B736-5EACA04D0A82}.Release Static|Win32.Build.0 = Release Static|Win32
{6B9B49C9-75CD-400D-B736-5EACA04D0A82}.Release Static|x64.ActiveCfg = Release Static|x64
{6B9B49C9-75CD-400D-B736-5EACA04D0A82}.Release Static|x64.Build.0 = Release Static|x64
{24587836-ED5E-49DF-A7AD-419FDC208C08}.Debug|Win32.ActiveCfg = Debug|Win32
{24587836-ED5E-49DF-A7AD-419FDC208C08}.Debug|Win32.Build.0 = Debug|Win32
{24587836-ED5E-49DF-A7AD-419FDC208C08}.Debug|x64.ActiveCfg = Debug|x64
{24587836-ED5E-49DF-A7AD-419FDC208C08}.Debug|x64.Build.0 = Debug|x64
{24587836-ED5E-49DF-A7AD-419FDC208C08}.Release Static|Win32.ActiveCfg = Release Static|Win32
{24587836-ED5E-49DF-A7AD-419FDC208C08}.Release Static|Win32.Build.0 = Release Static|Win32
{24587836-ED5E-49DF-A7AD-419FDC208C08}.Release Static|x64.ActiveCfg = Release Static|x64
{24587836-ED5E-49DF-A7AD-419FDC208C08}.Release Static|x64.Build.0 = Release Static|x64
{B6BBC220-1492-4BEA-A299-9D062133ABAA}.Debug|Win32.ActiveCfg = Debug|Win32
{B6BBC220-1492-4BEA-A299-9D062133ABAA}.Debug|Win32.Build.0 = Debug|Win32
{B6BBC220-1492-4BEA-A299-9D062133ABAA}.Debug|x64.ActiveCfg = Debug|x64
{B6BBC220-1492-4BEA-A299-9D062133ABAA}.Debug|x64.Build.0 = Debug|x64
{B6BBC220-1492-4BEA-A299-9D062133ABAA}.Release Static|Win32.ActiveCfg = Release Static|Win32
{B6BBC220-1492-4BEA-A299-9D062133ABAA}.Release Static|Win32.Build.0 = Release Static|Win32
{B6BBC220-1492-4BEA-A299-9D062133ABAA}.Release Static|x64.ActiveCfg = Release Static|x64
{B6BBC220-1492-4BEA-A299-9D062133ABAA}.Release Static|x64.Build.0 = Release Static|x64
{508A823C-8EAB-4C56-9DFE-4D85B0D24491}.Debug|Win32.ActiveCfg = Debug|Win32
{508A823C-8EAB-4C56-9DFE-4D85B0D24491}.Debug|Win32.Build.0 = Debug|Win32
{508A823C-8EAB-4C56-9DFE-4D85B0D24491}.Debug|x64.ActiveCfg = Debug|x64
{508A823C-8EAB-4C56-9DFE-4D85B0D24491}.Debug|x64.Build.0 = Debug|x64
{508A823C-8EAB-4C56-9DFE-4D85B0D24491}.Release Static|Win32.ActiveCfg = Release Static|Win32
{508A823C-8EAB-4C56-9DFE-4D85B0D24491}.Release Static|Win32.Build.0 = Release Static|Win32
{508A823C-8EAB-4C56-9DFE-4D85B0D24491}.Release Static|x64.ActiveCfg = Release Static|x64
{508A823C-8EAB-4C56-9DFE-4D85B0D24491}.Release Static|x64.Build.0 = Release Static|x64
{1B9223C8-DE20-4538-8214-776C6017D22B}.Debug|Win32.ActiveCfg = Debug|Win32
{1B9223C8-DE20-4538-8214-776C6017D22B}.Debug|Win32.Build.0 = Debug|Win32
{1B9223C8-DE20-4538-8214-776C6017D22B}.Debug|x64.ActiveCfg = Debug|x64
{1B9223C8-DE20-4538-8214-776C6017D22B}.Debug|x64.Build.0 = Debug|x64
{1B9223C8-DE20-4538-8214-776C6017D22B}.Release Static|Win32.ActiveCfg = Release Static|Win32
{1B9223C8-DE20-4538-8214-776C6017D22B}.Release Static|Win32.Build.0 = Release Static|Win32
{1B9223C8-DE20-4538-8214-776C6017D22B}.Release Static|x64.ActiveCfg = Release Static|x64
{1B9223C8-DE20-4538-8214-776C6017D22B}.Release Static|x64.Build.0 = Release Static|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libotf", "otflib\libotf_vs08.vcproj", "{6B9B49C9-75CD-400D-B736-5EACA04D0A82}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "otfaux", "tools\otfaux\otfaux_vs08.vcproj", "{24587836-ED5E-49DF-A7AD-419FDC208C08}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "otfcompress", "tools\otfcompress\otfcompress_vs08.vcproj", "{B6BBC220-1492-4BEA-A299-9D062133ABAA}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "otfdump", "tools\otfdump\otfdump_vs08.vcproj", "{508A823C-8EAB-4C56-9DFE-4D85B0D24491}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "otfmerge", "tools\otfmerge\otfmerge_vs08.vcproj", "{1B9223C8-DE20-4538-8214-776C6017D22B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release Static|Win32 = Release Static|Win32
Release Static|x64 = Release Static|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6B9B49C9-75CD-400D-B736-5EACA04D0A82}.Debug|Win32.ActiveCfg = Debug|Win32
{6B9B49C9-75CD-400D-B736-5EACA04D0A82}.Debug|Win32.Build.0 = Debug|Win32
{6B9B49C9-75CD-400D-B736-5EACA04D0A82}.Debug|x64.ActiveCfg = Debug|x64
{6B9B49C9-75CD-400D-B736-5EACA04D0A82}.Debug|x64.Build.0 = Debug|x64
{6B9B49C9-75CD-400D-B736-5EACA04D0A82}.Release Static|Win32.ActiveCfg = Release Static|Win32
{6B9B49C9-75CD-400D-B736-5EACA04D0A82}.Release Static|Win32.Build.0 = Release Static|Win32
{6B9B49C9-75CD-400D-B736-5EACA04D0A82}.Release Static|x64.ActiveCfg = Release Static|x64
{6B9B49C9-75CD-400D-B736-5EACA04D0A82}.Release Static|x64.Build.0 = Release Static|x64
{24587836-ED5E-49DF-A7AD-419FDC208C08}.Debug|Win32.ActiveCfg = Debug|Win32
{24587836-ED5E-49DF-A7AD-419FDC208C08}.Debug|Win32.Build.0 = Debug|Win32
{24587836-ED5E-49DF-A7AD-419FDC208C08}.Debug|x64.ActiveCfg = Debug|x64
{24587836-ED5E-49DF-A7AD-419FDC208C08}.Debug|x64.Build.0 = Debug|x64
{24587836-ED5E-49DF-A7AD-419FDC208C08}.Release Static|Win32.ActiveCfg = Release Static|Win32
{24587836-ED5E-49DF-A7AD-419FDC208C08}.Release Static|Win32.Build.0 = Release Static|Win32
{24587836-ED5E-49DF-A7AD-419FDC208C08}.Release Static|x64.ActiveCfg = Release Static|x64
{24587836-ED5E-49DF-A7AD-419FDC208C08}.Release Static|x64.Build.0 = Release Static|x64
{B6BBC220-1492-4BEA-A299-9D062133ABAA}.Debug|Win32.ActiveCfg = Debug|Win32
{B6BBC220-1492-4BEA-A299-9D062133ABAA}.Debug|Win32.Build.0 = Debug|Win32
{B6BBC220-1492-4BEA-A299-9D062133ABAA}.Debug|x64.ActiveCfg = Debug|x64
{B6BBC220-1492-4BEA-A299-9D062133ABAA}.Debug|x64.Build.0 = Debug|x64
{B6BBC220-1492-4BEA-A299-9D062133ABAA}.Release Static|Win32.ActiveCfg = Release Static|Win32
{B6BBC220-1492-4BEA-A299-9D062133ABAA}.Release Static|Win32.Build.0 = Release Static|Win32
{B6BBC220-1492-4BEA-A299-9D062133ABAA}.Release Static|x64.ActiveCfg = Release Static|x64
{B6BBC220-1492-4BEA-A299-9D062133ABAA}.Release Static|x64.Build.0 = Release Static|x64
{508A823C-8EAB-4C56-9DFE-4D85B0D24491}.Debug|Win32.ActiveCfg = Debug|Win32
{508A823C-8EAB-4C56-9DFE-4D85B0D24491}.Debug|Win32.Build.0 = Debug|Win32
{508A823C-8EAB-4C56-9DFE-4D85B0D24491}.Debug|x64.ActiveCfg = Debug|x64
{508A823C-8EAB-4C56-9DFE-4D85B0D24491}.Debug|x64.Build.0 = Debug|x64
{508A823C-8EAB-4C56-9DFE-4D85B0D24491}.Release Static|Win32.ActiveCfg = Release Static|Win32
{508A823C-8EAB-4C56-9DFE-4D85B0D24491}.Release Static|Win32.Build.0 = Release Static|Win32
{508A823C-8EAB-4C56-9DFE-4D85B0D24491}.Release Static|x64.ActiveCfg = Release Static|x64
{508A823C-8EAB-4C56-9DFE-4D85B0D24491}.Release Static|x64.Build.0 = Release Static|x64
{1B9223C8-DE20-4538-8214-776C6017D22B}.Debug|Win32.ActiveCfg = Debug|Win32
{1B9223C8-DE20-4538-8214-776C6017D22B}.Debug|Win32.Build.0 = Debug|Win32
{1B9223C8-DE20-4538-8214-776C6017D22B}.Debug|x64.ActiveCfg = Debug|x64
{1B9223C8-DE20-4538-8214-776C6017D22B}.Debug|x64.Build.0 = Debug|x64
{1B9223C8-DE20-4538-8214-776C6017D22B}.Release Static|Win32.ActiveCfg = Release Static|Win32
{1B9223C8-DE20-4538-8214-776C6017D22B}.Release Static|Win32.Build.0 = Release Static|Win32
{1B9223C8-DE20-4538-8214-776C6017D22B}.Release Static|x64.ActiveCfg = Release Static|x64
{1B9223C8-DE20-4538-8214-776C6017D22B}.Release Static|x64.Build.0 = Release Static|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
This diff is collapsed.
#ifndef DEF_SHADER
#define DEF_SHADER
//#include <GL/glew.h>
#include "common/common.hpp"
// Includes communs
#include <iostream>
#include <string>
#include <fstream>
// Classe Shader
class Shader
{
public:
/* Default constructor*/
Shader();
/*Constructor for shaders using textures. Parameter n is not used, it just allow to create a have another constructor. */
Shader(int glsl, int n);
/* Construct a Shader reading colors in the VBO. Still used for containers and selection*/
Shader(int glsl);
/* Construct Shaders we use for entities
param glsl says which version of GL Shading Language we are using
param rgb define the color
param shade should be true for states, false either*/
Shader(int glsl, Element_col, Element_col, Element_col, bool);
//Destructor
~Shader();
Shader& operator=(Shader const &shaderACopier);
/*Loading function*/
bool charger();
/*Compilation function*/
bool compilerShader(GLuint &shader, GLenum type, const std::string &code);
/*Getter*/
GLuint getProgramID() const;
private:
GLuint m_vertexID {0};
GLuint m_fragmentID {0};
GLuint m_programID {0};
std::string m_vertex_code;
std::string m_fragment_code;
};
#endif
#ifndef DEF_SHADER
#define DEF_SHADER
//#include <GL/glew.h>
#include "common/common.hpp"
// Includes communs
#include <iostream>
#include <string>
#include <fstream>
// Classe Shader
class Shader
{
public:
/* Default constructor*/
Shader();
/*Constructor for shaders using textures. Parameter n is not used, it just allow to create a have another constructor. */
Shader(int glsl, int n);
/* Construct a Shader reading colors in the VBO. Still used for containers and selection*/
Shader(int glsl);
/* Construct Shaders we use for entities
param glsl says which version of GL Shading Language we are using
param rgb define the color
param shade should be true for states, false either*/
Shader(int glsl, Element_col, Element_col, Element_col, bool);
//Destructor
~Shader();
Shader& operator=(Shader const &shaderACopier);
/*Loading function*/
bool charger();
/*Compilation function*/
bool compilerShader(GLuint &shader, GLenum type, const std::string &code);
/*Getter*/
GLuint getProgramID() const;
private:
GLuint m_vertexID {0};
GLuint m_fragmentID {0};
GLuint m_programID {0};
std::string m_vertex_code;
std::string m_fragment_code;
};
#endif
#version 330 core
// Interpolated values from the vertex shaders
in vec2 UV;
// Ouput data
out vec4 color;
// Values that stay constant for the whole mesh.
uniform sampler2D myTextureSampler;
void main(){
color = texture2D( myTextureSampler, UV );
#version 330 core
// Interpolated values from the vertex shaders
in vec2 UV;
// Ouput data
out vec4 color;
// Values that stay constant for the whole mesh.
uniform sampler2D myTextureSampler;
void main(){
color = texture2D( myTextureSampler, UV );
}
\ No newline at end of file
#version 330 core
// Input vertex data, different for all executions of this shader.
layout(location = 0) in vec2 vertexPosition_screenspace;
layout(location = 1) in vec2 vertexUV;
// Output data ; will be interpolated for each fragment.
out vec2 UV;
void main(){
// Output position of the vertex, in clip space
// map [0..800][0..600] to [-1..1][-1..1]
vec2 vertexPosition_homoneneousspace = vertexPosition_screenspace - vec2(400,300); // [0..800][0..600] -> [-400..400][-300..300]
vertexPosition_homoneneousspace /= vec2(400,300);
gl_Position = vec4(vertexPosition_homoneneousspace,0,1);
// UV of the vertex. No special space for this one.
UV = vertexUV;
}
#version 330 core
// Input vertex data, different for all executions of this shader.
layout(location = 0) in vec2 vertexPosition_screenspace;
layout(location = 1) in vec2 vertexUV;
// Output data ; will be interpolated for each fragment.
out vec2 UV;
void main(){
// Output position of the vertex, in clip space
// map [0..800][0..600] to [-1..1][-1..1]
vec2 vertexPosition_homoneneousspace = vertexPosition_screenspace - vec2(400,300); // [0..800][0..600] -> [-400..400][-300..300]
vertexPosition_homoneneousspace /= vec2(400,300);
gl_Position = vec4(vertexPosition_homoneneousspace,0,1);
// UV of the vertex. No special space for this one.
UV = vertexUV;
}
#include <vector>
#include <cstring>
#include <GL/glew.h>
#define GLM_FORCE_RADIANS
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
using namespace glm;
#include "Shader.hpp"
#include "texture.hpp"
#include "text2D.hpp"
unsigned int Text2DTextureID;
unsigned int Text2DVertexBufferID;
unsigned int Text2DUVBufferID;
Shader* _shader;
unsigned int Text2DUniformID;
void initText2D(const char * texturePath){
// Initialize texture
Text2DTextureID = loadDDS(texturePath);
// Initialize VBO
glGenBuffers(1, &Text2DVertexBufferID);
glGenBuffers(1, &Text2DUVBufferID);
// Initialize Shader
_shader = new Shader("TextVertexShader.vertexshader", "TextVertexShader.fragmentshader");
_shader->charger();
// Initialize uniforms' IDs
Text2DUniformID = glGetUniformLocation( _shader->getProgramID(), "myTextureSampler" );
}
void printText2D(const char * text, int x, int y, int size, glm::mat4 projection, glm::mat4 modelview){
unsigned int length = strlen(text);
// Fill buffers
std::vector<glm::vec2> vertices;
std::vector<glm::vec2> UVs;
for ( unsigned int i=0 ; i<length ; i++ ){
glm::vec2 vertex_up_left = glm::vec2( x+i*size , y+size );
glm::vec2 vertex_up_right = glm::vec2( x+i*size+size, y+size );
glm::vec2 vertex_down_right = glm::vec2( x+i*size+size, y-size );
glm::vec2 vertex_down_left = glm::vec2( x+i*size , y-size );
vertices.push_back(vertex_up_left );
vertices.push_back(vertex_down_left );
vertices.push_back(vertex_up_right );
vertices.push_back(vertex_down_right);
vertices.push_back(vertex_up_right);
vertices.push_back(vertex_down_left);
char character = text[i];
float uv_x = (character%16)/16.0f;
float uv_y = (character/16)/16.0f;
glm::vec2 uv_up_left = glm::vec2( uv_x , uv_y );
glm::vec2 uv_up_right = glm::vec2( uv_x+1.0f/16.0f, uv_y );
glm::vec2 uv_down_right = glm::vec2( uv_x+1.0f/16.0f, (uv_y + 1.0f/16.0f) );
glm::vec2 uv_down_left = glm::vec2( uv_x , (uv_y + 1.0f/16.0f) );
UVs.push_back(uv_up_left );
UVs.push_back(uv_down_left );
UVs.push_back(uv_up_right );
UVs.push_back(uv_down_right);
UVs.push_back(uv_up_right);
UVs.push_back(uv_down_left);
}
glBindBuffer(GL_ARRAY_BUFFER, Text2DVertexBufferID);
glBufferData(GL_ARRAY_BUFFER, vertices.size() * sizeof(glm::vec2), &vertices[0], GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, Text2DUVBufferID);
glBufferData(GL_ARRAY_BUFFER, UVs.size() * sizeof(glm::vec2), &UVs[0], GL_STATIC_DRAW);
// Bind shader
glUseProgram(_shader->getProgramID());
// Bind texture
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, Text2DTextureID);
// Set our "myTextureSampler" sampler to user Texture Unit 0
glUniform1i(Text2DUniformID, 0);
glUniformMatrix4fv(glGetUniformLocation(_shader->getProgramID(), "modelview"), 1, GL_FALSE, glm::value_ptr(modelview));
glUniformMatrix4fv(glGetUniformLocation(_shader->getProgramID(), "projection"), 1, GL_FALSE, glm::value_ptr(projection));
// 1rst attribute buffer : vertices
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, Text2DVertexBufferID);
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, (void*)0 );
// 2nd attribute buffer : UVs
glEnableVertexAttribArray(1);
glBindBuffer(GL_ARRAY_BUFFER, Text2DUVBufferID);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0, (void*)0 );
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// Draw call
glDrawArrays(GL_TRIANGLES, 0, vertices.size() );
glDisable(GL_BLEND);
glDisableVertexAttribArray(0);
glDisableVertexAttribArray(1);
}
void cleanupText2D(){
// Delete buffers
glDeleteBuffers(1, &Text2DVertexBufferID);
glDeleteBuffers(1, &Text2DUVBufferID);
// Delete texture
glDeleteTextures(1, &Text2DTextureID);
// Delete shader
glDeleteProgram(_shader->getProgramID());
}
#include <vector>
#include <cstring>
#include <GL/glew.h>
#define GLM_FORCE_RADIANS
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
using namespace glm;
#include "Shader.hpp"
#include "texture.hpp"
#include "text2D.hpp"
unsigned int Text2DTextureID;
unsigned int Text2DVertexBufferID;
unsigned int Text2DUVBufferID;
Shader* _shader;
unsigned int Text2DUniformID;
void initText2D(const char * texturePath){
// Initialize texture
Text2DTextureID = loadDDS(texturePath);
// Initialize VBO
glGenBuffers(1, &Text2DVertexBufferID);
glGenBuffers(1, &Text2DUVBufferID);
// Initialize Shader
_shader = new Shader("TextVertexShader.vertexshader", "TextVertexShader.fragmentshader");
_shader->charger();
// Initialize uniforms' IDs
Text2DUniformID = glGetUniformLocation( _shader->getProgramID(), "myTextureSampler" );
}
void printText2D(const char * text, int x, int y, int size, glm::mat4 projection, glm::mat4 modelview){
unsigned int length = strlen(text);
// Fill buffers
std::vector<glm::vec2> vertices;
std::vector<glm::vec2> UVs;
for ( unsigned int i=0 ; i<length ; i++ ){
glm::vec2 vertex_up_left = glm::vec2( x+i*size , y+size );
glm::vec2 vertex_up_right = glm::vec2( x+i*size+size, y+size );
glm::vec2 vertex_down_right = glm::vec2( x+i*size+size, y-size );
glm::vec2 vertex_down_left = glm::vec2( x+i*size , y-size );
vertices.push_back(vertex_up_left );
vertices.push_back(vertex_down_left );
vertices.push_back(vertex_up_right );
vertices.push_back(vertex_down_right);
vertices.push_back(vertex_up_right);
vertices.push_back(vertex_down_left);
char character = text[i];
float uv_x = (character%16)/16.0f;
float uv_y = (character/16)/16.0f;
glm::vec2 uv_up_left = glm::vec2( uv_x , uv_y );
glm::vec2 uv_up_right = glm::vec2( uv_x+1.0f/16.0f, uv_y );
glm::vec2 uv_down_right = glm::vec2( uv_x+1.0f/16.0f, (uv_y + 1.0f/16.0f) );
glm::vec2 uv_down_left = glm::vec2( uv_x , (uv_y + 1.0f/16.0f) );
UVs.push_back(uv_up_left );
UVs.push_back(uv_down_left );
UVs.push_back(uv_up_right );
UVs.push_back(uv_down_right);
UVs.push_back(uv_up_right);
UVs.push_back(uv_down_left);
}
glBindBuffer(GL_ARRAY_BUFFER, Text2DVertexBufferID);
glBufferData(GL_ARRAY_BUFFER, vertices.size() * sizeof(glm::vec2), &vertices[0], GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, Text2DUVBufferID);
glBufferData(GL_ARRAY_BUFFER, UVs.size() * sizeof(glm::vec2), &UVs[0], GL_STATIC_DRAW);
// Bind shader
glUseProgram(_shader->getProgramID());
// Bind texture
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, Text2DTextureID);
// Set our "myTextureSampler" sampler to user Texture Unit 0
glUniform1i(Text2DUniformID, 0);
glUniformMatrix4fv(glGetUniformLocation(_shader->getProgramID(), "modelview"), 1, GL_FALSE, glm::value_ptr(modelview));
glUniformMatrix4fv(glGetUniformLocation(_shader->getProgramID(), "projection"), 1, GL_FALSE, glm::value_ptr(projection));
// 1rst attribute buffer : vertices
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, Text2DVertexBufferID);
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, (void*)0 );
// 2nd attribute buffer : UVs
glEnableVertexAttribArray(1);
glBindBuffer(GL_ARRAY_BUFFER, Text2DUVBufferID);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0, (void*)0 );
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// Draw call
glDrawArrays(GL_TRIANGLES, 0, vertices.size() );
glDisable(GL_BLEND);
glDisableVertexAttribArray(0);
glDisableVertexAttribArray(1);
}
void cleanupText2D(){
// Delete buffers
glDeleteBuffers(1, &Text2DVertexBufferID);
glDeleteBuffers(1, &Text2DUVBufferID);
// Delete texture
glDeleteTextures(1, &Text2DTextureID);
// Delete shader
glDeleteProgram(_shader->getProgramID());
}
#ifndef TEXT2D_HPP
#define TEXT2D_HPP
void initText2D(const char * texturePath);
void printText2D(const char * text, int x, int y, int size, glm::mat4, glm::mat4);
void cleanupText2D();
#endif
#ifndef TEXT2D_HPP
#define TEXT2D_HPP
void initText2D(const char * texturePath);
void printText2D(const char * text, int x, int y, int size, glm::mat4, glm::mat4);
void cleanupText2D();
#endif
This diff is collapsed.
#ifndef TEXTURE_HPP
#define TEXTURE_HPP
// Load a .BMP file using our custom loader
//GLuint loadBMP_custom(const char * imagepath);
//// Since GLFW 3, glfwLoadTexture2D() has been removed. You have to use another texture loading library,
//// or do it yourself (just like loadBMP_custom and loadDDS)
//// Load a .TGA file using GLFW's own loader
//GLuint loadTGA_glfw(const char * imagepath);
// Load a .DDS file using GLFW's own loader
GLuint loadDDS(const char * imagepath);
#endif
#ifndef TEXTURE_HPP
#define TEXTURE_HPP
// Load a .BMP file using our custom loader
//GLuint loadBMP_custom(const char * imagepath);
//// Since GLFW 3, glfwLoadTexture2D() has been removed. You have to use another texture loading library,
//// or do it yourself (just like loadBMP_custom and loadDDS)
//// Load a .TGA file using GLFW's own loader
//GLuint loadTGA_glfw(const char * imagepath);
// Load a .DDS file using GLFW's own loader
GLuint loadDDS(const char * imagepath);
#endif
#pragma once
#include <boost/lexical_cast.hpp>
#include <boost/archive/basic_archive.hpp>
#include <boost/archive/archive_exception.hpp>
namespace eos {
// this value is written to the top of the stream
const signed char magic_byte = 'e' | 'o' | 's';
// flag for fp serialization
const unsigned no_infnan = 64;
// integral type for the archive version
#if BOOST_VERSION < 104400
typedef boost::archive::version_type archive_version_type;
#else
typedef boost::archive::library_version_type archive_version_type;
#endif
// version of the linked boost archive library
const archive_version_type archive_version(
#if BOOST_VERSION < 103700
boost::archive::ARCHIVE_VERSION()
#else
boost::archive::BOOST_ARCHIVE_VERSION()
#endif
);
/**
* \brief Exception being thrown when serialization cannot proceed.
*
* There are several situations in which the portable archives may fail and
* hence throw an exception:
* -# deserialization of an integer value that exceeds the range of the type
* -# (de)serialization of inf/nan through an archive with no_infnan flag set
* -# deserialization of a denormalized value without the floating point type
* supporting denormalized numbers
*
* Note that this exception will also be thrown if you mixed up your stream
* position and accidentially interpret some value for size data (in this case
* the reported size will be totally amiss most of the time).
*/
class portable_archive_exception : public boost::archive::archive_exception
{
std::string msg;
public:
//! type size is not large enough for deserialized number
portable_archive_exception(signed char invalid_size)
: boost::archive::archive_exception(other_exception)
, msg("requested integer size exceeds type size: ")
{
msg += boost::lexical_cast<std::string, int>(invalid_size);
}
//! negative number in unsigned type
portable_archive_exception()
: <