This commit is contained in:
end 2016-09-27 21:28:26 +02:00
commit a46b410717
6 changed files with 33 additions and 10 deletions

View file

@ -84,11 +84,12 @@ class GameWindow : public endofthejedi::GLWindow {
m_renderer.drawCircle(pos.x, pos.y, 0.01, color.x, color.y, color.z, 6); m_renderer.drawCircle(pos.x, pos.y, 0.01, color.x, color.y, color.z, 6);
} }
void drawTrace(const game::Trace *trace) void drawTrace(const game::Trace *trace) {
{
for (const game::Trace::TracePoint &p : trace->points) { for (const game::Trace::TracePoint &p : trace->points) {
glm::vec3 color = glm::vec3(0.1, 0.3, 1.0) / (1.0f + 500.0f*p.speed); glm::vec3 color =
m_renderer.drawCircle(p.position.x, p.position.y, 0.005, color.x, color.y, color.z, 3); glm::vec3(0.1, 0.3, 1.0) / (1.0f + 500.0f * p.speed);
m_renderer.drawCircle(p.position.x, p.position.y, 0.005, color.x,
color.y, color.z, 3);
} }
} }

View file

@ -27,17 +27,34 @@ bool endofthejedi::Shader::check() {
glGetProgramiv(m_program, GL_LINK_STATUS, &result); glGetProgramiv(m_program, GL_LINK_STATUS, &result);
glGetProgramiv(m_program, GL_INFO_LOG_LENGTH, &len); glGetProgramiv(m_program, GL_INFO_LOG_LENGTH, &len);
if (len > 1) { if (len > 1) {
char* error = (char*)malloc(len); char *error = (char *)malloc(len);
glGetProgramInfoLog(m_program, len, NULL, error); glGetProgramInfoLog(m_program, len, NULL, error);
std::string str(error); std::string str(error);
std::cout << str << "\n"; std::cout << str << "\n";
} }
std::cout << "checked program"
<< "\n";
return (bool)result; return (bool)result;
} }
bool endofthejedi::Shader::checkShader() { return false; } bool endofthejedi::Shader::checkShader(GLuint shader) {
GLint len = 0;
GLint result = 0;
glGetProgramiv(m_program, GL_LINK_STATUS, &result);
glGetProgramiv(m_program, GL_INFO_LOG_LENGTH, &len);
if (len > 1) {
char *error = (char *)malloc(len);
glGetShaderInfoLog(shader, 0, &len, error);
std::string str(error);
std::cout << str << "\n";
}
std::cout << "checked shader"
<< "\n";
return (bool)result;
}
void endofthejedi::Shader::bind() { glUseProgram(m_program); } void endofthejedi::Shader::bind() { glUseProgram(m_program); }
@ -48,8 +65,9 @@ void endofthejedi::Shader::load(std::string path, GLenum shadertype) {
const char *cheddardata = path.c_str(); const char *cheddardata = path.c_str();
glShaderSource(cheddar, 1, &cheddardata, NULL); glShaderSource(cheddar, 1, &cheddardata, NULL);
glCompileShader(cheddar); glCompileShader(cheddar);
checkShader(cheddar);
glAttachShader(m_program, cheddar); glAttachShader(m_program, cheddar);
glLinkProgram(m_program); glLinkProgram(m_program);
glDeleteShader(cheddar);
check(); check();
glDeleteShader(cheddar);
} }

View file

@ -44,7 +44,7 @@ class Shader {
private: private:
GLuint m_program; GLuint m_program;
bool check(); bool check();
bool checkShader(); bool checkShader(GLuint shader);
protected: protected:
public: public:
Shader(); Shader();

View file

@ -6,6 +6,8 @@
#include "game_window.hpp" #include "game_window.hpp"
#include "options.hpp" #include "options.hpp"
uint64_t optionsFlags;
using namespace std; using namespace std;
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {

View file

@ -10,7 +10,7 @@
#define SET_FLAG(x,y) optionsFlags&=(~((1)<<x));optionsFlags|=((y&1)<<x) #define SET_FLAG(x,y) optionsFlags&=(~((1)<<x));optionsFlags|=((y&1)<<x)
#define ISSET_FLAG(x) (optionsFlags&((1)<<x)) #define ISSET_FLAG(x) (optionsFlags&((1)<<x))
uint64_t optionsFlags; extern uint64_t optionsFlags;
/* /*
* usage: * usage:

View file

@ -10,6 +10,8 @@ static const char *fss =
endofthejedi::Renderer::Renderer() { endofthejedi::Renderer::Renderer() {
m_shader.load(vss, GL_VERTEX_SHADER); m_shader.load(vss, GL_VERTEX_SHADER);
m_shader.load(fss, GL_FRAGMENT_SHADER); m_shader.load(fss, GL_FRAGMENT_SHADER);
} }
endofthejedi::Renderer::~Renderer() {} endofthejedi::Renderer::~Renderer() {}