本文整理汇总了C++中GLShader::Use方法的典型用法代码示例。如果您正苦于以下问题:C++ GLShader::Use方法的具体用法?C++ GLShader::Use怎么用?C++ GLShader::Use使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GLShader
的用法示例。
在下文中一共展示了GLShader::Use方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int __cdecl main(int argc, char* argv[])
{
WNDCLASSEX wc={sizeof(WNDCLASSEX), 0, wp, 0, 0, 0, 0, 0, 0, 0, "GLAP301"};
wc.hCursor=LoadCursor(0, IDC_ARROW);;
wc.hIcon=LoadIcon(0,IDI_APPLICATION);
RegisterClassEx(&wc);
RECT wrect={0, 0, W, H};
AdjustWindowRectEx(&wrect, WS_OVERLAPPEDWINDOW, FALSE, WS_EX_APPWINDOW);
HWND win=CreateWindowEx(WS_EX_APPWINDOW, "GLAP301", "Render Window", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT,
wrect.right-wrect.left, wrect.bottom-wrect.top, 0, 0, 0, 0);
ShowWindow(win, SW_SHOWNORMAL);
UpdateWindow(win);
MSG msg={0, 0, 0, 0, 0, {0, 0}};
CTimer timer;
CUIGL GL;
GL.Init(W, H, 1, 1, win);
WGLPROC(glCreateShader);
WGLPROC(glShaderSource);
WGLPROC(glCompileShader);
WGLPROC(glGetShaderiv);
WGLPROC(glGetShaderInfoLog);
WGLPROC(glCreateProgram);
WGLPROC(glAttachShader);
WGLPROC(glLinkProgram);
WGLPROC(glUseProgram);
WGLPROC(glGenBuffers);
WGLPROC(glDeleteBuffers);
WGLPROC(glBindBuffer);
WGLPROC(glBufferData);
WGLPROC(glMapBuffer);
WGLPROC(glUnmapBuffer);
WGLPROC(glVertexAttribPointer);
WGLPROC(glGetAttribLocation);
WGLPROC(glEnableVertexAttribArray);
WGLPROC(glActiveTexture);
WGLPROC(glGetUniformLocation);
WGLPROC(glProgramUniform1i);
WGLPROC(glProgramUniform3f);
WGLPROC(glProgramUniform4f);
WGLPROC(glProgramUniformMatrix4fv);
GLuint ibo=-1;
glGenBuffers(1, &ibo);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, ibsize, ib, GL_STATIC_DRAW);
GLuint vbo=-1;
glGenBuffers(1, &vbo);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBufferData(GL_ARRAY_BUFFER, vbsize, vb, GL_STATIC_DRAW);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
glEnableVertexAttribArray(2);
glEnableVertexAttribArray(3);
glEnableVertexAttribArray(4);
glEnable(GL_DEPTH);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDepthFunc(GL_LESS);
glEnable(GL_CULL_FACE);
glCullFace(GL_FRONT);
GLuint body_tex=LoadTexture("data\\body_diff.png");
GLuint body_norm=LoadTexture("data\\body_norm.png");
GLuint fur_tex=LoadTexture("data\\fur_diff.png");
GLuint fur_norm=LoadTexture("data\\fur_norm.png");
GLShader sh;
glClearColor(0.3f, 0.5f, 0.8f, 1.0f);
glClearDepth(1.0f);
while(1)
{
while(PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
if(msg.message==WM_QUIT)
break;
}
if(gAppState.reloadShaders)
{
sh.CreateFromFile("data\\model.vs", "data\\model.fs");
gAppState.reloadShaders=false;
glVertexAttribPointer(glGetAttribLocation(sh.GetPName(), "i_pos"), 3, GL_FLOAT, GL_FALSE, 4*16, (void*)(0*4));
glVertexAttribPointer(glGetAttribLocation(sh.GetPName(), "i_nor"), 3, GL_FLOAT, GL_FALSE, 4*16, (void*)(3*4));
glVertexAttribPointer(glGetAttribLocation(sh.GetPName(), "i_tan"), 3, GL_FLOAT, GL_FALSE, 4*16, (void*)(10*4));
//.........这里部分代码省略.........