vid_null.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. // vid_null.c -- null video driver to aid porting efforts
  2. // this assumes that one of the refs is statically linked to the executable
  3. #include "../client/client.h"
  4. viddef_t viddef; // global video state
  5. refexport_t re;
  6. refexport_t GetRefAPI (refimport_t rimp);
  7. /*
  8. ==========================================================================
  9. DIRECT LINK GLUE
  10. ==========================================================================
  11. */
  12. #define MAXPRINTMSG 4096
  13. void VID_Printf (int print_level, char *fmt, ...)
  14. {
  15. va_list argptr;
  16. char msg[MAXPRINTMSG];
  17. va_start (argptr,fmt);
  18. vsprintf (msg,fmt,argptr);
  19. va_end (argptr);
  20. if (print_level == PRINT_ALL)
  21. Com_Printf ("%s", msg);
  22. else
  23. Com_DPrintf ("%s", msg);
  24. }
  25. void VID_Error (int err_level, char *fmt, ...)
  26. {
  27. va_list argptr;
  28. char msg[MAXPRINTMSG];
  29. va_start (argptr,fmt);
  30. vsprintf (msg,fmt,argptr);
  31. va_end (argptr);
  32. Com_Error (err_level, "%s", msg);
  33. }
  34. void VID_NewWindow (int width, int height)
  35. {
  36. viddef.width = width;
  37. viddef.height = height;
  38. }
  39. /*
  40. ** VID_GetModeInfo
  41. */
  42. typedef struct vidmode_s
  43. {
  44. const char *description;
  45. int width, height;
  46. int mode;
  47. } vidmode_t;
  48. vidmode_t vid_modes[] =
  49. {
  50. { "Mode 0: 320x240", 320, 240, 0 },
  51. { "Mode 1: 400x300", 400, 300, 1 },
  52. { "Mode 2: 512x384", 512, 384, 2 },
  53. { "Mode 3: 640x480", 640, 480, 3 },
  54. { "Mode 4: 800x600", 800, 600, 4 },
  55. { "Mode 5: 960x720", 960, 720, 5 },
  56. { "Mode 6: 1024x768", 1024, 768, 6 },
  57. { "Mode 7: 1152x864", 1152, 864, 7 },
  58. { "Mode 8: 1280x960", 1280, 960, 8 },
  59. { "Mode 9: 1600x1200", 1600, 1200, 9 }
  60. };
  61. #define VID_NUM_MODES ( sizeof( vid_modes ) / sizeof( vid_modes[0] ) )
  62. qboolean VID_GetModeInfo( int *width, int *height, int mode )
  63. {
  64. if ( mode < 0 || mode >= VID_NUM_MODES )
  65. return false;
  66. *width = vid_modes[mode].width;
  67. *height = vid_modes[mode].height;
  68. return true;
  69. }
  70. void VID_Init (void)
  71. {
  72. refimport_t ri;
  73. viddef.width = 320;
  74. viddef.height = 240;
  75. ri.Cmd_AddCommand = Cmd_AddCommand;
  76. ri.Cmd_RemoveCommand = Cmd_RemoveCommand;
  77. ri.Cmd_Argc = Cmd_Argc;
  78. ri.Cmd_Argv = Cmd_Argv;
  79. ri.Cmd_ExecuteText = Cbuf_ExecuteText;
  80. ri.Con_Printf = VID_Printf;
  81. ri.Sys_Error = VID_Error;
  82. ri.FS_LoadFile = FS_LoadFile;
  83. ri.FS_FreeFile = FS_FreeFile;
  84. ri.FS_Gamedir = FS_Gamedir;
  85. ri.Vid_NewWindow = VID_NewWindow;
  86. ri.Cvar_Get = Cvar_Get;
  87. ri.Cvar_Set = Cvar_Set;
  88. ri.Cvar_SetValue = Cvar_SetValue;
  89. ri.Vid_GetModeInfo = VID_GetModeInfo;
  90. re = GetRefAPI(ri);
  91. if (re.api_version != API_VERSION)
  92. Com_Error (ERR_FATAL, "Re has incompatible api_version");
  93. // call the init function
  94. if (re.Init (NULL, NULL) == -1)
  95. Com_Error (ERR_FATAL, "Couldn't start refresh");
  96. }
  97. void VID_Shutdown (void)
  98. {
  99. if (re.Shutdown)
  100. re.Shutdown ();
  101. }
  102. void VID_CheckChanges (void)
  103. {
  104. }
  105. void VID_MenuInit (void)
  106. {
  107. }
  108. void VID_MenuDraw (void)
  109. {
  110. }
  111. const char *VID_MenuKey( int k)
  112. {
  113. return NULL;
  114. }