当前位置: 首页>>代码示例>>C++>>正文


C++ GLShader::GetPName方法代码示例

本文整理汇总了C++中GLShader::GetPName方法的典型用法代码示例。如果您正苦于以下问题:C++ GLShader::GetPName方法的具体用法?C++ GLShader::GetPName怎么用?C++ GLShader::GetPName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GLShader的用法示例。


在下文中一共展示了GLShader::GetPName方法的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));
//.........这里部分代码省略.........
开发者ID:alxklk,项目名称:OGLBase,代码行数:101,代码来源:WIN32_Main.cpp


注:本文中的GLShader::GetPName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。