Windows窗口中创建OpenGL上下文并调用OpenGL函数
#include <Windows.h>
#include <iostream>
#include <GL/GL.h>
#pragma comment (lib, "opengl32.lib")
enum {
GL_VERTEX_SHADER=0x8B31, GL_COMPILE_STATUS=0x8B81, GL_FRAGMENT_SHADER=0x8B30, GL_LINK_STATUS=0x8B82, GL_ARRAY_BUFFER=0x8892, GL_STATIC_DRAW=0x88E4};
void* GetGLFuncAddress(const char* name);
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
typedef GLuint(__stdcall *hGlCreateShader)(GLenum shaderType);
hGlCreateShader glCreateShader;
typedef void (__stdcall *hGlShaderSource)(GLuint shader, GLsizei count, const char** string, const GLint* length);
hGlShaderSource glShaderSource;
typedef void (__stdcall *hGlCompileShader)(GLuint shader);
hGlCompileShader glCompileShader;
typedef void (__stdcall *hGlGetShaderiv)(GLuint shader, GLenum pname, GLint* params);
hGlGetShaderiv glGetShaderiv;
typedef void (__stdcall *hGlGetShaderInfoLog)(GLuint shader, GLsizei maxLength, GLsizei* length, char* infoLog);
hGlGetShaderInfoLog glGetShaderInfoLog;
typedef GLuint (__stdcall *hGlCreateProgram)(void);
hGlCreateProgram glCreateProgram;
typedef void (__stdcall *hGlAttachShader)(GLuint program, GLuint shader);
hGlAttachShader glAttachShader;
typedef void (__stdcall *hGlLinkProgram)(GLuint program);
hGlLinkProgram glLinkProgram;
typedef void (__stdcall *hGlGetProgramiv)(GLuint program, GLenum pname, GLint* params);
hGlGetProgramiv glGetProgramiv;
typedef void (__stdcall * hGlGetProgramInfoLog)(GLuint program, GLsizei maxLength, GLsizei* length, char* infoLog);
hGlGetProgramInfoLog glGetProgramInfoLog;
typedef void (__stdcall *hGlDeleteShader)(GLuint shader);
hGlDeleteShader glDeleteShader;
typedef void (__stdcall * hGlGenVertexArrays)(GLsizei n, GLuint* arrays);
hGlGenVertexArrays glGenVertexArrays;
typedef void (__stdcall *hGlGenBuffers)(GLsizei n, GLuint* buffers);
hGlGenBuffers glGenBuffers;
typedef void (__stdcall *hGlBindVertexArray)(GLuint array);
hGlBindVertexArray glBindVertexArray;
typedef void (__stdcall * hGlBindBuffer)(GLenum target, GLuint buffer);
hGlBindBuffer glBindBuffer;
typedef <