2008-01-27 11:25:03 +00:00
|
|
|
/*
|
|
|
|
** gl_framebuffer.cpp
|
|
|
|
** Implementation of the non-hardware specific parts of the
|
|
|
|
** OpenGL frame buffer
|
|
|
|
**
|
|
|
|
**---------------------------------------------------------------------------
|
|
|
|
** Copyright 2000-2007 Christoph Oelckers
|
|
|
|
** All rights reserved.
|
|
|
|
**
|
|
|
|
** Redistribution and use in source and binary forms, with or without
|
|
|
|
** modification, are permitted provided that the following conditions
|
|
|
|
** are met:
|
|
|
|
**
|
|
|
|
** 1. Redistributions of source code must retain the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer.
|
|
|
|
** 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer in the
|
|
|
|
** documentation and/or other materials provided with the distribution.
|
|
|
|
** 3. The name of the author may not be used to endorse or promote products
|
|
|
|
** derived from this software without specific prior written permission.
|
|
|
|
** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be
|
|
|
|
** covered by the terms of the GNU Lesser General Public License as published
|
|
|
|
** by the Free Software Foundation; either version 2.1 of the License, or (at
|
|
|
|
** your option) any later version.
|
- Added the following clause to all GL renderer related files (Skulltag devlopers, beware!):
Full disclosure of the entire project's source code, except for third party libraries is mandartory.
(NOTE: This clause is non-negotiable!)
- Fixed: The alpha for 3D floors was always set to 0.
Update to ZDoom r1056:
- Changed: I_Error and I_FatalError now use ZDoom's internal string formatting
code to process their messages. This was necessary to handle the %zu format
option used in some memory allocation failure messages.
- Fixed: The flat texture scaling action specials were completely broken.
- The sound code now handles restarting looping sounds itself. As far as
the rest of the game is concerned, these sounds will never stop once they
have been started until they are explicitly stopped. If they are evicted
from their channels, the sound code will restart them as soon as possible.
This means that instead of this:
if (!S_IsActorPlayingSomething(actor, CHAN_WEAPON, -1))
{
S_Sound(actor, CHAN_WEAPON|CHAN_LOOP, soundid, 1, ATTN_NORM);
}
The following is now just as effective:
S_Sound(actor, CHAN_WEAPON|CHAN_LOOP, soundid, 1, ATTN_NORM);
There are also a couple of other ramifications presented by this change:
* The full state of the sound system (sans music) is now stored in save
games. Any sounds that were playing when you saved will still be
playing when you load. (Try saving while Korax is making a speech in
Hexen to hear it.)
* Using snd_reset will also preserve any playing sounds.
* Movie playback is disabled, probably forever. I did not want to
update the MovieDisable/ResumeSound stuff for the new eviction
tracking code. A properly updated movie player will use the VMR,
which doesn't need these functions, since it would pipe the sound
straight through the sound system like everything else, so I decided
to dump them now, which leaves the movie player in a totally unworkable
state.
- Removed some unused constant definitions from sc_man.cpp.
git-svn-id: http://mancubus.net/svn/hosted/gzdoom/trunk@128 b0f79afe-0144-0410-b225-9a4edf0717df
2008-06-29 10:08:16 +00:00
|
|
|
** 5. Full disclosure of the entire project's source code, except for third
|
2008-06-29 10:27:22 +00:00
|
|
|
** party libraries is mandatory. (NOTE: This clause is non-negotiable!)
|
2008-01-27 11:25:03 +00:00
|
|
|
**
|
|
|
|
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
**---------------------------------------------------------------------------
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
|
2009-09-25 23:09:24 +00:00
|
|
|
#include "gl/system/gl_system.h"
|
2008-01-27 11:25:03 +00:00
|
|
|
#include "files.h"
|
|
|
|
#include "m_swap.h"
|
|
|
|
#include "r_draw.h"
|
|
|
|
#include "v_video.h"
|
2011-07-06 18:59:20 +00:00
|
|
|
#include "doomstat.h"
|
2008-01-27 11:25:03 +00:00
|
|
|
#include "m_png.h"
|
|
|
|
#include "m_crc32.h"
|
2009-07-11 07:06:31 +00:00
|
|
|
#include "vectors.h"
|
|
|
|
#include "v_palette.h"
|
|
|
|
#include "templates.h"
|
2011-07-06 18:59:20 +00:00
|
|
|
#include "farchive.h"
|
2008-01-27 11:25:03 +00:00
|
|
|
|
2009-09-25 18:10:15 +00:00
|
|
|
#include "gl/system/gl_framebuffer.h"
|
2009-09-25 21:57:47 +00:00
|
|
|
#include "gl/renderer/gl_renderer.h"
|
|
|
|
#include "gl/renderer/gl_lightdata.h"
|
2009-09-25 17:42:07 +00:00
|
|
|
#include "gl/data/gl_data.h"
|
2009-10-31 22:55:36 +00:00
|
|
|
#include "gl/textures/gl_hwtexture.h"
|
2009-09-24 22:31:33 +00:00
|
|
|
#include "gl/textures/gl_texture.h"
|
2009-09-25 17:42:07 +00:00
|
|
|
#include "gl/textures/gl_translate.h"
|
2010-07-29 12:44:36 +00:00
|
|
|
#include "gl/textures/gl_skyboxtexture.h"
|
2009-09-25 21:22:45 +00:00
|
|
|
#include "gl/utility/gl_clock.h"
|
|
|
|
#include "gl/utility/gl_templates.h"
|
2009-10-25 15:31:09 +00:00
|
|
|
#include "gl/gl_functions.h"
|
2009-09-24 22:31:33 +00:00
|
|
|
|
2008-01-27 11:25:03 +00:00
|
|
|
IMPLEMENT_CLASS(OpenGLFrameBuffer)
|
|
|
|
EXTERN_CVAR (Float, vid_brightness)
|
|
|
|
EXTERN_CVAR (Float, vid_contrast)
|
2009-11-02 07:53:09 +00:00
|
|
|
EXTERN_CVAR (Bool, vid_vsync)
|
2008-01-27 11:25:03 +00:00
|
|
|
|
2009-09-25 13:05:17 +00:00
|
|
|
FGLRenderer *GLRenderer;
|
2009-06-23 14:10:27 +00:00
|
|
|
|
2010-09-15 00:30:43 +00:00
|
|
|
void gl_SetupMenu();
|
|
|
|
|
2008-01-27 11:25:03 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2010-08-09 09:43:22 +00:00
|
|
|
OpenGLFrameBuffer::OpenGLFrameBuffer(void *hMonitor, int width, int height, int bits, int refreshHz, bool fullscreen) :
|
|
|
|
Super(hMonitor, width, height, bits, refreshHz, fullscreen)
|
2008-01-27 11:25:03 +00:00
|
|
|
{
|
2009-09-25 13:05:17 +00:00
|
|
|
GLRenderer = new FGLRenderer(this);
|
2008-01-27 11:25:03 +00:00
|
|
|
memcpy (SourcePalette, GPalette.BaseColors, sizeof(PalEntry)*256);
|
|
|
|
UpdatePalette ();
|
|
|
|
ScreenshotBuffer = NULL;
|
|
|
|
LastCamera = NULL;
|
|
|
|
|
|
|
|
InitializeState();
|
2010-09-15 00:30:43 +00:00
|
|
|
gl_SetupMenu();
|
2008-01-27 11:25:03 +00:00
|
|
|
gl_GenerateGlobalBrightmapFromColormap();
|
2009-10-19 20:15:13 +00:00
|
|
|
DoSetGamma();
|
|
|
|
needsetgamma = true;
|
2009-10-31 09:10:29 +00:00
|
|
|
swapped = false;
|
2009-12-15 20:27:57 +00:00
|
|
|
Accel2D = true;
|
2009-11-01 14:31:19 +00:00
|
|
|
if (gl.SetVSync!=NULL) gl.SetVSync(vid_vsync);
|
2008-01-27 11:25:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
OpenGLFrameBuffer::~OpenGLFrameBuffer()
|
|
|
|
{
|
2009-06-23 14:10:27 +00:00
|
|
|
delete GLRenderer;
|
2009-06-23 23:15:20 +00:00
|
|
|
GLRenderer = NULL;
|
2008-01-27 11:25:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// Initializes the GL renderer
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void OpenGLFrameBuffer::InitializeState()
|
|
|
|
{
|
|
|
|
static bool first=true;
|
|
|
|
|
|
|
|
gl.LoadExtensions();
|
|
|
|
Super::InitializeState();
|
|
|
|
if (first)
|
|
|
|
{
|
|
|
|
first=false;
|
|
|
|
// [BB] For some reason this crashes, if compiled with MinGW and optimization. Has to be investigated.
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
gl.PrintStartupLog();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (gl.flags&RFL_NPOT_TEXTURE)
|
|
|
|
{
|
|
|
|
Printf("Support for non power 2 textures enabled.\n");
|
|
|
|
}
|
|
|
|
if (gl.flags&RFL_OCCLUSION_QUERY)
|
|
|
|
{
|
|
|
|
Printf("Occlusion query enabled.\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
gl.ClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
|
|
|
gl.ClearDepth(1.0f);
|
|
|
|
gl.DepthFunc(GL_LESS);
|
|
|
|
gl.ShadeModel(GL_SMOOTH);
|
|
|
|
|
|
|
|
gl.Enable(GL_DITHER);
|
|
|
|
gl.Enable(GL_ALPHA_TEST);
|
|
|
|
gl.Disable(GL_CULL_FACE);
|
|
|
|
gl.Disable(GL_POLYGON_OFFSET_FILL);
|
|
|
|
gl.Enable(GL_POLYGON_OFFSET_LINE);
|
|
|
|
gl.Enable(GL_BLEND);
|
|
|
|
gl.Enable(GL_DEPTH_CLAMP_NV);
|
|
|
|
gl.Disable(GL_DEPTH_TEST);
|
|
|
|
gl.Enable(GL_TEXTURE_2D);
|
|
|
|
gl.Disable(GL_LINE_SMOOTH);
|
2009-11-03 21:32:27 +00:00
|
|
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
|
|
glAlphaFunc(GL_GEQUAL,0.5f);
|
2008-01-27 11:25:03 +00:00
|
|
|
gl.Hint(GL_LINE_SMOOTH_HINT, GL_NICEST);
|
|
|
|
gl.Hint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
|
|
|
|
gl.Hint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
|
2009-10-05 10:30:19 +00:00
|
|
|
|
|
|
|
// This was to work around a bug in some older driver. Probably doesn't make sense anymore.
|
|
|
|
gl.Enable(GL_FOG);
|
|
|
|
gl.Disable(GL_FOG);
|
|
|
|
|
|
|
|
gl.Hint(GL_FOG_HINT, GL_FASTEST);
|
|
|
|
gl.Fogi(GL_FOG_MODE, GL_EXP);
|
|
|
|
|
|
|
|
|
2008-01-27 11:25:03 +00:00
|
|
|
gl.Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
|
|
|
2010-08-09 09:43:22 +00:00
|
|
|
int trueH = GetTrueHeight();
|
|
|
|
int h = GetHeight();
|
|
|
|
gl.Viewport(0, (trueH - h)/2, GetWidth(), GetHeight());
|
2008-01-27 11:25:03 +00:00
|
|
|
|
|
|
|
Begin2D(false);
|
2009-06-25 21:27:36 +00:00
|
|
|
GLRenderer->Initialize();
|
2008-01-27 11:25:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// Updates the screen
|
|
|
|
//
|
|
|
|
//==========================================================================
|
2009-10-31 22:55:36 +00:00
|
|
|
|
|
|
|
// Testing only for now.
|
|
|
|
CVAR(Bool, gl_draw_sync, true, 0) //false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
2008-01-27 11:25:03 +00:00
|
|
|
|
|
|
|
void OpenGLFrameBuffer::Update()
|
|
|
|
{
|
2009-07-18 08:06:34 +00:00
|
|
|
if (!CanUpdate())
|
|
|
|
{
|
|
|
|
GLRenderer->Flush();
|
|
|
|
return;
|
|
|
|
}
|
2008-01-27 11:25:03 +00:00
|
|
|
|
|
|
|
Begin2D(false);
|
|
|
|
|
|
|
|
DrawRateStuff();
|
2009-07-18 08:06:34 +00:00
|
|
|
GLRenderer->Flush();
|
2008-01-27 11:25:03 +00:00
|
|
|
|
|
|
|
if (GetTrueHeight() != GetHeight())
|
|
|
|
{
|
2009-07-11 07:06:31 +00:00
|
|
|
if (GLRenderer != NULL)
|
|
|
|
GLRenderer->ClearBorders();
|
2008-01-27 11:25:03 +00:00
|
|
|
|
|
|
|
Begin2D(false);
|
|
|
|
}
|
2009-10-31 09:10:29 +00:00
|
|
|
if (gl_draw_sync || !swapped)
|
|
|
|
{
|
|
|
|
Swap();
|
|
|
|
}
|
|
|
|
swapped = false;
|
|
|
|
Unlock();
|
2009-11-05 08:04:08 +00:00
|
|
|
CheckBench();
|
2009-10-31 09:10:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// Swap the buffers
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void OpenGLFrameBuffer::Swap()
|
|
|
|
{
|
2008-01-27 11:25:03 +00:00
|
|
|
Finish.Reset();
|
Update to ZDoom r1146 (warning: massive changes ahead!)
- Removed DECORATE's ParseClass because it was only used to add data to fully
internal actor classes which no longer exist.
- Changed the state structure so that the Tics value doesn't need to be hacked
into misc1 with SF_BIGTIC anymore.
- Changed sprite processing so that sprite names are converted to indices
during parsing so that an additional postprocessing step is no longer needed.
- Fixed: Sprite names in DECORATE were case sensitive.
- Exported AActor's defaults to DECORATE and removed all code for the
internal property parser which is no longer needed.
- Converted the Heresiarch to DECORATE.
- Added an Active and Inactive state for monsters.
- Made the speed a parameter to A_RaiseMobj and A_SinkMobj and deleted
GetRaiseSpeed and GetSinkSpeed.
- Added some remaining DECORATE conversions for Hexen by Karate Chris.
- Changed Windows to use the performance counter instead of rdtsc.
- Changed Linux to use clock_gettime for profiling instead of rdtsc. This
avoids potential erroneous results on multicore and variable speed
processors.
- Converted the last of Hexen's inventory items to DECORATE so that I could
export AInventory.
- Removed AT_GAME_SET because it's no longer used anywhere.
- Converted the last remaining global classes to DECORATE.
- Fixed: Inventory.PickupFlash requires an class name as parameter not an
integer. Some Hexen definitions got it wrong.
- Converted Hexen's Pig to DECORATE.
- Replaced the ActorInfo definitions of all internal inventory classes with
DECORATE definitions.
- Added option to specify a powerup's duration in second by using a negative
number.
- Added Gez's Freedoom detection patch.
- SBARINFO update:
* Added: The ability to have drawkeybar auto detect spacing.
* Added: Offset parameter to drawkeybar to allow two key bars with
different keys.
* Added: Multi-row/column keybar parameters. Spacing can also be auto.
These defualt to left to right/top to bottom but can be switched.
* Added: Drawshadow flag to drawnumber. This will draw a solid color and
translucent number under the normal number.
* Added: hexenarmor to drawimage. This takes a parameter for a hexen
armor type and will fade the image like the hexen status bar.
* Added: centerbottom offset to draw(switchable)image.
* Added: translucent flag to drawinventorybar.
* Fixed: Accidentally removed flag from DrawTexture that allowed negative
coordinates to work with fullscreenoffsets. Hopefully this is the last
major bug in the fullscreenoffsets system.
- Ported vlinetallasm4 to AMD64 assembly. Even with the increased number of
registers AMD64 provides, this routine still needs to be written as self-
modifying code for maximum performance. The additional registers do allow
for further optimization over the x86 version by allowing all four pixels
to be in flight at the same time. The end result is that AMD64 ASM is about
2.18 times faster than AMD64 C and about 1.06 times faster than x86 ASM.
(For further comparison, AMD64 C and x86 C are practically the same for
this function.) Should I port any more assembly to AMD64, mvlineasm4 is the
most likely candidate, but it's not used enough at this point to bother.
Also, this may or may not work with Linux at the moment, since it doesn't
have the eh_handler metadata. Win64 is easier, since I just need to
structure the function prologue and epilogue properly and use some
assembler directives/macros to automatically generate the metadata. And
that brings up another point: You need YASM to assemble the AMD64 code,
because NASM doesn't support the Win64 metadata directives.
- Replaced the ActorInfo definitions of several internal classes with DECORATE definitions
- Converted teleport fog and destinations to DECORATE.
- AActor::PreExplode is gone now that the last item that was using it has been converted.
- Converted the Sigil and the remaining things in a_strifeitems.cpp to DECORATE.
- Exported Point pushers, CustomSprite and AmbientSound to DECORATE.
- Changed increased lightning damage for Centaurs into a damage factor.
- Changed PoisonCloud and Lightning special treatment in P_DamageMobj to use damage
types instead to keep dependencies on specific actor types out of the main engine code.
- Added Korax DECORATE conversion by Gez and a few others by Karate Chris.
- Removed FourthWeaponClass and based Hexen's fourth weapons on the generic weapon
pieces.
- Added DECORATE conversions for Hexen's Fighter weapons by Karate Chris.
- Added aWeaponGiver class to generalize the standing AssaultGun.
- converted a_Strifeweapons.cpp to DECORATE, except for the Sigil.
- Added an SSE version of DoBlending. This is strictly C intrinsics.
VC++ still throws around unneccessary register moves. GCC seems to be
pretty close to optimal, requiring only about 2 cycles/color. They're
both faster than my hand-written MMX routine, so I don't need to feel
bad about not hand-optimizing this for x64 builds.
- Removed an extra instruction from DoBlending_MMX, transposed two
instructions, and unrolled it once, shaving off about 80 cycles from the
time required to blend 256 palette entries. Why? Because I tried writing
a C version of the routine using compiler intrinsics and was appalled by
all the extra movq's VC++ added to the code. GCC was better, but still
generated extra instructions. I only wanted a C version because I can't
use inline assembly with VC++'s x64 compiler, and x64 assembly is a bit
of a pain. (It's a pain because Linux and Windows have different calling
conventions, and you need to maintain extra metadata for functions.) So,
the assembly version stays and the C version stays out.
- Converted the rest of a_strifestuff.cpp to DECORATE.
- Fixed: AStalker::CheckMeleeRange did not perform all checks of AActor::CheckMeleeRange.
I replaced this virtual override with a new flag MF5_NOVERTICALMELEERANGE so that
this feature can also be used by other actors.
- Converted Strife's Stalker to DECORATE.
- Converted ArtiTeleport to DECORATE.
- Removed the NoBlockingSet method from AActor because everything using it has been
converted to DECORATE using DropItem instead.
- Changed: Macil doesn't need the StrifeHumanoid's special death states so he might
as well inherit directly from AActor.
- Converted Strife's Coin, Oracle, Macil and StrifeHumanoid to DECORATE. Also moved
the burning hand states to StrifePlayer where they really belong.
- Added Gez's dropammofactor submission with some necessary changes. Also merged
redundant ammo multiplication code from P_DropItem and ADehackedPickup::TryPickup.
- Restricted native action function definitions to zdoom.pk3.
- Fixed. The Firedemon was missing a game filter.
- Added: disablegrin, disableouch, disablepain, and disablerampage flags to
drawmugshot.
- Fixed: LowerHealthCap did not work properly.
- Fixed: Various bugs I noticed in the fullscreenoffsets code.
- Removed all the pixel doubling r_detail modes, since the one platform they
were intended to assist (486) actually sees very little benefit from them.
- Rewrote CheckMMX in C and renamed it to CheckCPU.
- Fixed: CPUID function 0x80000005 is specified to return detailed L1 cache
only for AMD processors, so we must not use it on other architectures, or
we end up overwriting the L1 cache line size with 0 or some other number
we don't actually understand.
- The x87 precision control is now explicitly set for double precision, since
GCC defaults to extended precision instead, unlike Visual C++.
- Converted Strife's Programmer, Loremaster and Thingstoblowup to DECORATE.
- Fixed: Attacking a merchant in Strife didn't alert the enemies.
- Removed AT_GAME_SET(PowerInvulnerable) due to the problems it caused. The two
occurences in the code that depended on it were changed accordingly.
Invulnerability colormaps are now being set by the items exclusively.
- Changed many checks for the friendly Minotaur to a new flag MF5_SUMMONEDMONSTER
so that it can hopefully be generalized to be usable elsewhere later.
- Added Gez's submission for converting the Minotaur to DECORATE.
- Fixed a few minor DECORATE bugs.
- Changed coordinate storage for EntityBoss so that it works properly even
when the pod is not used to spawn it.
- Converted Strife's Spectres and Entity to DECORATE.
- Added: fullscreenoffsets flag for status bars. This changes the coordinate
system to be relative to the top left corner of the screen. This is useful
for full screen status bars.
- Changed: drawinventorybar will use the width of artibox or invcurs (strife)
to determine the spacing. Let me know if this breaks any released mods.
- Fixed: If a status bar height of 0 was specified in SBarInfo the wrong bar
would be shown.
- Fixed: If a static inventory bar was used the user still had to press invuse
in order to get rid of the "overlay".
- Fixed: forcescaled would not work if the height of the bar was 0.
- Added: keyslot to drawswitchableimage.
- Fixed: The transition effects for the log and keys popups were switched.
- Converted Strife's Crusader, Inquisitor and spectral missiles to
DECORATE.
- Converted Strife's Acolytes, Rebels, Sentinel, Reaver and Templar to
DECORATE.
- Added DECORATE conversions for Hexen's Cleric weapons by Karate Chris.
- Added a check to Zipdir that excludes files with a .orig extension. These
can be left behind by patch.exe and create problems.
- fixed: Unmorphing from chicken caused a crash when reading non-existent
meta-data strings.
- Converted the ScriptedMarines to DECORATE.
- Fixed: DLightTransfer and DWallLightTransfer were declared as actors.
- Converted the PhoenixRod and associated classes to DECORATE to make
the Heretic conversion complete.
- Converted the Minotaur's projectiles to DECORATE so that I can get
rid of the AT_SPEED_SET code.
- Converted Heretic's Blaster and SkullRod to DECORATE.
- Converted the mace and all related actors to DECORATE and generalized
the spawn function that only spawns one mace per level.
- Moved Mace respawning code into AInventory so that it works properly
for replacement actors.
- Added more DECORATE conversions by Karate Chris.
- Cleaned up the new bridge code and exported all related actors to
DECORATE so that the exported code pointers can be used.
- Separated Heretic's and Hexen's invulnerability items for stability
reasons.
- Fixed spurious warnings on 32-bit VC++ debug builds.
- Made the subsong (order) number a proper parameter to MusInfo::Play()
instead of requiring a separate SetPosition() call to do it.
- Added Gez's submission for custom bridge things.
- Fixed: ASpecialSpot must check the array's size before dividing by it.
git-svn-id: http://mancubus.net/svn/hosted/gzdoom/trunk@151 b0f79afe-0144-0410-b225-9a4edf0717df
2008-08-10 15:12:58 +00:00
|
|
|
Finish.Clock();
|
2009-10-31 09:10:29 +00:00
|
|
|
gl.Finish();
|
2009-10-19 20:15:13 +00:00
|
|
|
if (needsetgamma)
|
|
|
|
{
|
2009-10-31 22:55:36 +00:00
|
|
|
//DoSetGamma();
|
2009-10-19 20:15:13 +00:00
|
|
|
needsetgamma = false;
|
|
|
|
}
|
2008-01-27 11:25:03 +00:00
|
|
|
gl.SwapBuffers();
|
2009-10-30 11:13:29 +00:00
|
|
|
Finish.Unclock();
|
2009-10-31 09:10:29 +00:00
|
|
|
swapped = true;
|
2009-10-31 22:55:36 +00:00
|
|
|
FHardwareTexture::UnbindAll();
|
2008-01-27 11:25:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// DoSetGamma
|
|
|
|
//
|
|
|
|
// (Unfortunately Windows has some safety precautions that block gamma ramps
|
|
|
|
// that are considered too extreme. As a result this doesn't work flawlessly)
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void OpenGLFrameBuffer::DoSetGamma()
|
|
|
|
{
|
|
|
|
WORD gammaTable[768];
|
|
|
|
|
|
|
|
if (m_supportsGamma)
|
|
|
|
{
|
|
|
|
// This formula is taken from Doomsday
|
|
|
|
float gamma = clamp<float>(Gamma, 0.1f, 4.f);
|
|
|
|
float contrast = clamp<float>(vid_contrast, 0.1f, 3.f);
|
|
|
|
float bright = clamp<float>(vid_brightness, -0.8f, 0.8f);
|
|
|
|
|
|
|
|
double invgamma = 1 / gamma;
|
|
|
|
double norm = pow(255., invgamma - 1);
|
|
|
|
|
|
|
|
for (int i = 0; i < 256; i++)
|
|
|
|
{
|
|
|
|
double val = i * contrast - (contrast - 1) * 127;
|
|
|
|
if(gamma != 1) val = pow(val, invgamma) / norm;
|
|
|
|
val += bright * 128;
|
|
|
|
|
|
|
|
gammaTable[i] = gammaTable[i + 256] = gammaTable[i + 512] = (WORD)clamp<double>(val*256, 0, 0xffff);
|
|
|
|
}
|
|
|
|
SetGammaTable(gammaTable);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool OpenGLFrameBuffer::SetGamma(float gamma)
|
|
|
|
{
|
|
|
|
DoSetGamma();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool OpenGLFrameBuffer::SetBrightness(float bright)
|
|
|
|
{
|
|
|
|
DoSetGamma();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool OpenGLFrameBuffer::SetContrast(float contrast)
|
|
|
|
{
|
|
|
|
DoSetGamma();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool OpenGLFrameBuffer::UsesColormap() const
|
|
|
|
{
|
|
|
|
// The GL renderer has no use for colormaps so let's
|
|
|
|
// not create them and save us some time.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void OpenGLFrameBuffer::UpdatePalette()
|
|
|
|
{
|
|
|
|
int rr=0,gg=0,bb=0;
|
|
|
|
for(int x=0;x<256;x++)
|
|
|
|
{
|
|
|
|
rr+=GPalette.BaseColors[x].r;
|
|
|
|
gg+=GPalette.BaseColors[x].g;
|
|
|
|
bb+=GPalette.BaseColors[x].b;
|
|
|
|
}
|
|
|
|
rr>>=8;
|
|
|
|
gg>>=8;
|
|
|
|
bb>>=8;
|
|
|
|
|
|
|
|
palette_brightness = (rr*77 + gg*143 + bb*35)/255;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OpenGLFrameBuffer::GetFlashedPalette (PalEntry pal[256])
|
|
|
|
{
|
|
|
|
memcpy(pal, SourcePalette, 256*sizeof(PalEntry));
|
|
|
|
}
|
|
|
|
|
|
|
|
PalEntry *OpenGLFrameBuffer::GetPalette ()
|
|
|
|
{
|
|
|
|
return SourcePalette;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool OpenGLFrameBuffer::SetFlash(PalEntry rgb, int amount)
|
|
|
|
{
|
|
|
|
Flash = PalEntry(amount, rgb.r, rgb.g, rgb.b);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OpenGLFrameBuffer::GetFlash(PalEntry &rgb, int &amount)
|
|
|
|
{
|
|
|
|
rgb = Flash;
|
2009-07-11 07:06:31 +00:00
|
|
|
rgb.a = 0;
|
2008-01-27 11:25:03 +00:00
|
|
|
amount = Flash.a;
|
|
|
|
}
|
|
|
|
|
|
|
|
int OpenGLFrameBuffer::GetPageCount()
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2010-07-29 12:44:36 +00:00
|
|
|
|
|
|
|
void OpenGLFrameBuffer::GetHitlist(BYTE *hitlist)
|
|
|
|
{
|
|
|
|
Super::GetHitlist(hitlist);
|
|
|
|
|
|
|
|
// check skybox textures and mark the separate faces as used
|
|
|
|
for(int i=0;i<TexMan.NumTextures(); i++)
|
|
|
|
{
|
|
|
|
if (hitlist[i])
|
|
|
|
{
|
|
|
|
FTexture *tex = TexMan.ByIndex(i);
|
|
|
|
if (tex->gl_info.bSkybox)
|
|
|
|
{
|
|
|
|
FSkyBox *sb = static_cast<FSkyBox*>(tex);
|
|
|
|
for(int i=0;i<6;i++)
|
|
|
|
{
|
|
|
|
if (sb->faces[i])
|
|
|
|
{
|
|
|
|
int index = sb->faces[i]->id.GetIndex();
|
|
|
|
hitlist[index] |= 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// check model skins
|
|
|
|
}
|
|
|
|
|
2008-01-28 11:24:32 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// DFrameBuffer :: PrecacheTexture
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2009-09-24 18:09:41 +00:00
|
|
|
void OpenGLFrameBuffer::PrecacheTexture(FTexture *tex, int cache)
|
2008-01-28 11:24:32 +00:00
|
|
|
{
|
|
|
|
if (tex != NULL)
|
|
|
|
{
|
|
|
|
if (cache)
|
|
|
|
{
|
|
|
|
tex->PrecacheGL();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
tex->UncacheGL();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-25 15:31:09 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// DFrameBuffer :: StateChanged
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void OpenGLFrameBuffer::StateChanged(AActor *actor)
|
|
|
|
{
|
|
|
|
gl_SetActorLights(actor);
|
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// notify the renderer that serialization of the curent level is about to start/end
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void OpenGLFrameBuffer::StartSerialize(FArchive &arc)
|
|
|
|
{
|
|
|
|
gl_DeleteAllAttachedLights();
|
2011-07-06 18:59:20 +00:00
|
|
|
arc << fogdensity << outsidefogdensity << skyfog;
|
2009-10-25 15:31:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OpenGLFrameBuffer::EndSerialize(FArchive &arc)
|
|
|
|
{
|
|
|
|
gl_RecreateAllAttachedLights();
|
2010-01-16 06:51:55 +00:00
|
|
|
if (arc.IsLoading()) gl_InitPortals();
|
2009-10-25 15:31:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// Get max. view angle (renderer specific information so it goes here now)
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
EXTERN_CVAR(Float, maxviewpitch)
|
|
|
|
|
|
|
|
int OpenGLFrameBuffer::GetMaxViewPitch(bool down)
|
|
|
|
{
|
|
|
|
if (netgame) return Super::GetMaxViewPitch(down);
|
|
|
|
else return (down? maxviewpitch : -maxviewpitch) * ANGLE_1;
|
|
|
|
}
|
|
|
|
|
2008-01-27 11:25:03 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// DFrameBuffer :: CreatePalette
|
|
|
|
//
|
|
|
|
// Creates a native palette from a remap table, if supported.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
FNativePalette *OpenGLFrameBuffer::CreatePalette(FRemapTable *remap)
|
|
|
|
{
|
|
|
|
return GLTranslationPalette::CreatePalette(remap);
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
bool OpenGLFrameBuffer::Begin2D(bool)
|
|
|
|
{
|
|
|
|
gl.MatrixMode(GL_MODELVIEW);
|
|
|
|
gl.LoadIdentity();
|
|
|
|
gl.MatrixMode(GL_PROJECTION);
|
|
|
|
gl.LoadIdentity();
|
|
|
|
gl.Ortho(
|
|
|
|
(GLdouble) 0,
|
|
|
|
(GLdouble) GetWidth(),
|
|
|
|
(GLdouble) GetHeight(),
|
|
|
|
(GLdouble) 0,
|
|
|
|
(GLdouble) -1.0,
|
|
|
|
(GLdouble) 1.0
|
|
|
|
);
|
|
|
|
gl.Disable(GL_DEPTH_TEST);
|
|
|
|
gl.Disable(GL_MULTISAMPLE);
|
2009-07-11 07:06:31 +00:00
|
|
|
if (GLRenderer != NULL) GLRenderer->Begin2D();
|
2008-01-27 11:25:03 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// Draws a texture
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
Update to ZDoom r 1957:
- Changed all coordinates for DrawTexture() to floating point so that the
player sprites will retain the same precision they had when they were
rendered as part of the 3D view. (needed for propery alignment of flashes
on top of weapon sprites) It worked just fine for D3D, but software
rendering was another matter. I consequently did battle with imprecisions
in the whole masked texture drawing routines that had previously been
partially masked by only drawing on whole pixel boundaries. Particularly,
the tops of posts are calculated by multiplying by spryscale, and the
texture mapping coordinates are calculated by multiplying by dc_iscale
(where dc_iscale = 1 / spryscale). Since these are both 16.16 fixed point
values, there is a significant variance. For best results, the drawing
routines should only use one of these values, but that would mean
introducing division into the inner loop. If the division removed the
necessity for the fudge code in R_DrawMaskedColumn(), would it be worth it?
Or would the divide be slower than the fudging? Or would I be better off
doing it like Build and using transparent pixel checks instead, not
bothering with skipping transparent areas? For now, I chop off the
fractional part of the top coordinate for software drawing, since it was
the easiest thing to do (even if it wasn't the most correct thing to do).
git-svn-id: http://mancubus.net/svn/hosted/gzdoom/trunk@594 b0f79afe-0144-0410-b225-9a4edf0717df
2009-11-01 07:23:43 +00:00
|
|
|
void STACK_ARGS OpenGLFrameBuffer::DrawTextureV(FTexture *img, double x0, double y0, uint32 tag, va_list tags)
|
2008-01-27 11:25:03 +00:00
|
|
|
{
|
|
|
|
DrawParms parms;
|
|
|
|
|
2009-06-25 21:27:36 +00:00
|
|
|
if (ParseDrawTextureTags(img, x0, y0, tag, tags, &parms, true))
|
2008-01-27 11:25:03 +00:00
|
|
|
{
|
2009-06-25 21:27:36 +00:00
|
|
|
if (GLRenderer != NULL) GLRenderer->DrawTexture(img, parms);
|
2008-01-27 11:25:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
void OpenGLFrameBuffer::DrawLine(int x1, int y1, int x2, int y2, int palcolor, uint32 color)
|
|
|
|
{
|
2009-06-25 21:27:36 +00:00
|
|
|
if (GLRenderer != NULL)
|
|
|
|
GLRenderer->DrawLine(x1, y1, x2, y2, palcolor, color);
|
2008-01-27 11:25:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
void OpenGLFrameBuffer::DrawPixel(int x1, int y1, int palcolor, uint32 color)
|
|
|
|
{
|
2009-06-25 21:27:36 +00:00
|
|
|
if (GLRenderer != NULL)
|
|
|
|
GLRenderer->DrawPixel(x1, y1, palcolor, color);
|
2008-01-27 11:25:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
void OpenGLFrameBuffer::Dim(PalEntry)
|
|
|
|
{
|
|
|
|
// Unlike in the software renderer the color is being ignored here because
|
|
|
|
// view blending only affects the actual view with the GL renderer.
|
2009-09-16 21:39:52 +00:00
|
|
|
Super::Dim(0);
|
2008-01-27 11:25:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OpenGLFrameBuffer::Dim(PalEntry color, float damount, int x1, int y1, int w, int h)
|
|
|
|
{
|
2009-06-25 21:27:36 +00:00
|
|
|
if (GLRenderer != NULL)
|
|
|
|
GLRenderer->Dim(color, damount, x1, y1, w, h);
|
2008-01-27 11:25:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
void OpenGLFrameBuffer::FlatFill (int left, int top, int right, int bottom, FTexture *src, bool local_origin)
|
|
|
|
{
|
|
|
|
|
2009-06-25 21:27:36 +00:00
|
|
|
if (GLRenderer != NULL)
|
|
|
|
GLRenderer->FlatFill(left, top, right, bottom, src, local_origin);
|
2008-01-27 11:25:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
void OpenGLFrameBuffer::Clear(int left, int top, int right, int bottom, int palcolor, uint32 color)
|
|
|
|
{
|
2009-06-25 21:27:36 +00:00
|
|
|
if (GLRenderer != NULL)
|
|
|
|
GLRenderer->Clear(left, top, right, bottom, palcolor, color);
|
2008-01-27 11:25:03 +00:00
|
|
|
}
|
|
|
|
|
2010-08-27 22:26:15 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// D3DFB :: FillSimplePoly
|
|
|
|
//
|
|
|
|
// Here, "simple" means that a simple triangle fan can draw it.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void OpenGLFrameBuffer::FillSimplePoly(FTexture *texture, FVector2 *points, int npoints,
|
|
|
|
double originx, double originy, double scalex, double scaley,
|
|
|
|
angle_t rotation, FDynamicColormap *colormap, int lightlevel)
|
|
|
|
{
|
|
|
|
if (GLRenderer != NULL)
|
|
|
|
{
|
|
|
|
GLRenderer->FillSimplePoly(texture, points, npoints, originx, originy, scalex, scaley,
|
|
|
|
rotation, colormap, lightlevel);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-01-27 11:25:03 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// Takes a screenshot
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void OpenGLFrameBuffer::GetScreenshotBuffer(const BYTE *&buffer, int &pitch, ESSType &color_type)
|
|
|
|
{
|
|
|
|
int w = SCREENWIDTH;
|
|
|
|
int h = SCREENHEIGHT;
|
|
|
|
|
|
|
|
ReleaseScreenshotBuffer();
|
|
|
|
ScreenshotBuffer = new BYTE[w * h * 3];
|
2008-11-02 23:48:39 +00:00
|
|
|
|
|
|
|
gl.ReadPixels(0,(GetTrueHeight() - GetHeight()) / 2,w,h,GL_RGB,GL_UNSIGNED_BYTE,ScreenshotBuffer);
|
2008-01-27 11:25:03 +00:00
|
|
|
pitch = -w*3;
|
|
|
|
color_type = SS_RGB;
|
|
|
|
buffer = ScreenshotBuffer + w * 3 * (h - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// Releases the screenshot buffer.
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void OpenGLFrameBuffer::ReleaseScreenshotBuffer()
|
|
|
|
{
|
|
|
|
if (ScreenshotBuffer != NULL) delete [] ScreenshotBuffer;
|
|
|
|
ScreenshotBuffer = NULL;
|
|
|
|
}
|
2009-06-23 14:10:27 +00:00
|
|
|
|
|
|
|
|
2009-06-26 12:37:47 +00:00
|
|
|
void OpenGLFrameBuffer::WriteSavePic (player_t *player, FILE *file, int width, int height)
|
|
|
|
{
|
|
|
|
GLRenderer->WriteSavePic(player, file, width, height);
|
|
|
|
}
|
|
|
|
|
|
|
|
void OpenGLFrameBuffer::RenderView (player_t* player)
|
|
|
|
{
|
|
|
|
GLRenderer->RenderView(player);
|
|
|
|
}
|
|
|
|
|
2010-10-17 10:44:48 +00:00
|
|
|
void OpenGLFrameBuffer::RemapVoxels()
|
|
|
|
{
|
|
|
|
// no-op
|
|
|
|
}
|
|
|
|
|
2009-09-20 20:51:32 +00:00
|
|
|
|
|
|
|
void OpenGLFrameBuffer::DrawRemainingPlayerSprites()
|
|
|
|
{
|
|
|
|
// not used by hardware renderer
|
|
|
|
}
|
2010-12-15 23:16:24 +00:00
|
|
|
|
|
|
|
void OpenGLFrameBuffer::GameRestart()
|
|
|
|
{
|
|
|
|
memcpy (SourcePalette, GPalette.BaseColors, sizeof(PalEntry)*256);
|
|
|
|
UpdatePalette ();
|
|
|
|
ScreenshotBuffer = NULL;
|
|
|
|
LastCamera = NULL;
|
|
|
|
gl_GenerateGlobalBrightmapFromColormap();
|
|
|
|
}
|