static void set_best_resolution(_THIS, int width, int height) { Uint32 idok; int depth=8; if(SDL_Display) depth=GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_DEPTH); idok=BestCModeIDTags(CYBRBIDTG_NominalWidth,width, CYBRBIDTG_NominalHeight,height, CYBRBIDTG_Depth,depth, TAG_DONE); if(idok!=INVALID_ID) { if(SDL_Display) { if(currently_fullscreen) CloseScreen(SDL_Display); else UnlockPubScreen(NULL,SDL_Display); } SDL_Display=GFX_Display=OpenScreenTags(NULL,SA_Width,width,SA_Height,height, SA_Depth,depth,SA_DisplayID,idok, SA_ShowTitle,FALSE, TAG_DONE); } }
static void getvisual(void) { if (!(scr = LockPubScreen(NULL))) { cleanup("Can't lock pub screen!"); } if (1) { LONG val; val = GetCyberMapAttr(scr->RastPort.BitMap,CYBRMATTR_PIXFMT); printf("cgfx attribute = %ld\n", val); } if (GetBitMapAttr(scr->RastPort.BitMap, BMA_DEPTH) <= 8) { cleanup("Need hi or true color screen!"); } }
BOOL MESA3DGLStandardInit(struct mesa3dgl_context * ctx, struct TagItem *tagList) { LONG requestedwidth = 0, requestedheight = 0; LONG requestedright = 0, requestedbottom = 0; LONG defaultleft = 0, defaulttop = 0; LONG defaultright = 0, defaultbottom = 0; D(bug("[MESA3DGL] %s(ctx @ 0x%p, taglist @ 0x%p)\n", __PRETTY_FUNCTION__, ctx, tagList)); /* Set the defaults based on window information */ if (ctx->window) { if(!(ctx->window->Flags & WFLG_GIMMEZEROZERO)) { defaultleft = ctx->window->BorderLeft; defaulttop = ctx->window->BorderTop; defaultright = ctx->window->BorderRight; defaultbottom = ctx->window->BorderBottom; } } D(bug("[MESA3DGL] %s: Using RastPort @ 0x%p\n", __PRETTY_FUNCTION__, ctx->visible_rp)); ctx->visible_rp = CloneRastPort(ctx->visible_rp); D(bug("[MESA3DGL] %s: Cloned RastPort @ 0x%p\n", __PRETTY_FUNCTION__, ctx->visible_rp)); /* We assume left and top are given or if there is a window, set to border left/top or if there is no window set to 0 */ ctx->left = GetTagData(GLA_Left, defaultleft, tagList); ctx->top = GetTagData(GLA_Top, defaulttop, tagList); requestedright = GetTagData(GLA_Right, -1, tagList); requestedbottom = GetTagData(GLA_Bottom, -1, tagList); requestedwidth = GetTagData(GLA_Width, -1 , tagList); requestedheight = GetTagData(GLA_Height, -1 , tagList); /* Calculate rastport dimensions */ ctx->visible_rp_width = ctx->visible_rp->Layer->bounds.MaxX - ctx->visible_rp->Layer->bounds.MinX + 1; ctx->visible_rp_height = ctx->visible_rp->Layer->bounds.MaxY - ctx->visible_rp->Layer->bounds.MinY + 1; /* right will be either passed or calculated from width or 0 */ ctx->right = 0; if (requestedright < 0) { if (requestedwidth >= 0) { requestedright = ctx->visible_rp_width - ctx->left - requestedwidth; if (requestedright < 0) requestedright = 0; } else requestedright = defaultright; /* Set the default here, not in GetDataData */ } ctx->right = requestedright; /* bottom will be either passed or calculated from height or 0 */ ctx->bottom = 0; if (requestedbottom < 0) { if (requestedheight >= 0) { requestedbottom = ctx->visible_rp_height - ctx->top - requestedheight; if (requestedbottom < 0) requestedbottom = 0; } else requestedbottom = defaultbottom; /* Set the default here, not in GetDataData */ } ctx->bottom = requestedbottom; /* Init screen information */ if (ctx->Screen) ctx->BitsPerPixel = GetCyberMapAttr(ctx->Screen->RastPort.BitMap, CYBRMATTR_BPPIX) * 8; D(bug("[MESA3DGL] %s: Context Base dimensions set -:\n", __PRETTY_FUNCTION__)); D(bug("[MESA3DGL] %s: ctx->visible_rp_width = %d\n", __PRETTY_FUNCTION__, ctx->visible_rp_width)); D(bug("[MESA3DGL] %s: ctx->visible_rp_height = %d\n", __PRETTY_FUNCTION__, ctx->visible_rp_height)); D(bug("[MESA3DGL] %s: ctx->left = %d\n", __PRETTY_FUNCTION__, ctx->left)); D(bug("[MESA3DGL] %s: ctx->right = %d\n", __PRETTY_FUNCTION__, ctx->right)); D(bug("[MESA3DGL] %s: ctx->top = %d\n", __PRETTY_FUNCTION__, ctx->top)); D(bug("[MESA3DGL] %s: ctx->bottom = %d\n", __PRETTY_FUNCTION__, ctx->bottom)); return TRUE; }
int detect_screen(void) { struct Screen *myScreen; struct Window *myWindow; struct RastPort myRastPort; struct BitMap *myBitMap; APTR bitMapHandle; ULONG result; int bpp = 0; if((ULONG)IntuitionBase == 0) { IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 39L); } if((ULONG)GfxBase == 0) { GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 39L); } if((ULONG)CyberGfxBase == 0) { CyberGfxBase = OpenLibrary("cybergraphics.library", 0); } if(!CyberGfxBase) { if( !(CyberGfxBase=OpenLibrary("cybergraphics.library",40L))) { printf("Couldn't open cybergraphics."); return(-1); } } myScreen = LockPubScreen(NULL); if(myScreen != NULL) { UnlockPubScreen(NULL, myScreen); } else { printf("Couldnt get screen data.\n"); CloseLibrary((struct Library*)IntuitionBase); CloseLibrary(CyberGfxBase); CloseLibrary((struct Library *)GfxBase); return 5; } myBitMap = AllocBitMap(1, 1, 8, BMF_MINPLANES | BMF_DISPLAYABLE, myScreen->RastPort.BitMap); if((ULONG)myBitMap == 0) { printf("Couldnt allocate bitmap.\n"); CloseLibrary(CyberGfxBase); CloseLibrary((struct Library *)GfxBase); CloseLibrary((struct Library *)IntuitionBase); return 6; } //Creates the RastPort used for blitting InitRastPort(&myRastPort); myRastPort.BitMap = myBitMap; result=GetCyberMapAttr(myBitMap, CYBRMATTR_PIXFMT); switch(result) { case 0://PIXFMT_LUT8: bpp = 8; //printf("0"); break; case 1://PIXFMT_RGB15: bpp = 16; //printf("1"); break; case 2://PIXFMT_BGR15: bpp = 16; //printf("2"); break; case 3://PIXFMT_RGB15PC: bpp = 16; //printf("3"); break; case 4://PIXFMT_BGR15PC: bpp = 16; //printf("4"); break; case 5://PIXFMT_RGB16: bpp = 16; //printf("5"); break; case 6://PIXFMT_BGR16: bpp = 16; //printf("6"); break; case 7://PIXFMT_RGB16PC: bpp = 16; //printf("7"); break; case 8://PIXFMT_BGR16PC: bpp = 16; //printf("8"); break; case 9://PIXFMT_RGB24: bpp = 24; //printf("9"); break; case 10://PIXFMT_BGR24: bpp = 24; //printf("10"); break; case 11://PIXFMT_ARGB32: bpp = 32; //printf("11"); break; case 12://PIXFMT_BGRA32: #if defined NOVA_SDL bpp = 16; //printf("12"); #else bpp = 32; //printf("12"); #endif break; case 13://PIXFMT_RGBA32: bpp = 32; //printf("13"); break; default: bpp = 16; //printf("14"); } #ifdef DEBUG printf("Pixel format: %d \n",result); printf("Bpp: %d ",bpp); #endif FreeBitMap(myBitMap); CloseLibrary((struct Library *)IntuitionBase); //CloseLibrary(CyberGfxBase); //CloseLibrary((struct Library *)GfxBase); return bpp; }
int GetBitMapInfoA(struct BitMap *bm, UWORD displayID, TAGLIST tags) { int count = 0; if (bm) { BOOL cyberbitmap = FALSE; LONG depth; LONG *p; depth = GetBitMapAttr(bm, BMA_DEPTH); if (CyberGfxBase) { if (GetCyberMapAttr(bm, CYBRMATTR_ISCYBERGFX)) { cyberbitmap = TRUE; depth = GetCyberMapAttr(bm, CYBRMATTR_DEPTH); } } if (p = (LONG *) GetTagData(BMAPATTR_Width, NULL, tags)) { *p = GetBitMapAttr(bm, BMA_WIDTH); count++; } if (p = (LONG *) GetTagData(BMAPATTR_Height, NULL, tags)) { *p = GetBitMapAttr(bm, BMA_HEIGHT); count++; } if (p = (LONG *) GetTagData(BMAPATTR_Depth, NULL, tags)) { *p = depth; count++; } if (p = (LONG *) GetTagData(BMAPATTR_CyberGFX, NULL, tags)) { *p = (LONG) cyberbitmap; count++; } if (p = (LONG *) GetTagData(BMAPATTR_BitMapFormat, NULL, tags)) { if (cyberbitmap) { if (depth > 8) { *p = PIXFMT_BITMAP_RGB; } else { *p = PIXFMT_BITMAP_CLUT; } } else { if ((displayID != INVALID_ID) && (displayID & HAM)) { switch (depth) { case 8: *p = PIXFMT_BITMAP_HAM8; break; case 6: *p = PIXFMT_BITMAP_HAM6; break; default: *p = PIXFMT_BITMAP_CLUT; } } else { *p = PIXFMT_BITMAP_CLUT; } } count++; } if (p = (LONG *) GetTagData(BMAPATTR_PixelFormat, NULL, tags)) { LONG bf; GetBitMapInfo(bm, displayID, BMAPATTR_BitMapFormat, &bf, TAG_DONE); switch (bf) { case PIXFMT_BITMAP_HAM6: case PIXFMT_BITMAP_HAM8: case PIXFMT_BITMAP_RGB: *p = PIXFMT_0RGB_32; break; default: case PIXFMT_BITMAP_CLUT: *p = PIXFMT_CHUNKY_CLUT; break; } count++; } if (p = (LONG *) GetTagData(BMAPATTR_Flags, NULL, tags)) { *p = GetBitMapAttr(bm, BMA_FLAGS); count++; } } return count; }