Created Index buffer
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -1,2 +1,5 @@
|
||||
Main.cpp
|
||||
LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
|
||||
LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
|
||||
glew32s.lib(glew.obj) : warning LNK4099: PDB '' was not found with 'glew32s.lib(glew.obj)' or at ''; linking object as if no debug info
|
||||
Window_practice.vcxproj -> C:\dev\Glfw_Practice\c++\Window_practice\Debug\Window_practice.exe
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -112,21 +112,36 @@ int main(void){
|
||||
std::cout << "OpenGL version: " << glGetString(GL_VERSION) << std::endl;
|
||||
|
||||
//vertex positions
|
||||
float positions[6] = {
|
||||
-0.5f, -0.5f, //Vertex2f
|
||||
0.0f, 0.5f, //Vertex2f
|
||||
0.5f, -0.5f //Vertex2f
|
||||
float positions[] = {
|
||||
-0.5f, -0.5f,
|
||||
0.5f, -0.5f,
|
||||
0.5f, 0.5f,
|
||||
-0.5f, 0.5f
|
||||
};
|
||||
|
||||
//index buffer
|
||||
unsigned int indecies[]{
|
||||
0, 1, 2,
|
||||
2, 3, 0
|
||||
};
|
||||
|
||||
|
||||
|
||||
//Vertex buffer(s)
|
||||
unsigned int buffer;
|
||||
glGenBuffers(1, &buffer); //number of buffer to generate
|
||||
glBindBuffer(GL_ARRAY_BUFFER, buffer); //binding the buffer
|
||||
glBufferData(GL_ARRAY_BUFFER, 6 * sizeof(float), positions, GL_STATIC_DRAW);
|
||||
glBufferData(GL_ARRAY_BUFFER, 6 * 2 * sizeof(float), positions, GL_STATIC_DRAW);
|
||||
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 2, 0);
|
||||
|
||||
//index buffer setup
|
||||
unsigned int ibo; //index buffer object
|
||||
glGenBuffers(1, &ibo);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo); //binding the buffer
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, 6 * sizeof(unsigned int), indecies, GL_STATIC_DRAW);
|
||||
|
||||
ShaderProgramSource source = ParseShader("res/shaders/Basic.shader");
|
||||
std::cout << "VERTEX" << std::endl;
|
||||
std::cout << source.VertexSource << std::endl;
|
||||
@@ -143,7 +158,7 @@ int main(void){
|
||||
/* Render here */
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3); //without index buffer
|
||||
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, nullptr);
|
||||
|
||||
/* Swap front and back buffers */
|
||||
glfwSwapBuffers(window);
|
||||
|
||||
Reference in New Issue
Block a user