39 #elif defined(__APPLE__)
46 #if defined(_WIN32) && !defined(__GNUC__)
47 #pragma comment (lib, "opengl32")
48 #pragma comment (lib, "glu32")
52 static const int MIN_REQUIRED_GL_VERSION = 12;
55 static const int MIN_REQUIRED_GLSL_VERSION = 110;
69 static HDC GL_device_context = NULL;
70 static HGLRC GL_render_context = NULL;
71 static PIXELFORMATDESCRIPTOR GL_pfd;
74 static ushort *GL_original_gamma_ramp = NULL;
79 static ubyte *GL_saved_screen = NULL;
80 static ubyte *GL_saved_mouse_data = NULL;
81 static int GL_saved_screen_id = -1;
82 static GLuint GL_cursor_pbo = 0;
83 static GLuint GL_screen_pbo = 0;
85 static int GL_mouse_saved = 0;
86 static int GL_mouse_saved_x1 = 0;
87 static int GL_mouse_saved_y1 = 0;
88 static int GL_mouse_saved_x2 = 0;
89 static int GL_mouse_saved_y2 = 0;
103 static int GL_fullscreen = 0;
104 static int GL_windowed = 0;
105 static int GL_minimized = 0;
124 memset((
void*)&dm, 0,
sizeof(DEVMODE));
126 dm.dmSize =
sizeof(DEVMODE);
131 dm.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
133 if (dm.dmDisplayFrequency)
134 dm.dmFields |= DM_DISPLAYFREQUENCY;
136 if ( (ChangeDisplaySettings(&dm, CDS_FULLSCREEN)) != DISP_CHANGE_SUCCESSFUL ) {
137 if (dm.dmDisplayFrequency) {
139 dm.dmDisplayFrequency = 0;
140 dm.dmFields &= ~DM_DISPLAYFREQUENCY;
142 if ( (ChangeDisplaySettings(&dm, CDS_FULLSCREEN)) != DISP_CHANGE_SUCCESSFUL ) {
150 ShowWindow( wnd, SW_SHOWNORMAL );
153 SetForegroundWindow( wnd );
154 SetActiveWindow( wnd );
158 ClipCursor(&cursor_clip);
167 mprintf((
"Couldn't go fullscreen!\n"));
169 mprintf((
"Couldn't drop back to windowed mode either!\n"));
195 SetForegroundWindow( wnd );
196 SetActiveWindow( wnd );
206 ShowWindow( wnd, SW_SHOWNORMAL );
209 SetForegroundWindow( wnd );
210 SetActiveWindow( wnd );
219 if (SDL_GetVideoSurface()->
flags & SDL_FULLSCREEN) {
256 if (GL_original_gamma_ramp != NULL) {
257 SetDeviceGammaRamp( GL_device_context, GL_original_gamma_ramp );
260 ShowWindow(wnd, SW_MINIMIZE);
261 ChangeDisplaySettings(NULL, 0);
269 if ( !(SDL_GetVideoSurface()->
flags & SDL_FULLSCREEN) )
274 if (GL_original_gamma_ramp != NULL) {
275 SDL_SetGammaRamp( GL_original_gamma_ramp, (GL_original_gamma_ramp+256), (GL_original_gamma_ramp+512) );
278 SDL_WM_IconifyWindow();
297 if(!Cmdline_no_grab && !(SDL_GetVideoSurface()->
flags & SDL_FULLSCREEN)) {
298 SDL_WM_GrabInput(SDL_GRAB_ON);
306 if (SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_ON)
307 SDL_WM_GrabInput(SDL_GRAB_OFF);
347 SwapBuffers(GL_device_context);
351 SDL_GL_SwapBuffers();
360 mprintf((
"!!DEBUG!! OpenGL Errors this frame: %i\n", ic));
440 if ( (x == 0) && (y == 0) && (w == max_w) && (h == max_h) ) {
502 FILE *fout = fopen(tmp,
"wb");
533 if (pixels == NULL) {
549 memset( tga_hdr, 0,
sizeof(tga_hdr) );
552 memcpy( tga_hdr + 12, &width,
sizeof(
ushort) );
553 memcpy( tga_hdr + 14, &height,
sizeof(
ushort) );
556 fwrite( tga_hdr,
sizeof(tga_hdr), 1, fout );
560 #if BYTE_ORDER == BIG_ENDIAN
563 pix_tmp = (
int*)(pixels + i);
566 fwrite( &pix, 1, 3, fout );
568 fwrite( pixels + i, 1, 3, fout );
582 if (pixels != NULL) {
609 if (GL_render_context) {
610 if ( !wglMakeCurrent(NULL, NULL) ) {
614 if ( !wglDeleteContext(GL_render_context) ) {
618 GL_render_context = NULL;
627 ChangeDisplaySettings(NULL, 0);
637 Assert((r >= 0) && (r < 256));
638 Assert((g >= 0) && (g < 256));
639 Assert((b >= 0) && (b < 256));
658 fog_near *= fog_near;
701 return (enabled) ? 1 : 0;
721 return (enabled) ? 1 : 0;
817 static void opengl_make_gamma_ramp(
float gamma,
ushort *ramp)
828 memset( ramp, 0, 3 * 256 *
sizeof(
ushort) );
832 else if ( (gamma == 1.0
f) || (GL_original_gamma_ramp == NULL) ) {
833 if (GL_original_gamma_ramp != NULL) {
834 memcpy( ramp, GL_original_gamma_ramp, 3 * 256 *
sizeof(
ushort) );
838 for (x = 0; x < 256; x++) {
839 ramp[
x] = (x << 8) | x;
840 ramp[x + 256] = (x << 8) | x;
841 ramp[x + 512] = (x << 8) | x;
849 double g = 1.0 / (double)gamma;
852 Assert( GL_original_gamma_ramp != NULL );
854 for (x = 0; x < 256; x++) {
855 val = (pow(x/255.0, g) * 65535.0 + 0.5);
856 CLAMP( val, 0, 65535 );
861 for (y = 0; y < 3; y++) {
862 for (x = 0; x < 256; x++) {
863 val = (base_ramp[
x] * 2) - GL_original_gamma_ramp[x + y * 256];
864 CLAMP( val, 0, 65535 );
866 ramp[x + y * 256] = (
ushort)val;
874 ushort *gamma_ramp = NULL;
883 if (gamma_ramp == NULL) {
888 memset( gamma_ramp, 0, 3 * 256 *
sizeof(
ushort) );
891 opengl_make_gamma_ramp(gamma, gamma_ramp);
894 SetDeviceGammaRamp( GL_device_context, gamma_ramp );
896 SDL_SetGammaRamp( gamma_ramp, (gamma_ramp+256), (gamma_ramp+512) );
940 GL_mouse_saved_x1 =
x;
941 GL_mouse_saved_y1 =
y;
942 GL_mouse_saved_x2 = x+w-1;
943 GL_mouse_saved_y2 = y+h-1;
956 if (!GL_cursor_pbo) {
968 if (GL_saved_mouse_data == NULL)
971 if (GL_saved_mouse_data == NULL)
986 ubyte *sptr = NULL, *dptr = NULL;
987 ubyte *opengl_screen_tmp = NULL;
988 int width_times_pixel, mouse_times_pixel;
992 if (GL_saved_screen || GL_screen_pbo) {
999 if (!GL_saved_screen) {
1000 mprintf((
"Couldn't get memory for saved screen!\n" ));
1012 if (!GL_screen_pbo) {
1013 if (GL_saved_screen) {
1015 GL_saved_screen = NULL;
1031 sptr = (
ubyte *)pixels;
1035 dptr -= width_times_pixel;
1036 memcpy(dptr, sptr, width_times_pixel);
1037 sptr += width_times_pixel;
1043 if (GL_mouse_saved && GL_cursor_pbo) {
1048 sptr = (
ubyte *)pixels;
1049 dptr = (
ubyte *)&GL_saved_screen[(GL_mouse_saved_x1 + GL_mouse_saved_y2 *
gr_screen.
max_w) * 4];
1052 memcpy(dptr, sptr, mouse_times_pixel);
1053 sptr += mouse_times_pixel;
1054 dptr -= width_times_pixel;
1068 if (!opengl_screen_tmp) {
1069 if (GL_saved_screen) {
1071 GL_saved_screen = NULL;
1074 mprintf((
"Couldn't get memory for temporary saved screen!\n" ));
1082 dptr = (
ubyte *)GL_saved_screen;
1088 sptr -= width_times_pixel;
1089 memcpy(dptr, sptr, width_times_pixel);
1090 dptr += width_times_pixel;
1095 if (GL_mouse_saved && GL_saved_mouse_data) {
1096 sptr = (
ubyte *)GL_saved_mouse_data;
1097 dptr = (
ubyte *)&GL_saved_screen[(GL_mouse_saved_x1 + GL_mouse_saved_y2 *
gr_screen.
max_w) * 4];
1100 memcpy(dptr, sptr, mouse_times_pixel);
1101 sptr += mouse_times_pixel;
1102 dptr -= width_times_pixel;
1111 return GL_saved_screen_id;
1118 if ( !GL_saved_screen ) {
1123 Assert( (bmp_id < 0) || (bmp_id == GL_saved_screen_id) );
1125 if (GL_saved_screen_id < 0)
1134 if (!GL_saved_screen)
1138 GL_saved_screen = NULL;
1140 Assert( (bmp_id < 0) || (bmp_id == GL_saved_screen_id) );
1142 if (GL_saved_screen_id < 0)
1146 GL_saved_screen_id = -1;
1183 GLint current_matrix;
1199 GLint current_matrix;
1215 GLint current_matrix;
1246 return (
const char *)gluErrorString(error);
1257 const char *error_str = NULL;
1263 if (err_at != NULL) {
1264 nprintf((
"OpenGL",
"OpenGL Error from %s: %s\n", err_at, error_str));
1266 nprintf((
"OpenGL",
"OpenGL Error: %s\n", error_str));
1277 if ( (status < 0) || (status > 1) ) {
1282 #if defined(__APPLE__)
1285 CGLSetParameter(CGLGetCurrentContext(), kCGLCPSwapInterval, (
GLint*)&status);
1286 #elif defined(_WIN32)
1318 if (GL_cursor_pbo) {
1323 if (GL_saved_mouse_data != NULL) {
1325 GL_saved_mouse_data = NULL;
1339 if (GL_original_gamma_ramp != NULL) {
1340 SetDeviceGammaRamp( GL_device_context, GL_original_gamma_ramp );
1346 ChangeDisplaySettings( NULL, 0 );
1348 if (GL_original_gamma_ramp != NULL) {
1349 SDL_SetGammaRamp( GL_original_gamma_ramp, (GL_original_gamma_ramp+256), (GL_original_gamma_ramp+512) );
1353 if (GL_original_gamma_ramp != NULL) {
1354 vm_free(GL_original_gamma_ramp);
1355 GL_original_gamma_ramp = NULL;
1359 wglMakeCurrent(NULL, NULL);
1361 if (GL_render_context) {
1362 wglDeleteContext(GL_render_context);
1363 GL_render_context = NULL;
1366 GL_device_context = NULL;
1381 if ( (bpp != 16) && (bpp != 32) ) {
1479 if (GL_original_gamma_ramp == NULL) {
1480 mprintf((
" Unable to allocate memory for gamma ramp! Disabling...\n"));
1484 for (
ushort x = 0; x < 256; x++) {
1485 GL_original_gamma_ramp[
x] = GL_original_gamma_ramp[x + 256] = GL_original_gamma_ramp[x + 512] = (x << 8) | x;
1495 PIXELFORMATDESCRIPTOR pfd_test;
1497 mprintf((
" Initializing WGL...\n"));
1499 memset(&GL_pfd, 0,
sizeof(PIXELFORMATDESCRIPTOR));
1500 memset(&pfd_test, 0,
sizeof(PIXELFORMATDESCRIPTOR));
1502 GL_pfd.nSize =
sizeof(PIXELFORMATDESCRIPTOR);
1503 GL_pfd.nVersion = 1;
1504 GL_pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
1505 GL_pfd.iPixelType = PFD_TYPE_RGBA;
1506 GL_pfd.cColorBits = (
ubyte)bpp;
1511 GL_pfd.cDepthBits = (bpp == 32) ? 24 : 16;
1512 GL_pfd.cStencilBits = (bpp == 32) ? 8 : 1;
1521 if ( !GL_device_context ) {
1526 PixelFormat = ChoosePixelFormat(GL_device_context, &GL_pfd);
1528 if ( !PixelFormat ) {
1532 DescribePixelFormat(GL_device_context, PixelFormat,
sizeof(PIXELFORMATDESCRIPTOR), &pfd_test);
1535 if ( !
Fred_running && (pfd_test.dwFlags & PFD_GENERIC_FORMAT) && !(pfd_test.dwFlags & PFD_GENERIC_ACCELERATED) ) {
1539 GL_pfd.cAlphaBits = 0;
1540 GL_pfd.cDepthBits = 16;
1541 GL_pfd.cStencilBits = 1;
1544 PixelFormat = ChoosePixelFormat(GL_device_context, &GL_pfd);
1552 DescribePixelFormat(GL_device_context, PixelFormat,
sizeof(PIXELFORMATDESCRIPTOR), &pfd_test);
1554 if ( (pfd_test.dwFlags & PFD_GENERIC_FORMAT) && !(pfd_test.dwFlags & PFD_GENERIC_ACCELERATED) ) {
1561 if ( !SetPixelFormat(GL_device_context, PixelFormat, &GL_pfd) ) {
1566 GL_render_context = wglCreateContext(GL_device_context);
1567 if ( !GL_render_context ) {
1572 if ( !wglMakeCurrent(GL_device_context, GL_render_context) ) {
1577 mprintf((
" Requested WGL Video values = R: %d, G: %d, B: %d, depth: %d, stencil: %d, double-buffer: %d\n",
Gr_red.
bits,
Gr_green.
bits,
Gr_blue.
bits, GL_pfd.cDepthBits, GL_pfd.cStencilBits, (GL_pfd.dwFlags & PFD_DOUBLEBUFFER) > 0));
1581 DescribePixelFormat(GL_device_context, PixelFormat,
sizeof(PIXELFORMATDESCRIPTOR), &GL_pfd);
1583 int r = GL_pfd.cRedBits;
1584 int g = GL_pfd.cGreenBits;
1585 int b = GL_pfd.cBlueBits;
1586 int depth = GL_pfd.cDepthBits;
1587 int stencil = GL_pfd.cStencilBits;
1588 int db = ((GL_pfd.dwFlags & PFD_DOUBLEBUFFER) > 0);
1590 mprintf((
" Actual WGL Video values = R: %d, G: %d, B: %d, depth: %d, stencil: %d, double-buffer: %d\n", r, g, b, depth, stencil, db));
1593 if (GL_original_gamma_ramp != NULL) {
1594 GetDeviceGammaRamp( GL_device_context, GL_original_gamma_ramp );
1599 int flags = SDL_OPENGL;
1600 int r = 0, g = 0, b = 0, depth = 0, stencil = 1, db = 1;
1602 mprintf((
" Initializing SDL...\n"));
1604 if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) {
1605 fprintf (stderr,
"Couldn't init SDL: %s", SDL_GetError());
1611 SDL_WM_GrabInput(SDL_GRAB_ON);
1614 SDL_GL_SetAttribute(SDL_GL_RED_SIZE,
Gr_red.
bits);
1616 SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE,
Gr_blue.
bits);
1617 SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, (bpp == 32) ? 24 : 16);
1618 SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, (bpp == 32) ? 8 : 1);
1619 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, db);
1623 SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, (fsaa_samples == 0) ? 0 : 1);
1624 SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, fsaa_samples);
1627 setenv(
"force_s3tc_enable",
"true", 1);
1629 mprintf((
" Requested SDL Video values = R: %d, G: %d, B: %d, depth: %d, stencil: %d, double-buffer: %d, FSAA: %d\n",
Gr_red.
bits,
Gr_green.
bits,
Gr_blue.
bits, (bpp == 32) ? 24 : 16, (bpp == 32) ? 8 : 1, db, fsaa_samples));
1632 fprintf (stderr,
"Couldn't set video mode: %s", SDL_GetError());
1636 SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &r);
1637 SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &g);
1638 SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &b);
1639 SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &depth);
1640 SDL_GL_GetAttribute(SDL_GL_DOUBLEBUFFER, &db);
1641 SDL_GL_GetAttribute(SDL_GL_STENCIL_SIZE, &stencil);
1642 SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &fsaa_samples);
1644 mprintf((
" Actual SDL Video values = R: %d, G: %d, B: %d, depth: %d, stencil: %d, double-buffer: %d, FSAA: %d\n", r, g, b, depth, stencil, db, fsaa_samples));
1649 SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
1651 if (GL_original_gamma_ramp != NULL) {
1652 SDL_GetGammaRamp( GL_original_gamma_ramp, (GL_original_gamma_ramp+256), (GL_original_gamma_ramp+512) );
1835 int major = 0, minor = 0;
1845 mprintf((
"Initializing OpenGL graphics device at %ix%i with %i-bit color...\n",
1856 sscanf(ver,
"%d.%d", &major, &minor);
1861 Error(
LOCATION,
"Current GL Version of %d.%d is less than the "
1862 "required version of %d.%d.\n"
1863 "Switch video modes or update your drivers.",
1866 (MIN_REQUIRED_GL_VERSION / 10),
1867 (MIN_REQUIRED_GL_VERSION % 10));
1878 mprintf((
" OpenGL Version : %s\n", ver ));
1970 mprintf((
" Max render buffer size: %ix%i\n",
1987 mprintf((
"... OpenGL init is complete!\n"));
1995 DCF(ogl_minimize,
"Minimizes opengl")
1997 bool minimize_ogl =
false;
2000 dc_printf(
"Command only available in OpenGL mode.\n");
2005 dc_printf(
"[bool] If true is passed, then the OpenGL window will minimize.\n");
2015 DCF(ogl_anisotropy,
"toggles anisotropic filtering")
2017 bool process =
true;
2021 dc_printf(
"Can only set anisotropic filter in OpenGL mode.\n");
2026 dc_printf(
"Sets OpenGL anisotropic filtering level.\n");
2041 dc_printf(
"Error: Anisotropic filter is not settable!\n");
2049 dc_printf(
"Anisotropic filter value reset to default level.\n");
2065 return GLSL_version >= MIN_REQUIRED_GLSL_VERSION ?
true :
false;
GLboolean ColorMask(GLint state=-1)
WINGDIAPI void APIENTRY glOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar)
#define vm_malloc_q(size)
void SetPolygonMode(GLenum face, GLenum mode)
#define GL_PACK_ALIGNMENT
void(* gf_aaline)(vertex *v1, vertex *v2)
void(* gf_set_proj_matrix)(float, float, float, float)
uint os_config_read_uint(const char *section, const char *name, uint default_value)
#define OGL_EXT_FRAMEBUFFER_OBJECT
void gr_opengl_copy_effect_texture()
void gr_opengl_aaline(vertex *v1, vertex *v2)
void(* gf_destroy_light)(int)
void gr_opengl_shadow_map_end()
WINGDIAPI void APIENTRY glFinish(void)
void opengl_post_process_shutdown()
void(* gf_fog_set)(int fog_mode, int r, int g, int b, float fog_near, float fog_far)
void(* gf_bm_create)(int n)
void gr_opengl_end_projection_matrix()
#define GL_FOG_COORDINATE_SOURCE_EXT
GLfloat GLfloat GLfloat GLfloat h
WINGDIAPI void APIENTRY glLineWidth(GLfloat width)
void init(GLuint n_units)
void(* gf_set_palette)(const ubyte *new_pal, int restrict_alphacolor)
void(* gf_bm_free_data)(int n, bool release)
void(* gf_push_texture_matrix)(int unit)
void(* gf_free_screen)(int id)
int gr_opengl_zbuffer_set(int mode)
void gr_opengl_set_texture_panning(float u, float v, bool enable)
void(* gf_shadow_map_start)(const matrix4 *shadow_view_matrix, const matrix *light_matrix)
GLfloat opengl_get_max_anisotropy()
GLsizei const GLfloat * value
WINGDIAPI void APIENTRY glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
int gr_opengl_make_light(light *fs_light, int idx, int priority)
GLint GLfloat GLint stencil
GLint GL_max_elements_vertices
void(* gf_sphere_htl)(float rad)
void SetTextureSource(gr_texture_source ts)
GLboolean StencilTest(GLint state=-1)
void gr_opengl_set_line_width(float width)
WINGDIAPI void APIENTRY glMatrixMode(GLenum mode)
void(* gf_aabitmap_ex)(int x, int y, int w, int h, int sx, int sy, int resize_mode, bool mirror)
GLboolean ScissorTest(GLint state=-1)
WINGDIAPI void APIENTRY glLoadIdentity(void)
WINGDIAPI void APIENTRY glClear(GLbitfield mask)
void(* gf_stencil_clear)()
void(* gf_reset_lighting)()
#define GL_UNPACK_ALIGNMENT
void opengl_set_vsync(int status)
void(* gf_center_alpha)(int)
void(* gf_get_bitmap_from_texture)(void *data_out, int bitmap_num)
void(* gf_render_effect)(int nv, vertex *verts, float *radius_list, uint flags)
void(* gf_shadow_map_end)()
void _cdecl void void _cdecl void _cdecl Warning(char *filename, int line, SCP_FORMAT_STRING const char *format,...) SCP_FORMAT_STRING_ARGS(3
void(* gf_line)(int x1, int y1, int x2, int y2, int resize_mode)
int(* gf_bm_set_render_target)(int n, int face)
bool dc_maybe_stuff_int(int *i)
Tries to stuff an int from the Command_string.
void gr_opengl_end_clip_plane()
void gr_opengl_set_thrust_scale(float scale)
GLint GLint GLsizei GLsizei GLsizei depth
void(* gf_set_animated_effect)(int effect, float timer)
GLboolean DepthTest(GLint state=-1)
void gr_opengl_set_lighting(bool set, bool state)
GLint GL_max_elements_indices
void(* gf_flash)(int r, int g, int b)
void(* gf_set_view_matrix)(const vec3d *, const matrix *)
void gr_opengl_set_fill_mode(int mode)
void gr_opengl_set_transform_buffer_offset(int offset)
void(* gf_deferred_lighting_end)()
struct vec3d::@225::@227 xyz
void(* gf_post_process_set_effect)(const char *, int)
void(* gf_scene_texture_begin)()
void SetZbufferType(gr_zbuffer_type zt)
int Cmdline_ati_color_swap
const char * Osreg_user_dir
void gr_opengl_zbias(int bias)
void gr_opengl_push_texture_matrix(int unit)
int(* gf_set_cull)(int cull)
void gr_opengl_destroy_light(int idx)
void gr_opengl_aabitmap(int x, int y, int resize_mode, bool mirror)
bool gr_opengl_config_buffer(const int buffer_id, vertex_buffer *vb, bool update_ibuffer_only)
void gr_opengl_restore_screen(int bmp_id)
bool(* gf_pack_buffer)(const int buffer_id, vertex_buffer *vb)
#define vglUnmapBufferARB
void gr_opengl_reset_lighting()
int opengl_init_display_device()
int(* gf_maybe_create_shader)(shader_type type, unsigned int flags)
void gr_opengl_cross_fade(int bmap1, int bmap2, int x1, int y1, int x2, int y2, float pct, int resize_mode)
#define GL_UNSIGNED_SHORT_1_5_5_5_REV
int(* gf_set_color_buffer)(int mode)
int mouse_get_pos(int *xpos, int *ypos)
opengl_texture_state Texture
#define GR_FILL_MODE_SOLID
void gr_opengl_update_texture(int bitmap_handle, int bpp, const ubyte *data, int width, int height)
GLboolean CullFace(GLint state=-1)
void gr_opengl_activate(int active)
void gr_opengl_sphere_htl(float rad)
typedef HGLRC(WINAPI *PFNWGLCREATECONTEXTATTRIBSARBPROC)(HDC hDC
const char * detect_home(void)
void gr_set_bitmap(int bitmap_num, int alphablend_mode, int bitblt_mode, float alpha)
bool(* gf_bm_data)(int n, bitmap *bm)
void(* gf_draw_line_list)(const colored_vector *lines, int num)
int gr_opengl_stencil_set(int mode)
int gr_opengl_create_buffer()
color current_clear_color
int(* gf_stencil_set)(int mode)
void(* gf_bm_page_in_start)()
color_gun * Gr_current_green
void(* gf_pixel)(int x, int y, int resize_mode)
int bm_release(int handle, int clear_render_targets)
Frees both a bitmap's data and it's associated slot.
void(* gf_set_gamma)(float gamma)
void gr_opengl_end_instance_matrix()
void gr_opengl_clear_states()
void gr_opengl_center_alpha(int type)
int(* gf_create_buffer)()
void(* gf_translate_texture_matrix)(int unit, const vec3d *shift)
void opengl_tcache_shutdown()
WINGDIAPI void APIENTRY glPopMatrix(void)
GLenum CullFaceValue(GLenum new_val=GL_INVALID_ENUM)
void gr_opengl_modify_light(light *fs_light, int idx, int priority)
#define GL_FOG_COORDINATE_EXT
#define CLAMP(x, min, max)
void(* gf_circle)(int x, int y, int r, int resize_mode)
void SetStencilType(gr_stencil_type st)
void(* gf_arc)(int x, int y, float r, float angle_start, float angle_end, bool fill, int resize_mode)
WINGDIAPI void APIENTRY glFlush(void)
int _getcwd(char *buffer, unsigned int len)
int bm_is_valid(int handle)
Checks if the bitmap indexed by handle is valid.
void(* gf_set_clip)(int x, int y, int w, int h, int resize_mode)
int gr_opengl_bm_set_render_target(int n, int face)
void opengl_setup_viewport()
void(* gf_post_process_set_defaults)()
WINGDIAPI void APIENTRY glDepthRange(GLclampd zNear, GLclampd zFar)
void gr_opengl_flash_alpha(int r, int g, int b, int a)
typedef int(SCP_EXT_CALLCONV *SCPDLL_PFVERSION)(SCPDLL_Version *)
GLint GL_max_texture_height
void gr_opengl_line(int x1, int y1, int x2, int y2, int resize_mode)
void(* gf_unfilled_circle)(int x, int y, int r, int resize_mode)
void gr_opengl_set_light_factor(float factor)
void gr_opengl_render_stream_buffer(int buffer_handle, int offset, int n_verts, int flags)
void(* gf_destroy_buffer)(int)
void gr_opengl_bm_free_data(int n, bool release)
GLdouble GLdouble GLdouble r
int(* gf_alpha_mask_set)(int mode, float alpha)
void gr_opengl_scene_texture_begin()
int Texture_compression_available
void(* gf_start_clip_plane)()
#define GL_FOG_DISTANCE_MODE_NV
void opengl_extensions_init()
void opengl_go_fullscreen()
void gr_opengl_render_buffer(int start, const vertex_buffer *bufferp, int texi, int flags)
void(* gf_set_light_factor)(float)
void opengl_shader_shutdown()
void gr_opengl_deferred_lighting_finish()
#define vglDeleteBuffersARB
GLenum GLenum GLsizei const GLuint GLboolean enabled
int _mkdir(const char *path)
void gr_opengl_deferred_lighting_end()
void gr_opengl_set_clear_color(int r, int g, int b)
void gr_opengl_update_buffer_object(int handle, uint size, void *data)
void gr_opengl_reset_clip()
void opengl_tcache_flush()
const char * opengl_error_string()
bool GL_rendering_to_texture
void gr_opengl_stencil_clear()
void SetPolygonOffset(GLfloat factor, GLfloat units)
void(* gf_set_transform_buffer_offset)(int offset)
int Use_compressed_textures
GLboolean AlphaTest(GLint state=-1)
void(* gf_set_texture_panning)(float u, float v, bool enable)
#define GL_PERSPECTIVE_CORRECTION_HINT
void(* gf_tmapper)(int nv, vertex *verts[], uint flags)
void gr_opengl_destroy_buffer(int idx)
void gr_opengl_shutdown()
void(* gf_end_view_matrix)()
int(* gf_bm_make_render_target)(int n, int *width, int *height, ubyte *bpp, int *mm_lvl, int flags)
GLint GL_supported_texture_units
void SetAlphaBlendMode(gr_alpha_blend ab)
void gr_opengl_unfilled_circle(int xc, int yc, int d, int resize_mode)
color_gun * Gr_current_red
void gr_opengl_pixel(int x, int y, int resize_mode)
void(* gf_update_texture)(int bitmap_handle, int bpp, const ubyte *data, int width, int height)
void(* gf_restore_screen)(int id)
void opengl_light_shutdown()
int(* gf_zbuffer_set)(int mode)
void gr_opengl_cleanup(int minimize)
void(* gf_update_transform_buffer)(void *data, uint size)
void(* gf_end_clip_plane)()
void(* gf_clear_states)()
void gr_opengl_set_buffer(int idx)
void gr_opengl_bm_page_in_start()
WINGDIAPI void APIENTRY glTranslated(GLdouble x, GLdouble y, GLdouble z)
void(* gf_start_angles_instance_matrix)(const vec3d *, const angles *)
void gr_opengl_post_process_end()
bool dc_optional_string_either(const char *str1, const char *str2)
Searches for an optional string and it's alias.
color_gun * Gr_current_blue
void gr_opengl_push_scale_matrix(const vec3d *scale_factor)
void opengl_setup_function_pointers()
void gr_opengl_end_view_matrix()
void gr_opengl_string(float sx, float sy, const char *s, int resize_mode)
#define GL_CHECK_FOR_ERRORS(s)
void gr_opengl_circle(int xc, int yc, int d, int resize_mode)
void(* gf_lighting)(bool, bool)
void gr_opengl_free_screen(int bmp_id)
int(* gf_make_light)(light *, int, int)
void(* gf_bm_init)(int n)
int gr_opengl_set_color_buffer(int mode)
void gr_opengl_set_projection_matrix(float fov, float aspect, float z_near, float z_far)
int(* gf_preload)(int bitmap_num, int is_aabitmap)
void(* gf_post_process_begin)()
void(* gf_post_process_save_zbuffer)()
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
#define Is_Extension_Enabled(x)
void SetTarget(GLenum tex_target)
WINGDIAPI void APIENTRY glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
void(* gf_flash_alpha)(int r, int g, int b, int a)
void(* gf_scaler)(vertex *va, vertex *vb, bool bw_bitmap)
#define GL_FRONT_AND_BACK
void(* gf_string)(int x, int y, const char *text, int resize_mode)
GLint GLint GLint GLint GLint x
for(int idx=0;idx< i;idx++)
#define GL_MAX_ELEMENTS_INDICES
void gr_opengl_pop_scale_matrix()
void Enable(GLuint tex_id=0)
int bm_create(int bpp, int w, int h, void *data, int flags)
#define GL_MAX_ELEMENTS_VERTICES
void gr_opengl_aabitmap_ex(int x, int y, int w, int h, int sx, int sy, int resize_mode, bool mirror)
void(* gf_set_line_width)(float width)
int Cmdline_fullscreen_window
WINGDIAPI void APIENTRY glGetIntegerv(GLenum pname, GLint *params)
WINGDIAPI void APIENTRY glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
typedef HDC(WINAPI *PFNWGLGETCURRENTREADDCARBPROC)(void)
bool gr_opengl_bm_data(int n, bitmap *bm)
void opengl_save_mouse_area(int x, int y, int w, int h)
WINGDIAPI void APIENTRY glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels)
void gr_opengl_flash(int r, int g, int b)
void _cdecl void void _cdecl Error(const char *filename, int line, SCP_FORMAT_STRING const char *format,...) SCP_FORMAT_STRING_ARGS(3
GLint GL_max_texture_width
void gr_opengl_post_process_save_zbuffer()
void opengl_tcache_init()
#define GL_UNSIGNED_INT_8_8_8_8_REV
#define vglActiveTextureARB
void gr_opengl_render_effect(int nverts, vertex *verts, float *radius_list, uint flags)
void init(GLuint n_units)
void gr_opengl_post_process_begin()
void gr_opengl_set_team_color(const team_color *colors)
void(* gf_set_clear_color)(int r, int g, int b)
void gr_opengl_tmapper(int nverts, vertex **verts, uint flags)
DCF(ogl_minimize,"Minimizes opengl")
void(* gf_line_htl)(const vec3d *start, const vec3d *end)
GLboolean GLboolean GLboolean b
GLboolean PolygonOffsetFill(GLint state=-1)
void dc_stuff_boolean(bool *b)
stuffs a boolean evaluated integer or string into the given variable.
void gr_opengl_print_screen(const char *filename)
#define vglXSwapIntervalSGI
int gr_opengl_save_screen()
bool gr_resize_screen_pos(int *x, int *y, int *w, int *h, int resize_mode)
void opengl_setup_scene_textures()
void(* gf_set_texture_addressing)(int)
typedef float(SCP_EXT_CALLCONV *SCPTRACKIR_PFFLOATVOID)()
void(* gf_copy_effect_texture)()
int(* PFNGLXSWAPINTERVALSGIPROC)(int interval)
int gr_opengl_bm_make_render_target(int n, int *width, int *height, ubyte *bpp, int *mm_lvl, int flags)
void gr_opengl_deferred_lighting_begin()
void(* gf_scene_texture_end)()
void(* gf_pop_texture_matrix)(int unit)
int gr_opengl_maybe_create_shader(shader_type shader_t, unsigned int flags)
#define GL_FRAGMENT_DEPTH
void(* gf_set_fill_mode)(int)
GLint GLsizei GLsizei height
GLboolean Fog(GLint state=-1)
bool(* gf_config_buffer)(const int buffer_id, vertex_buffer *vb, bool update_ibuffer_only)
void(* gf_post_process_end)()
GLubyte GLubyte GLubyte GLubyte w
WINGDIAPI void APIENTRY glPushMatrix(void)
bool gr_opengl_pack_buffer(const int buffer_id, vertex_buffer *vb)
int gr_opengl_preload(int bitmap_num, int is_aabitmap)
int gr_opengl_alpha_mask_set(int mode, float alpha)
void(* gf_zbuffer_clear)(int use_zbuffer)
void gr_opengl_get_bitmap_from_texture(void *data_out, int bitmap_num)
void(* gf_set_ambient_light)(int, int, int)
void(* gf_start_instance_matrix)(const vec3d *, const matrix *)
void gr_opengl_set_gamma(float gamma)
WINGDIAPI void APIENTRY glHint(GLenum target, GLenum mode)
WINGDIAPI void APIENTRY glPixelStorei(GLenum pname, GLint param)
void opengl_set_texture_target(GLenum target)
void gr_opengl_line_htl(const vec3d *start, const vec3d *end)
void(* gf_pop_scale_matrix)()
void(* gf_deferred_lighting_finish)()
void gr_opengl_set_texture_addressing(int mode)
void gr_opengl_scaler(vertex *va, vertex *vb, bool bw_bitmap=false)
color_gun * Gr_current_alpha
void gr_opengl_pop_texture_matrix(int unit)
void gr_opengl_set_ambient_light(int red, int green, int blue)
An overhauled/updated debug console to allow monitoring, testing, and general debugging of new featur...
int gr_opengl_zbuffer_get()
#define OGL_EXT_TEXTURE_FILTER_ANISOTROPIC
WINGDIAPI void APIENTRY glFogf(GLenum pname, GLfloat param)
void gr_opengl_shadow_map_start(const matrix4 *shadow_view_matrix, const matrix *light_orient)
int MessageBox(HWND h, const char *s1, const char *s2, int i)
GLenum GLsizei GLenum GLenum const GLvoid * data
WINGDIAPI void APIENTRY glFogfv(GLenum pname, const GLfloat *params)
GLint GL_max_renderbuffer_size
void(* gf_set_light)(light *)
#define GL_SHADING_LANGUAGE_VERSION
void gr_opengl_start_instance_matrix(const vec3d *offset, const matrix *rotation)
void opengl_scene_texture_shutdown()
bool gr_unsize_screen_pos(int *x, int *y, int *w, int *h, int resize_mode)
int gr_opengl_create_stream_buffer_object()
void(* gf_push_scale_matrix)(const vec3d *)
WINGDIAPI const GLubyte *APIENTRY glGetString(GLenum name)
void opengl_go_windowed()
void gr_opengl_zbuffer_clear(int mode)
void(* gf_cross_fade)(int bmap1, int bmap2, int x1, int y1, int x2, int y2, float pct, int resize_mode)
void(* gf_zbias)(int zbias)
void gr_bitmap(int _x, int _y, int resize_mode)
void AlphaFunc(GLenum f_val, GLclampf r_val)
void gr_opengl_set_clip(int x, int y, int w, int h, int resize_mode)
int gr_opengl_tcache_set(int bitmap_handle, int bitmap_type, float *u_scale, float *v_scale, int stage)
void opengl_shader_init()
void(* gf_get_region)(int front, int w, int h, ubyte *data)
void(* gf_set_thrust_scale)(float)
void gr_opengl_translate_texture_matrix(int unit, const vec3d *shift)
void opengl_tcache_frame()
void gr_opengl_post_process_set_effect(const char *name, int value)
void dc_printf(const char *format,...)
Prints the given char string to the debug console.
WINGDIAPI void APIENTRY glShadeModel(GLenum mode)
void(* gf_aabitmap)(int x, int y, int resize_mode, bool mirror)
void(* gf_set_team_color)(const team_color *colors)
bool is_minimum_GLSL_version()
void(* gf_end_instance_matrix)()
void gr_opengl_start_clip_plane()
void opengl_post_process_init()
void gr_opengl_set_view_matrix(const vec3d *pos, const matrix *orient)
void(* gf_render_stream_buffer)(int buffer_handle, int offset, int n_verts, int flags)
void gr_opengl_bm_create(int n)
void gr_opengl_update_transform_buffer(void *data, uint size)
void(* gf_deferred_lighting_begin)()
#define GL_FOG_COORDINATE_SOURCE
void gr_opengl_set_palette(const ubyte *new_palette, int is_alphacolor)
void gr_opengl_fog_set(int fog_mode, int r, int g, int b, float fog_near, float fog_far)
#define vwglSwapIntervalEXT
#define GL_PIXEL_PACK_BUFFER_ARB
void(* gf_end_proj_matrix)()
void gr_opengl_set_light(light *fs_light)
void gr_opengl_arc(int xc, int yc, float r, float angle_start, float angle_end, bool fill, int resize_mode)
GLclampf GLclampf GLclampf alpha
void opengl_tnl_shutdown()
void gr_opengl_get_region(int front, int w, int h, ubyte *data)
void(* gf_curve)(int x, int y, int r, int direction, int resize_mode)
void(* gf_set_buffer)(int)
#define GL_COLOR_BUFFER_BIT
void(* gf_print_screen)(const char *filename)
GLenum FrontFaceValue(GLenum new_val=GL_INVALID_ENUM)
void gr_opengl_gradient(int x1, int y1, int x2, int y2, int resize_mode)
void(* gf_render)(int nv, vertex *verts, uint flags)
WINGDIAPI GLenum APIENTRY glGetError(void)
#define GL_MAX_TEXTURE_IMAGE_UNITS
void(* gf_bitmap_ex)(int x, int y, int w, int h, int sx, int sy, int resize_mode)
void gr_init_color(color *c, int r, int g, int b)
#define GL_MAX_TEXTURE_COORDS
void gr_opengl_start_instance_angles(const vec3d *pos, const angles *rotation)
void gr_opengl_scene_texture_end()
void gr_opengl_shader_set_animated_effect(int effect, float timer)
#define GL_STENCIL_BUFFER_BIT
void SetActiveUnit(GLuint id=0)
void(* gf_render_buffer)(int, const vertex_buffer *, int, int)
int opengl_check_for_errors(char *err_at)
int(* gf_create_stream_buffer)()
#define GR_FILL_MODE_WIRE
void gr_opengl_draw_line_list(const colored_vector *lines, int num)
void gr_opengl_curve(int xc, int yc, int r, int direction, int resize_mode)
int(* gf_tcache_set)(int bitmap_id, int bitmap_type, float *u_scale, float *v_scale, int stage)
void gr_opengl_bm_init(int n)
#define GL_DEPTH_BUFFER_BIT
void(* gf_update_buffer_object)(int handle, uint size, void *data)
void(* gf_modify_light)(light *, int, int)
WINGDIAPI void APIENTRY glReadBuffer(GLenum mode)
void gr_opengl_bitmap_ex(int x, int y, int w, int h, int sx, int sy, int resize_mode)
void(* gf_gradient)(int x1, int y1, int x2, int y2, int resize_mode)
int gr_opengl_set_cull(int cull)
void gr_opengl_render(int nverts, vertex *verts, uint flags)
void gr_opengl_post_process_set_defaults()