Rename sdl_dib to main_surface and move it to ags.h

This commit is contained in:
kichikuou
2025-02-19 12:15:06 +09:00
parent b28e3ef2fd
commit e2c75fbd9d
7 changed files with 81 additions and 82 deletions
+1 -1
View File
@@ -142,7 +142,7 @@ struct _ags {
};
typedef struct _ags ags_t;
extern struct SDL_Surface *main_surface;
/* 初期化関係 */
void ags_init(const char *render_driver, bool enable_zb);
+6 -6
View File
@@ -20,7 +20,7 @@
#define CONCAT(x, y) CONCATENATE(x, y)
static SDL_Rect CONCAT(sdl_floodFill_, TYPE)(int x, int y, Uint32 col) {
int old_color = *(TYPE *)PIXEL_AT(sdl_dib, x, y);
int old_color = *(TYPE *)PIXEL_AT(main_surface, x, y);
if (old_color == col)
return (SDL_Rect){};
@@ -36,15 +36,15 @@ static SDL_Rect CONCAT(sdl_floodFill_, TYPE)(int x, int y, Uint32 col) {
y = stack[top].y;
top--;
TYPE *line = PIXEL_AT(sdl_dib, 0, y);
TYPE *prev_line = (TYPE *)((uint8_t *)line - sdl_dib->pitch);
TYPE *next_line = (TYPE *)((uint8_t *)line + sdl_dib->pitch);
TYPE *line = PIXEL_AT(main_surface, 0, y);
TYPE *prev_line = (TYPE *)((uint8_t *)line - main_surface->pitch);
TYPE *next_line = (TYPE *)((uint8_t *)line + main_surface->pitch);
while (x >= 0 && line[x] == old_color) x--;
x++;
minx = min(x, minx);
bool span_above = false, span_below = false;
for (; x < sdl_dib->w && line[x] == old_color; x++) {
for (; x < main_surface->w && line[x] == old_color; x++) {
line[x] = col;
if (y > 0) {
if (!span_above && prev_line[x] == old_color) {
@@ -58,7 +58,7 @@ static SDL_Rect CONCAT(sdl_floodFill_, TYPE)(int x, int y, Uint32 col) {
span_above = false;
}
}
if (y < sdl_dib->h - 1) {
if (y < main_surface->h - 1) {
if (!span_below && next_line[x] == old_color) {
if (++top >= stack_size) {
stack_size *= 2;
+5 -5
View File
@@ -135,12 +135,12 @@ static void sdl_drawAntiAlias_8bpp(int dstx, int dsty, SDL_Surface *src, uint8_t
Uint8 cache[256*7];
memset(cache, 0, 256);
for (int y = 0; y < src->h && dsty + y < sdl_dib->h; y++) {
for (int y = 0; y < src->h && dsty + y < main_surface->h; y++) {
if (dsty + y < 0)
continue;
uint8_t *sp = (uint8_t*)src->pixels + y * src->pitch;
uint8_t *dp = (uint8_t*)sdl_dib->pixels + (dsty + y) * sdl_dib->pitch + dstx;
for (int x = 0; x < src->w && dstx + x < sdl_dib->w; x++) {
uint8_t *dp = (uint8_t*)main_surface->pixels + (dsty + y) * main_surface->pitch + dstx;
for (int x = 0; x < src->w && dstx + x < main_surface->w; x++) {
Uint8 r, g, b, alpha;
SDL_GetRGBA(*((Uint32*)sp), src->format, &r, &g, &b, &alpha);
alpha = alpha >> 5; // reduce bit depth
@@ -199,11 +199,11 @@ SDL_Rect font_draw_glyph(int x, int y, const char *str_utf8, uint8_t cl) {
y -= (TTF_FontHeight(fontset->id) - fontset->size) / 2;
r_dst = (SDL_Rect){x, y, w, h};
if (sdl_dib->format->BitsPerPixel == 8 && antialias) {
if (main_surface->format->BitsPerPixel == 8 && antialias) {
sdl_drawAntiAlias_8bpp(x, y, fs, cl);
} else {
r_src = (SDL_Rect){0, 0, w, h};
SDL_BlitSurface(fs, &r_src, sdl_dib, &r_dst);
SDL_BlitSurface(fs, &r_src, main_surface, &r_dst);
}
SDL_FreeSurface(fs);
+25 -25
View File
@@ -51,9 +51,9 @@ static void sdl_pal_check(void) {
}
static Uint32 palette_color(uint8_t c) {
if (sdl_dib->format->BitsPerPixel == 8)
if (main_surface->format->BitsPerPixel == 8)
return c;
return SDL_MapRGB(sdl_dib->format, sdl_col[c].r, sdl_col[c].g, sdl_col[c].b);
return SDL_MapRGB(main_surface->format, sdl_col[c].r, sdl_col[c].g, sdl_col[c].b);
}
void sdl_updateScreen(void) {
@@ -104,7 +104,7 @@ void sdl_wait_vsync() {
/* off-screen の指定領域を Main Window へ転送 */
void sdl_updateArea(MyRectangle *rect, MyPoint *dst) {
SDL_Rect sw = {0, 0, sdl_dib->w, sdl_dib->h};
SDL_Rect sw = {0, 0, main_surface->w, main_surface->h};
SDL_Rect dw = {0, 0, view_w, view_h};
SDL_Rect sr = {rect->x, rect->y, rect->w, rect->h};
SDL_Rect dr = {dst->x, dst->y, rect->w, rect->h};
@@ -115,7 +115,7 @@ void sdl_updateArea(MyRectangle *rect, MyPoint *dst) {
SDL_Surface *sf;
SDL_LockTextureToSurface(sdl_texture, &dr, &sf);
SDL_BlitSurface(sdl_dib, &sr, sf, NULL);
SDL_BlitSurface(main_surface, &sr, sf, NULL);
SDL_UnlockTexture(sdl_texture);
sdl_dirty = true;
@@ -133,8 +133,8 @@ void sdl_setPalette(Color *pal, int first, int count) {
sdl_col[first + i].g = pal[first + i].g;
sdl_col[first + i].b = pal[first + i].b;
}
if (sdl_dib->format->BitsPerPixel == 8)
SDL_SetPaletteColors(sdl_dib->format->palette, &sdl_col[first], first, count);
if (main_surface->format->BitsPerPixel == 8)
SDL_SetPaletteColors(main_surface->format->palette, &sdl_col[first], first, count);
}
/* 矩形の描画 */
@@ -143,16 +143,16 @@ void sdl_drawRectangle(int x, int y, int w, int h, uint8_t c) {
Uint32 col = palette_color(c);
SDL_Rect rect = {x, y, w, 1};
SDL_FillRect(sdl_dib, &rect, col);
SDL_FillRect(main_surface, &rect, col);
rect = (SDL_Rect){x, y, 1, h};
SDL_FillRect(sdl_dib, &rect, col);
SDL_FillRect(main_surface, &rect, col);
rect = (SDL_Rect){x, y + h - 1, w, 1};
SDL_FillRect(sdl_dib, &rect, col);
SDL_FillRect(main_surface, &rect, col);
rect = (SDL_Rect){x + w - 1, y, 1, h};
SDL_FillRect(sdl_dib, &rect, col);
SDL_FillRect(main_surface, &rect, col);
}
/* 矩形塗りつぶし */
@@ -160,15 +160,15 @@ void sdl_fillRectangle(int x, int y, int w, int h, uint8_t c) {
sdl_pal_check();
SDL_Rect rect = {x, y, w, h};
SDL_FillRect(sdl_dib, &rect, palette_color(c));
SDL_FillRect(main_surface, &rect, palette_color(c));
}
void sdl_fillRectangleRGB(int x, int y, int w, int h, uint8_t r, uint8_t g, uint8_t b) {
if (sdl_dib->format->BitsPerPixel == 8)
if (main_surface->format->BitsPerPixel == 8)
return;
SDL_Rect rect = {x, y, w, h};
SDL_FillRect(sdl_dib, &rect, SDL_MapRGB(sdl_dib->format, r, g, b));
SDL_FillRect(main_surface, &rect, SDL_MapRGB(main_surface->format, r, g, b));
}
void sdl_fillCircle(int left, int top, int diameter, uint8_t c) {
@@ -185,7 +185,7 @@ void sdl_fillCircle(int left, int top, int diameter, uint8_t c) {
for (int x = 0; 2*x < diameter; x++) {
if (dy*dy + dx*dx <= diameter*diameter) {
SDL_Rect rect = {left + x, top + y, diameter - 2*x, 1};
SDL_FillRect(sdl_dib, &rect, col);
SDL_FillRect(main_surface, &rect, col);
break;
}
dx -= 2;
@@ -206,7 +206,7 @@ void sdl_copyArea(int sx, int sy, int w, int h, int dx, int dy) {
void* region = sdl_saveRegion(sx, sy, w, h);
sdl_restoreRegion(region, dx, dy);
} else {
SDL_BlitSurface(sdl_dib, &r_src, sdl_dib, &r_dst);
SDL_BlitSurface(main_surface, &r_src, main_surface, &r_dst);
}
}
@@ -214,20 +214,20 @@ static void sdl_dib_sprite_copy(SDL_Surface *dst, int sx, int sy, int w, int h,
sdl_pal_check();
Uint32 col = palette_color(sp);
SDL_SetColorKey(sdl_dib, SDL_TRUE, col);
SDL_SetColorKey(main_surface, SDL_TRUE, col);
SDL_Rect r_src = {sx, sy, w, h};
SDL_Rect r_dst = {dx, dy, w, h};
SDL_BlitSurface(sdl_dib, &r_src, dst, &r_dst);
SDL_SetColorKey(sdl_dib, SDL_FALSE, 0);
SDL_BlitSurface(main_surface, &r_src, dst, &r_dst);
SDL_SetColorKey(main_surface, SDL_FALSE, 0);
}
/*
* dib に指定のパレット sp を抜いてコピー
*/
void sdl_copyAreaSP(int sx, int sy, int w, int h, int dx, int dy, uint8_t sp) {
sdl_dib_sprite_copy(sdl_dib, sx, sy, w, h, dx, dy, sp);
sdl_dib_sprite_copy(main_surface, sx, sy, w, h, dx, dy, sp);
}
SDL_Surface *sdl_dib_to_surface_colorkey(int x, int y, int w, int h, int sp) {
@@ -245,7 +245,7 @@ void sdl_drawImage8_fromData(cgdata *cg, int dx, int dy, int sprite_color) {
sdl_pal_check();
if (sdl_dib->format->BitsPerPixel > 8 && cg->pal) {
if (main_surface->format->BitsPerPixel > 8 && cg->pal) {
SDL_Color *c = s->format->palette->colors;
for (int i = 0; i < 256; i++) {
c->r = cg->pal[i].r;
@@ -262,7 +262,7 @@ void sdl_drawImage8_fromData(cgdata *cg, int dx, int dy, int sprite_color) {
SDL_Rect r_dst = {dx, dy, w, h};
SDL_BlitSurface(s, NULL, sdl_dib, &r_dst);
SDL_BlitSurface(s, NULL, main_surface, &r_dst);
SDL_FreeSurface(s);
}
@@ -270,7 +270,7 @@ void sdl_drawImage8_fromData(cgdata *cg, int dx, int dy, int sprite_color) {
void sdl_drawLine(int x1, int y1, int x2, int y2, uint8_t c) {
sdl_pal_check();
SDL_Renderer *renderer = SDL_CreateSoftwareRenderer(sdl_dib);
SDL_Renderer *renderer = SDL_CreateSoftwareRenderer(main_surface);
SDL_SetRenderDrawColor(renderer, sdl_col[c].r, sdl_col[c].g, sdl_col[c].b, SDL_ALPHA_OPAQUE);
SDL_RenderDrawLine(renderer, x1, y1, x2, y2);
SDL_DestroyRenderer(renderer);
@@ -289,7 +289,7 @@ void sdl_drawLine(int x1, int y1, int x2, int y2, uint8_t c) {
SDL_Rect sdl_floodFill(int x, int y, int c) {
Uint32 col = palette_color(c);
switch (sdl_dib->format->BytesPerPixel) {
switch (main_surface->format->BytesPerPixel) {
case 1:
return sdl_floodFill_uint8_t(x, y, col);
case 2:
@@ -326,7 +326,7 @@ SDL_Rect sdl_drawString(int x, int y, const char *str_utf8, uint8_t col) {
* 指定範囲にパレット col を rate の割合で重ねる CK1
*/
void sdl_wrapColor(int sx, int sy, int w, int h, uint8_t c, int rate) {
SDL_Surface *s = SDL_CreateRGBSurfaceWithFormat(0, w, h, sdl_dib->format->BitsPerPixel, sdl_dib->format->format);
SDL_Surface *s = SDL_CreateRGBSurfaceWithFormat(0, w, h, main_surface->format->BitsPerPixel, main_surface->format->format);
assert(s->format->BitsPerPixel > 8);
SDL_Rect r_src = {0, 0, w, h};
@@ -335,6 +335,6 @@ void sdl_wrapColor(int sx, int sy, int w, int h, uint8_t c, int rate) {
SDL_SetSurfaceBlendMode(s, SDL_BLENDMODE_BLEND);
SDL_SetSurfaceAlphaMod(s, rate);
SDL_Rect r_dst = {sx, sy, w, h};
SDL_BlitSurface(s, &r_src, sdl_dib, &r_dst);
SDL_BlitSurface(s, &r_src, main_surface, &r_dst);
SDL_FreeSurface(s);
}
+29 -29
View File
@@ -75,14 +75,14 @@ void sdl_FlipSurfaceVertical(SDL_Surface *s) {
#endif
}
// Scaled copy in sdl_dib
// Scaled copy in main_surface
void sdl_scaledCopyArea(int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh, int mirror) {
SDL_Rect src_rect = {sx, sy, sw, sh};
SDL_Rect dst_rect = {dx, dy, dw, dh};
SDL_BlitScaled(sdl_dib, &src_rect, sdl_dib, &dst_rect);
SDL_BlitScaled(main_surface, &src_rect, main_surface, &dst_rect);
if (mirror) {
SDL_IntersectRect(&dst_rect, &(SDL_Rect){0, 0, sdl_dib->w, sdl_dib->h}, &dst_rect);
SDL_Surface *view = sdl_createSurfaceView(sdl_dib, dst_rect.x, dst_rect.y, dst_rect.w, dst_rect.h);
SDL_IntersectRect(&dst_rect, &(SDL_Rect){0, 0, main_surface->w, main_surface->h}, &dst_rect);
SDL_Surface *view = sdl_createSurfaceView(main_surface, dst_rect.x, dst_rect.y, dst_rect.w, dst_rect.h);
if (mirror & 1)
sdl_FlipSurfaceVertical(view);
if (mirror & 2)
@@ -142,7 +142,7 @@ void sdl_drawImage16_fromData(cgdata *cg, int dx, int dy, int brightness, bool a
SDL_SetSurfaceColorMod(s, brightness, brightness, brightness);
SDL_Rect r_dst = {dx, dy, w, h};
SDL_BlitSurface(s, NULL, sdl_dib, &r_dst);
SDL_BlitSurface(s, NULL, main_surface, &r_dst);
SDL_FreeSurface(s);
}
@@ -159,7 +159,7 @@ void sdl_drawImage24_fromData(cgdata *cg, int x, int y, int brightness) {
SDL_SetSurfaceColorMod(s, brightness, brightness, brightness);
SDL_Rect r_dst = {x, y, cg->width, cg->height};
SDL_BlitSurface(s, NULL, sdl_dib, &r_dst);
SDL_BlitSurface(s, NULL, main_surface, &r_dst);
SDL_FreeSurface(s);
}
@@ -167,7 +167,7 @@ SDL_Surface *sdl_dib_to_surface_with_alpha(int x, int y, int w, int h) {
SDL_Surface *s = SDL_CreateRGBSurfaceWithFormat(0, w, h, 32, SDL_PIXELFORMAT_ARGB8888);
SDL_Rect r_src = {x, y, w, h};
SDL_BlitSurface(sdl_dib, &r_src, s, NULL);
SDL_BlitSurface(main_surface, &r_src, s, NULL);
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
uint8_t *p_ds = s->pixels + 3;
@@ -194,29 +194,29 @@ void sdl_copyAreaSP16_shadow(int sx, int sy, int w, int h, int dx, int dy, int l
SDL_SetSurfaceAlphaMod(s, lv);
SDL_Rect r_dst = {dx, dy, w, h};
SDL_BlitSurface(s, NULL, sdl_dib, &r_dst);
SDL_BlitSurface(s, NULL, main_surface, &r_dst);
SDL_FreeSurface(s);
}
void sdl_copyAreaSP16_alphaBlend(int sx, int sy, int w, int h, int dx, int dy, int lv) {
SDL_Rect r_src = {sx, sy, w, h};
SDL_Rect r_dst = {dx, dy, w, h};
SDL_SetSurfaceBlendMode(sdl_dib, SDL_BLENDMODE_BLEND);
SDL_SetSurfaceAlphaMod(sdl_dib, lv);
SDL_BlitSurface(sdl_dib, &r_src, sdl_dib, &r_dst);
SDL_SetSurfaceAlphaMod(sdl_dib, 255);
SDL_SetSurfaceBlendMode(sdl_dib, SDL_BLENDMODE_NONE);
SDL_SetSurfaceBlendMode(main_surface, SDL_BLENDMODE_BLEND);
SDL_SetSurfaceAlphaMod(main_surface, lv);
SDL_BlitSurface(main_surface, &r_src, main_surface, &r_dst);
SDL_SetSurfaceAlphaMod(main_surface, 255);
SDL_SetSurfaceBlendMode(main_surface, SDL_BLENDMODE_NONE);
}
void sdl_copyAreaSP16_alphaLevel(int sx, int sy, int w, int h, int dx, int dy, int lv) {
SDL_Rect r_src = {sx, sy, w, h};
SDL_Rect r_dst = {dx, dy, w, h};
SDL_SetSurfaceBlendMode(sdl_dib, SDL_BLENDMODE_BLEND);
SDL_SetSurfaceAlphaMod(sdl_dib, lv);
SDL_FillRect(sdl_dib, &r_dst, 0);
SDL_BlitSurface(sdl_dib, &r_src, sdl_dib, &r_dst);
SDL_SetSurfaceAlphaMod(sdl_dib, 255);
SDL_SetSurfaceBlendMode(sdl_dib, SDL_BLENDMODE_NONE);
SDL_SetSurfaceBlendMode(main_surface, SDL_BLENDMODE_BLEND);
SDL_SetSurfaceAlphaMod(main_surface, lv);
SDL_FillRect(main_surface, &r_dst, 0);
SDL_BlitSurface(main_surface, &r_src, main_surface, &r_dst);
SDL_SetSurfaceAlphaMod(main_surface, 255);
SDL_SetSurfaceBlendMode(main_surface, SDL_BLENDMODE_NONE);
}
void sdl_copy_from_alpha(int sx, int sy, int w, int h, int dx, int dy, ALPHA_DIB_COPY_TYPE flag) {
@@ -231,13 +231,13 @@ void sdl_copy_to_alpha(int sx, int sy, int w, int h, int dx, int dy, ALPHA_DIB_C
* dib のピクセル情報を取得
*/
void sdl_getPixel(int x, int y, Palette *cell) {
uint8_t *p = PIXEL_AT(sdl_dib, x, y);
if (sdl_dib->format->BitsPerPixel == 8) {
uint8_t *p = PIXEL_AT(main_surface, x, y);
if (main_surface->format->BitsPerPixel == 8) {
cell->pixel = *p;
} else {
Uint32 cl=0;
switch (sdl_dib->format->BytesPerPixel) {
switch (main_surface->format->BytesPerPixel) {
case 2:
{
unsigned short *pp = (unsigned short *)p;
@@ -258,7 +258,7 @@ void sdl_getPixel(int x, int y, Palette *cell) {
}
break;
}
SDL_GetRGB(cl, sdl_dib->format, &cell->r, &cell->g, &cell->b);
SDL_GetRGB(cl, main_surface->format, &cell->r, &cell->g, &cell->b);
}
}
@@ -266,13 +266,13 @@ void sdl_getPixel(int x, int y, Palette *cell) {
* dib から領域の切り出し
*/
void* sdl_saveRegion(int x, int y, int w, int h) {
SDL_Surface *s = SDL_CreateRGBSurfaceWithFormat(0, w, h, sdl_dib->format->BitsPerPixel, sdl_dib->format->format);
if (sdl_dib->format->BitsPerPixel == 8)
memcpy(s->format->palette->colors, sdl_dib->format->palette->colors,
sizeof(SDL_Color) * sdl_dib->format->palette->ncolors);
SDL_Surface *s = SDL_CreateRGBSurfaceWithFormat(0, w, h, main_surface->format->BitsPerPixel, main_surface->format->format);
if (main_surface->format->BitsPerPixel == 8)
memcpy(s->format->palette->colors, main_surface->format->palette->colors,
sizeof(SDL_Color) * main_surface->format->palette->ncolors);
SDL_Rect r_src = {x, y, w, h};
SDL_Rect r_dst = {0, 0, w, h};
SDL_BlitSurface(sdl_dib, &r_src, s, &r_dst);
SDL_BlitSurface(main_surface, &r_src, s, &r_dst);
return s;
}
@@ -292,7 +292,7 @@ void sdl_putRegion(void *psrc, int x, int y) {
SDL_Rect r_src = {0, 0, src->w, src->h};
SDL_Rect r_dst = {x, y, src->w, src->h};
SDL_BlitSurface(src, &r_src, sdl_dib, &r_dst);
SDL_BlitSurface(src, &r_src, main_surface, &r_dst);
}
/*
-1
View File
@@ -33,7 +33,6 @@
extern SDL_Window *sdl_window;
extern SDL_Renderer *sdl_renderer;
extern SDL_Texture *sdl_texture;
extern SDL_Surface *sdl_dib; // offscreen surface
extern SDL_Color sdl_col[256]; // color palette
extern agsurface_t *sdl_dibinfo;
extern int view_w;
+15 -15
View File
@@ -39,7 +39,7 @@
SDL_Window *sdl_window;
SDL_Renderer *sdl_renderer;
SDL_Texture *sdl_texture;
SDL_Surface *sdl_dib; // offscreen surface
SDL_Surface *main_surface; // offscreen surface
SDL_Color sdl_col[256]; // color palette
agsurface_t *sdl_dibinfo;
int view_w;
@@ -104,8 +104,8 @@ int sdl_Initialize(const char *render_driver) {
}
void sdl_Remove(void) {
if (sdl_dib)
SDL_FreeSurface(sdl_dib);
if (main_surface)
SDL_FreeSurface(main_surface);
if (sdl_renderer)
SDL_DestroyRenderer(sdl_renderer);
if (js)
@@ -159,8 +159,8 @@ static void window_init(const char *render_driver) {
static void makeDIB(int width, int height, int depth) {
if (sdl_dib) {
SDL_FreeSurface(sdl_dib);
if (main_surface) {
SDL_FreeSurface(main_surface);
}
uint32_t format = 0;
@@ -180,10 +180,10 @@ static void makeDIB(int width, int height, int depth) {
SYSERROR("invalid pixel depth %d", depth);
}
sdl_dib = SDL_CreateRGBSurfaceWithFormat(0, width, height, depth, format);
main_surface = SDL_CreateRGBSurfaceWithFormat(0, width, height, depth, format);
if (sdl_dib->format->BitsPerPixel == 8) {
memset(sdl_dib->format->palette->colors, 0, sizeof(SDL_Color)*256);
if (main_surface->format->BitsPerPixel == 8) {
memset(main_surface->format->palette->colors, 0, sizeof(SDL_Color)*256);
}
if (sdl_dibinfo) {
@@ -191,14 +191,14 @@ static void makeDIB(int width, int height, int depth) {
}
sdl_dibinfo = calloc(1, sizeof(agsurface_t));
sdl_dibinfo->depth = sdl_dib->format->BitsPerPixel;
sdl_dibinfo->bytes_per_pixel = sdl_dib->format->BytesPerPixel;
sdl_dibinfo->bytes_per_line = sdl_dib->pitch;
sdl_dibinfo->pixel = sdl_dib->pixels;
sdl_dibinfo->depth = main_surface->format->BitsPerPixel;
sdl_dibinfo->bytes_per_pixel = main_surface->format->BytesPerPixel;
sdl_dibinfo->bytes_per_line = main_surface->pitch;
sdl_dibinfo->pixel = main_surface->pixels;
sdl_dibinfo->width = width;
sdl_dibinfo->height = height;
sdl_dibinfo->alpha = NULL;
sdl_dibinfo->sdl_surface = sdl_dib;
sdl_dibinfo->sdl_surface = main_surface;
image_setdepth(sdl_dibinfo->depth);
}
@@ -206,7 +206,7 @@ static void makeDIB(int width, int height, int depth) {
/* offscreen の設定 */
void sdl_setWorldSize(int width, int height, int depth) {
makeDIB(width, height, depth);
SDL_FillRect(sdl_dib, NULL, 0);
SDL_FillRect(main_surface, NULL, 0);
}
/* display の size と depth の取得 */
@@ -299,7 +299,7 @@ void sdl_setIntegerScaling(bool enable) {
bool EMSCRIPTEN_KEEPALIVE save_screenshot(const char* path) {
SDL_Rect *r = &nact->ags.view_area;
SDL_Surface *view = sdl_createSurfaceView(sdl_dib, r->x, r->y, r->w, r->h);
SDL_Surface *view = sdl_createSurfaceView(main_surface, r->x, r->y, r->w, r->h);
bool ok = SDL_SaveBMP(view, path) == 0;
SDL_FreeSurface(view);
return ok;