Open lfwin opened 1 year ago
I try to modify code '3_gl_intro_classic_triangle_vbo_shader.cpp' in example folder as following,
void sample() { pangolin::CreateWindowAndBind("Classic GL Triangle With VBO and Shader", 500, 500); // Build and compile our shader program // ------------------------------------ Shader shader("9.1.geometry_shader.vert", "9.1.geometry_shader.frag", "9.1.geometry_shader.geom"); float points[] = { -0.5f, 0.5f, 1.0f, 0.0f, 0.0f, // top-left 0.5f, 0.5f, 0.0f, 1.0f, 0.0f, // top-right 0.5f, -0.5f, 0.0f, 0.0f, 1.0f, // bottom-right -0.5f, -0.5f, 1.0f, 1.0f, 0.0f // bottom-left }; unsigned int VBO, VAO; glGenBuffers(1, &VBO); glGenVertexArrays(1, &VAO); glBindVertexArray(VAO); glBindBuffer(GL_ARRAY_BUFFER, VBO); glBufferData(GL_ARRAY_BUFFER, sizeof(points), &points, GL_STATIC_DRAW); glEnableVertexAttribArray(0); glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(float), 0); glEnableVertexAttribArray(1); glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (void*)(2 * sizeof(float))); glBindVertexArray(0); // Setup a variable to progress a simple animation as a function of time float time = 0.01f; while( !pangolin::ShouldQuit() ) { glClearColor(0.1f, 0.1f, 0.1f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); shader.use(); // Set our buffer as the current one for OpenGL glBindVertexArray(VAO); // This buffer contains floating point vertices with 3 dimensions. // They starts from the 0th element and are packed without padding. //glVertexPointer(3, GL_FLOAT, 0, 0); // Use Them! glEnableClientState(GL_VERTEX_ARRAY); //GLint u_time = glGetUniformLocation(shaderProgram, "u_time"); //glUniform1f( u_time, time); shader.setFloat("u_time", time); glDrawArrays(GL_POINTS, 0, 4); //pangolin::RenderVbo(VAO, GL_POINTS); // Disable the stuff we enabled... glDisableClientState(GL_VERTEX_ARRAY); glBindVertexArray(0); time += 0.01; pangolin::FinishFrame(); } // Deallocate the OpenGL buffer we made glDeleteVertexArrays(1, &VAO); glDeleteBuffers(1, &VBO); // Deallocate the GlSl Shader program // glDeleteProgram(shaderProgram); } int main( int /*argc*/, char** /*argv*/ ) { sample(); return 0; }
This just draw four points, but what i want to draw is 4 circles.
You seem to be using a different shader library, and you don't include the shader code, so I don't know that you'll be able to get much help here.
I try to modify code '3_gl_intro_classic_triangle_vbo_shader.cpp' in example folder as following,
This just draw four points, but what i want to draw is 4 circles.