X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=init.cpp;h=b7604e4333979bcd2faa3b06f9bb46864bee8db6;hb=d398770154ecc4bc95282dc45656789dd5686309;hp=4003163d9494843b3eccc42910ca41084b52a691;hpb=92573f7be18bfca16dd3292cbe536d7d7912198f;p=movit diff --git a/init.cpp b/init.cpp index 4003163..b7604e4 100644 --- a/init.cpp +++ b/init.cpp @@ -101,28 +101,23 @@ void measure_texel_subpixel_precision() 0.25f, 0.0f }; - int position_attrib = glGetAttribLocation(glsl_program_num, "position"); - assert(position_attrib != -1); - int texcoord_attrib = glGetAttribLocation(glsl_program_num, "texcoord"); - assert(texcoord_attrib != -1); - glEnableVertexAttribArray(position_attrib); + GLuint vao; + glGenVertexArrays(1, &vao); check_error(); - glVertexAttribPointer(position_attrib, 2, GL_FLOAT, GL_FALSE, 0, vertices); - check_error(); - glEnableVertexAttribArray(texcoord_attrib); - check_error(); - glVertexAttribPointer(texcoord_attrib, 2, GL_FLOAT, GL_FALSE, 0, texcoords); + glBindVertexArray(vao); check_error(); + GLuint position_vbo = fill_vertex_attribute(glsl_program_num, "position", 2, GL_FLOAT, sizeof(vertices), vertices); + GLuint texcoord_vbo = fill_vertex_attribute(glsl_program_num, "texcoord", 2, GL_FLOAT, sizeof(texcoords), texcoords); + glDrawArrays(GL_QUADS, 0, 4); check_error(); + cleanup_vertex_attribute(glsl_program_num, "position", position_vbo); + cleanup_vertex_attribute(glsl_program_num, "texcoord", texcoord_vbo); + glUseProgram(0); check_error(); - glDisableVertexAttribArray(position_attrib); - check_error(); - glDisableVertexAttribArray(texcoord_attrib); - check_error(); // Now read the data back and see what the card did. // (We only look at the red channel; the others will surely be the same.) @@ -153,6 +148,8 @@ void measure_texel_subpixel_precision() check_error(); resource_pool.release_glsl_program(glsl_program_num); + glDeleteVertexArrays(1, &vao); + check_error(); } void measure_roundoff_problems() @@ -230,25 +227,24 @@ void measure_roundoff_problems() 0.75f, 0.0f, 0.25f, 0.0f }; - int position_attrib = glGetAttribLocation(glsl_program_num, "position"); - assert(position_attrib != -1); - int texcoord_attrib = glGetAttribLocation(glsl_program_num, "texcoord"); - assert(texcoord_attrib != -1); - glEnableVertexAttribArray(position_attrib); - check_error(); - glVertexAttribPointer(position_attrib, 2, GL_FLOAT, GL_FALSE, 0, vertices); - check_error(); - glEnableVertexAttribArray(texcoord_attrib); + + GLuint vao; + glGenVertexArrays(1, &vao); check_error(); - glVertexAttribPointer(texcoord_attrib, 2, GL_FLOAT, GL_FALSE, 0, texcoords); + glBindVertexArray(vao); check_error(); + + GLuint position_vbo = fill_vertex_attribute(glsl_program_num, "position", 2, GL_FLOAT, sizeof(vertices), vertices); + GLuint texcoord_vbo = fill_vertex_attribute(glsl_program_num, "texcoord", 2, GL_FLOAT, sizeof(texcoords), texcoords); + glDrawArrays(GL_QUADS, 0, 4); + check_error(); + + cleanup_vertex_attribute(glsl_program_num, "position", position_vbo); + cleanup_vertex_attribute(glsl_program_num, "texcoord", texcoord_vbo); glUseProgram(0); check_error(); - glDisableVertexAttribArray(position_attrib); - check_error(); - glDisableVertexAttribArray(texcoord_attrib); // Now read the data back and see what the card did. (Ignore the last value.) // (We only look at the red channel; the others will surely be the same.) @@ -281,6 +277,8 @@ void measure_roundoff_problems() check_error(); resource_pool.release_glsl_program(glsl_program_num); + glDeleteVertexArrays(1, &vao); + check_error(); } bool check_extensions()