Got some geometry up and rotating. It will be pretty trivial to pass in
the camera rotation now and have it follow along.
This commit is contained in:
@@ -2,6 +2,18 @@
|
||||
|
||||
GL_Testing::GL_Testing() {
|
||||
|
||||
GLfloat tmp[] = {
|
||||
|
||||
1, 0, 0, 0,
|
||||
0, cos(1), sin(1), 0,
|
||||
0, -sin(1), cos(1), 0,
|
||||
0, 0, 0, 1
|
||||
|
||||
};
|
||||
|
||||
matrix = new GLfloat[16];
|
||||
memcpy(matrix, tmp, sizeof(GLfloat) * 16);
|
||||
|
||||
GLint err = glewInit();
|
||||
|
||||
if (err) {
|
||||
@@ -12,7 +24,6 @@ GL_Testing::GL_Testing() {
|
||||
|
||||
void GL_Testing::compile_shader(std::string file_path, Shader_Type t) {
|
||||
|
||||
|
||||
|
||||
// Load in the source and cstring it
|
||||
const char* source;
|
||||
@@ -107,6 +118,31 @@ void GL_Testing::create_buffers() {
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
|
||||
void GL_Testing::transform()
|
||||
{
|
||||
GLuint transformLoc = glGetUniformLocation(shader_program, "transform");
|
||||
|
||||
glUseProgram(shader_program);
|
||||
glUniformMatrix4fv(transformLoc, 1, GL_FALSE, matrix);
|
||||
}
|
||||
|
||||
void GL_Testing::rotate(double delta) {
|
||||
|
||||
counter += delta;
|
||||
|
||||
GLfloat tmp[] = {
|
||||
|
||||
1, 0, 0, 0,
|
||||
0, cos(counter), sin(counter), 0,
|
||||
0, -sin(counter), cos(counter), 0,
|
||||
0, 0, 0, 1
|
||||
|
||||
};
|
||||
|
||||
memcpy(matrix, tmp, sizeof(GLfloat) * 16);
|
||||
|
||||
}
|
||||
|
||||
void GL_Testing::draw() {
|
||||
|
||||
glUseProgram(shader_program);
|
||||
|
||||
@@ -73,6 +73,7 @@ int main() {
|
||||
t.compile_shader("../shaders/passthrough.vert", GL_Testing::Shader_Type::VERTEX);
|
||||
t.create_program();
|
||||
t.create_buffers();
|
||||
t.transform();
|
||||
|
||||
// Initialize the raycaster hardware, compat, or software
|
||||
RayCaster *rc = new Hardware_Caster();
|
||||
@@ -231,9 +232,12 @@ int main() {
|
||||
|
||||
window.popGLStates();
|
||||
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||
//glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||
t.rotate(delta_time);
|
||||
t.transform();
|
||||
t.draw();
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
|
||||
//glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
|
||||
window.pushGLStates();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user