示例#1
0
static int graphicsrender_drawCropped_GL(
        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) {
    // source UV coords:
    assert(gt->width >= 0);
    assert(gt->height >= 0);
    double sx = ((double)sourcex) / (double)gt->width;
    double sy = ((double)sourcey) / (double)gt->height;
    double sw = ((double)sourcewidth) / (double)gt->width;
    double sh = ((double)sourceheight) / (double)gt->height;
    assert(sw >= 0);
    assert(sh >= 0);

    GLenum err;
    if ((err = glGetError()) != GL_NO_ERROR) {
        printwarning("graphicsrender_drawCropped_GL: "
            "lingering error before render: %s",
            glGetErrorString(err));
    }

    glEnable(GL_TEXTURE_2D);

    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); 
    glPushMatrix();
    // apply sprite rotation:
    glTranslatef((x + drawwidth * 0.5), (y + drawheight * 0.5), 0);
    glRotated(rotationangle, 0, 0, 1);
    glTranslatef(-(x + drawwidth * 0.5), -(y + drawheight * 0.5),
        -(0));
    // draw sprite:
    if (graphicstexture_bindGl(gt, renderts)) {
        glBegin(GL_QUADS);

        glTexCoord2f(sx, sy + sh); 
        glVertex2d(x, y + drawheight);
        glTexCoord2f(sx + sw, sy + sh);
        glVertex2d(x + drawwidth, y + drawheight);
        glTexCoord2f(sx + sw, sy);
        glVertex2d(x + drawwidth, y);
        glTexCoord2f(sx, sy);
        glVertex2d(x, y);

        glEnd();
    }
    glPopMatrix();
    glDisable(GL_BLEND);
    if ((err = glGetError()) != GL_NO_ERROR) {
        printwarning("graphicsrender_drawCropped_GL: "
            "error after render: %s",
            glGetErrorString(err));
    }
    return 1;
}
示例#2
0
void graphicssdlrender_startFrame(void) {
#ifdef USE_SDL_GRAPHICS_OPENGL_EFFECTS
    if (maincontext) {
        GLenum err;
        if ((err = glGetError()) != GL_NO_ERROR) {
            printwarning("graphicsrender_startFrame: earlier error "
                "around: %s", glGetErrorString(err));
        }

        renderts = time_getMilliseconds();

        glClearColor(0, 0, 0, 1);
        glClear(GL_COLOR_BUFFER_BIT);
        if ((err = glGetError()) != GL_NO_ERROR) {
            printwarning("graphicsrender_startFrame: "
                "glClear error: %s", glGetErrorString(err));
        }

        int actualwidth, actualheight;
        SDL_GetWindowSize(mainwindow, &actualwidth, &actualheight);
        renderwindow_width = actualwidth;
        renderwindow_height = actualheight;

        glDisable(GL_DEPTH_TEST);
        glDisable(GL_LIGHTING);

        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        glOrtho(0, actualwidth, actualheight, 0, -1, 1);

        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
        return;
    }
#endif
    SDL_SetRenderDrawColor(mainrenderer, 0, 0, 0, 1);
    SDL_RenderClear(mainrenderer);
}
示例#3
0
void graphicssdlrender_completeFrame(void) {
#ifdef USE_SDL_GRAPHICS_OPENGL_EFFECTS
    if (maincontext) {
        SDL_GL_SwapWindow(mainwindow);
        GLenum err;
        if ((err = glGetError()) != GL_NO_ERROR) {
            printwarning("graphicsrender_completeFrame: "
                "error after SDL_GL_SwapWindow: %s",
                glGetErrorString(err));
        }
        return;
    }
#endif
    SDL_RenderPresent(mainrenderer);
}
示例#4
0
	bool marmaladeRenderErrorCheck( ServiceProviderInterface * _serviceProvider, const char * _file, int _line )
	{
		GLenum err = glGetError();

		if( err == GL_NO_ERROR )
		{
			return false;
		}

		const char * err_str = glGetErrorString( err );		

		LOGGER_ERROR(_serviceProvider)("Marmalade render: %s:%d error %s:%d"
			, _file
			, _line
			, err_str
			, err 
			);

        return true;
	}