src/SDL12_compat.c
changeset 56 a8a08936f60f
parent 55 852e5d3808f2
child 57 9bc9f6285f0b
equal deleted inserted replaced
55:852e5d3808f2 56:a8a08936f60f
   418 } VideoModeList;
   418 } VideoModeList;
   419 
   419 
   420 // !!! FIXME: go through all of these.
   420 // !!! FIXME: go through all of these.
   421 static VideoModeList *VideoModes = NULL;
   421 static VideoModeList *VideoModes = NULL;
   422 static int VideoModesCount = 0;
   422 static int VideoModesCount = 0;
   423 static SDL12_VideoInfo VideoInfo;
   423 static SDL12_VideoInfo VideoInfo12;
   424 static SDL_Window *VideoWindow20 = NULL;
   424 static SDL_Window *VideoWindow20 = NULL;
   425 static SDL12_Surface *WindowSurface = NULL;
   425 static SDL_Renderer *VideoRenderer20 = NULL;
   426 static SDL12_Surface *VideoSurface = NULL;
   426 static SDL_Texture *VideoTexture20 = NULL;
   427 static SDL12_Surface *ShadowSurface = NULL;
   427 static SDL12_Surface *VideoSurface12 = NULL;
   428 static SDL12_Surface *PublicSurface = NULL;
   428 static SDL_Surface *VideoConvertSurface20 = NULL;
   429 static SDL_GLContext *VideoContext = NULL;
   429 static SDL_GLContext *VideoGLContext20 = NULL;
   430 static Uint32 VideoFlags = 0;
       
   431 static SDL_Rect VideoViewport;
       
   432 static char *WindowTitle = NULL;
   430 static char *WindowTitle = NULL;
   433 static char *WindowIconTitle = NULL;
   431 static char *WindowIconTitle = NULL;
   434 static SDL_Surface *VideoIcon;
   432 static SDL12_Surface *VideoIcon12;
   435 static int EnabledUnicode = 0;
   433 static int EnabledUnicode = 0;
   436 static int VideoDisplayIndex = 0;
   434 static int VideoDisplayIndex = 0;
   437 static int CDRomInit = 0;
   435 static int CDRomInit = 0;
   438 static SDL12_EventFilter EventFilter12 = NULL;
   436 static SDL12_EventFilter EventFilter12 = NULL;
   439 static SDL12_Cursor *CurrentCursor = NULL;
   437 static SDL12_Cursor *CurrentCursor12 = NULL;
   440 static Uint8 EventStates[SDL12_NUMEVENTS];
   438 static Uint8 EventStates[SDL12_NUMEVENTS];
   441 static int SwapInterval = 0;
   439 static int SwapInterval = 0;
   442 
   440 
   443 // !!! FIXME: need a mutex for the event queue.
   441 // !!! FIXME: need a mutex for the event queue.
   444 #define SDL12_MAXEVENTS 128
   442 #define SDL12_MAXEVENTS 128
   755         SDL20_free(VideoModes[i].modeslist);
   753         SDL20_free(VideoModes[i].modeslist);
   756         SDL20_free(VideoModes[i].modes);
   754         SDL20_free(VideoModes[i].modes);
   757     }
   755     }
   758     SDL20_free(VideoModes);
   756     SDL20_free(VideoModes);
   759 
   757 
   760     SDL20_FreeFormat(VideoInfo.vfmt);
   758     SDL20_FreeFormat(VideoInfo12.vfmt);
   761     SDL20_zero(VideoInfo);
   759     SDL20_zero(VideoInfo12);
   762 
   760 
   763     EventFilter12 = NULL;
   761     EventFilter12 = NULL;
   764     EventQueueAvailable = EventQueueHead = EventQueueTail = NULL;
   762     EventQueueAvailable = EventQueueHead = EventQueueTail = NULL;
   765     CurrentCursor = NULL;
   763     CurrentCursor12 = NULL;
   766     VideoModes = NULL;
   764     VideoModes = NULL;
   767     VideoModesCount = 0;
   765     VideoModesCount = 0;
   768 }
   766 }
   769 
   767 
   770 DECLSPEC void SDLCALL
   768 DECLSPEC void SDLCALL
  1422 DECLSPEC const SDL12_VideoInfo * SDLCALL
  1420 DECLSPEC const SDL12_VideoInfo * SDLCALL
  1423 SDL_GetVideoInfo(void)
  1421 SDL_GetVideoInfo(void)
  1424 {
  1422 {
  1425     SDL_DisplayMode mode;
  1423     SDL_DisplayMode mode;
  1426 
  1424 
  1427     // !!! FIXME: calculate this in Init12Video(), then this just does: return VideoInfo.vfmt ? &VideoInfo : NULL;
  1425     FIXME("calculate this in Init12Video(), then this just does: return VideoInfo.vfmt ? &VideoInfo : NULL;");
  1428 
  1426 
  1429     if (!VideoInfo.vfmt && SDL20_GetDesktopDisplayMode(VideoDisplayIndex, &mode) == 0) {
  1427     if (!VideoInfo12.vfmt && SDL20_GetDesktopDisplayMode(VideoDisplayIndex, &mode) == 0) {
  1430         VideoInfo.vfmt = SDL20_AllocFormat(mode.format);
  1428         VideoInfo12.vfmt = SDL20_AllocFormat(mode.format);
  1431         VideoInfo.current_w = mode.w;
  1429         VideoInfo12.current_w = mode.w;
  1432         VideoInfo.current_h = mode.h;
  1430         VideoInfo12.current_h = mode.h;
  1433         // !!! FIXME
  1431         FIXME("vidinfo details commented out");
  1434         //VideoInfo.wm_available = 1;
  1432         //VideoInfo12.wm_available = 1;
  1435         //VideoInfo.video_mem = 1024 * 256;
  1433         //VideoInfo12.video_mem = 1024 * 256;
  1436     }
  1434     }
  1437     return &VideoInfo;
  1435     return &VideoInfo12;
  1438 }
  1436 }
  1439 
  1437 
  1440 DECLSPEC int SDLCALL
  1438 DECLSPEC int SDLCALL
  1441 SDL_VideoModeOK(int width, int height, int bpp, Uint32 sdl12flags)
  1439 SDL_VideoModeOK(int width, int height, int bpp, Uint32 sdl12flags)
  1442 {
  1440 {
  1476 
  1474 
  1477     if (!SDL20_WasInit(SDL_INIT_VIDEO)) {
  1475     if (!SDL20_WasInit(SDL_INIT_VIDEO)) {
  1478         return NULL;
  1476         return NULL;
  1479     }
  1477     }
  1480 
  1478 
  1481     if ((!format12) && (!VideoInfo.vfmt)) {
  1479     if ((!format12) && (!VideoInfo12.vfmt)) {
  1482         SDL20_SetError("No pixel format specified");
  1480         SDL20_SetError("No pixel format specified");
  1483         return NULL;
  1481         return NULL;
  1484     }
  1482     }
  1485 
  1483 
  1486     if (!(flags & SDL12_FULLSCREEN)) {
  1484     if (!(flags & SDL12_FULLSCREEN)) {
  1488     }
  1486     }
  1489 
  1487 
  1490     if (format12) {
  1488     if (format12) {
  1491         fmt = SDL20_MasksToPixelFormatEnum(format12->BitsPerPixel, format12->Rmask, format12->Gmask, format12->Bmask, format12->Amask);
  1489         fmt = SDL20_MasksToPixelFormatEnum(format12->BitsPerPixel, format12->Rmask, format12->Gmask, format12->Bmask, format12->Amask);
  1492     } else {
  1490     } else {
  1493         fmt = VideoInfo.vfmt->format;
  1491         fmt = VideoInfo12.vfmt->format;
  1494     }
  1492     }
  1495 
  1493 
  1496     for (i = 0; i < VideoModesCount; i++) {
  1494     for (i = 0; i < VideoModesCount; i++) {
  1497         VideoModeList *modes = &VideoModes[i];
  1495         VideoModeList *modes = &VideoModes[i];
  1498         if (modes->format == fmt) {
  1496         if (modes->format == fmt) {
  1562 }
  1560 }
  1563 
  1561 
  1564 DECLSPEC void SDLCALL
  1562 DECLSPEC void SDLCALL
  1565 SDL_SetCursor(SDL12_Cursor *cursor)
  1563 SDL_SetCursor(SDL12_Cursor *cursor)
  1566 {
  1564 {
  1567     CurrentCursor = cursor;
  1565     CurrentCursor12 = cursor;
  1568     SDL20_SetCursor(cursor ? cursor->wm_cursor : NULL);
  1566     SDL20_SetCursor(cursor ? cursor->wm_cursor : NULL);
  1569 }
  1567 }
  1570 
  1568 
  1571 DECLSPEC SDL12_Cursor * SDLCALL
  1569 DECLSPEC SDL12_Cursor * SDLCALL
  1572 SDL_GetCursor(void)
  1570 SDL_GetCursor(void)
  1573 {
  1571 {
  1574     return CurrentCursor;
  1572     return CurrentCursor12;
  1575 }
  1573 }
  1576 
  1574 
  1577 static void
  1575 static void
  1578 GetEnvironmentWindowPosition(int w, int h, int *x, int *y)
  1576 GetEnvironmentWindowPosition(int w, int h, int *x, int *y)
  1579 {
  1577 {
  1624 }
  1622 }
  1625 
  1623 
  1626 DECLSPEC SDL12_Surface * SDLCALL
  1624 DECLSPEC SDL12_Surface * SDLCALL
  1627 SDL_GetVideoSurface(void)
  1625 SDL_GetVideoSurface(void)
  1628 {
  1626 {
  1629 #error write me
  1627     return VideoSurface12;
  1630 }
  1628 }
  1631 
  1629 
  1632 DECLSPEC int SDLCALL
  1630 DECLSPEC int SDLCALL
  1633 SDL_SetAlpha(SDL12_Surface * surface, Uint32 flag, Uint8 value)
  1631 SDL_SetAlpha(SDL12_Surface * surface, Uint32 flag, Uint8 value)
  1634 {
  1632 {