本文整理汇总了C++中GLTexture::enable方法的典型用法代码示例。如果您正苦于以下问题:C++ GLTexture::enable方法的具体用法?C++ GLTexture::enable怎么用?C++ GLTexture::enable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GLTexture
的用法示例。
在下文中一共展示了GLTexture::enable方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateScreenBackground
//.........这里部分代码省略.........
vertexData[15] = pBox->x2;
vertexData[16] = pBox->y1;
vertexData[17] = 0.0f;
streamingBuffer->addVertices (6, vertexData);
pBox++;
}
colorData[0] = colorData[1] = colorData[2] = 0;
colorData[3] = std::numeric_limits <unsigned short>::max ();
streamingBuffer->addColors (1, colorData);
streamingBuffer->end ();
streamingBuffer->render (transform);
}
else
{
n = nBox;
for (unsigned int i = 0; i < backgroundTextures.size (); i++)
{
GLfloat textureData[12];
GLTexture *bg = backgroundTextures[i];
CompRegion r = region & *bg;
pBox = const_cast <Region> (r.handle ())->rects;
nBox = const_cast <Region> (r.handle ())->numRects;
n = nBox;
streamingBuffer->begin (GL_TRIANGLES);
while (n--)
{
GLfloat tx1 = COMP_TEX_COORD_X (bg->matrix (), pBox->x1);
GLfloat tx2 = COMP_TEX_COORD_X (bg->matrix (), pBox->x2);
GLfloat ty1 = COMP_TEX_COORD_Y (bg->matrix (), pBox->y1);
GLfloat ty2 = COMP_TEX_COORD_Y (bg->matrix (), pBox->y2);
vertexData[0] = pBox->x1;
vertexData[1] = pBox->y1;
vertexData[2] = 0.0f;
vertexData[3] = pBox->x1;
vertexData[4] = pBox->y2;
vertexData[5] = 0.0f;
vertexData[6] = pBox->x2;
vertexData[7] = pBox->y1;
vertexData[8] = 0.0f;
vertexData[9] = pBox->x1;
vertexData[10] = pBox->y2;
vertexData[11] = 0.0f;
vertexData[12] = pBox->x2;
vertexData[13] = pBox->y2;
vertexData[14] = 0.0f;
vertexData[15] = pBox->x2;
vertexData[16] = pBox->y1;
vertexData[17] = 0.0f;
textureData[0] = tx1;
textureData[1] = ty1;
textureData[2] = tx1;
textureData[3] = ty2;
textureData[4] = tx2;
textureData[5] = ty1;
textureData[6] = tx1;
textureData[7] = ty2;
textureData[8] = tx2;
textureData[9] = ty2;
textureData[10] = tx2;
textureData[11] = ty1;
streamingBuffer->addVertices (6, vertexData);
streamingBuffer->addTexCoords (0, 6, textureData);
pBox++;
}
streamingBuffer->end ();
if (bg->name ())
{
if (transformed)
bg->enable (GLTexture::Good);
else
bg->enable (GLTexture::Fast);
streamingBuffer->render (transform);
bg->disable ();
}
}
}
}
示例2: glGetIntegerv
void
CompText::draw (const GLMatrix &transform,
float x,
float y,
float alpha) const
{
GLint oldBlendSrc, oldBlendDst;
GLushort colorData[4];
GLfloat textureData[8];
GLfloat vertexData[12];
GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer ();
if (texture.empty ())
return;
#ifdef USE_GLES
GLint oldBlendSrcAlpha, oldBlendDstAlpha;
glGetIntegerv (GL_BLEND_SRC_RGB, &oldBlendSrc);
glGetIntegerv (GL_BLEND_DST_RGB, &oldBlendDst);
glGetIntegerv (GL_BLEND_SRC_ALPHA, &oldBlendSrcAlpha);
glGetIntegerv (GL_BLEND_DST_ALPHA, &oldBlendDstAlpha);
#else
glGetIntegerv (GL_BLEND_SRC, &oldBlendSrc);
glGetIntegerv (GL_BLEND_DST, &oldBlendDst);
GLboolean wasBlend;
wasBlend = glIsEnabled (GL_BLEND);
if (!wasBlend)
glEnable (GL_BLEND);
#endif
glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
colorData[0] = alpha * 65535;
colorData[1] = alpha * 65535;
colorData[2] = alpha * 65535;
colorData[3] = alpha * 65535;
for (unsigned int i = 0; i < texture.size (); i++)
{
GLTexture *tex = texture[i];
GLTexture::Matrix m = tex->matrix ();
tex->enable (GLTexture::Good);
streamingBuffer->begin (GL_TRIANGLE_STRIP);
vertexData[0] = x;
vertexData[1] = y - height;
vertexData[2] = 0;
vertexData[3] = x;
vertexData[4] = y;
vertexData[5] = 0;
vertexData[6] = x + width;
vertexData[7] = y - height;
vertexData[8] = 0;
vertexData[9] = x + width;
vertexData[10] = y;
vertexData[11] = 0;
textureData[0] = COMP_TEX_COORD_X (m, 0);
textureData[1] = COMP_TEX_COORD_Y (m, 0);
textureData[2] = COMP_TEX_COORD_X (m, 0);
textureData[3] = COMP_TEX_COORD_Y (m, height);
textureData[4] = COMP_TEX_COORD_X (m, width);
textureData[5] = COMP_TEX_COORD_Y (m, 0);
textureData[6] = COMP_TEX_COORD_X (m, width);
textureData[7] = COMP_TEX_COORD_Y (m, height);
streamingBuffer->addColors (1, colorData);
streamingBuffer->addVertices (4, vertexData);
streamingBuffer->addTexCoords (0, 4, textureData);
streamingBuffer->end ();
streamingBuffer->render (transform);
tex->disable ();
}
#ifdef USE_GLES
glBlendFuncSeparate (oldBlendSrc, oldBlendDst,
oldBlendSrcAlpha, oldBlendDstAlpha);
#else
if (!wasBlend)
glDisable (GL_BLEND);
glBlendFunc (oldBlendSrc, oldBlendDst);
#endif
}