diff --git a/source/gui/CInput.cpp b/source/gui/CInput.cpp index 54fa4a3f28..a3489841b1 100755 --- a/source/gui/CInput.cpp +++ b/source/gui/CInput.cpp @@ -573,14 +573,14 @@ void CInput::HandleMessage(const SGUIMessage &Message) break; case GUIM_MOUSE_WHEEL_DOWN: - GetScrollBar(0).ScrollMinus(); + GetScrollBar(0).ScrollPlus(); // Since the scroll was changed, let's simulate a mouse movement // to check if scrollbar now is hovered HandleMessage(SGUIMessage(GUIM_MOUSE_MOTION)); break; case GUIM_MOUSE_WHEEL_UP: - GetScrollBar(0).ScrollPlus(); + GetScrollBar(0).ScrollMinus(); // Since the scroll was changed, let's simulate a mouse movement // to check if scrollbar now is hovered HandleMessage(SGUIMessage(GUIM_MOUSE_MOTION)); diff --git a/source/lib/sysdep/win/wsdl.cpp b/source/lib/sysdep/win/wsdl.cpp index 4b7adb2597..d73c5a3a40 100755 --- a/source/lib/sysdep/win/wsdl.cpp +++ b/source/lib/sysdep/win/wsdl.cpp @@ -93,8 +93,8 @@ HWND hWnd = (HWND)INVALID_HANDLE_VALUE; static DEVMODE dm; // current video mode -static HDC hDC; -static HGLRC hGLRC; +static HDC hDC = (HDC)INVALID_HANDLE_VALUE; +static HGLRC hGLRC = (HGLRC)INVALID_HANDLE_VALUE; static int depth_bits = 24; // depth buffer size; set via SDL_GL_SetAttribute diff --git a/source/ps/GameSetup/GameSetup.cpp b/source/ps/GameSetup/GameSetup.cpp index 7973a4b835..e070241edb 100644 --- a/source/ps/GameSetup/GameSetup.cpp +++ b/source/ps/GameSetup/GameSetup.cpp @@ -793,7 +793,7 @@ void Shutdown() # pragma optimize("", off) #endif -void Init(int argc, char* argv[], bool setup_gfx, bool setup_gui) +void Init(int argc, char* argv[], bool setup_videomode, bool setup_gui) { debug_printf("INIT &argc=%p &argv=%p\n", &argc, &argv); @@ -837,7 +837,7 @@ void Init(int argc, char* argv[], bool setup_gfx, bool setup_gui) // and fonts are set later in InitPs()) g_Console = new CConsole(); - if(setup_gfx) + if(setup_videomode) InitSDL(); // preferred video mode = current desktop settings @@ -860,7 +860,7 @@ void Init(int argc, char* argv[], bool setup_gfx, bool setup_gui) bool windowed = false; CFG_GET_SYS_VAL("windowed", Bool, windowed); - if (setup_gfx) + if (setup_videomode) { SDL_WM_SetCaption("0 A.D.", "0 A.D."); @@ -870,14 +870,14 @@ void Init(int argc, char* argv[], bool setup_gfx, bool setup_gui) LOG(ERROR, LOG_CATEGORY, "Could not set %dx%d graphics mode: %s", g_xres, g_yres, SDL_GetError()); throw PSERROR_System_VmodeFailed(); } - - uint quality = SANE_TEX_QUALITY_DEFAULT; // TODO: set value from config file - SetTextureQuality(quality); - - // required by ogl_tex to detect broken gfx card/driver combos - get_gfx_info(); } + uint quality = SANE_TEX_QUALITY_DEFAULT; // TODO: set value from config file + SetTextureQuality(quality); + + // required by ogl_tex to detect broken gfx card/driver combos + get_gfx_info(); + oglCheck(); if(!g_Quickstart) @@ -961,7 +961,6 @@ void Init(int argc, char* argv[], bool setup_gfx, bool setup_gui) } #endif - if (setup_gfx) { TIMER(Init_renderblank); MICROLOG(L"render blank"); diff --git a/source/ps/GameSetup/GameSetup.h b/source/ps/GameSetup/GameSetup.h index 273a5e7543..5f2825ce1b 100644 --- a/source/ps/GameSetup/GameSetup.h +++ b/source/ps/GameSetup/GameSetup.h @@ -19,4 +19,6 @@ extern void Render(); extern void Shutdown(); -extern void Init(int argc, char* argv[], bool setup_gfx, bool setup_gui); +// If setup_videmode is false, it is assumed that the video mode has already +// been set up and is ready for rendering. +extern void Init(int argc, char* argv[], bool setup_videomode, bool setup_gui); diff --git a/source/renderer/Renderer.cpp b/source/renderer/Renderer.cpp index 11688798e9..117fb79ab5 100755 --- a/source/renderer/Renderer.cpp +++ b/source/renderer/Renderer.cpp @@ -90,6 +90,8 @@ CRenderer::CRenderer() m_TWaterScrollCounter=0; m_WaterCurrentTex=0; + cur_loading_water_tex = 0; + ONCE( ScriptingInit(); ); } @@ -1462,7 +1464,6 @@ void CRenderer::UnloadAlphaMaps() int CRenderer::LoadWaterTextures() { - uint i; const uint num_textures = ARRAY_SIZE(m_WaterTexture); // yield after this time is reached. balances increased progress bar @@ -1471,26 +1472,30 @@ int CRenderer::LoadWaterTextures() // initialize to 0 in case something fails below // (we then abort the loop, but don't want undefined values in here) - for (i = 0; i < num_textures; i++) - m_WaterTexture[i] = 0; + if (cur_loading_water_tex == 0) + { + for (uint i = 0; i < num_textures; i++) + m_WaterTexture[i] = 0; + } - for (i = 0; i < num_textures; i++) + while (cur_loading_water_tex < num_textures) { char waterName[VFS_MAX_PATH]; // TODO: add a member variable and setter for this. (can't make this // a parameter because this function is called via delay-load code) const char* water_type = "animation2"; - snprintf(waterName, ARRAY_SIZE(waterName), "art/textures/terrain/types/water/%s/water%02d.dds", water_type, i+1); + snprintf(waterName, ARRAY_SIZE(waterName), "art/textures/terrain/types/water/%s/water%02d.dds", water_type, cur_loading_water_tex+1); Handle ht = ogl_tex_load(waterName); if (ht <= 0) { LOG(ERROR, LOG_CATEGORY, "LoadWaterTextures failed on \"%s\"", waterName); return ht; } - m_WaterTexture[i]=ht; + m_WaterTexture[cur_loading_water_tex]=ht; RETURN_ERR(ogl_tex_upload(ht)); - - LDR_CHECK_TIMEOUT(i, num_textures); + + cur_loading_water_tex++; + LDR_CHECK_TIMEOUT(cur_loading_water_tex, num_textures); } return 0; diff --git a/source/renderer/Renderer.h b/source/renderer/Renderer.h index 29f3e20bcd..84bc5e1d44 100755 --- a/source/renderer/Renderer.h +++ b/source/renderer/Renderer.h @@ -371,6 +371,9 @@ protected: // If false, use a multipass fallback for player colors. bool m_FastPlayerColor; + + // State used by LoadWaterTextures with progressive loading + uint cur_loading_water_tex; };