Changeset 7280257 in opengl-game


Ignore:
Timestamp:
Apr 25, 2018, 12:39:01 AM (6 years ago)
Author:
Dmitry Portnoy <dmitry.portnoy@…>
Branches:
feature/imgui-sdl, master, points-test
Children:
05e43cf
Parents:
baa5848
Message:

Remove uniform buffer code until I figure out how to use it correctly.

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • color.vert

    rbaa5848 r7280257  
    11#version 410
    2 
    3 layout (std140) uniform model_block {
    4    mat4 M;
    5 };
    62
    73uniform mat4 model, view, proj;
  • new-game.cpp

    rbaa5848 r7280257  
    307307      vec3(points2[15], points2[16], points2[17]),
    308308   };
    309 
    310    int ubo_id = 0;
    311    GLuint ubo = 0;
    312    glGenBuffers(1, &ubo);
    313    glBindBuffer(GL_UNIFORM_BUFFER, ubo);
    314    glBufferData(GL_ARRAY_BUFFER, sizeof(float)*16*2, NULL, GL_STATIC_DRAW);
    315 
    316    glBindBufferBase(GL_UNIFORM_BUFFER, ubo_id, ubo);
    317    glBufferSubData(GL_UNIFORM_BUFFER, 0, sizeof(float) * 16, value_ptr(objects[0].model_mat));
    318    glBufferSubData(GL_UNIFORM_BUFFER, sizeof(float) * 16, sizeof(float) * 16, value_ptr(objects[1].model_mat));
    319309
    320310   GLuint points_vbo = 0;
     
    396386   GLuint shader_program2 = loadShaderProgram("./texture.vert", "./texture.frag");
    397387
    398    GLuint ub_index = glGetUniformBlockIndex(shader_program, "model_block");
    399    glUniformBlockBinding(shader_program, ub_index, ubo_id);
    400 
    401    GLuint ub_index2 = glGetUniformBlockIndex(shader_program2, "model_block");
    402    glUniformBlockBinding(shader_program2, ub_index2, ubo_id);
    403 
    404    cout << "Uniform Buffer Debugging" << endl;
    405    cout << "ubo: " << ubo << endl;
    406    cout << "ub_index: " << ub_index << endl;
    407    cout << "ub_index2: " << ub_index2 << endl;
    408 
    409388   float speed = 1.0f;
    410389   float last_position = 0.0f;
     
    453432   glUniformMatrix4fv(proj_test_loc, 1, GL_FALSE, value_ptr(proj_mat));
    454433
    455    glBindBufferRange(GL_UNIFORM_BUFFER, ub_index, ubo, 0, sizeof(float) * 16);
    456 
    457434   glUseProgram(shader_program2);
    458435   glUniformMatrix4fv(model_mat_loc, 1, GL_FALSE, value_ptr(objects[1].model_mat));
    459436   glUniformMatrix4fv(view_mat_loc, 1, GL_FALSE, value_ptr(view_mat));
    460437   glUniformMatrix4fv(proj_mat_loc, 1, GL_FALSE, value_ptr(proj_mat));
    461 
    462    glBindBufferRange(GL_UNIFORM_BUFFER, ub_index2, ubo, sizeof(float) * 16, sizeof(float) * 16);
    463438
    464439   objects[0].shader_program = shader_program;
  • opengl-notes.txt

    rbaa5848 r7280257  
    4040
    4141Camera position = (0, 0, 0)
     42
     43
     44BUFFER FUNCTIONS
     45-----------------
     46
     47glGenBuffers creates a buffer
     48glBindBuffer sets the currently active buffer
     49glBufferData populates the buffer with data
     50
     51glGenVertexArrays creates a vao
     52glBindVertexArray sets the currently active vao
     53glEnableVertexAttribArray sets the active index in the vao
     54glVertexAttribPointer determines the layout of a buffer in a VAO
     55   -The last params (often NULL), specifies the offset in the buffer
  • texture.vert

    rbaa5848 r7280257  
    11#version 410
    2 
    3 layout (std140) uniform model_block {
    4    mat4 M;
    5 };
    62
    73uniform mat4 model, view, proj;
Note: See TracChangeset for help on using the changeset viewer.