Fullscreen=yes working now, speed rendering improved.

This commit is contained in:
Pere Pujal i Carabantes 2015-01-29 00:32:50 +01:00
parent fc904c7906
commit 690fb2ec4e

View file

@ -906,7 +906,7 @@ static void SDL_UpdateRect(SDL_Surface * screen, Sint32 x, Sint32 y, Sint32 w, S
r.w = w; r.w = w;
r.h = h; r.h = h;
SDL_UpdateTexture(texture, NULL, screen->pixels, screen->pitch); SDL_UpdateTexture(texture, &r, screen->pixels + (y * screen->pitch + x * 4), screen->pitch);
// NOTE docs says one should clear the renderer, however this means a refresh of the whole thing. // NOTE docs says one should clear the renderer, however this means a refresh of the whole thing.
// SDL_RenderClear(renderer); // SDL_RenderClear(renderer);
@ -23297,45 +23297,52 @@ static void setup(void)
window_screen = SDL_CreateWindow("Tux Paint", window_screen = SDL_CreateWindow("Tux Paint",
SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
0,0, //0,0,
// WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_WIDTH, WINDOW_HEIGHT,
SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_HWSURFACE); SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_HWSURFACE);
printf("1\n"); printf("1\n");
if (window_screen == NULL) if (window_screen == NULL)
printf("window_screen = NULL 1\n"); printf("window_screen = NULL 1\n");
#else #else
/* screen = SDL_SetVideoMode(WINDOW_WIDTH, WINDOW_HEIGHT, /* screen = SDL_SetVideoMode(WINDOW_WIDTH, WINDOW_HEIGHT,
VIDEO_BPP, SDL_FULLSCREEN | SDL_SWSURFACE);*/ VIDEO_BPP, SDL_FULLSCREEN | SDL_SWSURFACE);*/
window_screen = SDL_CreateWindow(NULL, window_screen = SDL_CreateWindow(NULL,
//"Tux Paint", //"Tux Paint",
SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
0, 0, //0, 0,
// WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_WIDTH, WINDOW_HEIGHT,
SDL_WINDOW_FULLSCREEN_DESKTOP); SDL_WINDOW_FULLSCREEN_DESKTOP);
printf("2\n"); printf("2\n");
if (window_screen == NULL) if (window_screen == NULL)
printf("window_screen = NULL 2\n"); printf("window_screen = NULL 2\n");
#endif #endif
renderer = SDL_CreateRenderer(window_screen, -1, 0); renderer = SDL_CreateRenderer(window_screen, -1, 0);
SDL_GL_GetDrawableSize(window_screen, &ww, &hh); if ( native_screensize)
texture = SDL_CreateTexture(renderer, {
SDL_PIXELFORMAT_RGB888, SDL_GL_GetDrawableSize(window_screen, &ww, &hh);
SDL_TEXTUREACCESS_STATIC, }
ww, hh); else
{
screen = SDL_CreateRGBSurface(0, ww, hh, 32, ww = WINDOW_WIDTH;
0x00FF0000, hh = WINDOW_HEIGHT;
0x0000FF00, }
0x000000FF,
0xFF000000);
// texture = SDL_CreateTextureFromSurface(renderer, screen);
texture = SDL_CreateTexture(renderer,
SDL_PIXELFORMAT_RGB888,
SDL_TEXTUREACCESS_STATIC,
ww, hh);
screen = SDL_CreateRGBSurface(0, ww, hh, 32,
0x00FF0000,
0x0000FF00,
0x000000FF,
0xFF000000);
if (screen == NULL) if (screen == NULL)
{ {
fprintf(stderr, fprintf(stderr,
@ -23403,7 +23410,6 @@ VIDEO_BPP, SDL_SWSURFACE);*/
renderer = SDL_CreateRenderer(window_screen, -1, 0); renderer = SDL_CreateRenderer(window_screen, -1, 0);
SDL_GL_GetDrawableSize(window_screen, &ww, &hh); SDL_GL_GetDrawableSize(window_screen, &ww, &hh);
texture = SDL_CreateTexture(renderer, texture = SDL_CreateTexture(renderer,
SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888,
@ -23432,6 +23438,9 @@ VIDEO_BPP, SDL_SWSURFACE);*/
cleanup(); cleanup();
exit(1); exit(1);
}} }}
SDL_RenderSetLogicalSize(renderer, WINDOW_WIDTH, WINDOW_HEIGHT);
window_format = SDL_GetWindowPixelFormat(window_screen); window_format = SDL_GetWindowPixelFormat(window_screen);
/* (Need to do this after native screen resolution is handled) */ /* (Need to do this after native screen resolution is handled) */