本文整理汇总了C++中Texture::BindTexture方法的典型用法代码示例。如果您正苦于以下问题:C++ Texture::BindTexture方法的具体用法?C++ Texture::BindTexture怎么用?C++ Texture::BindTexture使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Texture
的用法示例。
在下文中一共展示了Texture::BindTexture方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RenderWorld
void RenderWorld()
{
glEnable(GL_LIGHTING);
txrGround.BindTexture();
mtrGround.Apply();
glBegin(GL_QUADS);
glNormal3f(0.0,1.0,0.0);
glTexCoord2f(0.0, 0.0); glVertex3f(-700.0, -20, 700.0);
glTexCoord2f(0.0, 1.0); glVertex3f(700.0, -20, 700.0);
glTexCoord2f(1.0, 1.0); glVertex3f(700.0, -20, -700.0);
glTexCoord2f(1.0, 0.0); glVertex3f(-700.0, -20, -700.0);
glEnd();
txrGround.UnBindTexture();
/*
glTexGeni(GL_S,GL_TEXTURE_GEN_MODE,GL_SPHERE_MAP);
glTexGeni(GL_T,GL_TEXTURE_GEN_MODE,GL_SPHERE_MAP);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
GLUquadricObj *obj;
obj = gluNewQuadric();
gluQuadricDrawStyle( obj, GLU_FILL );
gluQuadricOrientation( obj, GLU_OUTSIDE );
gluQuadricTexture( obj, GL_TRUE );
gluQuadricNormals( obj, GLU_SMOOTH );
gluSphere(obj,800,360,180);
glDisable(GL_TEXTURE_GEN_S);
glDisable(GL_TEXTURE_GEN_T);
*/
glPushMatrix();
glRotatef(90,1,0,0);
glScalef(800,800,800);
txrSky.BindTexture();
mtrSpace.Apply();
glCallList(SphereList);
txrSky.UnBindTexture();
glPopMatrix();
DrawEarth();
DrawMoon();
}
示例2: Draw
//--------------------------------------------------------------
// Draw this actor
//--------------------------------------------------------------
void Actor::Draw() const
{
// Bind data
Material* pMaterial = pMesh->GetMaterial();
Texture* pTexture = pMaterial->GetTexture();
pTexture->BindTexture();
pMesh->BindVertexBuffers();
// Draw
glDrawElements(GL_TRIANGLES, pMesh->GetNumVertices(), GL_UNSIGNED_INT, 0);
// Unbind data
pMesh->UnbindVertexBuffers();
pTexture->UnbindTexture();
}
示例3: DrawMoon
void DrawMoon()
{
static float fAngle = 0.0;
glPushMatrix();
glRotatef(fAngle,0,1,0);
glTranslatef(0,200,300);
glScalef(20,20,20);
txrMoon.BindTexture();
mtrMoon.Apply();
glCallList(SphereList);
txrMoon.UnBindTexture();
glPopMatrix();
fAngle += 0.8;
}
示例4: DrawEarth
void DrawEarth()
{
static float fAngle = 0;
glPushMatrix();
glTranslatef(0,200,300);
glRotatef(fAngle,0,-1,0);
glScalef(70,70,70);
txrEarth.BindTexture();
mtrEarth.Apply();
glCallList(SphereList);
txrEarth.UnBindTexture();
glPopMatrix();
fAngle+=0.5;
}
示例5: RenderScene
void RenderScene(LPVOID lpParam)
{
// typecast lpParam to Render pointer
Render* glRender = (Render*)lpParam;
////Rendering happens here////
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
int iModelViewLoc = glGetUniformLocation(spShader.GetShaderProgramID(), "modelViewMatrix");
int iProjectionLoc = glGetUniformLocation(spShader.GetShaderProgramID(), "projectionMatrix");
glUniformMatrix4fv(iProjectionLoc, 1, GL_FALSE, glm::value_ptr(*glRender->GetProjectionMatrix()));
glm::mat4 mModelView = glm::lookAt(glm::vec3(0, 12, 27), glm::vec3(0, 0, 0), glm::vec3(0.0f, 1.0f, 0.0f));
glm::mat4 mCurrent;
glBindVertexArray(uVAO);
// texture binding set GL_ACTIVE_TEXTURE0, then tellfragment shader
// that Sampler variable will get data from GL_ACTIVE_TEXTURE0
int iSimplerLoc = glGetUniformLocation(spShader.GetShaderProgramID(), "gSampler");
glUniform1i(iSimplerLoc, 0);
tGold.BindTexture(0);
// render cube
mCurrent = glm::translate(mModelView, glm::vec3(-8.0f, 0.0f, 0.0f));
mCurrent = glm::scale(mCurrent, glm::vec3(10.0f, 10.0f, 10.0f));
mCurrent = glm::rotate(mCurrent, fRotationAngleCube, glm::vec3(1.0f, 0.0f, 0.0f));
glUniformMatrix4fv(iModelViewLoc, 1, GL_FALSE, glm::value_ptr(mCurrent));
glDrawArrays(GL_TRIANGLES, 0, 36);
// Rendering of pyramid
mCurrent = glm::translate(mModelView, glm::vec3(8.0f, 0.0f, 0.0f));
mCurrent = glm::scale(mCurrent, glm::vec3(10.0f, 10.0f, 10.0f));
mCurrent = glm::rotate(mCurrent, fRotationAnglePyramid, glm::vec3(0.0f, 1.0f, 0.0f));
glUniformMatrix4fv(iModelViewLoc, 1, GL_FALSE, glm::value_ptr(mCurrent));
glDrawArrays(GL_TRIANGLES, 36, 12);
// render ground
tSnow.BindTexture();
glUniformMatrix4fv(iModelViewLoc, 1, GL_FALSE, glm::value_ptr(mModelView));
glDrawArrays(GL_TRIANGLES, 48, 6);
// user control
if (Keys::Key(VK_UP))fCubeRotationSpeed -= appMain.sof(60.0f);
if (Keys::Key(VK_DOWN))fCubeRotationSpeed += appMain.sof(60.0f);
if (Keys::Key(VK_RIGHT))fPyramidRotationSpeed += appMain.sof(60.0f);
if (Keys::Key(VK_LEFT))fPyramidRotationSpeed -= appMain.sof(60.0f);
fRotationAngleCube += appMain.sof(fCubeRotationSpeed);
fRotationAnglePyramid += appMain.sof(fPyramidRotationSpeed);
// toggle FPS and V-Sync
if (Keys::OneKey(VK_F1))
{
bShowFPS = !bShowFPS;
if (!bShowFPS)
{
SetWindowText(appMain.hWnd, "Test Open GL Window");
}
}
if (Keys::OneKey(VK_F2))
{
bVSync = !bVSync;
glRender->SetVerticalSynchronization(bVSync);
}
else if (Keys::OneKey(VK_F3))
{
tGold.SetFiltering((tGold.GetMagnificationFilter() + 1) % 2, tGold.GetMinificationFilter());
tSnow.SetFiltering((tSnow.GetMagnificationFilter() + 1) % 2, tSnow.GetMinificationFilter());
displayTexFilerInfo();
}
else if (Keys::OneKey(VK_F4))
{
int newMinFilter = tSnow.GetMinificationFilter() == TEXTURE_FILTER_MIN_TRILINEAR ? TEXTURE_FILTER_MIN_NEAREST : tSnow.GetMinificationFilter() + 1;
tSnow.SetFiltering(tSnow.GetMagnificationFilter(), newMinFilter);
tGold.SetFiltering(tGold.GetMagnificationFilter(), newMinFilter);
displayTexFilerInfo();
}
if (bShowFPS)
{
char buff[55];
sprintf_s(buff, "FPS: %d, VSync: %s", glRender->GetFPS(), bVSync ? "On" : "Off");
SetWindowText(appMain.hWnd, buff);
}
if (Keys::OneKey(VK_ESCAPE))
//.........这里部分代码省略.........