Skip to content

Commit

Permalink
MorphOS: test bitmap on fullscreen mode
Browse files Browse the repository at this point in the history
Fix some bug with FreeBitMap

Now use BitMap with BMF_3DTARGET flags when use Window or FullScreen mode
  • Loading branch information
BeWorld2018 committed Oct 10, 2023
1 parent 4bc63b6 commit c3b26d0
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 17 deletions.
3 changes: 2 additions & 1 deletion src/video/morphos/SDL_mosmodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,12 +295,13 @@ MOS_GetScreen(_THIS, BYTE fullscreen, SDL_bool support3d)
int use_wb_screen = 0;
ULONG openError = 0;

D("[%s] support3d=%d - Use monitor '%s' - Screen %d\n", __FUNCTION__, support3d, data->ScrMonName ? data->ScrMonName : (STRPTR)"Workbench", data->CustomScreen);

if (!fullscreen && data->ScrMonName == NULL) {
data->CustomScreen = NULL;
screen = LockPubScreen(NULL);
use_wb_screen = 1;
D("[%s] USE WORKBENCH\n", __FUNCTION__);

} else {

screen = OpenScreenTags(NULL,
Expand Down
50 changes: 34 additions & 16 deletions src/video/morphos/SDL_mosopengl.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,30 @@ SDL_bool MOS_GL_AllocBitmap(_THIS, SDL_Window * window)
{
D("[%s]\n", __FUNCTION__);
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
SDL_VideoData *vd = data->videodata;
int sizex = 0;
int sizey = 0;
ULONG bmflags;

if (data->bitmap == NULL) {
if (data->bitmap != NULL) {
//D("[%s] FreeBitMap\n", __FUNCTION__);
FreeBitMap(data->bitmap);
data->bitmap = NULL;
}

int sizex = window->w; //data->win->Width - data->win->BorderLeft - data->win->BorderRight;
int sizey = window->h; //data->win->Height - data->win->BorderTop - data->win->BorderBottom;
data->bitmap = AllocBitMap(sizex, sizey, data->win->RPort->BitMap->Depth, BMF_MINPLANES|BMF_DISPLAYABLE|BMF_3DTARGET, data->win->RPort->BitMap);
BYTE fullscreen = data->winflags & SDL_MOS_WINDOW_FULLSCREEN;
if (fullscreen) {
sizex = vd->ScrWidth;
sizey = vd->ScrHeight;

}else{

sizex = window->w; //data->win->Width - data->win->BorderLeft - data->win->BorderRight;
sizey = window->h; //data->win->Height - data->win->BorderTop - data->win->BorderBottom;
}

bmflags = BMF_MINPLANES|BMF_DISPLAYABLE|BMF_3DTARGET;
data->bitmap = AllocBitMap(sizex, sizey, data->win->RPort->BitMap->Depth, bmflags, data->win->RPort->BitMap);

if (data->bitmap == NULL) {
D("[%s] Failed to create Bitmap\n", __FUNCTION__);
Expand All @@ -123,6 +138,7 @@ SDL_bool MOS_GL_InitContext(_THIS, SDL_Window * window, GLContext *glcont)
if (data->__tglContext != NULL) {
GLADestroyContext(data->__tglContext);
if (data->bitmap != NULL) {
//D("[%s] FreeBitMap\n", __FUNCTION__);
FreeBitMap(data->bitmap);
data->bitmap = NULL;
}
Expand All @@ -137,16 +153,13 @@ SDL_bool MOS_GL_InitContext(_THIS, SDL_Window * window, GLContext *glcont)

SDL_VideoData *vd = data->videodata;
BYTE fullscreen = data->winflags & SDL_MOS_WINDOW_FULLSCREEN;
if (fullscreen) {

tgltags[0].ti_Tag = TGL_CONTEXT_SCREEN;
tgltags[0].ti_Data = (IPTR)vd->CustomScreen;

if (MOS_GL_AllocBitmap(_this, window)) {
tgltags[0].ti_Tag = TGL_CONTEXT_BITMAP;
tgltags[0].ti_Data = (IPTR)data->bitmap;
} else {

if (MOS_GL_AllocBitmap(_this, window)) {
tgltags[0].ti_Tag = TGL_CONTEXT_BITMAP;
tgltags[0].ti_Data = (IPTR)data->bitmap;
if (fullscreen) {
tgltags[0].ti_Tag = TGL_CONTEXT_SCREEN;
tgltags[0].ti_Data = (IPTR)vd->CustomScreen;
} else {
tgltags[0].ti_Tag = TGL_CONTEXT_WINDOW;
tgltags[0].ti_Data = (IPTR)data->win;
Expand All @@ -168,7 +181,8 @@ SDL_bool MOS_GL_InitContext(_THIS, SDL_Window * window, GLContext *glcont)
if (withnewextension)
tglEnableNewExtensions(0); // Active TinyGL New extensions
}

//D("[%s] success=%d\n", __FUNCTION__, success);

return success ? SDL_TRUE : SDL_FALSE;
}

Expand All @@ -193,7 +207,8 @@ MOS_GL_CreateContext(_THIS, SDL_Window * window)
return glcont;
}
D("[%s] FAILED 0x%08lx\n", __FUNCTION__, glcont);
if (data->bitmap) {
if (data->bitmap != NULL) {
//D("[%s] FreeBitMap\n", __FUNCTION__);
FreeBitMap(data->bitmap);
data->bitmap = NULL;
}
Expand Down Expand Up @@ -308,8 +323,11 @@ MOS_GL_DeleteContext(_THIS, SDL_GLContext context)
D("[%s] Found TinyGL context 0x%08lx, clearing window binding\n", __FUNCTION__, context);
GLADestroyContext(context);

if (data->bitmap != NULL)
if (data->bitmap != NULL) {
FreeBitMap(data->bitmap);
//D("[%s] FreeBitMap\n", __FUNCTION__);
data->bitmap = NULL;
}

GLClose(context);
data->__tglContext = NULL;
Expand Down

0 comments on commit c3b26d0

Please sign in to comment.