Skip to content

Commit e47884e

Browse files
committed
Merge pull request #543 from asarium/cleanup/graphics
Clean up the renderer interface
2 parents 81bd363 + 108d603 commit e47884e

File tree

9 files changed

+3
-386
lines changed

9 files changed

+3
-386
lines changed

code/freespace2/freespace.cpp

Lines changed: 0 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -3897,97 +3897,6 @@ void john_debug_stuff(vec3d *eye_pos, matrix *eye_orient)
38973897
}
38983898
#endif
38993899

3900-
// following function for dumping frames for purposes of building trailers.
3901-
#ifndef NDEBUG
3902-
3903-
// function to toggle state of dumping every frame into PCX when playing the game
3904-
DCF(dump_frames, "Toggles On/off frame dumping at 15 hz")
3905-
{
3906-
if ( Debug_dump_frames == 0 ) {
3907-
// Turn it on
3908-
Debug_dump_frames = 15;
3909-
Debug_dump_trigger = 0;
3910-
gr_dump_frame_start( Debug_dump_frame_num, DUMP_BUFFER_NUM_FRAMES );
3911-
dc_printf( "Frame dumping at 15 hz is now ON\n" );
3912-
} else {
3913-
// Turn it off
3914-
Debug_dump_frames = 0;
3915-
Debug_dump_trigger = 0;
3916-
gr_dump_frame_stop();
3917-
dc_printf( "Frame dumping is now OFF\n" );
3918-
}
3919-
}
3920-
3921-
DCF(dump_frames_trigger, "Starts/stop frame dumping at 15 hz")
3922-
{
3923-
if ( Debug_dump_frames == 0 ) {
3924-
// Turn it on
3925-
Debug_dump_frames = 15;
3926-
Debug_dump_trigger = 1;
3927-
gr_dump_frame_start( Debug_dump_frame_num, DUMP_BUFFER_NUM_FRAMES );
3928-
dc_printf( "Frame dumping at 15 hz is now ON\n" );
3929-
} else {
3930-
// Turn it off
3931-
Debug_dump_frames = 0;
3932-
Debug_dump_trigger = 0;
3933-
gr_dump_frame_stop();
3934-
dc_printf( "Frame dumping is now OFF\n" );
3935-
}
3936-
}
3937-
3938-
DCF(dump_frames30, "Starts/stop frame dumping at 30 hz")
3939-
{
3940-
if ( Debug_dump_frames == 0 ) {
3941-
// Turn it on
3942-
Debug_dump_frames = 30;
3943-
Debug_dump_trigger = 0;
3944-
gr_dump_frame_start( Debug_dump_frame_num, DUMP_BUFFER_NUM_FRAMES );
3945-
dc_printf( "Frame dumping at 30 hz is now ON\n" );
3946-
} else {
3947-
// Turn it off
3948-
Debug_dump_frames = 0;
3949-
Debug_dump_trigger = 0;
3950-
gr_dump_frame_stop();
3951-
dc_printf( "Frame dumping is now OFF\n" );
3952-
}
3953-
}
3954-
3955-
DCF(dump_frames30_trigger, "Starts/stop frame dumping at 30 hz")
3956-
{
3957-
if ( Debug_dump_frames == 0 ) {
3958-
// Turn it on
3959-
Debug_dump_frames = 30;
3960-
Debug_dump_trigger = 1;
3961-
gr_dump_frame_start( Debug_dump_frame_num, DUMP_BUFFER_NUM_FRAMES );
3962-
dc_printf( "Triggered frame dumping at 30 hz is now ON\n" );
3963-
} else {
3964-
// Turn it off
3965-
Debug_dump_frames = 0;
3966-
Debug_dump_trigger = 0;
3967-
gr_dump_frame_stop();
3968-
dc_printf( "Triggered frame dumping is now OFF\n" );
3969-
}
3970-
}
3971-
3972-
void game_maybe_dump_frame()
3973-
{
3974-
if ( !Debug_dump_frames ){
3975-
return;
3976-
}
3977-
3978-
if( Debug_dump_trigger && !keyd_pressed[KEY_Q] ){
3979-
return;
3980-
}
3981-
3982-
game_stop_time();
3983-
3984-
gr_dump_frame();
3985-
Debug_dump_frame_num++;
3986-
3987-
game_start_time();
3988-
}
3989-
#endif
3990-
39913900
extern int Player_dead_state;
39923901

39933902
// Flip the page and time how long it took.
@@ -4620,9 +4529,6 @@ void game_frame(bool paused)
46204529
DEBUG_GET_TIME( flip_time2 )
46214530
}
46224531

4623-
#ifndef NDEBUG
4624-
game_maybe_dump_frame(); // used to dump pcx files for building trailers
4625-
#endif
46264532
} else {
46274533
game_show_standalone_framerate();
46284534
}

code/graphics/2d.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,6 @@ static bool gr_init_sub(int mode, int width, int height, int depth, float center
849849
gr_screen.bits_per_pixel = depth;
850850
gr_screen.bytes_per_pixel= depth / 8;
851851
gr_screen.rendering_to_texture = -1;
852-
gr_screen.recording_state_block = false;
853852
gr_screen.envmap_render_target = -1;
854853
gr_screen.mode = mode;
855854
gr_screen.res = res;

code/graphics/2d.h

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -405,23 +405,12 @@ typedef struct screen {
405405

406406
int envmap_render_target;
407407

408-
bool recording_state_block;
409-
int current_state_block;
410-
411-
void (*gf_start_state_block)();
412-
int (*gf_end_state_block)();
413-
void (*gf_set_state_block)(int);
414-
415408
//switch onscreen, offscreen
416409
void (*gf_flip)();
417410

418411
// Sets the current palette
419412
void (*gf_set_palette)(const ubyte *new_pal, int restrict_alphacolor);
420-
421-
// Fade the screen in/out
422-
void (*gf_fade_in)(int instantaneous);
423-
void (*gf_fade_out)(int instantaneous);
424-
413+
425414
// Flash the screen
426415
void (*gf_flash)( int r, int g, int b );
427416
void (*gf_flash_alpha)(int r, int g, int b, int a);
@@ -511,17 +500,7 @@ typedef struct screen {
511500

512501
// Frees up a saved screen.
513502
void (*gf_free_screen)(int id);
514-
515-
// CODE FOR DUMPING FRAMES TO A FILE
516-
// Begin frame dumping
517-
void (*gf_dump_frame_start)( int first_frame_number, int nframes_between_dumps );
518-
519-
// Dump the current frame to file
520-
void (*gf_dump_frame)();
521-
522-
// Dump the current frame to file
523-
void (*gf_dump_frame_stop)();
524-
503+
525504
// Sets the gamma
526505
void (*gf_set_gamma)(float gamma);
527506

@@ -583,11 +562,7 @@ typedef struct screen {
583562

584563
int (*gf_create_stream_buffer)();
585564
void (*gf_render_stream_buffer)(int buffer_handle, int offset, int n_verts, int flags);
586-
587-
int (*gf_make_flat_buffer)(poly_list*);
588-
int (*gf_make_line_buffer)(line_list*);
589565

590-
591566
//the projection matrix; fov, aspect ratio, near, far
592567
void (*gf_set_proj_matrix)(float, float, float, float);
593568
void (*gf_end_proj_matrix)();
@@ -634,7 +609,6 @@ typedef struct screen {
634609
void (*gf_end_clip_plane)();
635610

636611
void (*gf_zbias)(int zbias);
637-
void (*gf_setup_background_fog)(bool);
638612

639613
void (*gf_set_fill_mode)(int);
640614
void (*gf_set_texture_panning)(float u, float v, bool enable);
@@ -836,8 +810,6 @@ __inline void gr_gradient(int x1, int y1, int x2, int y2, int resize_mode = GR_R
836810
(*gr_screen.gf_gradient)(x1, y1, x2, y2, resize_mode);
837811
}
838812

839-
#define gr_fade_in GR_CALL(gr_screen.gf_fade_in)
840-
#define gr_fade_out GR_CALL(gr_screen.gf_fade_out)
841813
#define gr_flash GR_CALL(gr_screen.gf_flash)
842814
#define gr_flash_alpha GR_CALL(gr_screen.gf_flash_alpha)
843815

@@ -854,10 +826,6 @@ __inline void gr_gradient(int x1, int y1, int x2, int y2, int resize_mode = GR_R
854826
#define gr_restore_screen GR_CALL(gr_screen.gf_restore_screen)
855827
#define gr_free_screen GR_CALL(gr_screen.gf_free_screen)
856828

857-
#define gr_dump_frame_start GR_CALL(gr_screen.gf_dump_frame_start)
858-
#define gr_dump_frame_stop GR_CALL(gr_screen.gf_dump_frame_stop)
859-
#define gr_dump_frame GR_CALL(gr_screen.gf_dump_frame)
860-
861829
#define gr_set_gamma GR_CALL(gr_screen.gf_set_gamma)
862830

863831
#define gr_get_region GR_CALL(gr_screen.gf_get_region)
@@ -921,9 +889,6 @@ __inline void gr_render_buffer(int start, const vertex_buffer *bufferp, int texi
921889
#define gr_render_stream_buffer_end GR_CALL(*gr_screen.gf_render_stream_buffer_end)
922890

923891
#define gr_set_buffer GR_CALL(*gr_screen.gf_set_buffer)
924-
925-
#define gr_make_flat_buffer GR_CALL(*gr_screen.gf_make_flat_buffer)
926-
#define gr_make_line_buffer GR_CALL(*gr_screen.gf_make_line_buffer)
927892

928893
#define gr_set_proj_matrix GR_CALL(*gr_screen.gf_set_proj_matrix)
929894
#define gr_end_proj_matrix GR_CALL(*gr_screen.gf_end_proj_matrix)
@@ -968,12 +933,6 @@ __inline void gr_render_buffer(int start, const vertex_buffer *bufferp, int texi
968933
#define gr_set_fill_mode GR_CALL(*gr_screen.gf_set_fill_mode)
969934
#define gr_set_texture_panning GR_CALL(*gr_screen.gf_set_texture_panning)
970935

971-
#define gr_start_state_block GR_CAL(*gr_screen.gf_start_state_block)
972-
#define gr_end_state_block GR_CALL(*gr_screen.gf_end_state_block)
973-
#define gr_set_state_block GR_CALL(*gr_screen.gf_set_state_block)
974-
975-
#define gr_setup_background_fog GR_CALL(*gr_screen.gf_setup_background_fog)
976-
977936
#define gr_draw_line_list GR_CALL(*gr_screen.gf_draw_line_list)
978937

979938
#define gr_set_line_width GR_CALL(*gr_screen.gf_set_line_width)

code/graphics/gropengl.cpp

Lines changed: 0 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,6 @@ static ushort *GL_original_gamma_ramp = NULL;
7676
int Use_VBOs = 0;
7777
int Use_PBOs = 0;
7878

79-
static int GL_dump_frames = 0;
80-
static ubyte *GL_dump_buffer = NULL;
81-
static int GL_dump_frame_number = 0;
82-
static int GL_dump_frame_count = 0;
83-
static int GL_dump_frame_count_max = 0;
84-
static int GL_dump_frame_size = 0;
85-
8679
static ubyte *GL_saved_screen = NULL;
8780
static ubyte *GL_saved_mouse_data = NULL;
8881
static int GL_saved_screen_id = -1;
@@ -1153,96 +1146,6 @@ void gr_opengl_free_screen(int bmp_id)
11531146
GL_saved_screen_id = -1;
11541147
}
11551148

1156-
static void opengl_flush_frame_dump()
1157-
{
1158-
char filename[MAX_FILENAME_LEN];
1159-
1160-
Assert( GL_dump_buffer != NULL);
1161-
1162-
for (int i = 0; i < GL_dump_frame_count; i++) {
1163-
sprintf(filename, NOX("frm%04d.tga"), GL_dump_frame_number );
1164-
GL_dump_frame_number++;
1165-
1166-
CFILE *f = cfopen(filename, "wb", CFILE_NORMAL, CF_TYPE_DATA);
1167-
1168-
// Write the TGA header
1169-
cfwrite_ubyte( 0, f ); // IDLength;
1170-
cfwrite_ubyte( 0, f ); // ColorMapType;
1171-
cfwrite_ubyte( 2, f ); // ImageType; // 2 = 24bpp, uncompressed, 10=24bpp rle compressed
1172-
cfwrite_ushort( 0, f ); // CMapStart;
1173-
cfwrite_ushort( 0, f ); // CMapLength;
1174-
cfwrite_ubyte( 0, f ); // CMapDepth;
1175-
cfwrite_ushort( 0, f ); // XOffset;
1176-
cfwrite_ushort( 0, f ); // YOffset;
1177-
cfwrite_ushort( (ushort)gr_screen.max_w, f ); // Width;
1178-
cfwrite_ushort( (ushort)gr_screen.max_h, f ); // Height;
1179-
cfwrite_ubyte( 24, f ); //PixelDepth;
1180-
cfwrite_ubyte( 0, f ); //ImageDesc;
1181-
1182-
glReadBuffer(GL_FRONT);
1183-
glReadPixels(0, 0, gr_screen.max_w, gr_screen.max_h, GL_BGR_EXT, GL_UNSIGNED_BYTE, GL_dump_buffer);
1184-
1185-
// save the data out
1186-
cfwrite( GL_dump_buffer, GL_dump_frame_size, 1, f );
1187-
1188-
cfclose(f);
1189-
1190-
}
1191-
1192-
GL_dump_frame_count = 0;
1193-
}
1194-
1195-
void gr_opengl_dump_frame_start(int first_frame, int frames_between_dumps)
1196-
{
1197-
if ( GL_dump_frames ) {
1198-
Int3(); // We're already dumping frames. See John.
1199-
return;
1200-
}
1201-
1202-
GL_dump_frames = 1;
1203-
GL_dump_frame_number = first_frame;
1204-
GL_dump_frame_count = 0;
1205-
GL_dump_frame_count_max = frames_between_dumps; // only works if it's 1
1206-
GL_dump_frame_size = gr_screen.max_w * gr_screen.max_h * 3;
1207-
1208-
if ( !GL_dump_buffer ) {
1209-
int size = GL_dump_frame_count_max * GL_dump_frame_size;
1210-
1211-
GL_dump_buffer = (ubyte *)vm_malloc(size);
1212-
1213-
if ( !GL_dump_buffer ) {
1214-
Error(LOCATION, "Unable to malloc %d bytes for dump buffer", size );
1215-
}
1216-
}
1217-
}
1218-
1219-
void gr_opengl_dump_frame_stop()
1220-
{
1221-
if ( !GL_dump_frames ) {
1222-
Int3(); // We're not dumping frames. See John.
1223-
return;
1224-
}
1225-
1226-
// dump any remaining frames
1227-
opengl_flush_frame_dump();
1228-
1229-
GL_dump_frames = 0;
1230-
1231-
if ( GL_dump_buffer ) {
1232-
vm_free(GL_dump_buffer);
1233-
GL_dump_buffer = NULL;
1234-
}
1235-
}
1236-
1237-
void gr_opengl_dump_frame()
1238-
{
1239-
GL_dump_frame_count++;
1240-
1241-
if ( GL_dump_frame_count == GL_dump_frame_count_max ) {
1242-
opengl_flush_frame_dump();
1243-
}
1244-
}
1245-
12461149
//fill mode, solid/wire frame
12471150
void gr_opengl_set_fill_mode(int mode)
12481151
{
@@ -1327,13 +1230,6 @@ void gr_opengl_translate_texture_matrix(int unit, const vec3d *shift)
13271230
// tex_shift=vmd_zero_vector;
13281231
}
13291232

1330-
void gr_opengl_setup_background_fog(bool set)
1331-
{
1332-
if (Cmdline_nohtl) {
1333-
return;
1334-
}
1335-
}
1336-
13371233
void gr_opengl_set_line_width(float width)
13381234
{
13391235
glLineWidth(width);
@@ -1798,8 +1694,6 @@ void opengl_setup_function_pointers()
17981694
gr_screen.gf_set_palette = gr_opengl_set_palette;
17991695
gr_screen.gf_print_screen = gr_opengl_print_screen;
18001696

1801-
gr_screen.gf_fade_in = gr_opengl_fade_in;
1802-
gr_screen.gf_fade_out = gr_opengl_fade_out;
18031697
gr_screen.gf_flash = gr_opengl_flash;
18041698
gr_screen.gf_flash_alpha = gr_opengl_flash_alpha;
18051699

@@ -1816,10 +1710,6 @@ void opengl_setup_function_pointers()
18161710
gr_screen.gf_restore_screen = gr_opengl_restore_screen;
18171711
gr_screen.gf_free_screen = gr_opengl_free_screen;
18181712

1819-
gr_screen.gf_dump_frame_start = gr_opengl_dump_frame_start;
1820-
gr_screen.gf_dump_frame_stop = gr_opengl_dump_frame_stop;
1821-
gr_screen.gf_dump_frame = gr_opengl_dump_frame;
1822-
18231713
gr_screen.gf_set_gamma = gr_opengl_set_gamma;
18241714

18251715
gr_screen.gf_fog_set = gr_opengl_fog_set;
@@ -1913,12 +1803,6 @@ void opengl_setup_function_pointers()
19131803
gr_screen.gf_center_alpha = gr_opengl_center_alpha;
19141804
gr_screen.gf_set_thrust_scale = gr_opengl_set_thrust_scale;
19151805

1916-
gr_screen.gf_setup_background_fog = gr_opengl_setup_background_fog;
1917-
1918-
gr_screen.gf_start_state_block = gr_opengl_start_state_block;
1919-
gr_screen.gf_end_state_block = gr_opengl_end_state_block;
1920-
gr_screen.gf_set_state_block = gr_opengl_set_state_block;
1921-
19221806
gr_screen.gf_draw_line_list = gr_opengl_draw_line_list;
19231807

19241808
gr_screen.gf_set_line_width = gr_opengl_set_line_width;

code/graphics/gropengldraw.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2036,17 +2036,6 @@ void gr_opengl_flash_alpha(int r, int g, int b, int a)
20362036
opengl_draw_coloured_quad((GLint)x1, (GLint)y1, (GLint)x2, (GLint)y2);
20372037
}
20382038

2039-
2040-
void gr_opengl_fade_in(int instantaneous)
2041-
{
2042-
// Empty - DDOI
2043-
}
2044-
2045-
void gr_opengl_fade_out(int instantaneous)
2046-
{
2047-
// Empty - DDOI
2048-
}
2049-
20502039
void opengl_bitmap_ex_internal(int x, int y, int w, int h, int sx, int sy, int resize_mode)
20512040
{
20522041
if ( (w < 1) || (h < 1) ) {

0 commit comments

Comments
 (0)