1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
|
diff --git a/GLSLProgram.cpp b/GLSLProgram.cpp
index 8ee16d8..6ddd32f 100644
--- a/GLSLProgram.cpp
+++ b/GLSLProgram.cpp
@@ -33,11 +33,6 @@ void GLSLProgram::linkShaders()
glGetProgramiv(programID, GL_LINK_STATUS, &isLinked) ;
if(isLinked != GL_TRUE)
{
- glDeleteProgram(programID) ;
- glDetachShader(programID, vertexID) ;
- glDetachShader(programID, fragmentID) ;
- glDeleteShader(vertexID) ;
- glDeleteShader(fragmentID) ;
/* Récupération des log */
GLchar *infoLog = nullptr ;
@@ -47,11 +42,17 @@ void GLSLProgram::linkShaders()
if(!infoLog){return ;}
glGetProgramInfoLog(programID, infoLogLenth, &infoLogLenth, infoLog) ;
- std::cout << infoLog << '\n' ;
+ std::cout << "error "<< '\n';
+ std::cout << infoLog << '\n' ;
std::cout << __FILE__ << __LINE__ << '\n' ;
std::cout << "Impossible de linker le Program !\n" ;
delete [] infoLog ;
+ glDeleteProgram(programID) ;
+ glDetachShader(programID, vertexID) ;
+ glDetachShader(programID, fragmentID) ;
+ glDeleteShader(vertexID) ;
+ glDeleteShader(fragmentID) ;
return ;
}
@@ -59,7 +60,6 @@ void GLSLProgram::linkShaders()
glDetachShader(programID, fragmentID) ;
}
-
void GLSLProgram::addAttribute(const std::string &attributeName)
{
glBindAttribLocation(programID, numAtrrib, attributeName.c_str()) ;
diff --git a/GLSLProgram.hpp b/GLSLProgram.hpp
index 2f5b105..e90c008 100644
--- a/GLSLProgram.hpp
+++ b/GLSLProgram.hpp
@@ -3,6 +3,7 @@
#include <GL/glew.h>
#include <iostream>
+#include <string>
class GLSLProgram
{
@@ -23,7 +24,6 @@ public:
void addAttribute(const std::string &attributeName) ;
void compileShaders(const std::string &vertexShaderFilePath, const std::string &fragmentShaderFilePath) ;
void linkShaders() ;
-
inline void use()
{
glUseProgram(programID);
diff --git a/mainGame.hpp b/mainGame.hpp
index 358ead1..430bcc8 100644
--- a/mainGame.hpp
+++ b/mainGame.hpp
@@ -6,7 +6,7 @@
#include <SDL2/SDL.h>
#include "sprite.hpp"
#include "GLSLProgram.hpp"
-#include "../../../Documents/2015-2016/C++/Game Programming/SDL2/Labo/essential/timer.hxx"
+//#include "../../../Documents/2015-2016/C++/Game Programming/SDL2/Labo/essential/timer.hxx"
#define RED glColor3f(1.0f, 0.0f, 0.0f)
#define GREEN glColor3f(0.0f, 1.0f, 0.0f)
@@ -32,7 +32,7 @@ private:
GLSLProgram colorShader ;
/*Un chrono pour la gestion des FPS*/
- Timer fps ;
+ // Timer fps ;
/* Le Gamestate*/
GAMESTATE mstate ;
@@ -73,7 +73,7 @@ public:
} ;
MainGame::MainGame(std::string label, int w, int h):
- mLabel(label), width(w), height(h), m_sprite(), fps()
+ mLabel(label), width(w), height(h), m_sprite()
{
mWindow = nullptr ;
glContext = nullptr ;
@@ -121,9 +121,9 @@ bool MainGame::initSystems()
return false ;
}
- GLuint VertexArrayID;
- glGenVertexArrays(1, &VertexArrayID);
- glBindVertexArray(VertexArrayID);
+ //GLuint VertexArrayID;
+ //glGenVertexArrays(1, &VertexArrayID);
+ //glBindVertexArray(VertexArrayID);
// Attriubu pour activer opengl 3.1
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3) ;
@@ -131,7 +131,7 @@ bool MainGame::initSystems()
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1) ;
// Couleur de fond
- glClearColor(1, 0, 1, 0) ;
+ glClearColor(1, 1, 1, 0) ;
// Initialisation du shader
initShader() ;
@@ -141,7 +141,7 @@ bool MainGame::initSystems()
void MainGame::initShader()
{
- colorShader.compileShaders("/home/jordy/Codes Sources/Game OGL/OpenGL/vertexShader.vert" ,"/home/jordy/Codes Sources/Game OGL/OpenGL/fragmentShader.frag") ;
+ colorShader.compileShaders("./vertexShader.vert" ,"./fragmentShader.frag") ;
colorShader.addAttribute("position") ;
colorShader.linkShaders() ;
}
@@ -154,10 +154,10 @@ void MainGame::drawGame()
glEnableClientState(GL_VERTEX_ARRAY) ;
colorShader.use() ;
-
m_sprite.Sprite_Draw() ;
colorShader.unse() ;
+ SDL_GL_SwapWindow(mWindow);
}
void MainGame::input()
@@ -191,7 +191,7 @@ void MainGame::gameLoop()
SDL_GL_SwapWindow(mWindow) ;
//std::cout << "Frame: " << frame << '\n' ;
}
- frame = (int) fps.Timer_GetTicks() ;
+ //frame = (int) fps.Timer_GetTicks() ;
}
}
@@ -202,7 +202,7 @@ void MainGame::run()
std::cout << "OPENGL: " << glGetString(GL_VERSION) << " GLSL " << glGetString(GL_SHADING_LANGUAGE_VERSION) << '\n' ;
/* Le conteur de FPS est activer*/
- fps.Timer_Start() ;
+ //fps.Timer_Start() ;
m_sprite.Sprite_Init(-1.0f, -1.0f, 1.0f, 1.0f) ;
diff --git a/sprite.cpp b/sprite.cpp
index 1ef0ae5..8903104 100644
--- a/sprite.cpp
+++ b/sprite.cpp
@@ -1,6 +1,5 @@
#include <iostream>
#include "sprite.hpp"
-
Sprite::~Sprite()
{
if(VBO)
@@ -62,7 +61,7 @@ void Sprite::Sprite_Draw()
glEnableVertexAttribArray(0) ;
- glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, vertice) ;
+ glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, 0) ;
glDrawArrays(GL_TRIANGLES, 0, 6) ;
diff --git a/vertexShader.vert b/vertexShader.vert
index c236b4c..f2677bc 100644
--- a/vertexShader.vert
+++ b/vertexShader.vert
@@ -2,10 +2,7 @@
// in: variables en entrée provenant de OpenGL
in vec2 position ;
-
void main()
{
- gl_Position.xy = position ;
- gl_Position.y = 0 ;
- gl_Position.w = 1.0 ;
+ gl_Position = vec4(position,0,1.0);
} |
Partager