本文整理汇总了C++中Texture::Draw方法的典型用法代码示例。如果您正苦于以下问题:C++ Texture::Draw方法的具体用法?C++ Texture::Draw怎么用?C++ Texture::Draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Texture
的用法示例。
在下文中一共展示了Texture::Draw方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
//OpenGL Setup
if (!glfwInit())
{
std::cout << "GLFW failed to initialize!\n";
return 1;
}
glfwOpenWindow(Width,Height,0,0,0,0,0,0,GLFW_WINDOW);
if (glewInit() != GLEW_OK)
{
std::cout << "GLEW failed to initialize!\n";
return 1;
}
glfwSetWindowTitle("it's done.");
glViewport(0,0,Width, Height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0,0,0,0,0,100);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glClearColor(1,0,0,1);
//OpenGL Setup end
Texture tex;
while (true)
{
glClear (GL_COLOR_BUFFER_BIT);
tex.Draw();
glfwSwapBuffers();
if (glfwGetKey (GLFW_KEY_ESC))
{
return 0;
}
}
}
示例2: Draw
void Draw() const
{
if(t)
{
Texture::Enable();
tex.Draw();
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2, GL_FLOAT, 0, t);
}
glVertexPointer(3, GL_FLOAT, 0, v);
glNormalPointer(GL_FLOAT, 0, n);
glDrawArrays(mode, 0, s);
if(t)
{
Texture::Disable();
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
}
示例3: Draw
void Smoke::Draw()
{
Texture* tx = TextureManager::GetInstance().GetTexture("smoke");
tx->color = 0xffdddddd;
tx->Draw(vPos, &vScale, 0, 0, fAlpha);
}
示例4: main
int main()
{
//OpenGL Setup
if (!glfwInit())
{
std::cout << "GLFW failed to initialize!\n";
return 1;
}
glfwOpenWindow(Width,Height,0,0,0,0,0,0,GLFW_WINDOW);
if (glewInit() != GLEW_OK)
{
std::cout << "GLEW failed to initialize!\n";
return 1;
}
glfwSetWindowTitle("it's done.");
glViewport(0,0,Width, Height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0,0,0,0,0,100);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glClearColor(1,0,0,1);
//OpenGL Setup end
Texture tex;
/*// If you had a class, this would be in the contructor.
GLuint programID = LoadShaders ("tex.vert" , "tex.frag"); std::cout << programID << std::flush;
GLuint img = SOIL_load_OGL_texture("runner_01.png", SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_FLAG_MIPMAPS);
std::vector <glm::vec2> Verts;
Verts.push_back (glm::vec2 (-1.0f , -1.0f));
Verts.push_back (glm::vec2 (-1.0f , 1.0f));
Verts.push_back (glm::vec2 (1.0f , 1.0f));
Verts.push_back (glm::vec2 (1.0f , -1.0f));
std::vector <glm::vec2> UV;
UV.push_back (glm::vec2 (0.0f , 1.0f));
UV.push_back (glm::vec2 (0.0f , 0.0f));
UV.push_back (glm::vec2 (1.0f , 0.0f));
UV.push_back (glm::vec2 (1.0f , 1.0f));
GLuint VertBuffer;
glGenBuffers (1 , &VertBuffer);
glBindBuffer (GL_ARRAY_BUFFER, VertBuffer);
glBufferData (GL_ARRAY_BUFFER , Verts.size()*sizeof(glm::vec2) , &Verts[0] , GL_STATIC_DRAW);
GLuint UVBuffer;
glGenBuffers (1 , &UVBuffer);
glBindBuffer (GL_ARRAY_BUFFER , UVBuffer);
glBufferData (GL_ARRAY_BUFFER , UV.size()*sizeof(glm::vec2) , &UV[0] , GL_STATIC_DRAW);
// Constructor end. */
while (true)
{
glClear (GL_COLOR_BUFFER_BIT);
tex.Draw();
// This would be in the classes Draw() function.
// Shader failure/success added.
/*if (programID == NULL) // Was not able to compile, fallback.
{
glEnableClientState (GL_VERTEX_ARRAY);
glBindBuffer (GL_ARRAY_BUFFER , VertBuffer);
glVertexPointer (2 , GL_FLOAT , 0 , NULL);
glEnableClientState (GL_TEXTURE_COORD_ARRAY);
glBindBuffer (GL_ARRAY_BUFFER , UVBuffer);
glTexCoordPointer (2 , GL_FLOAT , 0 , NULL);
glEnable (GL_TEXTURE_2D);
glBindTexture (GL_TEXTURE_2D , img);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glColor4f(1,1,1,1);
glDrawArrays (GL_QUADS , 0 , Verts.size());
glDisable (GL_TEXTURE_2D);
glDisable(GL_BLEND);
glDisableClientState (GL_VERTEX_ARRAY);
glDisableClientState (GL_TEXTURE_COORD_ARRAY);
}
else // Is able to compile.
{
glUseProgram (ProgramID);
glActiveTexture (GL_TEXTURE0);
glBindTexture (GL_TEXTURE_2D , TextureID);
glUniform1i (TextureID , 0);
glEnableVertexAttribArray (0);
//.........这里部分代码省略.........