d_init.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. /*
  2. Copyright (C) 1996-1997 Id Software, Inc.
  3. This program is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU General Public License
  5. as published by the Free Software Foundation; either version 2
  6. of the License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. See the GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  14. */
  15. // d_init.c: rasterization driver initialization
  16. #include "quakedef.h"
  17. #include "d_local.h"
  18. #define NUM_MIPS 4
  19. cvar_t d_subdiv16 = {"d_subdiv16", "1"};
  20. cvar_t d_mipcap = {"d_mipcap", "0"};
  21. cvar_t d_mipscale = {"d_mipscale", "1"};
  22. surfcache_t *d_initial_rover;
  23. qboolean d_roverwrapped;
  24. int d_minmip;
  25. float d_scalemip[NUM_MIPS-1];
  26. static float basemip[NUM_MIPS-1] = {1.0, 0.5*0.8, 0.25*0.8};
  27. extern int d_aflatcolor;
  28. void (*d_drawspans) (espan_t *pspan);
  29. /*
  30. ===============
  31. D_Init
  32. ===============
  33. */
  34. void D_Init (void)
  35. {
  36. r_skydirect = 1;
  37. Cvar_RegisterVariable (&d_subdiv16);
  38. Cvar_RegisterVariable (&d_mipcap);
  39. Cvar_RegisterVariable (&d_mipscale);
  40. r_drawpolys = false;
  41. r_worldpolysbacktofront = false;
  42. r_recursiveaffinetriangles = true;
  43. r_pixbytes = 1;
  44. r_aliasuvscale = 1.0;
  45. }
  46. /*
  47. ===============
  48. D_CopyRects
  49. ===============
  50. */
  51. void D_CopyRects (vrect_t *prects, int transparent)
  52. {
  53. // this function is only required if the CPU doesn't have direct access to the
  54. // back buffer, and there's some driver interface function that the driver
  55. // doesn't support and requires Quake to do in software (such as drawing the
  56. // console); Quake will then draw into wherever the driver points vid.buffer
  57. // and will call this function before swapping buffers
  58. UNUSED(prects);
  59. UNUSED(transparent);
  60. }
  61. /*
  62. ===============
  63. D_EnableBackBufferAccess
  64. ===============
  65. */
  66. void D_EnableBackBufferAccess (void)
  67. {
  68. VID_LockBuffer ();
  69. }
  70. /*
  71. ===============
  72. D_TurnZOn
  73. ===============
  74. */
  75. void D_TurnZOn (void)
  76. {
  77. // not needed for software version
  78. }
  79. /*
  80. ===============
  81. D_DisableBackBufferAccess
  82. ===============
  83. */
  84. void D_DisableBackBufferAccess (void)
  85. {
  86. VID_UnlockBuffer ();
  87. }
  88. /*
  89. ===============
  90. D_SetupFrame
  91. ===============
  92. */
  93. void D_SetupFrame (void)
  94. {
  95. int i;
  96. if (r_dowarp)
  97. d_viewbuffer = r_warpbuffer;
  98. else
  99. d_viewbuffer = (void *)(byte *)vid.buffer;
  100. if (r_dowarp)
  101. screenwidth = WARP_WIDTH;
  102. else
  103. screenwidth = vid.rowbytes;
  104. d_roverwrapped = false;
  105. d_initial_rover = sc_rover;
  106. d_minmip = d_mipcap.value;
  107. if (d_minmip > 3)
  108. d_minmip = 3;
  109. else if (d_minmip < 0)
  110. d_minmip = 0;
  111. for (i=0 ; i<(NUM_MIPS-1) ; i++)
  112. d_scalemip[i] = basemip[i] * d_mipscale.value;
  113. #if id386
  114. if (d_subdiv16.value)
  115. d_drawspans = D_DrawSpans16;
  116. else
  117. d_drawspans = D_DrawSpans8;
  118. #else
  119. d_drawspans = D_DrawSpans8;
  120. #endif
  121. d_aflatcolor = 0;
  122. }
  123. /*
  124. ===============
  125. D_UpdateRects
  126. ===============
  127. */
  128. void D_UpdateRects (vrect_t *prect)
  129. {
  130. // the software driver draws these directly to the vid buffer
  131. UNUSED(prect);
  132. }