Beispiel #1
0
static void
draw(void)
{
   glClear(GL_COLOR_BUFFER_BIT);

   glDrawTexfOES(view_posx, view_posy, 0.0, width, height);
}
Beispiel #2
0
void CanvasContext::drawImage (const Texture* texture,
    float destX, float destY, float sourceX, float sourceY, float sourceW, float sourceH)
{
    const CanvasState& state = _states.top();

    prepare(texture);

    if (state.canDrawTexture) {
        // Use GL draw_texture
        int windowHeight;
        getSize(NULL, &windowHeight);
        float destW = state.scaleX * sourceW;
        float destH = state.scaleY * sourceH;
        GLfloat cropRect[] = {
            sourceX, sourceY + sourceH, sourceW, -sourceH
        };
        glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, cropRect);
        glDrawTexfOES(state.translateX + destX,
            windowHeight - destY - destH - state.translateY,
            0, destW, destH);

    } else {
        // Use GL vertex arrays
        GLfloat verts[] = {
            destX, destY,
            destX + sourceW, destY,
            destX, destY + sourceH,
            destX + sourceW, destY + sourceH,
        };

        float inverseMaxU = texture->getMaxU();
        float inverseMaxV = texture->getMaxV();
        float x1 = sourceX/texture->getWidth() * inverseMaxU;
        float y1 = sourceY/texture->getHeight() * inverseMaxV;
        float x2 = x1 + sourceW/texture->getWidth() * inverseMaxU;
        float y2 = y1 + sourceH/texture->getHeight() * inverseMaxV;
        GLfloat uv[] = {
            x1, y1,
            x2, y1,
            x1, y2,
            x2, y2,
        };
        glVertexPointer(2, GL_FLOAT, 0, verts);
        glTexCoordPointer(2, GL_FLOAT, 0, uv);
        glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
    }
}
void glDrawTexfOESLogged(GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height) {
	printf("glDrawTexfOES(%.2f, %.2f, %.2f, %.2f, %.2f)\n", x, y, z, width, height);
	glDrawTexfOES(x, y, z, width, height);
}