本文整理汇总了C++中GLVertexBuffer::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ GLVertexBuffer::begin方法的具体用法?C++ GLVertexBuffer::begin怎么用?C++ GLVertexBuffer::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GLVertexBuffer
的用法示例。
在下文中一共展示了GLVertexBuffer::begin方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void
GLScreen::glBufferStencil (const GLMatrix &matrix,
GLVertexBuffer &vertexBuffer,
CompOutput *output)
{
WRAPABLE_HND_FUNCTN (glBufferStencil, matrix, vertexBuffer, output);
GLfloat x = output->x ();
GLfloat y = screen->height () - output->y2 ();
GLfloat x2 = output->x () + output->width ();
GLfloat y2 = screen->height () - output->y2 () + output->height ();
GLfloat vertices[] =
{
x, y, 0,
x, y2, 0,
x2, y, 0,
x2, y2, 0
};
GLushort colorData[] = { 0xffff, 0xffff, 0xffff, 0xffff };
vertexBuffer.begin (GL_TRIANGLE_STRIP);
vertexBuffer.addVertices (4, vertices);
vertexBuffer.addColors (1, colorData);
vertexBuffer.end ();
}
示例2: updateScreenBackground
void
PrivateGLScreen::paintBackground (const GLMatrix &transform,
const CompRegion ®ion,
bool transformed)
{
GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer ();
GLfloat vertexData[18];
GLushort colorData[4];
BoxPtr pBox = const_cast <Region> (region.handle ())->rects;
int n, nBox = const_cast <Region> (region.handle ())->numRects;
if (!nBox)
return;
if (screen->desktopWindowCount ())
{
if (!backgroundTextures.empty ())
{
backgroundTextures.clear ();
}
backgroundLoaded = false;
return;
}
else
{
if (!backgroundLoaded)
updateScreenBackground ();
backgroundLoaded = true;
}
if (backgroundTextures.empty ())
{
streamingBuffer->begin (GL_TRIANGLES);
n = nBox;
while (n--)
{
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;
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;
//.........这里部分代码省略.........
示例3: damage
void
ResizeScreen::glPaintRectangle (const GLScreenPaintAttrib &sAttrib,
const GLMatrix &transform,
CompOutput *output,
unsigned short *borderColor,
unsigned short *fillColor)
{
GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer ();
BoxRec box;
GLMatrix sTransform (transform);
GLfloat vertexData [12];
GLfloat vertexData2[24];
GLint origSrc, origDst;
GLushort fc[4], bc[4];
#ifdef USE_GLES
GLint origSrcAlpha, origDstAlpha;
glGetIntegerv (GL_BLEND_SRC_RGB, &origSrc);
glGetIntegerv (GL_BLEND_DST_RGB, &origDst);
glGetIntegerv (GL_BLEND_SRC_ALPHA, &origSrcAlpha);
glGetIntegerv (GL_BLEND_DST_ALPHA, &origDstAlpha);
#else
glGetIntegerv (GL_BLEND_SRC, &origSrc);
glGetIntegerv (GL_BLEND_DST, &origDst);
#endif
/* Premultiply the alpha values */
bc[3] = (float) borderColor[3] / (float) 65535.0f;
bc[0] = ((float) borderColor[0] / 65535.0f) * bc[3];
bc[1] = ((float) borderColor[1] / 65535.0f) * bc[3];
bc[2] = ((float) borderColor[2] / 65535.0f) * bc[3];
logic.getPaintRectangle (&box);
vertexData[0] = box.x1;
vertexData[1] = box.y1;
vertexData[2] = 0.0f;
vertexData[3] = box.x1;
vertexData[4] = box.y2;
vertexData[5] = 0.0f;
vertexData[6] = box.x2;
vertexData[7] = box.y1;
vertexData[8] = 0.0f;
vertexData[9] = box.x2;
vertexData[10] = box.y2;
vertexData[11] = 0.0f;
// FIXME: this is a quick work-around.
// GL_LINE_LOOP and GL_LINE_STRIP primitive types in the SGX Pvr X11 driver
// take special number of vertices (and reorder them). Thus, usage of
// those line primitive is currently not supported by our GLVertexBuffer
// implementation. This is a quick workaround to make it all work until
// we come up with a better GLVertexBuffer::render(...) function.
vertexData2[0] = box.x1;
vertexData2[1] = box.y1;
vertexData2[2] = 0.0f;
vertexData2[3] = box.x1;
vertexData2[4] = box.y2;
vertexData2[5] = 0.0f;
vertexData2[6] = box.x1;
vertexData2[7] = box.y2;
vertexData2[8] = 0.0f;
vertexData2[9] = box.x2;
vertexData2[10] = box.y2;
vertexData2[11] = 0.0f;
vertexData2[12] = box.x2;
vertexData2[13] = box.y2;
vertexData2[14] = 0.0f;
vertexData2[15] = box.x2;
vertexData2[16] = box.y1;
vertexData2[17] = 0.0f;
vertexData2[18] = box.x2;
vertexData2[19] = box.y1;
vertexData2[20] = 0.0f;
vertexData2[21] = box.x1;
vertexData2[22] = box.y1;
vertexData2[23] = 0.0f;
sTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA);
glEnable (GL_BLEND);
glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
/* fill rectangle */
if (fillColor)
{
fc[3] = fillColor[3];
fc[0] = fillColor[0] * (unsigned long)fc[3] / 65535;
fc[1] = fillColor[1] * (unsigned long)fc[3] / 65535;
fc[2] = fillColor[2] * (unsigned long)fc[3] / 65535;
streamingBuffer->begin (GL_TRIANGLE_STRIP);
streamingBuffer->addColors (1, fc);
streamingBuffer->addVertices (4, &vertexData[0]);
streamingBuffer->end ();
streamingBuffer->render (sTransform);
}
//.........这里部分代码省略.........
示例4: glIsEnabled
bool
FireScreen::glPaintOutput (const GLScreenPaintAttrib &attrib,
const GLMatrix &transform,
const CompRegion ®ion,
CompOutput *output,
unsigned int mask)
{
bool status = gScreen->glPaintOutput (attrib, transform, region, output, mask);
if ((!init && ps.active) || brightness < 1.0)
{
GLMatrix sTransform = transform;
sTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA);
if (brightness < 1.0)
{
/* cover the screen with a rectangle and darken it
* (coded as two GL_TRIANGLES for GLES compatibility)
*/
GLfloat vertices[18];
GLushort colors[24];
vertices[0] = (GLfloat)output->region ()->extents.x1;
vertices[1] = (GLfloat)output->region ()->extents.y1;
vertices[2] = 0.0f;
vertices[3] = (GLfloat)output->region ()->extents.x1;
vertices[4] = (GLfloat)output->region ()->extents.y2;
vertices[5] = 0.0f;
vertices[6] = (GLfloat)output->region ()->extents.x2;
vertices[7] = (GLfloat)output->region ()->extents.y2;
vertices[8] = 0.0f;
vertices[9] = (GLfloat)output->region ()->extents.x2;
vertices[10] = (GLfloat)output->region ()->extents.y2;
vertices[11] = 0.0f;
vertices[12] = (GLfloat)output->region ()->extents.x2;
vertices[13] = (GLfloat)output->region ()->extents.y1;
vertices[14] = 0.0f;
vertices[15] = (GLfloat)output->region ()->extents.x1;
vertices[16] = (GLfloat)output->region ()->extents.y1;
vertices[17] = 0.0f;
for (int i = 0; i <= 5; ++i)
{
colors[i*4+0] = 0;
colors[i*4+1] = 0;
colors[i*4+2] = 0;
colors[i*4+3] = (1.0 - brightness) * 65535.0f;
}
GLVertexBuffer *stream = GLVertexBuffer::streamingBuffer ();
GLboolean glBlendEnabled = glIsEnabled (GL_BLEND);
if (!glBlendEnabled)
glEnable (GL_BLEND);
stream->begin (GL_TRIANGLES);
stream->addVertices (6, vertices);
stream->addColors (6, colors);
if (stream->end ())
stream->render (sTransform);
/* only disable blending if it was already disabled */
if (!glBlendEnabled)
glDisable (GL_BLEND);
}
if (!init && ps.active)
ps.drawParticles (sTransform);
}
return status;
}
示例5: optionGetIntensity
bool
ShowrepaintScreen::glPaintOutput (const GLScreenPaintAttrib &attrib,
const GLMatrix &transform,
const CompRegion ®ion,
CompOutput *output,
unsigned int mask)
{
bool status;
GLMatrix sTransform; // initially identity matrix
unsigned short color[4];
status = gScreen->glPaintOutput (attrib, transform, region, output, mask);
tmpRegion = region.intersected (*output);
if (tmpRegion.isEmpty ())
return status;
sTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA);
color[3] = optionGetIntensity () * 0xffff / 100;
color[0] = (rand () & 7) * color[3] / 8;
color[1] = (rand () & 7) * color[3] / 8;
color[2] = (rand () & 7) * color[3] / 8;
GLboolean glBlendEnabled = glIsEnabled (GL_BLEND);
if (!glBlendEnabled)
glEnable (GL_BLEND);
std::vector<GLfloat> vertices;
/* for each rectangle, use two triangles to display it */
foreach (const CompRect &box, tmpRegion.rects ())
{
//first triangle
vertices.push_back (box.x1 ());
vertices.push_back (box.y1 ());
vertices.push_back (0.0f);
vertices.push_back (box.x1 ());
vertices.push_back (box.y2 ());
vertices.push_back (0.0f);
vertices.push_back (box.x2 ());
vertices.push_back (box.y2 ());
vertices.push_back (0.0f);
//second triangle
vertices.push_back (box.x2 ());
vertices.push_back (box.y2 ());
vertices.push_back (0.0f);
vertices.push_back (box.x2 ());
vertices.push_back (box.y1 ());
vertices.push_back (0.0f);
vertices.push_back (box.x1 ());
vertices.push_back (box.y1 ());
vertices.push_back (0.0f);
}
GLVertexBuffer *stream = GLVertexBuffer::streamingBuffer ();
stream->begin (GL_TRIANGLES);
stream->color4f ((float)color[0] / 65535.0f, (float)color[1] / 65535.0f, (float)color[2] / 65535.0f, (float)color[3] / 65535.0f);
stream->addVertices (vertices.size () / 3, &vertices[0]);
if (stream->end ())
stream->render (sTransform);
stream->colorDefault ();
/* only disable blending if it was disabled before */
if (!glBlendEnabled)
glDisable (GL_BLEND);
return status;
}
示例6: 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
}