本文整理汇总了C++中SkyBox::getTexHandle方法的典型用法代码示例。如果您正苦于以下问题:C++ SkyBox::getTexHandle方法的具体用法?C++ SkyBox::getTexHandle怎么用?C++ SkyBox::getTexHandle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkyBox
的用法示例。
在下文中一共展示了SkyBox::getTexHandle方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: displayBoxFun
// RENDERS AN OBJECT USING A SKYBOX AS THE TEXTURE SOURCE
void displayBoxFun(GLuint shaderProg) {
Matrix4f viewMat, projMat, modelMat, m;
// set up the mode to wireframe
// setting up the transformaiton of the object from model coord. system to world coord.
modelMat = Matrix4f::identity();
//modelMat = Matrix4f::translation(0,0,0);
modelMat = Matrix4f::scale(50,50,50);
// ROATE THE OBJECT AROUND THE CAMERA VECTOR
// CAN ADD ROTATIONS AROUND THE PRIMARY AXIS
modelMat = modelMat * Matrix4f::rotateVector(cam.getLookAtVector(),angle,1);
// setting up the viewpoint transformation
viewMat = cam.getViewMatrix(NULL);
// setting up the projection transformation
projMat= cam.getProjectionMatrix(NULL);
// putting it all together
m = projMat * viewMat * modelMat;
// tell openfl which shader program to use
glUseProgram(shaderProg);
// transfer the modelViewProjection matrix to the shader
GLuint locMat= 0;
locMat=glGetUniformLocation(shaderProg, "modelViewProjMat");
glUniformMatrix4fv(locMat,1,1,(float *)m.vm);
// transfer the modelView matrix to the shader
m = viewMat * modelMat;
locMat=glGetUniformLocation(shaderProg, "modelViewMat");
glUniformMatrix4fv(locMat,1,1,(float *)m.vm);
// transfer the model matrix to the shader
m = modelMat;
locMat=glGetUniformLocation(shaderProg, "modelMat");
glUniformMatrix4fv(locMat,1,1,(float *)m.vm);
// load the camera position to the shader
locMat=glGetUniformLocation(shaderProg, "camPos");
Vector3f camPos = cam.getPosition();
glUniform3fv(locMat,1, (float *) &camPos);
// load the refract flag to the shader
locMat=glGetUniformLocation(shaderProg, "refractFlag");
glUniform1i(locMat, refractFlag);
glActiveTexture(GL_TEXTURE3);
GLuint texCube = skybox.getTexHandle();
glBindTexture(GL_TEXTURE_CUBE_MAP, texCube);
GLuint samLoc = glGetUniformLocation(shaderProg, "texCube");
glUniform1i(samLoc, 3);
GLint ttt = 0;
glGetUniformiv(shaderProg, samLoc, &ttt);
// bind the buffers to the shaders
GLuint positionLoc = glGetAttribLocation(shaderProg, "vertex_position");
GLuint normalLoc = glGetAttribLocation(shaderProg, "vertex_normal");
glEnableVertexAttribArray(positionLoc);
glEnableVertexAttribArray(normalLoc);
glBindBuffer(GL_ARRAY_BUFFER, vertex_handle);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, triangle_handle);
// Tells OpenGL how to walk through the two VBOs
struct sphereVertex v;
int relAddress = (char *) v.pos - (char *) &v;
glVertexAttribPointer(positionLoc,4,GL_FLOAT, GL_FALSE, sizeof(struct sphereVertex),(char*) NULL+relAddress);
relAddress = (char *) v.normal - (char *) &v;
glVertexAttribPointer(normalLoc,4,GL_FLOAT, GL_FALSE, sizeof(struct sphereVertex),(char*) NULL+relAddress);
// draw the triangles
glDrawElements(GL_TRIANGLES, numTriangles*3, GL_UNSIGNED_INT, (char*) NULL+0);
// glUseProgram(0);
// glUseProgram(shaderProg);
// draw the second sphere
modelMat = Matrix4f::identity();
//modelMat = Matrix4f::translation(0,0,0);
modelMat = Matrix4f::scale(50,50,50) * Matrix4f::translation(2, 0, 0);
// ROATE THE OBJECT AROUND THE CAMERA VECTOR
// CAN ADD ROTATIONS AROUND THE PRIMARY AXIS
modelMat = modelMat * Matrix4f::rotateVector(cam.getLookAtVector(),angle,1);
// setting up the viewpoint transformation
viewMat = cam.getViewMatrix(NULL);
// setting up the projection transformation
projMat= cam.getProjectionMatrix(NULL);
//.........这里部分代码省略.........