You are on page 1of 1

float positions[] = {

0.0f, 0.5f,
-0.5f, -0.5f,
0.5f, -0.5f
};

unsigned int indices[] = {


0, 1, 3,
1, 2, 3
};

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);

ShaderProgramSource source = ParseShader("res/shaders/Basic.shader");


std::cout << source.VertexSource << std::endl;
std::cout << source.FragmentSource << std::endl;

unsigned int shader = CreateShader(source.VertexSource, source.FragmentSource);


glUseProgram(shader);

/* Loop until the user closes the window */


while (!glfwWindowShouldClose(window))
{
/* Render here */
glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);

/*
glBegin(GL_TRIANGLES);
glVertex2f(-0.5f, -0.5f);
glVertex2f( 0.0f, 0.5f);
glVertex2f( 0.5f, -0.5f);
glEnd();
*/
glDrawArrays(GL_TRIANGLES, 0, 3);

/* Swap front and back buffers */


glfwSwapBuffers(window);

/* Poll for and process events */


glfwPollEvents();
}

glDeleteProgram(shader);

glfwTerminate();
return 0;
}

You might also like