|
@ -1,4 +1,3 @@ |
|
|
#define _CRT_SECURE_NO_WARNINGS
|
|
|
|
|
|
#include <windows.h>
|
|
|
#include <windows.h>
|
|
|
#include "glew.h"
|
|
|
#include "glew.h"
|
|
|
#include "Glm/glm.hpp"
|
|
|
#include "Glm/glm.hpp"
|
|
@ -217,6 +216,14 @@ INT WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine |
|
|
glBufferData(GL_ARRAY_BUFFER, sizeof(float)*7*3, vertex, GL_STATIC_DRAW); |
|
|
glBufferData(GL_ARRAY_BUFFER, sizeof(float)*7*3, vertex, GL_STATIC_DRAW); |
|
|
glBindBuffer(GL_ARRAY_BUFFER, 0); |
|
|
glBindBuffer(GL_ARRAY_BUFFER, 0); |
|
|
|
|
|
|
|
|
|
|
|
/*创建IBO*/ |
|
|
|
|
|
unsigned int indexes[] = {0,1,2}; |
|
|
|
|
|
GLuint ibo; |
|
|
|
|
|
glGenBuffers(1, &ibo); |
|
|
|
|
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo); |
|
|
|
|
|
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(unsigned int) * 3, indexes, GL_STATIC_DRAW); |
|
|
|
|
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); |
|
|
|
|
|
|
|
|
glClearColor(1.0f, 1.0f, 0.0f, 1.0f); |
|
|
glClearColor(1.0f, 1.0f, 0.0f, 1.0f); |
|
|
|
|
|
|
|
|
//创建一个单位矩阵和一个投影矩阵,后面用来传递到shader
|
|
|
//创建一个单位矩阵和一个投影矩阵,后面用来传递到shader
|
|
@ -259,7 +266,10 @@ INT WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine |
|
|
glVertexAttribPointer(colorLocation, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)(sizeof(float) * 3)); |
|
|
glVertexAttribPointer(colorLocation, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)(sizeof(float) * 3)); |
|
|
glBindBuffer(GL_ARRAY_BUFFER, 0); |
|
|
glBindBuffer(GL_ARRAY_BUFFER, 0); |
|
|
|
|
|
|
|
|
glDrawArrays(GL_TRIANGLES, 0, 3); |
|
|
|
|
|
|
|
|
//glDrawArrays(GL_TRIANGLES, 0, 3);
|
|
|
|
|
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo); |
|
|
|
|
|
glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_INT, 0); |
|
|
|
|
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); |
|
|
|
|
|
|
|
|
glUseProgram(0); |
|
|
glUseProgram(0); |
|
|
SwapBuffers(dc); |
|
|
SwapBuffers(dc); |
|
|