|
|
@ -1,3 +1,4 @@ |
|
|
|
#define _CRT_SECURE_NO_WARNINGS
|
|
|
|
#include <windows.h>
|
|
|
|
#include "glew.h"
|
|
|
|
#include <gl/GL.h>
|
|
|
@ -5,6 +6,11 @@ |
|
|
|
#pragma comment(lib,"opengl32.lib")
|
|
|
|
#pragma comment(lib, "glew32.lib")
|
|
|
|
|
|
|
|
struct Vertex { |
|
|
|
float pos[3]; |
|
|
|
float color[4]; |
|
|
|
}; |
|
|
|
|
|
|
|
/**
|
|
|
|
* @hwnd 发起消息的窗口 |
|
|
|
* @msg 消息类型 |
|
|
@ -38,6 +44,9 @@ char* LoadFileContent(const char *path) { |
|
|
|
return fileContent; |
|
|
|
} |
|
|
|
|
|
|
|
/**
|
|
|
|
* 创建一个GPU程序 |
|
|
|
*/ |
|
|
|
GLuint CreateGPUProgram(const char* vsShaderPath, const char* fsShaderPath) { |
|
|
|
//创建program
|
|
|
|
GLuint program = glCreateProgram(); |
|
|
@ -136,8 +145,41 @@ INT WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine |
|
|
|
/*glew初始化*/ |
|
|
|
glewInit(); |
|
|
|
|
|
|
|
/*创建program*/ |
|
|
|
GLuint program = CreateGPUProgram("test.vs", "test.fs"); |
|
|
|
|
|
|
|
/*创建vbo*/ |
|
|
|
Vertex vertex[3]; |
|
|
|
|
|
|
|
vertex[0].pos[0] = 0; |
|
|
|
vertex[0].pos[1] = 0; |
|
|
|
vertex[0].pos[2] = -100.0f; |
|
|
|
vertex[0].color[0] = 1.0f; |
|
|
|
vertex[0].color[1] = 1.0f; |
|
|
|
vertex[0].color[2] = 1.0f; |
|
|
|
vertex[0].color[3] = 1.0f; |
|
|
|
|
|
|
|
vertex[1].pos[0] = 10; |
|
|
|
vertex[1].pos[1] = 0; |
|
|
|
vertex[1].pos[2] = -100.0f; |
|
|
|
vertex[1].color[0] = 1.0f; |
|
|
|
vertex[1].color[1] = 1.0f; |
|
|
|
vertex[1].color[2] = 1.0f; |
|
|
|
vertex[1].color[3] = 1.0f; |
|
|
|
|
|
|
|
vertex[2].pos[0] = 0; |
|
|
|
vertex[2].pos[1] = 10; |
|
|
|
vertex[2].pos[2] = -100.0f; |
|
|
|
vertex[2].color[0] = 1.0f; |
|
|
|
vertex[2].color[1] = 1.0f; |
|
|
|
vertex[2].color[2] = 1.0f; |
|
|
|
vertex[2].color[3] = 1.0f; |
|
|
|
GLuint vbo; |
|
|
|
glGenBuffers(1, &vbo); |
|
|
|
glBindBuffer(GL_ARRAY_BUFFER, vbo); |
|
|
|
glBufferData(GL_ARRAY_BUFFER, sizeof(float)*7*3, vertex, GL_STATIC_DRAW); |
|
|
|
glBindBuffer(GL_ARRAY_BUFFER, 0); |
|
|
|
|
|
|
|
glClearColor(1.0f, 1.0f, 0.0f, 1.0f); |
|
|
|
|
|
|
|
/*显示窗口*/ |
|
|
|