mirror of
https://github.com/VARCem/PDCurses.git
synced 2026-09-23 23:35:20 +00:00
Fix SDL2 rendering
The pdc_render and pdc_texture globals are no longer needed.
This commit is contained in:
11
doc/sdl2.txt
11
doc/sdl2.txt
@@ -52,8 +52,6 @@ variables:
|
||||
The SDL2 port adds:
|
||||
|
||||
SDL_Window *pdc_window;
|
||||
SDL_Renderer *pdc_render;
|
||||
SDL_Texture *pdc_texture;
|
||||
|
||||
Using SDL_ttf (with SDL2 or SDL) adds:
|
||||
|
||||
@@ -64,11 +62,10 @@ Using SDL_ttf (with SDL2 or SDL) adds:
|
||||
int pdc_ttffont_hint;
|
||||
|
||||
These can be used or modified in your own code. Like the pdc_screen variable
|
||||
used by the SDL port, you can initialize pdc_window, pdc_render,
|
||||
pdc_texture in your own code. If it's not initialized, PDCurses will do
|
||||
it for you. See the sdltest demo for an example. If PDCurses is built with
|
||||
the PDC_WIDE flag, it will clean up/deallocate these variables on exit when
|
||||
needed.
|
||||
used by the SDL port, you can initialize pdc_window in your own code. If it's
|
||||
not initialized, PDCurses will do it for you. See the sdltest demo for an
|
||||
example. If PDCurses is built with the PDC_WIDE flag, it will clean up/
|
||||
deallocate these variables on exit when needed.
|
||||
|
||||
Default font for SDL_TTF is assumed to be DejaVuSansMono.ttf from the Open
|
||||
Source DejaVu fonts. The code looks for this font to already be installed in
|
||||
|
||||
@@ -85,19 +85,9 @@ void PDC_update_rects(void)
|
||||
probably better off doing a full screen update */
|
||||
|
||||
if (rectcount == MAXRECT)
|
||||
{
|
||||
SDL_UpdateTexture(pdc_texture, NULL, pdc_screen->pixels, pdc_screen->pitch);
|
||||
SDL_RenderClear(pdc_render);
|
||||
SDL_RenderCopy(pdc_render, pdc_texture, NULL, NULL);
|
||||
SDL_RenderPresent(pdc_render);
|
||||
}
|
||||
SDL_UpdateWindowSurface(pdc_window);
|
||||
else
|
||||
{
|
||||
SDL_UpdateTexture(pdc_texture, NULL, pdc_screen->pixels, pdc_screen->pitch);
|
||||
SDL_RenderClear(pdc_render);
|
||||
SDL_RenderCopy(pdc_render, pdc_texture, NULL, NULL);
|
||||
SDL_RenderPresent(pdc_render);
|
||||
}
|
||||
SDL_UpdateWindowSurfaceRects(pdc_window, uprect, rectcount);
|
||||
|
||||
pdc_lastupdate = SDL_GetTicks();
|
||||
rectcount = 0;
|
||||
|
||||
@@ -466,8 +466,7 @@ int PDC_get_key(void)
|
||||
break;
|
||||
case SDL_WINDOWEVENT_RESTORED:
|
||||
case SDL_WINDOWEVENT_EXPOSED:
|
||||
SDL_RenderPresent(pdc_render);
|
||||
/* SDL_UpdateWindowSurface(pdc_window); */
|
||||
SDL_UpdateWindowSurface(pdc_window);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -9,8 +9,6 @@ RCSID("$Id: pdcscrn.c,v 1.34 2008/07/14 04:24:52 wmcbrine Exp $")
|
||||
#include "deficon.h"
|
||||
|
||||
SDL_Window *pdc_window = NULL;
|
||||
SDL_Renderer *pdc_render = NULL;
|
||||
SDL_Texture *pdc_texture = NULL;
|
||||
SDL_Surface *pdc_screen = NULL, *pdc_font = NULL, *pdc_icon = NULL,
|
||||
*pdc_back = NULL, *pdc_tileback = NULL;
|
||||
int pdc_sheight = 0, pdc_swidth = 0, pdc_yoffset = 0, pdc_xoffset = 0;
|
||||
@@ -64,16 +62,6 @@ void PDC_clean(void)
|
||||
SDL_FreeSurface(pdc_font);
|
||||
pdc_font = NULL;
|
||||
}
|
||||
if (pdc_texture != NULL)
|
||||
{
|
||||
SDL_DestroyTexture (pdc_texture);
|
||||
pdc_texture = NULL;
|
||||
}
|
||||
if (pdc_render != NULL)
|
||||
{
|
||||
SDL_DestroyRenderer (pdc_render);
|
||||
pdc_render = NULL;
|
||||
}
|
||||
if (pdc_window != NULL)
|
||||
{
|
||||
SDL_DestroyWindow(pdc_window);
|
||||
@@ -261,18 +249,6 @@ int PDC_scr_open(int argc, char **argv)
|
||||
fprintf(stderr, "Could not open SDL window surface: %s\n", SDL_GetError());
|
||||
return ERR;
|
||||
}
|
||||
pdc_render = SDL_CreateRenderer(pdc_window, -1, 0);
|
||||
if (pdc_render == NULL)
|
||||
{
|
||||
fprintf(stderr, "Could not open SDL window renderer: %s\n", SDL_GetError());
|
||||
return ERR;
|
||||
}
|
||||
pdc_texture = SDL_CreateTexture(pdc_render, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, pdc_swidth, pdc_sheight);
|
||||
if (pdc_texture == NULL)
|
||||
{
|
||||
fprintf(stderr, "Could not open SDL texture: %s\n", SDL_GetError());
|
||||
return ERR;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -338,10 +314,6 @@ int PDC_resize_screen(int nlines, int ncols)
|
||||
|
||||
SDL_SetWindowSize(pdc_window, pdc_swidth, pdc_sheight);
|
||||
pdc_screen = SDL_GetWindowSurface(pdc_window);
|
||||
if (pdc_texture != NULL)
|
||||
SDL_DestroyTexture (pdc_texture);
|
||||
SDL_RenderClear(pdc_render);
|
||||
pdc_texture = SDL_CreateTexture(pdc_render, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, pdc_swidth, pdc_sheight);
|
||||
|
||||
if (pdc_tileback)
|
||||
PDC_retile();
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
#include <SDL_ttf.h>
|
||||
|
||||
PDCEX SDL_Window *pdc_window;
|
||||
PDCEX SDL_Renderer *pdc_render;
|
||||
PDCEX SDL_Texture *pdc_texture;
|
||||
PDCEX SDL_Surface *pdc_screen, *pdc_font, *pdc_icon, *pdc_back;
|
||||
PDCEX int pdc_sheight, pdc_swidth, pdc_yoffset, pdc_xoffset;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user