new code for ogl_offscreen_render, used it to reduce flickering in credits and spinning robots, improved way to regognize hires briefing images
This commit is contained in:
parent
d4a78a5794
commit
3d3aed73d0
|
@ -1109,26 +1109,28 @@ bool ogl_ubitblt_copy(int w,int h,int dx,int dy, int sx, int sy, grs_bitmap * sr
|
|||
}
|
||||
|
||||
grs_canvas *offscreen_save_canv=NULL, *offscreen_canv=NULL;
|
||||
|
||||
void ogl_start_offscreen_render(int x, int y, int w, int h) {
|
||||
int y2;
|
||||
float pixels [SWIDTH*SHEIGHT];
|
||||
if (offscreen_canv) Error("ogl_start_offscreen_render: offscreen_canv!=NULL");
|
||||
offscreen_save_canv = grd_curcanv;
|
||||
offscreen_canv = gr_create_sub_canvas(grd_curcanv, x, y, w, h);
|
||||
gr_set_current_canvas(offscreen_canv);
|
||||
glDrawBuffer(GL_BACK);
|
||||
y2 = last_height - offscreen_canv->cv_bitmap.bm_y - offscreen_canv->cv_bitmap.bm_h;
|
||||
glReadPixels(offscreen_canv->cv_bitmap.bm_x,y2,w,h,GL_RGBA,GL_UNSIGNED_BYTE,pixels);
|
||||
}
|
||||
void ogl_end_offscreen_render(void) {
|
||||
int y;
|
||||
float pixels [SWIDTH*SHEIGHT];
|
||||
if (!offscreen_canv) Error("ogl_end_offscreen_render: no offscreen_canv");
|
||||
|
||||
glDrawBuffer(GL_FRONT);
|
||||
glReadBuffer(GL_BACK);
|
||||
OGL_DISABLE(TEXTURE_2D);
|
||||
|
||||
y = last_height - offscreen_canv->cv_bitmap.bm_y - offscreen_canv->cv_bitmap.bm_h;
|
||||
glRasterPos2f(offscreen_canv->cv_bitmap.bm_x/(float)last_width, y/(float)last_height);
|
||||
glCopyPixels(offscreen_canv->cv_bitmap.bm_x, y,
|
||||
offscreen_canv->cv_bitmap.bm_w, offscreen_canv->cv_bitmap.bm_h, GL_COLOR);
|
||||
|
||||
glDrawPixels(offscreen_canv->cv_bitmap.bm_w, offscreen_canv->cv_bitmap.bm_h,GL_RGBA,GL_UNSIGNED_BYTE,pixels);
|
||||
gr_free_sub_canvas(offscreen_canv);
|
||||
gr_set_current_canvas(offscreen_save_canv);
|
||||
offscreen_canv=NULL;
|
||||
|
|
|
@ -55,7 +55,7 @@ static char rcsid[] = "$Id: credits.c,v 1.1.1.1 2006/03/17 19:44:11 zicodxx Exp
|
|||
#endif
|
||||
|
||||
#define ROW_SPACING (GHEIGHT/17)
|
||||
#define NUM_LINES 14
|
||||
#define NUM_LINES 20 //14
|
||||
#define CREDITS_BACKGROUND_FILENAME "stars.pcx"
|
||||
#define CREDITS_FILE "credits.tex"
|
||||
|
||||
|
@ -178,7 +178,11 @@ void credits_show(char *credits_filename)
|
|||
gr_update();
|
||||
gr_palette_fade_in( gr_palette, 32, 0 );
|
||||
|
||||
#ifndef OGL
|
||||
CreditsOffscreenBuf = gr_create_canvas(GWIDTH,GHEIGHT);
|
||||
#else
|
||||
CreditsOffscreenBuf = gr_create_sub_canvas(grd_curcanv,0,0,GWIDTH,GHEIGHT);
|
||||
#endif
|
||||
|
||||
if (!CreditsOffscreenBuf)
|
||||
Error("Not enough memory to allocate Credits Buffer.");
|
||||
|
@ -187,11 +191,9 @@ void credits_show(char *credits_filename)
|
|||
|
||||
last_time = timer_get_fixed_seconds();
|
||||
done = 0;
|
||||
#ifdef OGL
|
||||
first_line_offset = GHEIGHT/8; // ZICO - keep the lines in canvas
|
||||
#else
|
||||
|
||||
first_line_offset = 0;
|
||||
#endif
|
||||
|
||||
while( 1 ) {
|
||||
int k;
|
||||
|
||||
|
@ -215,11 +217,13 @@ void credits_show(char *credits_filename)
|
|||
} while (extra_inc--);
|
||||
extra_inc = 0;
|
||||
|
||||
for (i=0; i<ROW_SPACING; i += (SWIDTH>=640?2:1) ) {
|
||||
for (i=0; i<ROW_SPACING; i += (SWIDTH>=640?FONTSCALE_Y(2):1) ) {
|
||||
int y;
|
||||
|
||||
y = first_line_offset - i;
|
||||
|
||||
#ifdef OGL
|
||||
ogl_start_offscreen_render(0,-1,GWIDTH,GHEIGHT);
|
||||
#endif
|
||||
gr_set_current_canvas(CreditsOffscreenBuf);
|
||||
show_fullscr(&backdrop);
|
||||
|
||||
|
@ -265,10 +269,6 @@ void credits_show(char *credits_filename)
|
|||
|
||||
for (j=0; j<NUM_LINES; j++ )
|
||||
{
|
||||
#ifdef OGL
|
||||
glScissor (0,GHEIGHT/6,GWIDTH,GHEIGHT-(GHEIGHT/3)); // ZICO - create borders for new line endings
|
||||
glEnable (0x0C11);
|
||||
#endif
|
||||
new_box = &dirty_box[j];
|
||||
|
||||
tempbmp = &(CreditsOffscreenBuf->cv_bitmap);
|
||||
|
@ -329,14 +329,18 @@ void credits_show(char *credits_filename)
|
|||
free(backdrop.bm_data);
|
||||
cfclose(file);
|
||||
songs_play_song( SONG_TITLE, 1 );
|
||||
if (CreditsOffscreenBuf != VR_offscreen_buffer)
|
||||
gr_free_canvas(CreditsOffscreenBuf);
|
||||
gr_palette_load( gr_palette );
|
||||
#ifdef OGL
|
||||
glDisable(0x0C11);
|
||||
gr_free_sub_canvas(CreditsOffscreenBuf);
|
||||
ogl_end_offscreen_render();
|
||||
#else
|
||||
gr_free_canvas(CreditsOffscreenBuf);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
#ifdef OGL
|
||||
ogl_end_offscreen_render();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -768,11 +768,10 @@ void draw_model_picture(int mn,vms_angvec *orient_angles)
|
|||
#ifndef OGL
|
||||
grs_canvas *save_canv = grd_curcanv,*temp_canv;
|
||||
#endif
|
||||
gr_clear_canvas( BM_XRGB(0,0,0) );
|
||||
Assert(mn>=0 && mn<N_polygon_models);
|
||||
|
||||
#ifdef OGL
|
||||
ogl_start_frame();
|
||||
ogl_start_offscreen_render(0,0,grd_curcanv->cv_bitmap.bm_w,grd_curcanv->cv_bitmap.bm_h);
|
||||
#else
|
||||
temp_canv = gr_create_canvas(save_canv->cv_bitmap.bm_w,save_canv->cv_bitmap.bm_h);
|
||||
gr_set_current_canvas(temp_canv);
|
||||
|
@ -791,7 +790,7 @@ void draw_model_picture(int mn,vms_angvec *orient_angles)
|
|||
g3_end_frame();
|
||||
|
||||
#ifdef OGL
|
||||
ogl_end_frame();
|
||||
ogl_end_offscreen_render();
|
||||
#else
|
||||
gr_set_current_canvas(save_canv);
|
||||
gr_bitmap(0,0,&temp_canv->cv_bitmap);
|
||||
|
|
|
@ -155,6 +155,7 @@ typedef struct {
|
|||
#define BRIEFING_OFFSET_NUM 4 // This must correspond to the first level screen (ie, past the bald guy briefing screens)
|
||||
#define SHAREWARE_ENDING_LEVEL_NUM 0x7f
|
||||
#define REGISTERED_ENDING_LEVEL_NUM 0x7e
|
||||
#define Briefing_screens_LH ((SWIDTH >= 640 && cfexist(DESCENT_DATA_PATH "brief01h.pcx"))?Briefing_screens_h:Briefing_screens)
|
||||
|
||||
briefing_screen Briefing_screens[] = {
|
||||
{ "brief01.pcx", 0, 1, 13, 140, 290, 59 },
|
||||
|
@ -288,13 +289,8 @@ char * get_briefing_screen( int level_num )
|
|||
{
|
||||
int i, found_level=0, last_level=0;
|
||||
for (i = 0; i < MAX_BRIEFING_SCREEN; i++) {
|
||||
if (SWIDTH >= 640 && cfexist(DESCENT_DATA_PATH "brief01h.pcx")) {
|
||||
if ( found_level && Briefing_screens_h[i].level_num != level_num )
|
||||
return Briefing_screens_h[last_level].bs_name;
|
||||
} else {
|
||||
if ( found_level && Briefing_screens[i].level_num != level_num )
|
||||
return Briefing_screens[last_level].bs_name;
|
||||
}
|
||||
if ( found_level && Briefing_screens_LH[i].level_num != level_num )
|
||||
return Briefing_screens_LH[last_level].bs_name;
|
||||
if (Briefing_screens[i].level_num == level_num ) {
|
||||
found_level=1;
|
||||
last_level = i;
|
||||
|
@ -467,6 +463,8 @@ void show_spinning_robot_frame(int robot_num)
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
void init_spinning_robot(void)
|
||||
{
|
||||
|
@ -546,20 +544,12 @@ int show_char_delay(char the_char, int delay, int robot_num, int cursor_flag)
|
|||
int load_briefing_screen( int screen_num )
|
||||
{
|
||||
int pcx_error;
|
||||
if (SWIDTH >= 640 && cfexist(DESCENT_DATA_PATH "brief01h.pcx")) // ZICO - use hires if available
|
||||
{
|
||||
if ((pcx_error=pcx_read_fullscr( Briefing_screens_h[screen_num].bs_name, New_pal ))!=PCX_ERROR_NONE) {
|
||||
printf( "File '%s', PCX load error: %s\n (It's a briefing screen. Does this cause you pain?)\n",Briefing_screens_h[screen_num].bs_name, pcx_errormsg(pcx_error));
|
||||
Int3();
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
if ((pcx_error=pcx_read_fullscr( Briefing_screens[screen_num].bs_name, New_pal ))!=PCX_ERROR_NONE) {
|
||||
printf( "File '%s', PCX load error: %s\n (It's a briefing screen. Does this cause you pain?)\n",Briefing_screens[screen_num].bs_name, pcx_errormsg(pcx_error));
|
||||
Int3();
|
||||
return 0;
|
||||
}
|
||||
if ((pcx_error=pcx_read_fullscr( Briefing_screens_LH[screen_num].bs_name, New_pal ))!=PCX_ERROR_NONE) {
|
||||
printf( "File '%s', PCX load error: %s\n (It's a briefing screen. Does this cause you pain?)\n",Briefing_screens_LH[screen_num].bs_name, pcx_errormsg(pcx_error));
|
||||
Int3();
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -994,6 +984,28 @@ int show_briefing_text(int screen_num)
|
|||
return show_briefing_message(screen_num, message_ptr);
|
||||
}
|
||||
|
||||
#ifdef OGL
|
||||
// ZICO - this function will load the bitmap frame for spinning robots in the offscreen buffer.
|
||||
// this way we can be sure the frame is shown when offscreen render is called in draw_model_picture().
|
||||
// some GPU configurations seem (dunno why) to mess it up otherwise...
|
||||
void ogl_init_robot_frame()
|
||||
{
|
||||
CFILE * file;
|
||||
int pcx_error;
|
||||
grs_bitmap backdrop;
|
||||
|
||||
backdrop.bm_data=NULL;
|
||||
pcx_error = pcx_read_bitmap("brief03.pcx",&backdrop, BM_LINEAR,New_pal);
|
||||
if (pcx_error != PCX_ERROR_NONE) {
|
||||
cfclose(file);
|
||||
return;
|
||||
}
|
||||
ogl_start_offscreen_render(0, 0, SWIDTH, SHEIGHT);
|
||||
show_fullscr(&backdrop);
|
||||
ogl_end_offscreen_render();
|
||||
}
|
||||
#endif
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Return true if screen got aborted by user, else return false.
|
||||
int show_briefing_screen( int screen_num, int allow_keys)
|
||||
|
@ -1011,29 +1023,23 @@ int show_briefing_screen( int screen_num, int allow_keys)
|
|||
|
||||
gr_init_bitmap_data (&briefing_bm);
|
||||
|
||||
if (SWIDTH >= 640 && cfexist(DESCENT_DATA_PATH "brief01h.pcx")) // ZICO - use hires if available
|
||||
{
|
||||
if ((pcx_error=pcx_read_bitmap( Briefing_screens_h[screen_num].bs_name, &briefing_bm, BM_LINEAR, New_pal ))!=PCX_ERROR_NONE) {
|
||||
printf( "PCX load error: %s. File '%s'\n\n", pcx_errormsg(pcx_error), Briefing_screens_h[screen_num].bs_name);
|
||||
mprintf((0, "File '%s', PCX load error: %s (%i)\n (It's a briefing screen. Does this cause you pain?)\n",Briefing_screens_h[screen_num].bs_name, pcx_errormsg(pcx_error), pcx_error));
|
||||
if ((pcx_error=pcx_read_bitmap( Briefing_screens_LH[screen_num].bs_name, &briefing_bm, BM_LINEAR, New_pal ))!=PCX_ERROR_NONE) {
|
||||
printf( "PCX load error: %s. File '%s'\n\n", pcx_errormsg(pcx_error), Briefing_screens_LH[screen_num].bs_name);
|
||||
mprintf((0, "File '%s', PCX load error: %s (%i)\n (It's a briefing screen. Does this cause you pain?)\n",Briefing_screens_LH[screen_num].bs_name, pcx_errormsg(pcx_error), pcx_error));
|
||||
Int3();
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
if ((pcx_error=pcx_read_bitmap( Briefing_screens[screen_num].bs_name, &briefing_bm, BM_LINEAR, New_pal ))!=PCX_ERROR_NONE) {
|
||||
printf( "PCX load error: %s. File '%s'\n\n", pcx_errormsg(pcx_error), Briefing_screens[screen_num].bs_name);
|
||||
mprintf((0, "File '%s', PCX load error: %s (%i)\n (It's a briefing screen. Does this cause you pain?)\n",Briefing_screens[screen_num].bs_name, pcx_errormsg(pcx_error), pcx_error));
|
||||
Int3();
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
#ifdef OGL
|
||||
gr_palette_load(New_pal);
|
||||
|
||||
if (screen_num>1)
|
||||
ogl_init_robot_frame();
|
||||
#else
|
||||
gr_palette_clear();
|
||||
#endif
|
||||
|
||||
|
||||
show_fullscr(&briefing_bm );
|
||||
|
||||
//added on 9/13/98 by adb to make arch's requiring updates work
|
||||
|
|
Loading…
Reference in a new issue