update
This commit is contained in:
parent
840e2ebe30
commit
ddcec9cb64
@ -4,6 +4,10 @@
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <glpy.h>
|
||||
|
||||
static int CreateShader(const std::string& vertexShader, const std::string& fragmentShader){
|
||||
unsigned int program = glCreateProgram();
|
||||
unsigned int vs = glCreateShader(GL_VERTEX_SHADER);
|
||||
}
|
||||
|
||||
int tests::glfw_window(unsigned width,unsigned height, std::string title)
|
||||
{
|
||||
@ -28,17 +32,35 @@ int tests::glfw_window(unsigned width,unsigned height, std::string title)
|
||||
|
||||
std::cout<<"-- OPEN_GL_VERSION: "<<glGetString(GL_VERSION)<<std::endl;
|
||||
|
||||
float positions[6] = {
|
||||
-0.5f,-0.5f,
|
||||
0.0f, 0.5f,
|
||||
0.5f,-0.5f,
|
||||
};
|
||||
|
||||
unsigned int buffer;
|
||||
glGenBuffers(1,&buffer);
|
||||
glBindBuffer(GL_ARRAY_BUFFER,buffer);
|
||||
glBufferData(GL_ARRAY_BUFFER,6 * sizeof(float),positions,GL_STATIC_DRAW);
|
||||
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0,2,GL_FLOAT,GL_FALSE,2*sizeof(float),0);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER,0);
|
||||
|
||||
/* Loop until the user closes the window */
|
||||
while (!glfwWindowShouldClose(window))
|
||||
{
|
||||
/* Render here */
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
glVertex2f(-0.5f,-0.5f);
|
||||
glVertex2f(0.0f,0.5f);
|
||||
glVertex2f(0.5f,-0.5f);
|
||||
glEnd();
|
||||
//create a triangle
|
||||
glDrawArrays(GL_TRIANGLES,0, 3);
|
||||
// glBegin(GL_TRIANGLES);
|
||||
// glVertex2f(-0.5f,-0.5f);
|
||||
// glVertex2f(0.0f,0.5f );
|
||||
// glVertex2f(0.5f,-0.5f);
|
||||
// glEnd();
|
||||
|
||||
/* Swap front and back buffers */
|
||||
glfwSwapBuffers(window);
|
||||
|
Loading…
Reference in New Issue
Block a user