mirror of
https://github.com/dhewm/dhewm3.git
synced 2025-03-22 18:51:05 +00:00
(Hopefully) fix Editors messing up game viewport for good, fix #300
I worked around the issue for the particle editor, but now it turned out it can also somehow happen when switching from the Radiant to the Engine (with F2), so I implemented the "proper" fix of restoring glConfig.vidWidth/Height, that are overwritten in RenderSystemLocal::BeginFrame(), in RenderSystemLocal::EndFrame().
This commit is contained in:
parent
28e83b27a1
commit
31e26856e0
4 changed files with 18 additions and 22 deletions
|
@ -610,13 +610,11 @@ void idRenderSystemLocal::BeginFrame( int windowWidth, int windowHeight ) {
|
|||
windowHeight = tiledViewport[1];
|
||||
}
|
||||
|
||||
// DG: FIXME: WTF?! this is *not* reset in EndFrame() and next time
|
||||
// idSessionLocal::UpdateScreen() calls this function to render a proper frame,
|
||||
// passing renderSystem->GetScreenWidth()/Height() WHICH JUST RETURN glConfig.vidWidth/Height
|
||||
// will render the whole frame in that resolution (in a corner of the window), unless someone
|
||||
// resets glConfig.vid* manually... this is quite fragile, I wonder how many (more) bugs
|
||||
// (esp. in Editor code) will turn up because of this, but right now I don't dare to change
|
||||
// the behavior either, in case "fixing" it breaks other things
|
||||
// DG: save the original size, so editors don't mess up the game viewport
|
||||
// with their tiny (texture-preview etc) viewports.
|
||||
origWidth = glConfig.vidWidth;
|
||||
origHeight = glConfig.vidHeight;
|
||||
|
||||
glConfig.vidWidth = windowWidth;
|
||||
glConfig.vidHeight = windowHeight;
|
||||
|
||||
|
@ -730,6 +728,12 @@ void idRenderSystemLocal::EndFrame( int *frontEndMsec, int *backEndMsec ) {
|
|||
}
|
||||
}
|
||||
|
||||
// DG: restore the original size that was set before BeginFrame() overwrote it
|
||||
// with its function-arguments, so editors don't mess up our viewport.
|
||||
// (unsure why/how this at least *kinda* worked in original Doom3,
|
||||
// maybe glConfig.vidWidth/Height was reset if the window gained focus or sth)
|
||||
glConfig.vidWidth = origWidth;
|
||||
glConfig.vidHeight = origHeight;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -2143,6 +2143,8 @@ void idRenderSystemLocal::Init( void ) {
|
|||
identitySpace.modelMatrix[0*4+0] = 1.0f;
|
||||
identitySpace.modelMatrix[1*4+1] = 1.0f;
|
||||
identitySpace.modelMatrix[2*4+2] = 1.0f;
|
||||
|
||||
origWidth = origHeight = 0; // DG: for resetting width/height in EndFrame()
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -796,6 +796,11 @@ public:
|
|||
int guiRecursionLevel; // to prevent infinite overruns
|
||||
class idGuiModel * guiModel;
|
||||
class idGuiModel * demoGuiModel;
|
||||
|
||||
// DG: remember the original glConfig.vidWidth/Height values that get overwritten in BeginFrame()
|
||||
// so they can be reset in EndFrame() (Editors tend to mess up the viewport by using BeginFrame())
|
||||
int origWidth;
|
||||
int origHeight;
|
||||
};
|
||||
|
||||
extern backEndState_t backEnd;
|
||||
|
|
|
@ -446,18 +446,6 @@ void idGLDrawableMaterial::draw(int x, int y, int w, int h) {
|
|||
|
||||
renderView_t refdef;
|
||||
|
||||
// DG: renderSystem->BeginFrame() changes glConfig.vidWidth and vidHeight to w and h
|
||||
// that is never reset automatically and for some reason glConfig.vidWith/height is even
|
||||
// used for renderSystem->GetScreenWidth()/Height() so idSessionLocal::UpdateScreen()
|
||||
// which calls renderSystem->BeginFrame( renderSystem->GetScreenWidth(), renderSystem->GetScreenHeight() );
|
||||
// won't reset those values to something sane either, causing the game to be rendered in a tiny rectangle
|
||||
// at the lower left corner of the screen once we're done picking a material here..
|
||||
// I don't dare to fix this in renderSystem, as other code might rely on this behavior..
|
||||
// (OTOH I wouldn't be surprised if other callers of renderSystem->BeginFrame() cause the same issue)
|
||||
// Anyway, my workaround is to remember glConfig.vidWith/Height and set them to the original
|
||||
// values once we're done rendering here..
|
||||
int oldWidth = glConfig.vidWidth;
|
||||
int oldHeight = glConfig.vidHeight;
|
||||
// render it
|
||||
renderSystem->BeginFrame(w, h);
|
||||
memset( &refdef, 0, sizeof( refdef ) );
|
||||
|
@ -482,9 +470,6 @@ void idGLDrawableMaterial::draw(int x, int y, int w, int h) {
|
|||
|
||||
qglMatrixMode( GL_MODELVIEW );
|
||||
qglLoadIdentity();
|
||||
// DG: reset glConfig.vidWidth/Height
|
||||
glConfig.vidWidth = oldWidth;
|
||||
glConfig.vidHeight = oldHeight;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue