コード例 #1
0
ファイル: gfx.c プロジェクト: Voka/lpp-3ds
void gfxFlushBuffers(void)
{
	u32 topSize = 400 * 240 * __get_bytes_per_pixel(gfxGetScreenFormat(GFX_TOP));
	u32 bottomSize = 320 * 240 * __get_bytes_per_pixel(gfxGetScreenFormat(GFX_BOTTOM));

	GSPGPU_FlushDataCache(gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL), topSize);
	if(enable3d)GSPGPU_FlushDataCache(gfxGetFramebuffer(GFX_TOP, GFX_RIGHT, NULL, NULL), topSize);
	GSPGPU_FlushDataCache(gfxGetFramebuffer(GFX_BOTTOM, GFX_LEFT, NULL, NULL), bottomSize);
}
コード例 #2
0
ファイル: gfx_3ds.cpp プロジェクト: rychenga/GameYob
void gfxTakeScreenshot() {
    gfxScreen_t screen = gameScreen == 0 ? GFX_TOP : GFX_BOTTOM;
    if(gfxGetScreenFormat(screen) != GSP_BGR8_OES) {
        return;
    }

    u16 width = 0;
    u16 height = 0;
    u8* fb = gfxGetFramebuffer(screen, GFX_LEFT, &height, &width);

    if(fb == NULL) {
        return;
    }

    u32 headerSize = 0x36;
    u32 imageSize = (u32) (width * height * 3);

    u8* header = new u8[headerSize]();

    *(u16*) &header[0x0] = 0x4D42;
    *(u32*) &header[0x2] = headerSize + imageSize;
    *(u32*) &header[0xA] = headerSize;
    *(u32*) &header[0xE] = 0x28;
    *(u32*) &header[0x12] = width;
    *(u32*) &header[0x16] = height;
    *(u32*) &header[0x1A] = 0x00180001;
    *(u32*) &header[0x22] = imageSize;

    u8* image = new u8[imageSize]();

    for(u32 x = 0; x < width; x++) {
        for(u32 y = 0; y < height; y++) {
            u8* src = &fb[(x * height + y) * 3];
            u8* dst = &image[(y * width + x) * 3];

            *(u16*) dst = *(u16*) src;
            dst[2] = src[2];
        }
    }

    std::stringstream fileStream;
    fileStream << "/gameyob_" << time(NULL) << ".bmp";

    std::ofstream stream(fileStream.str(), std::ios::binary);
    if(stream.is_open()) {
        stream.write((char*) header, (size_t) headerSize);
        stream.write((char*) image, (size_t) imageSize);
        stream.close();
    } else {
        systemPrintDebug("Failed to open screenshot file: %s\n", strerror(errno));
    }

    delete[] header;
    delete[] image;
}
コード例 #3
0
ファイル: video.c プロジェクト: Amadren/3Damnesic
void display(AVFrame *pFrame)
{
//    gspWaitForVBlank();
//    gfxSwapBuffers();
    int i, j, c;
    const int width = 400 <= pFrame->width ? 400 : pFrame->width;
    const int height = 240 <= pFrame->height ? 240 : pFrame->height;
    if (gfxGetScreenFormat(GFX_TOP) == GSP_BGR8_OES)
    {

        u8 *const src = pFrame->data[0];
        u8 *const fbuffer = gfxGetFramebuffer(GFX_TOP, GFX_LEFT, 0, 0);

        for (i = 0; i < width; ++i)
        {
            for (j = 0; j < height; ++j)
            {
                for (c = 0; c < 3; ++c)
                {
                    fbuffer[3 * 240 * i + (239 - j) * 3 + c] = src[1024 * 3 * j + i * 3 + c];
                }
            }
        }
    }
    else if (gfxGetScreenFormat(GFX_TOP) == GSP_RGBA8_OES)
    {

        u32 *const src = (u32 *) pFrame->data[0];
        u32 *const fbuffer = (u32 *) gfxGetFramebuffer(GFX_TOP, GFX_LEFT, 0, 0);
        for (i = 0; i < width; ++i)
        {
            for (j = 0; j < height; ++j)
            {
                fbuffer[240 * i + (239 - j)] = src[1024 * j + i];
            }
        }
    }
    else
    {
        printf("format not supported\n");
    }
}
コード例 #4
0
ファイル: utils.c プロジェクト: Kyraminol/TIKdevil
// Graphics Functions
void clear_screen(gfxScreen_t screen)
{
	u8* buffer1;
	u8* buffer2 = NULL;
	u16 width, height;
	u32 bpp;
	GSPGPU_FramebufferFormats format = gfxGetScreenFormat(screen);

	if (screen == GFX_TOP)
	{
		buffer1 = gfxGetFramebuffer(screen, GFX_LEFT, &width, &height);
		buffer2 = gfxGetFramebuffer(screen, GFX_RIGHT, &width, &height);
	} else {
		buffer1 = gfxGetFramebuffer(screen, GFX_LEFT, &width, &height);
	}

	switch (format)
	{
    case GSP_RGBA8_OES:
        bpp = 4;
    case GSP_BGR8_OES:
        bpp = 3;
    case GSP_RGB565_OES:
    case GSP_RGB5_A1_OES:
    case GSP_RGBA4_OES:
        bpp = 2;
    default:
    	bpp = 3;
	}

	memset(buffer1, 0, (width * height * bpp));
	if (buffer2)
		memset(buffer2, 0, (width * height * bpp));

    gfxFlushBuffers();
    gfxSwapBuffers();
    gspWaitForVBlank();
}
コード例 #5
0
ファイル: gfx.c プロジェクト: ObsidianX/3ds_monty
STATIC mp_obj_t mod_citrus_gfx_get_screen_format(mp_obj_t which) {
    int screen = _mod_citrus_gfx_get_gfx_screen(which);

    int ret = gfxGetScreenFormat(screen);
    return mp_obj_new_int(ret);
}