本文整理汇总了C++中OpenGLTexture::sampler方法的典型用法代码示例。如果您正苦于以下问题:C++ OpenGLTexture::sampler方法的具体用法?C++ OpenGLTexture::sampler怎么用?C++ OpenGLTexture::sampler使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenGLTexture
的用法示例。
在下文中一共展示了OpenGLTexture::sampler方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: render_overlay
void OpenGLGraphics::render_overlay(CoreOverlay* overlay) {
if (!overlay->visible()) {
return;
}
float x = overlay->corner_x();
float y = overlay->corner_y();
// Now translate to the top-left corner of the overlay, and render
// the text and background image
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glTranslatef(x, y, 0.0f);
// Render the background as a single quad
OpenGLTexture* background = static_cast<OpenGLTexture*>(overlay->background());
if (background) {
background->sampler(0);
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f);
glVertex2f(0.0f, 0.0f);
glTexCoord2f(1.0f, 0.0f);
glVertex2f(overlay->width(), 0.0f);
glTexCoord2f(1.0f, 1.0f);
glVertex2f(overlay->width(), overlay->height());
glTexCoord2f(0.0f, 1.0f);
glVertex2f(0.0f, overlay->height());
glEnd();
}
// Now render the text
OpenGLFont* font = static_cast<OpenGLFont*>(overlay->font());
if (!overlay->text().empty() && font) {
glColor4fv(overlay->text_color());
glPushMatrix();
glTranslatef(0, (float)font->height(), 0);
font->render(overlay->text());
glPopMatrix();
}
// Render all the children
for (Iterator<CoreOverlayPtr> i = overlay->children(); i; i++) {
render_overlay(i->get());
}
glPopMatrix();
}
示例2: render_visible_quad_sets
void OpenGLGraphics::render_visible_quad_sets() {
OpenGLTexture* texture = 0;
glDisable(GL_LIGHTING);
glDisable(GL_CULL_FACE);
glEnable(GL_BLEND);
glEnable(GL_TEXTURE_2D);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glColor3f(1.0f, 1.0f, 1.0f);
// Render all quad sets
for (vector<CoreQuadSetPtr>::iterator i = quad_sets_.begin(); i != quad_sets_.end(); i++) {
// Switch textures if necessary
CoreQuadSet* quad_set = i->get();
OpenGLTexture* next_texture = static_cast<OpenGLTexture*>(quad_set->texture());
if (texture != next_texture) {
texture = next_texture;
texture->sampler(TS_DIFFUSE);
}
// Transform the modelview an dtexture matrics
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glMultMatrixf(quad_set->parent()->matrix());
glBegin(GL_QUADS);
for (size_t i = 0; i < quad_set->vertex_count(); i++) {
const Vertex& v = quad_set->vertex_data()[i];
glNormal3fv(v.normal);
glTexCoord2fv(v.texcoord);
glVertex3fv(v.position);
}
glEnd();
// Set the matrix mode
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
}
glEnable(GL_LIGHTING);
glEnable(GL_CULL_FACE);
glDisable(GL_TEXTURE_2D);
glDisable(GL_BLEND);
}