From bdb3cff6fdc8675fd38f26930181ebad8c8bbef5 Mon Sep 17 00:00:00 2001 From: Steven Fuller Date: Thu, 6 Dec 2001 03:40:38 +0000 Subject: [PATCH] Implemented the Progress Bar during Loading. --- TODO | 2 +- src/avp/win95/progress_bar.cpp | 29 ++++--------- src/opengl.c | 77 +++++++++++++++++++++++++++++++++- src/win95/aw.h | 2 +- 4 files changed, 86 insertions(+), 24 deletions(-) diff --git a/TODO b/TODO index 26881d2..773e838 100644 --- a/TODO +++ b/TODO @@ -3,7 +3,7 @@ [DONE] [11/10/01] Save/Load Game support. [DONE] [11/25/01] CD Audio. [DONE] [12/05/01] Menus. -* Progress bar. +[DONE] [12/05/01] Progress bar. * Make vidmodes work. * Debug "pure virtual method called" * Proper file loading/saving (ignore case, search certain directories) and diff --git a/src/avp/win95/progress_bar.cpp b/src/avp/win95/progress_bar.cpp index 68694bb..4396b21 100644 --- a/src/avp/win95/progress_bar.cpp +++ b/src/avp/win95/progress_bar.cpp @@ -28,6 +28,8 @@ extern int FadingGameInAfterLoading; extern void RenderBriefingText(int centreY, int brightness); extern void InGameFlipBuffers(); + +extern void BltImage(RECT *dest, DDSurface *image, RECT *src); }; static int CurrentPosition=0; @@ -47,13 +49,10 @@ RECT LoadingBarEmpty_SrcRect; RECT LoadingBarFull_DestRect; RECT LoadingBarFull_SrcRect; - - void Start_Progress_Bar() { AAFontImageNumber = CL_LoadImageOnce("Common\\aa_font.RIM",LIO_D3DTEXTURE|LIO_RELATIVEPATH|LIO_RESTORABLE); -#if 0 /* TODO: disabled for port */ /* load other graphics */ { char buffer[100]; @@ -153,7 +152,6 @@ void Start_Progress_Bar() 0 ); } -#endif //draw initial progress bar @@ -170,9 +168,8 @@ void Start_Progress_Bar() for (int i=0; i<2; i++) { ColourFillBackBuffer(0); -#if 0 /* TODO: disabled for port */ - if (LoadingBarEmpty) lpDDSBack->Blt(&LoadingBarEmpty_DestRect,LoadingBarEmpty,&LoadingBarEmpty_SrcRect,DDBLT_WAIT,0); -#endif + if (LoadingBarEmpty) BltImage(&LoadingBarEmpty_DestRect,LoadingBarEmpty,&LoadingBarEmpty_SrcRect); + FlushD3DZBuffer(); ThisFramesRenderingHasBegun(); @@ -185,7 +182,6 @@ void Start_Progress_Bar() InGameFlipBuffers(); } -#if 0 /* TODO: disabled for port */ if(image) { ReleaseDDSurface(image); @@ -194,7 +190,7 @@ void Start_Progress_Bar() { ReleaseDDSurface(LoadingBarEmpty); } -#endif + CurrentPosition=0; @@ -217,9 +213,8 @@ void Set_Progress_Bar_Position(int pos) LoadingBarFull_DestRect.top=(ScreenDescriptorBlock.SDB_Height *11)/12; LoadingBarFull_DestRect.bottom=ScreenDescriptorBlock.SDB_Height-1; -#if 0 /* TODO: disabled for port */ - if (LoadingBarFull) lpDDSBack->Blt(&LoadingBarFull_DestRect,LoadingBarFull,&LoadingBarFull_SrcRect,DDBLT_WAIT,0); -#endif + if (LoadingBarFull) BltImage(&LoadingBarFull_DestRect,LoadingBarFull,&LoadingBarFull_SrcRect); + /* FlipBuffers(); */ InGameFlipBuffers(); @@ -268,8 +263,6 @@ void Game_Has_Loaded(void) CheckForWindowsMessages(); ReadUserInput(); -// InGameFlipBuffers(); - ColourFillBackBufferQuad ( 0, @@ -292,9 +285,8 @@ void Game_Has_Loaded(void) LoadingBarFull_DestRect.top=(ScreenDescriptorBlock.SDB_Height *11)/12+h; LoadingBarFull_DestRect.bottom=ScreenDescriptorBlock.SDB_Height-1-h; -#if 0 /* TODO: disabled for port */ - if (LoadingBarFull) lpDDSBack->Blt(&LoadingBarFull_DestRect,LoadingBarFull,&LoadingBarFull_SrcRect,DDBLT_WAIT,0); -#endif + if (LoadingBarFull) BltImage(&LoadingBarFull_DestRect,LoadingBarFull,&LoadingBarFull_SrcRect); + f-=NormalFrameTime; if (f<0) f=0; } @@ -333,13 +325,10 @@ void Game_Has_Loaded(void) FadingGameInAfterLoading=ONE_FIXED; -#if 0 /* TODO: disabled for port */ if (LoadingBarFull) { ReleaseDDSurface(LoadingBarFull); } -#endif } - }; diff --git a/src/opengl.c b/src/opengl.c index 07626e4..7bffa6a 100644 --- a/src/opengl.c +++ b/src/opengl.c @@ -2388,16 +2388,55 @@ void ColourFillBackBuffer(int FillColour) glClear(GL_COLOR_BUFFER_BIT); } -void ColourFillBackBufferQuad(int FillColour, int LeftX, int TopY, int RightX, int BotY) +void ColourFillBackBufferQuad(int FillColour, int x0, int y0, int x1, int y1) { + GLfloat x[4], y[4]; int r, g, b, a; + + if (y1 <= y0) + return; + + CheckTranslucencyModeIsCorrect(TRANSLUCENCY_OFF); + CheckBoundTextureIsCorrect(NULL); b = ((FillColour >> 0) & 0xFF); g = ((FillColour >> 8) & 0xFF); r = ((FillColour >> 16) & 0xFF); a = ((FillColour >> 24) & 0xFF); + + glColor4ub(r, g, b, a); + + x[0] = x0; + x[0] = (x[0] - ScreenDescriptorBlock.SDB_CentreX)/ScreenDescriptorBlock.SDB_CentreX; + y[0] = y0; + y[0] = -(y[0] - ScreenDescriptorBlock.SDB_CentreY)/ScreenDescriptorBlock.SDB_CentreY; - D3D_Rectangle(LeftX, TopY, RightX, BotY, r, g, b, a); + x[1] = x1 - 1; + x[1] = (x[1] - ScreenDescriptorBlock.SDB_CentreX)/ScreenDescriptorBlock.SDB_CentreX; + y[1] = y0; + y[1] = -(y[1] - ScreenDescriptorBlock.SDB_CentreY)/ScreenDescriptorBlock.SDB_CentreY; + + x[2] = x1 - 1; + x[2] = (x[2] - ScreenDescriptorBlock.SDB_CentreX)/ScreenDescriptorBlock.SDB_CentreX; + y[2] = y1 - 1; + y[2] = -(y[2] - ScreenDescriptorBlock.SDB_CentreY)/ScreenDescriptorBlock.SDB_CentreY; + + x[3] = x0; + x[3] = (x[3] - ScreenDescriptorBlock.SDB_CentreX)/ScreenDescriptorBlock.SDB_CentreX; + y[3] = y1 - 1; + y[3] = -(y[3] - ScreenDescriptorBlock.SDB_CentreY)/ScreenDescriptorBlock.SDB_CentreY; + + SelectPolygonBeginType(3); /* triangles */ + + glVertex3f(x[0], y[0], -1.0f); + glVertex3f(x[1], y[1], -1.0f); + glVertex3f(x[3], y[3], -1.0f); + + glVertex3f(x[1], y[1], -1.0f); + glVertex3f(x[2], y[2], -1.0f); + glVertex3f(x[3], y[3], -1.0f); + + glEnd(); } void D3D_DrawBackdrop() @@ -2457,6 +2496,40 @@ void D3D_DrawBackdrop() } } +void BltImage(RECT *dest, DDSurface *image, RECT *src) +{ + int width1, width; + int height1, height; + + width = dest->right - dest->left + 1; + width1 = src->right - src->left + 1; + height = dest->bottom - dest->top + 1; + height1 = src->bottom - src->top + 1; + + glPushAttrib(GL_COLOR_BUFFER_BIT | GL_PIXEL_MODE_BIT); + glPushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT); + + glDisable(GL_BLEND); + + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glPixelStorei(GL_UNPACK_ROW_LENGTH, image->w); + glPixelZoom((double)width/(double)width1, (double)height/(double)height1); + + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + + glOrtho(0.0, ScreenDescriptorBlock.SDB_Width, 0.0, ScreenDescriptorBlock.SDB_Height, -1.0, 1.0); + glRasterPos2i(dest->left, ScreenDescriptorBlock.SDB_Height-dest->bottom); + + glDrawPixels(width1, height1, GL_RGBA, GL_UNSIGNED_BYTE, image->buf); + + glPopMatrix(); + + glPopClientAttrib(); + glPopAttrib();; +} + /* ** */ /* Hacked in special effects */ diff --git a/src/win95/aw.h b/src/win95/aw.h index 902d9f4..0a7ac4b 100644 --- a/src/win95/aw.h +++ b/src/win95/aw.h @@ -6,6 +6,7 @@ typedef struct AwBackupTexture * AW_BACKUPTEXTUREHANDLE; typedef struct DIRECTDRAWSURFACE { + unsigned char *buf; int id; int w; @@ -20,7 +21,6 @@ typedef DIRECTDRAWSURFACE DDSurface; typedef struct DIRECT3DTEXTURE { unsigned char *buf; - int id; int w;