Ejemplo n.º 1
0
int graphicsrender_drawCropped(
        struct graphicstexture *gt, int x, int y, float alpha,
        unsigned int sourcex, unsigned int sourcey,
        unsigned int sourcewidth, unsigned int sourceheight,
        unsigned int drawwidth, unsigned int drawheight,
        int rotationcenterx, int rotationcentery, double rotationangle,
        int horiflipped,
        double red, double green, double blue, int textureFiltering) {
    if (alpha <= 0) {
        return 1;
    }
    if (alpha > 1) {
        alpha = 1;
    }
    if (red > 1) {
        red = 1;
    }
    if (red < 0) {
        red = 0;
    }
    if (blue > 1) {
        blue = 1;
    }
    if (blue < 0) {
        blue = 0;
    }
    if (green > 1) {
        green = 1;
    }
    if (green < 0) {
        green = 0;
    }
    if (sourcewidth == 0) {
        sourcewidth = gt->width;
    }
    if (sourceheight == 0) {
        sourceheight = gt->height;
    }
    if (drawwidth == 0 || drawheight == 0) {
        drawwidth = sourcewidth;
        drawheight = sourceheight;
    }
#ifdef USE_SDL_GRAPHICS_OPENGL_EFFECTS
    if (maincontext) {
        return graphicsrender_drawCropped_GL(gt, x, y, alpha,
            sourcex, sourcey, sourcewidth, sourceheight,
            drawwidth, drawheight, rotationcenterx, rotationcentery,
            rotationangle, horiflipped, red, green, blue, textureFiltering);
    }
#endif
    return graphicsrender_drawCropped_SDL(gt, x, y, alpha,
        sourcex, sourcey, sourcewidth, sourceheight,
        drawwidth, drawheight, rotationcenterx, rotationcentery,
        rotationangle, horiflipped, red, green, blue, textureFiltering);
}
Ejemplo n.º 2
0
int graphicsrender_drawCropped(
        struct graphicstexture *gt, int x, int y, float alpha,
        unsigned int sourcex, unsigned int sourcey,
        unsigned int sourcewidth, unsigned int sourceheight,
        unsigned int drawwidth, unsigned int drawheight,
        int rotationcenterx, int rotationcentery, double rotationangle,
        int horiflipped,
        double red, double green, double blue, int textureFiltering) {

    // enforce boundaries for given color and alpha values:
    alpha = fmin(1, fmax(alpha, 0));
    red = fmin(1, fmax(red, 0));
    blue = fmin(1, fmax(blue, 0));
    green = fmin(1, fmax(green, 0));

    if (sourcewidth == 0) {
        sourcewidth = gt->width;
    }
    if (sourceheight == 0) {
        sourceheight = gt->height;
    }
    if (drawwidth == 0 || drawheight == 0) {
        drawwidth = sourcewidth;
        drawheight = sourceheight;
    }
#ifdef USE_SDL_GRAPHICS_OPENGL_EFFECTS
    if (maincontext) {
        return graphicsrender_drawCropped_GL(gt, x, y, alpha,
            sourcex, sourcey, sourcewidth, sourceheight,
            drawwidth, drawheight, rotationcenterx, rotationcentery,
            rotationangle, horiflipped, red, green, blue, textureFiltering);
    }
#endif
    return graphicsrender_drawCropped_SDL(gt, x, y, alpha,
        sourcex, sourcey, sourcewidth, sourceheight,
        drawwidth, drawheight, rotationcenterx, rotationcentery,
        rotationangle, horiflipped, red, green, blue, textureFiltering);
}