# Conflicts:
#	src/r_things.cpp
#	src/sound/fmod_wrap.h
#	src/sound/fmodsound.cpp
#	src/sound/fmodsound.h
This commit is contained in:
nashmuhandes 2016-08-29 17:28:07 +08:00
commit 4dfc4fb468
78 changed files with 731 additions and 470 deletions

View file

@ -1,11 +1,17 @@
cmake_minimum_required( VERSION 2.8.7 )
if( NOT NO_FMOD AND FMOD_INCLUDE_DIR )
add_library( output_sdl MODULE output_sdl.c )
include_directories( ${FMOD_INCLUDE_DIR} ${SDL2_INCLUDE_DIR} )
target_link_libraries( output_sdl ${SDL2_LIBRARY} )
check_library_exists(${FMOD_LIBRARY} "FMOD_System_GetDriverCaps" "fmod.h" FMOD_IS_EX)
FILE( WRITE ${CMAKE_CURRENT_BINARY_DIR}/link-make "if [ ! -e ${ZDOOM_OUTPUT_DIR}/liboutput_sdl.so ]; then ln -sf output_sdl/liboutput_sdl.so ${ZDOOM_OUTPUT_DIR}/liboutput_sdl.so; fi" )
add_custom_command( TARGET output_sdl POST_BUILD
COMMAND chmod +x ${CMAKE_CURRENT_BINARY_DIR}/link-make
COMMAND /bin/sh -c ${CMAKE_CURRENT_BINARY_DIR}/link-make )
# Only usable with FMOD Ex
if( FMOD_IS_EX )
include_directories( ${FMOD_INCLUDE_DIR} ${SDL2_INCLUDE_DIR} )
add_library( output_sdl MODULE output_sdl.c )
target_link_libraries( output_sdl ${SDL2_LIBRARY} )
FILE( WRITE ${CMAKE_CURRENT_BINARY_DIR}/link-make "if [ ! -e ${ZDOOM_OUTPUT_DIR}/liboutput_sdl.so ]; then ln -sf output_sdl/liboutput_sdl.so ${ZDOOM_OUTPUT_DIR}/liboutput_sdl.so; fi" )
add_custom_command( TARGET output_sdl POST_BUILD
COMMAND chmod +x ${CMAKE_CURRENT_BINARY_DIR}/link-make
COMMAND /bin/sh -c ${CMAKE_CURRENT_BINARY_DIR}/link-make )
endif()
endif()

View file

@ -494,7 +494,7 @@ bool FCajunMaster::LoadBots ()
tmp = M_GetCajunPath(BOTFILENAME);
if (tmp.IsEmpty())
{
DPrintf ("No " BOTFILENAME ", so no bots\n");
DPrintf (DMSG_ERROR, "No " BOTFILENAME ", so no bots\n");
return false;
}
try

View file

@ -612,12 +612,12 @@ int Printf (const char *format, ...)
return count;
}
int DPrintf (const char *format, ...)
int DPrintf (int level, const char *format, ...)
{
va_list argptr;
int count;
if (developer)
if (developer >= level)
{
va_start (argptr, format);
count = VPrintf (PRINT_HIGH, format, argptr);

View file

@ -399,7 +399,7 @@ void CheckCompatibility(MapData *map)
flags = BCompatMap.CheckKey(md5);
if (developer)
if (developer >= DMSG_NOTIFY)
{
Printf("MD5 = ");
for (size_t j = 0; j < sizeof(md5.Bytes); ++j)

View file

@ -450,7 +450,7 @@ int FindStyle (const char *namestr)
{
if (!stricmp(StyleNames[i].Name, namestr)) return StyleNames[i].Num;
}
DPrintf("Unknown render style %s\n", namestr);
DPrintf(DMSG_ERROR, "Unknown render style %s\n", namestr);
return -1;
}
@ -861,7 +861,7 @@ static int PatchThing (int thingy)
}
else
{
DPrintf ("Thing %d\n", thingy);
DPrintf (DMSG_SPAMMY, "Thing %d\n", thingy);
if (thingy > 0)
{
type = InfoNames[thingy - 1];
@ -1086,7 +1086,7 @@ static int PatchThing (int thingy)
}
if (i == BitNames.Size())
{
DPrintf("Unknown bit mnemonic %s\n", strval);
DPrintf(DMSG_ERROR, "Unknown bit mnemonic %s\n", strval);
}
}
}
@ -1242,7 +1242,7 @@ static int PatchThing (int thingy)
else
info->renderflags &= ~RF_INVISIBLE;
}
DPrintf ("Bits: %d,%d (0x%08x,0x%08x)\n", info->flags.GetValue(), info->flags2.GetValue(),
DPrintf (DMSG_SPAMMY, "Bits: %d,%d (0x%08x,0x%08x)\n", info->flags.GetValue(), info->flags2.GetValue(),
info->flags.GetValue(), info->flags2.GetValue());
}
else if (stricmp (Line1, "ID #") == 0)
@ -1328,7 +1328,7 @@ static int PatchSound (int soundNum)
{
int result;
DPrintf ("Sound %d (no longer supported)\n", soundNum);
//DPrintf ("Sound %d (no longer supported)\n", soundNum);
/*
sfxinfo_t *info, dummy;
int offset = 0;
@ -1385,7 +1385,7 @@ static int PatchFrame (int frameNum)
info = FindState (frameNum);
if (info)
{
DPrintf ("Frame %d\n", frameNum);
DPrintf (DMSG_SPAMMY, "Frame %d\n", frameNum);
if (frameNum == 47)
{ // Use original tics for S_DSGUNFLASH1
tics = 5;
@ -1487,7 +1487,7 @@ static int PatchSprite (int sprNum)
if ((unsigned)sprNum < OrgSprNames.Size())
{
DPrintf ("Sprite %d\n", sprNum);
DPrintf (DMSG_SPAMMY, "Sprite %d\n", sprNum);
}
else
{
@ -1534,7 +1534,7 @@ static int PatchAmmo (int ammoNum)
if (ammoNum >= 0 && ammoNum < 4 && (unsigned)ammoNum <= AmmoNames.Size())
{
DPrintf ("Ammo %d.\n", ammoNum);
DPrintf (DMSG_SPAMMY, "Ammo %d.\n", ammoNum);
ammoType = AmmoNames[ammoNum];
if (ammoType != NULL)
{
@ -1617,7 +1617,7 @@ static int PatchWeapon (int weapNum)
if (type != NULL)
{
info = (AWeapon *)GetDefaultByType (type);
DPrintf ("Weapon %d\n", weapNum);
DPrintf (DMSG_SPAMMY, "Weapon %d\n", weapNum);
}
}
@ -1757,7 +1757,7 @@ static int PatchPointer (int ptrNum)
{
if (CodePConv[ptrNum] == indexnum) break;
}
DPrintf("Final ptrNum: %i\n", ptrNum);
DPrintf(DMSG_SPAMMY, "Final ptrNum: %i\n", ptrNum);
}
// End of hack.
@ -1765,7 +1765,7 @@ static int PatchPointer (int ptrNum)
// Better to just use the size of the array rather than a hardcoded value.
if (ptrNum >= 0 && (unsigned int) ptrNum < CodePConv.Size())
{
DPrintf ("Pointer %d\n", ptrNum);
DPrintf (DMSG_SPAMMY, "Pointer %d\n", ptrNum);
}
else
{
@ -1789,7 +1789,7 @@ static int PatchPointer (int ptrNum)
{
SetPointer(state, Actions[index], CodePConv[ptrNum]);
}
DPrintf("%s has a hacked state for pointer num %i with index %i\nLine1=%s, Line2=%s\n",
DPrintf(DMSG_SPAMMY, "%s has a hacked state for pointer num %i with index %i\nLine1=%s, Line2=%s\n",
state->StaticFindStateOwner(state)->TypeName.GetChars(), ptrNum, index, Line1, Line2);
}
else
@ -1806,7 +1806,7 @@ static int PatchCheats (int dummy)
{
int result;
DPrintf ("Cheats (support removed by request)\n");
DPrintf (DMSG_NOTIFY, "Dehacked cheats support removed by request\n");
while ((result = GetLine ()) == 1)
{
@ -1836,7 +1836,7 @@ static int PatchMisc (int dummy)
};
int result;
DPrintf ("Misc\n");
DPrintf (DMSG_SPAMMY, "Misc\n");
while ((result = GetLine()) == 1)
{
@ -2017,7 +2017,7 @@ static int PatchPars (int dummy)
level_info_t *info;
int result, par;
DPrintf ("[Pars]\n");
DPrintf (DMSG_SPAMMY, "[Pars]\n");
while ( (result = GetLine()) ) {
// Argh! .bex doesn't follow the same rules as .deh
@ -2058,7 +2058,7 @@ static int PatchPars (int dummy)
}
info->partime = par;
DPrintf ("Par for %s changed to %d\n", mapname, par);
DPrintf (DMSG_SPAMMY, "Par for %s changed to %d\n", mapname, par);
}
return result;
}
@ -2067,7 +2067,7 @@ static int PatchCodePtrs (int dummy)
{
int result;
DPrintf ("[CodePtr]\n");
DPrintf (DMSG_SPAMMY, "[CodePtr]\n");
while ((result = GetLine()) == 1)
{
@ -2132,7 +2132,7 @@ static int PatchMusic (int dummy)
{
int result;
DPrintf ("[Music]\n");
DPrintf (DMSG_SPAMMY, "[Music]\n");
while ((result = GetLine()) == 1)
{
@ -2142,7 +2142,7 @@ static int PatchMusic (int dummy)
keystring << "MUSIC_" << Line1;
GStrings.SetString (keystring, newname);
DPrintf ("Music %s set to:\n%s\n", keystring.GetChars(), newname);
DPrintf (DMSG_SPAMMY, "Music %s set to:\n%s\n", keystring.GetChars(), newname);
}
return result;
@ -2198,7 +2198,7 @@ static int PatchText (int oldSize)
goto donewithtext;
}
DPrintf ("Searching for text:\n%s\n", oldStr);
DPrintf (DMSG_SPAMMY, "Searching for text:\n%s\n", oldStr);
good = false;
// Search through sprite names; they are always 4 chars
@ -2264,7 +2264,7 @@ static int PatchText (int oldSize)
if (!good)
{
DPrintf (" (Unmatched)\n");
DPrintf (DMSG_SPAMMY, " (Unmatched)\n");
}
donewithtext:
@ -2284,7 +2284,7 @@ static int PatchStrings (int dummy)
{
int result;
DPrintf ("[Strings]\n");
DPrintf (DMSG_SPAMMY, "[Strings]\n");
while ((result = GetLine()) == 1)
{
@ -2310,7 +2310,7 @@ static int PatchStrings (int dummy)
const char *ll = Line1;
if (!stricmp(ll, "GOTREDSKULL")) ll = "GOTREDSKUL";
GStrings.SetString (ll, holdstring);
DPrintf ("%s set to:\n%s\n", Line1, holdstring.GetChars());
DPrintf (DMSG_SPAMMY, "%s set to:\n%s\n", Line1, holdstring.GetChars());
}
return result;
@ -2350,7 +2350,7 @@ static int DoInclude (int dummy)
else
{
data = Line2;
DPrintf ("Including %s\n", data);
DPrintf (DMSG_SPAMMY, "Including %s\n", data);
savepatchname = PatchName;
savepatchfile = PatchFile;
savepatchpt = PatchPt;
@ -2384,7 +2384,7 @@ static int DoInclude (int dummy)
delete[] path;
}
DPrintf ("Done with include\n");
DPrintf (DMSG_SPAMMY, "Done with include\n");
PatchName = savepatchname;
PatchFile = savepatchfile;
PatchPt = savepatchpt;
@ -2536,7 +2536,7 @@ static bool DoDehPatch()
}
else
{
DPrintf ("Patch does not have DeHackEd signature. Assuming .bex\n");
DPrintf (DMSG_WARNING, "Patch does not have DeHackEd signature. Assuming .bex\n");
dversion = 19;
pversion = 6;
PatchPt = PatchFile;
@ -3027,7 +3027,7 @@ void FinishDehPatch ()
subclass->Replacement = old_replacement;
}
DPrintf ("%s replaces %s\n", subclass->TypeName.GetChars(), type->TypeName.GetChars());
DPrintf (DMSG_NOTIFY, "%s replaces %s\n", subclass->TypeName.GetChars(), type->TypeName.GetChars());
}
// Now that all Dehacked patches have been processed, it's okay to free StateMap.

View file

@ -232,7 +232,7 @@ static struct TicSpecial
specialsize = MAX(specialsize * 2, needed + 30);
DPrintf ("Expanding special size to %zu\n", specialsize);
DPrintf (DMSG_NOTIFY, "Expanding special size to %zu\n", specialsize);
for (i = 0; i < BACKUPTICS; i++)
streams[i] = (BYTE *)M_Realloc (streams[i], specialsize);

View file

@ -2134,7 +2134,7 @@ bool PArray::ReadValue(FArchive &ar, void *addr) const
}
if (i < ElementCount)
{
DPrintf("Array on disk (%u) is bigger than in memory (%u)\n",
DPrintf(DMSG_WARNING, "Array on disk (%u) is bigger than in memory (%u)\n",
count, ElementCount);
for (; i < ElementCount; ++i)
{
@ -2501,13 +2501,13 @@ bool PStruct::ReadFields(FArchive &ar, void *addr) const
const PSymbol *sym = Symbols.FindSymbol(FName(label, true), true);
if (sym == NULL)
{
DPrintf("Cannot find field %s in %s\n",
DPrintf(DMSG_ERROR, "Cannot find field %s in %s\n",
label, TypeName.GetChars());
SkipValue(ar);
}
else if (!sym->IsKindOf(RUNTIME_CLASS(PField)))
{
DPrintf("Symbol %s in %s is not a field\n",
DPrintf(DMSG_ERROR, "Symbol %s in %s is not a field\n",
label, TypeName.GetChars());
SkipValue(ar);
}
@ -2806,7 +2806,7 @@ bool PClass::ReadValue(FArchive &ar, void *addr) const
}
else
{
DPrintf("Unknown superclass %s of class %s\n",
DPrintf(DMSG_ERROR, "Unknown superclass %s of class %s\n",
type->TypeName.GetChars(), TypeName.GetChars());
SkipValue(ar, VAL_Struct);
}
@ -3243,7 +3243,7 @@ PClass *PClass::CreateDerivedClass(FName name, unsigned int size)
{
I_Error("%s must inherit from %s but doesn't.", name.GetChars(), type->ParentClass->TypeName.GetChars());
}
DPrintf("Defining placeholder class %s\n", name.GetChars());
DPrintf(DMSG_SPAMMY, "Defining placeholder class %s\n", name.GetChars());
notnew = true;
}
else
@ -3327,7 +3327,7 @@ PClass *PClass::FindClassTentative(FName name, bool fatal)
return static_cast<PClass *>(found);
}
PClass *type = static_cast<PClass *>(GetClass()->CreateNew());
DPrintf("Creating placeholder class %s : %s\n", name.GetChars(), TypeName.GetChars());
DPrintf(DMSG_SPAMMY, "Creating placeholder class %s : %s\n", name.GetChars(), TypeName.GetChars());
type->TypeName = name;
type->ParentClass = this;

View file

@ -40,7 +40,7 @@ FStringTable GStrings;
EGameSpeed GameSpeed = SPEED_Normal;
// Show developer messages if true.
CVAR (Bool, developer, false, 0)
CVAR (Int, developer, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
// [RH] Feature control cvars
CVAR (Bool, var_friction, true, CVAR_SERVERINFO);

View file

@ -205,7 +205,7 @@ extern int bodyqueslot;
// ---- [RH] ----
EXTERN_CVAR (Bool, developer)
EXTERN_CVAR (Int, developer)
extern bool ToggleFullscreen;

View file

@ -148,7 +148,7 @@ int Printf (int printlevel, const char *, ...) GCCPRINTF(2,3);
int Printf (const char *, ...) GCCPRINTF(1,2);
// [RH] Same here:
int DPrintf (const char *, ...) GCCPRINTF(1,2);
int DPrintf (int level, const char *, ...) GCCPRINTF(2,3);
extern "C" int mysnprintf(char *buffer, size_t count, const char *format, ...) GCCPRINTF(3,4);
extern "C" int myvsnprintf(char *buffer, size_t count, const char *format, va_list argptr) GCCFORMAT(3);
@ -161,15 +161,19 @@ enum
PRINT_MEDIUM, // death messages
PRINT_HIGH, // critical messages
PRINT_CHAT, // chat messages
PRINT_TEAMCHAT // chat messages from a teammate
PRINT_TEAMCHAT, // chat messages from a teammate
PRINT_LOG, // only to logfile
PRINT_BOLD = 200 // What Printf_Bold used
};
enum
{
DMSG_OFF, // no developer messages.
DMSG_ERROR, // general notification messages
DMSG_WARNING, // warnings
DMSG_NOTIFY, // general notification messages
DMSG_SPAMMY, // for those who want to see everything, regardless of its usefulness.
};
#define PRINT_LOW 0 // pickup messages
#define PRINT_MEDIUM 1 // death messages
#define PRINT_HIGH 2 // critical messages
#define PRINT_CHAT 3 // chat messages
#define PRINT_TEAMCHAT 4 // chat messages from a teammate
#define PRINT_LOG 5 // only to logfile
#define PRINT_BOLD 200 // What Printf_Bold used
struct PalEntry
{

View file

@ -77,6 +77,11 @@ public:
static void RunThinkers (int statnum);
static void DestroyAllThinkers ();
static void DestroyMostThinkers ();
static void DestroyThinkersInList(int statnum)
{
DestroyThinkersInList(Thinkers[statnum]);
DestroyThinkersInList(FreshThinkers[statnum]);
}
static void SerializeAll (FArchive &arc, bool keepPlayers);
static void MarkRoots();

View file

@ -354,12 +354,12 @@ void FCompressedFile::Implode ()
// If the data could not be compressed, store it as-is.
if (r != Z_OK || outlen >= len)
{
DPrintf ("cfile could not be compressed\n");
DPrintf (DMSG_SPAMMY, "cfile could not be compressed\n");
outlen = 0;
}
else
{
DPrintf ("cfile shrank from %lu to %lu bytes\n", len, outlen);
DPrintf (DMSG_SPAMMY, "cfile shrank from %lu to %lu bytes\n", len, outlen);
}
}
else
@ -717,7 +717,7 @@ void FArchive::Close ()
{
m_File->Close ();
m_File = NULL;
DPrintf ("Processed %u objects\n", ArchiveToObject.Size());
DPrintf (DMSG_SPAMMY, "Processed %u objects\n", ArchiveToObject.Size());
}
}
@ -1194,6 +1194,7 @@ FArchive &FArchive::ReadObject (DObject* &obj, PClass *wanttype)
const PClass *type;
BYTE playerNum;
DWORD index;
DObject *newobj;
operator<< (objHead);
@ -1255,11 +1256,11 @@ FArchive &FArchive::ReadObject (DObject* &obj, PClass *wanttype)
case NEW_CLS_OBJ:
type = ReadClass (wanttype);
// Printf ("New class: %s (%u)\n", type->Name, m_File->Tell());
obj = type->CreateNew ();
newobj = obj = type->CreateNew ();
MapObject (obj);
obj->SerializeUserVars (*this);
obj->Serialize (*this);
obj->CheckIfSerialized ();
newobj->SerializeUserVars (*this);
newobj->Serialize (*this);
newobj->CheckIfSerialized ();
break;
case NEW_PLYR_OBJ:

View file

@ -1280,7 +1280,7 @@ void G_FinishTravel ()
for (inv = pawn->Inventory; inv != NULL; inv = inv->Inventory)
{
inv->ChangeStatNum (STAT_DEFAULT);
inv->ChangeStatNum (STAT_INVENTORY);
inv->LinkToWorld ();
inv->Travelled ();
}
@ -1295,6 +1295,11 @@ void G_FinishTravel ()
}
bglobal.FinishTravel ();
// make sure that, after travelling has completed, no travelling thinkers are left.
// Since this list is excluded from regular thinker cleaning, anything that may survive through here
// will endlessly multiply and severely break the following savegames or just simply crash on broken pointers.
DThinker::DestroyThinkersInList(STAT_TRAVELLING);
}
//==========================================================================

View file

@ -825,13 +825,13 @@ void ADecal::BeginPlay ()
// without effectively doing anything.
if (NULL == ShootDecal(tpl, this, Sector, X(), Y(), Z(), Angles.Yaw + 180, 64., true))
{
DPrintf ("Could not find a wall to stick decal to at (%f,%f)\n", X(), Y());
DPrintf (DMSG_WARNING, "Could not find a wall to stick decal to at (%f,%f)\n", X(), Y());
}
}
}
else
{
DPrintf ("Decal actor at (%f,%f) does not have a good template\n", X(), Y());
DPrintf (DMSG_ERROR, "Decal actor at (%f,%f) does not have a good template\n", X(), Y());
}
// This actor doesn't need to stick around anymore.
Destroy();

View file

@ -821,6 +821,7 @@ void AInventory::BecomeItem ()
}
RemoveFromHash ();
flags &= ~MF_SPECIAL;
ChangeStatNum(STAT_INVENTORY);
SetState (FindState("Held"));
}
@ -847,6 +848,7 @@ void AInventory::BecomePickup ()
}
flags = (GetDefault()->flags | MF_DROPPED) & ~MF_COUNTITEM;
renderflags &= ~RF_INVISIBLE;
ChangeStatNum(STAT_DEFAULT);
SetState (SpawnState);
}

View file

@ -647,35 +647,27 @@ void GLFlat::DrawSubsectorLights(subsector_t * sub, int pass)
void GLFlat::DrawLightsCompat(int pass)
{
gl_RenderState.Apply();
if (sub)
// Draw the subsectors belonging to this sector
for (int i = 0; i<sector->subsectorcount; i++)
{
// This represents a single subsector
DrawSubsectorLights(sub, pass);
}
else
{
// Draw the subsectors belonging to this sector
for (int i = 0; i<sector->subsectorcount; i++)
subsector_t * sub = sector->subsectors[i];
if (gl_drawinfo->ss_renderflags[sub - subsectors] & renderflags)
{
subsector_t * sub = sector->subsectors[i];
if (gl_drawinfo->ss_renderflags[sub - subsectors] & renderflags)
{
DrawSubsectorLights(sub, pass);
}
DrawSubsectorLights(sub, pass);
}
}
// Draw the subsectors assigned to it due to missing textures
if (!(renderflags&SSRF_RENDER3DPLANES))
// Draw the subsectors assigned to it due to missing textures
if (!(renderflags&SSRF_RENDER3DPLANES))
{
gl_subsectorrendernode * node = (renderflags&SSRF_RENDERFLOOR) ?
gl_drawinfo->GetOtherFloorPlanes(sector->sectornum) :
gl_drawinfo->GetOtherCeilingPlanes(sector->sectornum);
while (node)
{
gl_subsectorrendernode * node = (renderflags&SSRF_RENDERFLOOR) ?
gl_drawinfo->GetOtherFloorPlanes(sector->sectornum) :
gl_drawinfo->GetOtherCeilingPlanes(sector->sectornum);
while (node)
{
DrawSubsectorLights(node->sub, pass);
node = node->next;
}
DrawSubsectorLights(node->sub, pass);
node = node->next;
}
}
}
@ -772,11 +764,13 @@ void GLWall::RenderLightsCompat(int pass)
}
if (PrepareLight(light, pass))
{
RenderWall(RWF_TEXTURED, NULL);
vertcount = 0;
RenderWall(RWF_TEXTURED);
}
node = node->nextLight;
}
memcpy(tcs, save, sizeof(tcs));
vertcount = 0;
}
//==========================================================================

View file

@ -294,7 +294,7 @@ static void PrepareSectorData()
seg[j].PartnerSeg!=NULL &&
subsectors[i].render_sector != seg[j].PartnerSeg->Subsector->render_sector)
{
DPrintf("Found hack: (%f,%f) (%f,%f)\n", seg[j].v1->fX(), seg[j].v1->fY(), seg[j].v2->fX(), seg[j].v2->fY());
DPrintf(DMSG_NOTIFY, "Found hack: (%f,%f) (%f,%f)\n", seg[j].v1->fX(), seg[j].v1->fY(), seg[j].v2->fX(), seg[j].v2->fY());
subsectors[i].hacked|=5;
SpreadHackedFlag(&subsectors[i]);
}

View file

@ -126,6 +126,7 @@ void FSimpleVertexBuffer::EnableColorArray(bool on)
void FSimpleVertexBuffer::set(FSimpleVertex *verts, int count)
{
glBindBuffer(GL_ARRAY_BUFFER, vbo_id);
gl_RenderState.ResetVertexBuffer();
gl_RenderState.SetVertexBuffer(this);
glBufferData(GL_ARRAY_BUFFER, count * sizeof(*verts), verts, GL_STREAM_DRAW);
}
@ -139,21 +140,35 @@ void FSimpleVertexBuffer::set(FSimpleVertex *verts, int count)
FFlatVertexBuffer::FFlatVertexBuffer(int width, int height)
: FVertexBuffer(gl.buffermethod != BM_CLIENTARRAY)
{
if (gl.buffermethod != BM_CLIENTARRAY)
switch (gl.buffermethod)
{
case BM_PERSISTENT:
{
unsigned int bytesize = BUFFER_SIZE * sizeof(FFlatVertex);
glBindBuffer(GL_ARRAY_BUFFER, vbo_id);
glBufferStorage(GL_ARRAY_BUFFER, bytesize, NULL, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT);
map = (FFlatVertex*)glMapBufferRange(GL_ARRAY_BUFFER, 0, bytesize, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT);
break;
}
else
case BM_DEFERRED:
{
unsigned int bytesize = BUFFER_SIZE * sizeof(FFlatVertex);
glBindBuffer(GL_ARRAY_BUFFER, vbo_id);
glBufferData(GL_ARRAY_BUFFER, bytesize, NULL, GL_STREAM_DRAW);
map = nullptr;
break;
}
case BM_CLIENTARRAY:
{
// The fallback path uses immediate mode rendering and does not set up an actual vertex buffer
vbo_shadowdata.Reserve(BUFFER_SIZE);
map = new FFlatVertex[BUFFER_SIZE];
break;
}
}
mIndex = mCurIndex = 0;
mNumReserved = 12;
mNumReserved = NUM_RESERVED;
vbo_shadowdata.Resize(mNumReserved);
// the first quad is reserved for handling coordinates through uniforms.
@ -174,6 +189,24 @@ FFlatVertexBuffer::FFlatVertexBuffer(int width, int height)
vbo_shadowdata[10].Set(1.0f, -1.0f, 0, 1.f, 0.0f);
vbo_shadowdata[11].Set(1.0f, 1.0f, 0, 1.f, 1.f);
// The next two are the stencil caps.
vbo_shadowdata[12].Set(-32767.0f, 32767.0f, -32767.0f, 0, 0);
vbo_shadowdata[13].Set(-32767.0f, 32767.0f, 32767.0f, 0, 0);
vbo_shadowdata[14].Set(32767.0f, 32767.0f, 32767.0f, 0, 0);
vbo_shadowdata[15].Set(32767.0f, 32767.0f, -32767.0f, 0, 0);
vbo_shadowdata[16].Set(-32767.0f, -32767.0f, -32767.0f, 0, 0);
vbo_shadowdata[17].Set(-32767.0f, -32767.0f, 32767.0f, 0, 0);
vbo_shadowdata[18].Set(32767.0f, -32767.0f, 32767.0f, 0, 0);
vbo_shadowdata[19].Set(32767.0f, -32767.0f, -32767.0f, 0, 0);
if (gl.buffermethod == BM_DEFERRED)
{
Map();
memcpy(map, &vbo_shadowdata[0], mNumReserved * sizeof(FFlatVertex));
Unmap();
}
}
FFlatVertexBuffer::~FFlatVertexBuffer()
@ -184,7 +217,7 @@ FFlatVertexBuffer::~FFlatVertexBuffer()
glUnmapBuffer(GL_ARRAY_BUFFER);
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
else
if (gl.buffermethod == BM_CLIENTARRAY)
{
delete[] map;
}
@ -197,7 +230,7 @@ void FFlatVertexBuffer::BindVBO()
glBindBuffer(GL_ARRAY_BUFFER, vbo_id);
if (gl.glslversion > 0)
{
if (vbo_id != 0) // set this up only if there is an actual buffer.
if (gl.buffermethod != BM_CLIENTARRAY)
{
glVertexAttribPointer(VATTR_VERTEX, 3, GL_FLOAT, false, sizeof(FFlatVertex), &VTO->x);
glVertexAttribPointer(VATTR_TEXCOORD, 2, GL_FLOAT, false, sizeof(FFlatVertex), &VTO->u);
@ -215,12 +248,37 @@ void FFlatVertexBuffer::BindVBO()
}
else
{
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glVertexPointer(3, GL_FLOAT, sizeof(FFlatVertex), &map->x);
glTexCoordPointer(2, GL_FLOAT, sizeof(FFlatVertex), &map->u);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
}
}
void FFlatVertexBuffer::Map()
{
if (gl.buffermethod == BM_DEFERRED)
{
unsigned int bytesize = BUFFER_SIZE * sizeof(FFlatVertex);
glBindBuffer(GL_ARRAY_BUFFER, vbo_id);
gl_RenderState.ResetVertexBuffer();
map = (FFlatVertex*)glMapBufferRange(GL_ARRAY_BUFFER, 0, bytesize, GL_MAP_WRITE_BIT|GL_MAP_UNSYNCHRONIZED_BIT);
}
}
void FFlatVertexBuffer::Unmap()
{
if (gl.buffermethod == BM_DEFERRED)
{
unsigned int bytesize = BUFFER_SIZE * sizeof(FFlatVertex);
glBindBuffer(GL_ARRAY_BUFFER, vbo_id);
gl_RenderState.ResetVertexBuffer();
glUnmapBuffer(GL_ARRAY_BUFFER);
map = nullptr;
}
}
//==========================================================================
//
// Initialize a single vertex
@ -401,7 +459,9 @@ void FFlatVertexBuffer::CreateVBO()
vbo_shadowdata.Resize(mNumReserved);
CreateFlatVBO();
mCurIndex = mIndex = vbo_shadowdata.Size();
Map();
memcpy(map, &vbo_shadowdata[0], vbo_shadowdata.Size() * sizeof(FFlatVertex));
Unmap();
}
//==========================================================================

View file

@ -83,6 +83,17 @@ class FFlatVertexBuffer : public FVertexBuffer
static const unsigned int BUFFER_SIZE_TO_USE = 1999500;
public:
enum
{
QUAD_INDEX = 0,
FULLSCREEN_INDEX = 4,
PRESENT_INDEX = 8,
STENCILTOP_INDEX = 12,
STENCILBOTTOM_INDEX = 16,
NUM_RESERVED = 20
};
TArray<FFlatVertex> vbo_shadowdata; // this is kept around for updating the actual (non-readable) buffer and as stand-in for pre GL 4.x
FFlatVertexBuffer(int width, int height);
@ -138,6 +149,9 @@ public:
mCurIndex = mIndex;
}
void Map();
void Unmap();
private:
int CreateSubsectorVertices(subsector_t *sub, const secplane_t &plane, int floor);
int CreateSectorVertices(sector_t *sec, const secplane_t &plane, int floor);

View file

@ -114,7 +114,7 @@ void FGLRenderer::RenderScreenQuad()
{
mVBO->BindVBO();
gl_RenderState.ResetVertexBuffer();
glDrawArrays(GL_TRIANGLE_STRIP, 8, 4);
GLRenderer->mVBO->RenderArray(GL_TRIANGLE_STRIP, FFlatVertexBuffer::PRESENT_INDEX, 4);
}
//-----------------------------------------------------------------------------
@ -278,6 +278,12 @@ void FGLRenderer::BindTonemapPalette(int texunit)
}
}
void FGLRenderer::ClearTonemapPalette()
{
delete mTonemapPalette;
mTonemapPalette = nullptr;
}
//-----------------------------------------------------------------------------
//
// Apply lens distortion and place the result in the HUD/2D texture

View file

@ -81,6 +81,6 @@ void FQuadDrawer::DoRender(int type)
glUniformMatrix4fv(shader->vertexmatrix_index, 1, false, matV);
glUniformMatrix4fv(shader->texcoordmatrix_index, 1, false, matT);
glUniform1i(shader->quadmode_index, 1);
GLRenderer->mVBO->RenderArray(type, 0, 4);
GLRenderer->mVBO->RenderArray(type, FFlatVertexBuffer::QUAD_INDEX, 4);
glUniform1i(shader->quadmode_index, 0);
}

View file

@ -65,6 +65,12 @@ CVAR(Bool, gl_renderbuffers, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG);
FGLRenderBuffers::FGLRenderBuffers()
{
for (int i = 0; i < NumPipelineTextures; i++)
{
mPipelineTexture[i] = 0;
mPipelineFB[i] = 0;
}
glGetIntegerv(GL_FRAMEBUFFER_BINDING, (GLint*)&mOutputFB);
glGetIntegerv(GL_MAX_SAMPLES, &mMaxSamples);
}
@ -141,10 +147,10 @@ void FGLRenderBuffers::DeleteFrameBuffer(GLuint &handle)
//
//==========================================================================
void FGLRenderBuffers::Setup(int width, int height, int sceneWidth, int sceneHeight)
bool FGLRenderBuffers::Setup(int width, int height, int sceneWidth, int sceneHeight)
{
if (!IsEnabled())
return;
return false;
if (width <= 0 || height <= 0)
I_FatalError("Requested invalid render buffer sizes: screen = %dx%d", width, height);
@ -183,6 +189,20 @@ void FGLRenderBuffers::Setup(int width, int height, int sceneWidth, int sceneHei
glActiveTexture(activeTex);
glBindRenderbuffer(GL_RENDERBUFFER, 0);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
if (FailedCreate)
{
ClearScene();
ClearPipeline();
ClearBloom();
mWidth = 0;
mHeight = 0;
mSamples = 0;
mBloomWidth = 0;
mBloomHeight = 0;
}
return !FailedCreate;
}
//==========================================================================
@ -268,7 +288,7 @@ void FGLRenderBuffers::CreateBloom(int width, int height)
GLuint FGLRenderBuffers::GetHdrFormat()
{
return ((gl.flags & RFL_NO_RGBA16F) != 0) ? GL_RGBA8 : GL_RGBA16;
return ((gl.flags & RFL_NO_RGBA16F) != 0) ? GL_RGBA8 : GL_RGBA16F;
}
//==========================================================================
@ -279,7 +299,7 @@ GLuint FGLRenderBuffers::GetHdrFormat()
GLuint FGLRenderBuffers::Create2DTexture(const FString &name, GLuint format, int width, int height)
{
GLuint type = (format == GL_RGBA16) ? GL_UNSIGNED_SHORT : GL_UNSIGNED_BYTE;
GLuint type = (format == GL_RGBA16F) ? GL_FLOAT : GL_UNSIGNED_BYTE;
GLuint handle = 0;
glGenTextures(1, &handle);
glBindTexture(GL_TEXTURE_2D, handle);
@ -334,8 +354,8 @@ GLuint FGLRenderBuffers::CreateFrameBuffer(const FString &name, GLuint colorbuff
glBindFramebuffer(GL_FRAMEBUFFER, handle);
FGLDebug::LabelObject(GL_FRAMEBUFFER, handle, name);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorbuffer, 0);
CheckFrameBufferCompleteness();
ClearFrameBuffer(false, false);
if (CheckFrameBufferCompleteness())
ClearFrameBuffer(false, false);
return handle;
}
@ -350,8 +370,8 @@ GLuint FGLRenderBuffers::CreateFrameBuffer(const FString &name, GLuint colorbuff
else
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorbuffer, 0);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, depthstencil);
CheckFrameBufferCompleteness();
ClearFrameBuffer(true, true);
if (CheckFrameBufferCompleteness())
ClearFrameBuffer(true, true);
return handle;
}
@ -367,8 +387,8 @@ GLuint FGLRenderBuffers::CreateFrameBuffer(const FString &name, GLuint colorbuff
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorbuffer, 0);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depth);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, stencil);
CheckFrameBufferCompleteness();
ClearFrameBuffer(true, true);
if (CheckFrameBufferCompleteness())
ClearFrameBuffer(true, true);
return handle;
}
@ -378,12 +398,15 @@ GLuint FGLRenderBuffers::CreateFrameBuffer(const FString &name, GLuint colorbuff
//
//==========================================================================
void FGLRenderBuffers::CheckFrameBufferCompleteness()
bool FGLRenderBuffers::CheckFrameBufferCompleteness()
{
GLenum result = glCheckFramebufferStatus(GL_FRAMEBUFFER);
if (result == GL_FRAMEBUFFER_COMPLETE)
return;
return true;
FailedCreate = true;
#if 0
FString error = "glCheckFramebufferStatus failed: ";
switch (result)
{
@ -398,6 +421,9 @@ void FGLRenderBuffers::CheckFrameBufferCompleteness()
case GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS: error << "GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS"; break;
}
I_FatalError(error);
#endif
return false;
}
//==========================================================================
@ -477,7 +503,7 @@ void FGLRenderBuffers::BindSceneFB()
void FGLRenderBuffers::BindCurrentTexture(int index)
{
glActiveTexture(GL_TEXTURE0 + index);
glBindTexture(GL_TEXTURE_2D, mPipelineFB[mCurrentPipelineTexture]);
glBindTexture(GL_TEXTURE_2D, mPipelineTexture[mCurrentPipelineTexture]);
}
//==========================================================================
@ -533,5 +559,7 @@ void FGLRenderBuffers::BindOutputFB()
bool FGLRenderBuffers::IsEnabled()
{
return gl_renderbuffers && gl.glslversion != 0;
return gl_renderbuffers && gl.glslversion != 0 && !FailedCreate;
}
bool FGLRenderBuffers::FailedCreate = false;

View file

@ -20,7 +20,7 @@ public:
FGLRenderBuffers();
~FGLRenderBuffers();
void Setup(int width, int height, int sceneWidth, int sceneHeight);
bool Setup(int width, int height, int sceneWidth, int sceneHeight);
void BindSceneFB();
void BlitSceneToTexture();
@ -53,7 +53,7 @@ private:
GLuint CreateFrameBuffer(const FString &name, GLuint colorbuffer);
GLuint CreateFrameBuffer(const FString &name, GLuint colorbuffer, GLuint depthstencil, bool colorIsARenderBuffer);
GLuint CreateFrameBuffer(const FString &name, GLuint colorbuffer, GLuint depth, GLuint stencil, bool colorIsARenderBuffer);
void CheckFrameBufferCompleteness();
bool CheckFrameBufferCompleteness();
void ClearFrameBuffer(bool stencil, bool depth);
void DeleteTexture(GLuint &handle);
void DeleteRenderBuffer(GLuint &handle);
@ -84,6 +84,8 @@ private:
// Back buffer frame buffer
GLuint mOutputFB = 0;
static bool FailedCreate;
};
#endif

View file

@ -111,6 +111,7 @@ FGLRenderer::FGLRenderer(OpenGLFrameBuffer *fb)
gllight = glpart2 = glpart = mirrortexture = NULL;
mLights = NULL;
m2DDrawer = nullptr;
mTonemapPalette = nullptr;
}
void gl_LoadModels();
@ -288,9 +289,8 @@ void FGLRenderer::SetupLevel()
void FGLRenderer::Begin2D()
{
if (FGLRenderBuffers::IsEnabled())
if (mBuffers->Setup(mScreenViewport.width, mScreenViewport.height, mSceneViewport.width, mSceneViewport.height))
{
mBuffers->Setup(mScreenViewport.width, mScreenViewport.height, mSceneViewport.width, mSceneViewport.height);
if (mDrawingScene2D)
mBuffers->BindSceneFB();
else

View file

@ -167,6 +167,7 @@ public:
void BloomScene();
void TonemapScene();
void BindTonemapPalette(int texunit);
void ClearTonemapPalette();
void LensDistortScene();
void CopyToBackbuffer(const GL_IRECT *bounds, bool applyGamma);
void Flush() { CopyToBackbuffer(nullptr, true); }

View file

@ -80,19 +80,43 @@ void FRenderState::Reset()
mDstBlend = GL_ONE_MINUS_SRC_ALPHA;
mAlphaThreshold = 0.5f;
mBlendEquation = GL_FUNC_ADD;
mModelMatrixEnabled = false;
mTextureMatrixEnabled = false;
mObjectColor = 0xffffffff;
mVertexBuffer = mCurrentVertexBuffer = NULL;
mColormapState = CM_DEFAULT;
mSoftLight = 0;
mLightParms[0] = mLightParms[1] = mLightParms[2] = 0.0f;
mLightParms[3] = -1.f;
mSpecialEffect = EFF_NONE;
mClipHeight = 0.f;
mClipHeightDirection = 0.f;
mShaderTimer = 0.0f;
ClearClipSplit();
stSrcBlend = stDstBlend = -1;
stBlendEquation = -1;
stAlphaThreshold = -1.f;
stAlphaTest = 0;
mLastDepthClamp = true;
mInterpolationFactor = 0.0f;
mColor.Set(1.0f, 1.0f, 1.0f, 1.0f);
mCameraPos.Set(0.0f, 0.0f, 0.0f, 0.0f);
mGlowTop.Set(0.0f, 0.0f, 0.0f, 0.0f);
mGlowBottom.Set(0.0f, 0.0f, 0.0f, 0.0f);
mGlowTopPlane.Set(0.0f, 0.0f, 0.0f, 0.0f);
mGlowBottomPlane.Set(0.0f, 0.0f, 0.0f, 0.0f);
mSplitTopPlane.Set(0.0f, 0.0f, 0.0f, 0.0f);
mSplitBottomPlane.Set(0.0f, 0.0f, 0.0f, 0.0f);
mClipLine.Set(0.0f, 0.0f, 0.0f, 0.0f);
mDynColor.Set(0.0f, 0.0f, 0.0f, 0.0f);
mEffectState = 0;
activeShader = nullptr;
mProjectionMatrix.loadIdentity();
mViewMatrix.loadIdentity();
mModelMatrix.loadIdentity();
mTextureMatrix.loadIdentity();
}
//==========================================================================

View file

@ -325,6 +325,7 @@ void GLDrawList::SortWallIntoPlane(SortNode * head,SortNode * sort)
if (gl.glslversion < 1.3f)
{
GLWall * ws1;
ws->vertcount = 0; // invalidate current vertices.
ws1=&walls[walls.Size()-1];
ws=&walls[drawitems[sort->itemindex].index]; // may have been reallocated!
float newtexv = ws->tcs[GLWall::UPLFT].v + ((ws->tcs[GLWall::LOLFT].v - ws->tcs[GLWall::UPLFT].v) / (ws->zbottom[0] - ws->ztop[0])) * (fh->z - ws->ztop[0]);
@ -467,6 +468,7 @@ void GLDrawList::SortWallIntoWall(SortNode * head,SortNode * sort)
float izt=(float)(ws->ztop[0]+r*(ws->ztop[1]-ws->ztop[0]));
float izb=(float)(ws->zbottom[0]+r*(ws->zbottom[1]-ws->zbottom[0]));
ws->vertcount = 0; // invalidate current vertices.
GLWall w=*ws;
AddWall(&w);
ws1=&walls[walls.Size()-1];

View file

@ -47,6 +47,7 @@
#include "doomstat.h"
#include "d_player.h"
#include "portal.h"
#include "templates.h"
#include "gl/system/gl_interface.h"
#include "gl/system/gl_cvars.h"
@ -64,6 +65,7 @@
#include "gl/utility/gl_clock.h"
#include "gl/utility/gl_convert.h"
#include "gl/utility/gl_templates.h"
#include "gl/renderer/gl_quaddrawer.h"
#ifdef _DEBUG
CVAR(Int, gl_breaksec, -1, 0)
@ -175,18 +177,46 @@ void GLFlat::SetupSubsectorLights(int pass, subsector_t * sub, int *dli)
void GLFlat::DrawSubsector(subsector_t * sub)
{
FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer();
for (unsigned int k = 0; k < sub->numlines; k++)
if (gl.buffermethod != BM_DEFERRED)
{
vertex_t *vt = sub->firstline[k].v1;
ptr->x = vt->fX();
ptr->z = plane.plane.ZatPoint(vt) + dz;
ptr->y = vt->fY();
ptr->u = vt->fX() / 64.f;
ptr->v = -vt->fY() / 64.f;
ptr++;
FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer();
for (unsigned int k = 0; k < sub->numlines; k++)
{
vertex_t *vt = sub->firstline[k].v1;
ptr->x = vt->fX();
ptr->z = plane.plane.ZatPoint(vt) + dz;
ptr->y = vt->fY();
ptr->u = vt->fX() / 64.f;
ptr->v = -vt->fY() / 64.f;
ptr++;
}
GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN);
}
else
{
// if we cannot access the buffer, use the quad drawer as fallback by splitting the subsector into quads.
// Trying to get this into the vertex buffer in the processing pass is too costly and this is only used for render hacks.
FQuadDrawer qd;
unsigned int vi[4];
vi[0] = 0;
for (unsigned int i = 1; i < sub->numlines-1; i += 2)
{
if (i < sub->numlines - 3)
{
for (unsigned int j = 1; j < 4; j++)
{
vi[j] = MIN(i + j, sub->numlines - 1);
}
for (unsigned int x = 0; x < 4; x++)
{
vertex_t *vt = sub->firstline[vi[x]].v1;
qd.Set(x, vt->fX(), plane.plane.ZatPoint(vt) + dz, vt->fY(), vt->fX() / 64.f, -vt->fY() / 64.f);
}
qd.Render(GL_TRIANGLE_FAN);
}
}
}
GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN);
flatvertices += sub->numlines;
flatprimitives++;
@ -203,35 +233,27 @@ void GLFlat::ProcessLights(bool istrans)
{
dynlightindex = GLRenderer->mLights->GetIndexPtr();
if (sub)
// Draw the subsectors belonging to this sector
for (int i=0; i<sector->subsectorcount; i++)
{
// This represents a single subsector
SetupSubsectorLights(GLPASS_LIGHTSONLY, sub);
}
else
{
// Draw the subsectors belonging to this sector
for (int i=0; i<sector->subsectorcount; i++)
subsector_t * sub = sector->subsectors[i];
if (gl_drawinfo->ss_renderflags[sub-subsectors]&renderflags || istrans)
{
subsector_t * sub = sector->subsectors[i];
if (gl_drawinfo->ss_renderflags[sub-subsectors]&renderflags || istrans)
{
SetupSubsectorLights(GLPASS_LIGHTSONLY, sub);
}
SetupSubsectorLights(GLPASS_LIGHTSONLY, sub);
}
}
// Draw the subsectors assigned to it due to missing textures
if (!(renderflags&SSRF_RENDER3DPLANES))
// Draw the subsectors assigned to it due to missing textures
if (!(renderflags&SSRF_RENDER3DPLANES))
{
gl_subsectorrendernode * node = (renderflags&SSRF_RENDERFLOOR)?
gl_drawinfo->GetOtherFloorPlanes(sector->sectornum) :
gl_drawinfo->GetOtherCeilingPlanes(sector->sectornum);
while (node)
{
gl_subsectorrendernode * node = (renderflags&SSRF_RENDERFLOOR)?
gl_drawinfo->GetOtherFloorPlanes(sector->sectornum) :
gl_drawinfo->GetOtherCeilingPlanes(sector->sectornum);
while (node)
{
SetupSubsectorLights(GLPASS_LIGHTSONLY, node->sub);
node = node->next;
}
SetupSubsectorLights(GLPASS_LIGHTSONLY, node->sub);
node = node->next;
}
}
}
@ -248,60 +270,52 @@ void GLFlat::DrawSubsectors(int pass, bool processlights, bool istrans)
int dli = dynlightindex;
gl_RenderState.Apply();
if (sub)
if (vboindex >= 0)
{
// This represents a single subsector
if (processlights) SetupSubsectorLights(GLPASS_ALL, sub, &dli);
DrawSubsector(sub);
}
else
{
if (vboindex >= 0)
int index = vboindex;
for (int i=0; i<sector->subsectorcount; i++)
{
int index = vboindex;
for (int i=0; i<sector->subsectorcount; i++)
{
subsector_t * sub = sector->subsectors[i];
subsector_t * sub = sector->subsectors[i];
if (gl_drawinfo->ss_renderflags[sub-subsectors]&renderflags || istrans)
{
if (processlights) SetupSubsectorLights(GLPASS_ALL, sub, &dli);
drawcalls.Clock();
glDrawArrays(GL_TRIANGLE_FAN, index, sub->numlines);
drawcalls.Unclock();
flatvertices += sub->numlines;
flatprimitives++;
}
index += sub->numlines;
}
}
else
{
// Draw the subsectors belonging to this sector
for (int i=0; i<sector->subsectorcount; i++)
{
subsector_t * sub = sector->subsectors[i];
if (gl_drawinfo->ss_renderflags[sub-subsectors]&renderflags || istrans)
{
if (processlights) SetupSubsectorLights(GLPASS_ALL, sub, &dli);
DrawSubsector(sub);
}
if (gl_drawinfo->ss_renderflags[sub-subsectors]&renderflags || istrans)
{
if (processlights) SetupSubsectorLights(GLPASS_ALL, sub, &dli);
drawcalls.Clock();
glDrawArrays(GL_TRIANGLE_FAN, index, sub->numlines);
drawcalls.Unclock();
flatvertices += sub->numlines;
flatprimitives++;
}
index += sub->numlines;
}
}
else
{
// Draw the subsectors belonging to this sector
// (can this case even happen?)
for (int i=0; i<sector->subsectorcount; i++)
{
subsector_t * sub = sector->subsectors[i];
if (gl_drawinfo->ss_renderflags[sub-subsectors]&renderflags || istrans)
{
if (processlights) SetupSubsectorLights(GLPASS_ALL, sub, &dli);
DrawSubsector(sub);
}
}
}
// Draw the subsectors assigned to it due to missing textures
if (!(renderflags&SSRF_RENDER3DPLANES))
{
gl_subsectorrendernode * node = (renderflags&SSRF_RENDERFLOOR)?
gl_drawinfo->GetOtherFloorPlanes(sector->sectornum) :
gl_drawinfo->GetOtherCeilingPlanes(sector->sectornum);
// Draw the subsectors assigned to it due to missing textures
if (!(renderflags&SSRF_RENDER3DPLANES))
{
gl_subsectorrendernode * node = (renderflags&SSRF_RENDERFLOOR)?
gl_drawinfo->GetOtherFloorPlanes(sector->sectornum) :
gl_drawinfo->GetOtherCeilingPlanes(sector->sectornum);
while (node)
{
if (processlights) SetupSubsectorLights(GLPASS_ALL, node->sub, &dli);
DrawSubsector(node->sub);
node = node->next;
}
while (node)
{
if (processlights) SetupSubsectorLights(GLPASS_ALL, node->sub, &dli);
DrawSubsector(node->sub);
node = node->next;
}
}
}
@ -318,7 +332,6 @@ void GLFlat::DrawSubsectors(int pass, bool processlights, bool istrans)
void GLFlat::DrawSkyboxSector(int pass, bool processlights)
{
FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer();
float minx = FLT_MAX, miny = FLT_MAX;
float maxx = -FLT_MAX, maxy = -FLT_MAX;
@ -345,36 +358,13 @@ void GLFlat::DrawSkyboxSector(int pass, bool processlights)
static float vvals[] = { 1, 0, 0, 1 };
int rot = -xs_FloorToInt(plane.Angle / 90.f);
FQuadDrawer qd;
ptr->x = minx;
ptr->z = z;
ptr->y = miny;
ptr->u = uvals[rot & 3];
ptr->v = vvals[rot & 3];
ptr++;
ptr->x = minx;
ptr->z = z;
ptr->y = maxy;
ptr->u = uvals[(rot + 1) & 3];
ptr->v = vvals[(rot + 1) & 3];
ptr++;
ptr->x = maxx;
ptr->z = z;
ptr->y = maxy;
ptr->u = uvals[(rot + 2) & 3];
ptr->v = vvals[(rot + 2) & 3];
ptr++;
ptr->x = maxx;
ptr->z = z;
ptr->y = miny;
ptr->u = uvals[(rot + 3) & 3];
ptr->v = vvals[(rot + 3) & 3];
ptr++;
GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN);
qd.Set(0, minx, z, miny, uvals[rot & 3], vvals[rot & 3]);
qd.Set(1, minx, z, maxy, uvals[(rot + 1) & 3], vvals[(rot + 1) & 3]);
qd.Set(2, maxx, z, maxy, uvals[(rot + 2) & 3], vvals[(rot + 2) & 3]);
qd.Set(3, maxx, z, miny, uvals[(rot + 3) & 3], vvals[(rot + 3) & 3]);
qd.Render(GL_TRIANGLE_FAN);
flatvertices += 4;
flatprimitives++;
@ -588,7 +578,6 @@ void GLFlat::ProcessSector(sector_t * frontsector)
// Get the real sector for this one.
sector = &sectors[frontsector->sectornum];
extsector_t::xfloor &x = sector->e->XFloor;
this->sub = NULL;
dynlightindex = -1;
byte &srf = gl_drawinfo->sectorrenderflags[sector->sectornum];

View file

@ -147,31 +147,13 @@ void GLPortal::DrawPortalStencil()
{
if (mPrimIndices.Size() == 0)
{
bool cap = NeedCap() && lines.Size() > 1;
mPrimIndices.Resize(2 * lines.Size() + 4 * cap);
mPrimIndices.Resize(2 * lines.Size());
for (unsigned int i = 0; i<lines.Size(); i++)
for (unsigned int i = 0; i < lines.Size(); i++)
{
lines[i].RenderWall(GLWall::RWF_NORENDER, &mPrimIndices[i * 2]);
}
if (cap)
{
// Cap the stencil at the top and bottom
int n = lines.Size() * 2;
FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer();
ptr[0].Set(-32767.0f, 32767.0f, -32767.0f, 0, 0);
ptr[1].Set(-32767.0f, 32767.0f, 32767.0f, 0, 0);
ptr[2].Set(32767.0f, 32767.0f, 32767.0f, 0, 0);
ptr[3].Set(32767.0f, 32767.0f, -32767.0f, 0, 0);
ptr += 4;
mPrimIndices[n + 1] = GLRenderer->mVBO->GetCount(ptr, &mPrimIndices[n]);
ptr[0].Set(-32767.0f, -32767.0f, -32767.0f, 0, 0);
ptr[1].Set(-32767.0f, -32767.0f, 32767.0f, 0, 0);
ptr[2].Set(32767.0f, -32767.0f, 32767.0f, 0, 0);
ptr[3].Set(32767.0f, -32767.0f, -32767.0f, 0, 0);
ptr += 4;
mPrimIndices[n + 3] = GLRenderer->mVBO->GetCount(ptr, &mPrimIndices[n + 2]);
if (gl.buffermethod != BM_DEFERRED) lines[i].MakeVertices(false);
mPrimIndices[i * 2] = lines[i].vertindex;
mPrimIndices[i * 2 + 1] = lines[i].vertcount;
}
}
gl_RenderState.Apply();
@ -179,6 +161,11 @@ void GLPortal::DrawPortalStencil()
{
GLRenderer->mVBO->RenderArray(GL_TRIANGLE_FAN, mPrimIndices[i], mPrimIndices[i + 1]);
}
if (NeedCap() && lines.Size() > 1)
{
GLRenderer->mVBO->RenderArray(GL_TRIANGLE_FAN, FFlatVertexBuffer::STENCILTOP_INDEX, 4);
GLRenderer->mVBO->RenderArray(GL_TRIANGLE_FAN, FFlatVertexBuffer::STENCILBOTTOM_INDEX, 4);
}
}
@ -1083,6 +1070,66 @@ void GLLineToLinePortal::RenderAttached()
//
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
GLHorizonPortal::GLHorizonPortal(GLHorizonInfo * pt, bool local)
: GLPortal(local)
{
origin = pt;
// create the vertex data for this horizon portal.
GLSectorPlane * sp = &origin->plane;
const float vx = ViewPos.X;
const float vy = ViewPos.Y;
const float vz = ViewPos.Z;
const float z = sp->Texheight;
const float tz = (z - vz);
// Draw to some far away boundary
// This is not drawn as larger strips because it causes visual glitches.
FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer();
for (float x = -32768 + vx; x<32768 + vx; x += 4096)
{
for (float y = -32768 + vy; y<32768 + vy; y += 4096)
{
ptr->Set(x, z, y, x / 64, -y / 64);
ptr++;
ptr->Set(x + 4096, z, y, x / 64 + 64, -y / 64);
ptr++;
ptr->Set(x, z, y + 4096, x / 64, -y / 64 - 64);
ptr++;
ptr->Set(x + 4096, z, y + 4096, x / 64 + 64, -y / 64 - 64);
ptr++;
}
}
// fill the gap between the polygon and the true horizon
// Since I can't draw into infinity there can always be a
// small gap
ptr->Set(-32768 + vx, z, -32768 + vy, 512.f, 0);
ptr++;
ptr->Set(-32768 + vx, vz, -32768 + vy, 512.f, tz);
ptr++;
ptr->Set(-32768 + vx, z, 32768 + vy, -512.f, 0);
ptr++;
ptr->Set(-32768 + vx, vz, 32768 + vy, -512.f, tz);
ptr++;
ptr->Set(32768 + vx, z, 32768 + vy, 512.f, 0);
ptr++;
ptr->Set(32768 + vx, vz, 32768 + vy, 512.f, tz);
ptr++;
ptr->Set(32768 + vx, z, -32768 + vy, -512.f, 0);
ptr++;
ptr->Set(32768 + vx, vz, -32768 + vy, -512.f, tz);
ptr++;
ptr->Set(-32768 + vx, z, -32768 + vy, 512.f, 0);
ptr++;
ptr->Set(-32768 + vx, vz, -32768 + vy, 512.f, tz);
ptr++;
vcount = GLRenderer->mVBO->GetCount(ptr, &voffset) - 10;
}
//-----------------------------------------------------------------------------
//
// GLHorizonPortal::DrawContents
@ -1092,11 +1139,10 @@ void GLHorizonPortal::DrawContents()
{
PortalAll.Clock();
GLSectorPlane * sp=&origin->plane;
FMaterial * gltexture;
PalEntry color;
float z;
player_t * player=&players[consoleplayer];
GLSectorPlane * sp = &origin->plane;
gltexture=FMaterial::ValidateTexture(sp->texture, false, true);
if (!gltexture)
@ -1108,9 +1154,6 @@ void GLHorizonPortal::DrawContents()
gl_RenderState.SetCameraPos(ViewPos.X, ViewPos.Y, ViewPos.Z);
z=sp->Texheight;
if (gltexture && gltexture->tex->isFullbright())
{
// glowing textures are always drawn full bright without color
@ -1133,58 +1176,11 @@ void GLHorizonPortal::DrawContents()
gl_RenderState.Apply();
float vx= ViewPos.X;
float vy= ViewPos.Y;
// Draw to some far away boundary
// This is not drawn as larher strips because it causes visual glitches.
for(float x=-32768+vx; x<32768+vx; x+=4096)
for (unsigned i = 0; i < vcount; i += 4)
{
for(float y=-32768+vy; y<32768+vy;y+=4096)
{
FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer();
ptr->Set(x, z, y, x / 64, -y / 64);
ptr++;
ptr->Set(x + 4096, z, y, x / 64 + 64, -y / 64);
ptr++;
ptr->Set(x, z, y + 4096, x / 64, -y / 64 - 64);
ptr++;
ptr->Set(x + 4096, z, y + 4096, x / 64 + 64, -y / 64 - 64);
ptr++;
GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP);
}
GLRenderer->mVBO->RenderArray(GL_TRIANGLE_STRIP, voffset + i, 4);
}
float vz= ViewPos.Z;
float tz=(z-vz);///64.0f;
// fill the gap between the polygon and the true horizon
// Since I can't draw into infinity there can always be a
// small gap
FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer();
ptr->Set(-32768 + vx, z, -32768 + vy, 512.f, 0);
ptr++;
ptr->Set(-32768 + vx, vz, -32768 + vy, 512.f, tz);
ptr++;
ptr->Set(-32768 + vx, z, 32768 + vy, -512.f, 0);
ptr++;
ptr->Set(-32768 + vx, vz, 32768 + vy, -512.f, tz);
ptr++;
ptr->Set(32768 + vx, z, 32768 + vy, 512.f, 0);
ptr++;
ptr->Set(32768 + vx, vz, 32768 + vy, 512.f, tz);
ptr++;
ptr->Set(32768 + vx, z, -32768 + vy, -512.f, 0);
ptr++;
ptr->Set(32768 + vx, vz, -32768 + vy, -512.f, tz);
ptr++;
ptr->Set(-32768 + vx, z, -32768 + vy, 512.f, 0);
ptr++;
ptr->Set(-32768 + vx, vz, -32768 + vy, 512.f, tz);
ptr++;
GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP);
GLRenderer->mVBO->RenderArray(GL_TRIANGLE_STRIP, voffset + vcount, 10);
gl_RenderState.EnableTextureMatrix(false);
PortalAll.Unclock();

View file

@ -365,6 +365,8 @@ public:
struct GLHorizonPortal : public GLPortal
{
GLHorizonInfo * origin;
unsigned int voffset;
unsigned int vcount;
friend struct GLEEHorizonPortal;
protected:
@ -376,12 +378,7 @@ protected:
public:
GLHorizonPortal(GLHorizonInfo * pt, bool local = false)
: GLPortal(local)
{
origin=pt;
}
GLHorizonPortal(GLHorizonInfo * pt, bool local = false);
};
struct GLEEHorizonPortal : public GLPortal

View file

@ -168,9 +168,8 @@ void FGLRenderer::Reset3DViewport()
void FGLRenderer::Set3DViewport(bool mainview)
{
if (mainview && FGLRenderBuffers::IsEnabled())
if (mainview && mBuffers->Setup(mScreenViewport.width, mScreenViewport.height, mSceneViewport.width, mSceneViewport.height))
{
mBuffers->Setup(mScreenViewport.width, mScreenViewport.height, mSceneViewport.width, mSceneViewport.height);
mBuffers->BindSceneFB();
}
@ -285,6 +284,7 @@ void FGLRenderer::CreateScene()
for(unsigned i=0;i<portals.Size(); i++) portals[i]->glportal = NULL;
gl_spriteindex=0;
Bsp.Clock();
GLRenderer->mVBO->Map();
R_SetView();
validcount++; // used for processing sidedefs only once by the renderer.
gl_RenderBSPNode (nodes + numnodes - 1);
@ -296,6 +296,7 @@ void FGLRenderer::CreateScene()
gl_drawinfo->HandleMissingTextures(); // Missing upper/lower textures
gl_drawinfo->HandleHackedSubsectors(); // open sector hacks for deep water
gl_drawinfo->ProcessSectorStacks(); // merge visplanes of sector stacks
GLRenderer->mVBO->Unmap();
ProcessAll.Unclock();
@ -526,7 +527,7 @@ void gl_FillScreen()
gl_RenderState.EnableTexture(false);
gl_RenderState.Apply();
// The fullscreen quad is stored at index 4 in the main vertex buffer.
glDrawArrays(GL_TRIANGLE_STRIP, 4, 4);
GLRenderer->mVBO->RenderArray(GL_TRIANGLE_STRIP, FFlatVertexBuffer::FULLSCREEN_INDEX, 4);
}
//==========================================================================

View file

@ -172,6 +172,9 @@ public:
float zceil[2];
float zfloor[2];
unsigned int vertindex;
unsigned int vertcount;
public:
seg_t * seg; // this gives the easiest access to all other structs involved
subsector_t * sub; // For polyobjects
@ -192,7 +195,8 @@ private:
void SetupLights();
bool PrepareLight(ADynamicLight * light, int pass);
void RenderWall(int textured, unsigned int *store = NULL);
void MakeVertices(bool nosplit);
void RenderWall(int textured);
void RenderTextured(int rflags);
void FloodPlane(int pass);
@ -284,7 +288,6 @@ public:
friend struct GLDrawList;
sector_t * sector;
subsector_t * sub; // only used for translucent planes
float dz; // z offset for rendering hacks
float z; // the z position of the flat (only valid for non-sloped planes)
FMaterial *gltexture;

View file

@ -135,6 +135,7 @@ void GLWall::PutWall(bool translucent)
if (translucent) // translucent walls
{
ViewDistance = (ViewPos - (seg->linedef->v1->fPos() + seg->linedef->Delta() / 2)).XY().LengthSquared();
if (gl.buffermethod == BM_DEFERRED) MakeVertices(true);
gl_drawinfo->drawlists[GLDL_TRANSLUCENT].AddWall(this);
}
else
@ -157,16 +158,19 @@ void GLWall::PutWall(bool translucent)
{
list = masked ? GLDL_MASKEDWALLS : GLDL_PLAINWALLS;
}
if (gl.buffermethod == BM_DEFERRED) MakeVertices(false);
gl_drawinfo->drawlists[list].AddWall(this);
}
lightlist = NULL;
vertcount = 0; // make sure that following parts of the same linedef do not get this one's vertex info.
}
void GLWall::PutPortal(int ptype)
{
GLPortal * portal;
if (gl.buffermethod == BM_DEFERRED) MakeVertices(false);
switch (ptype)
{
// portals don't go into the draw list.
@ -237,6 +241,7 @@ void GLWall::PutPortal(int ptype)
portal->AddLine(this);
break;
}
vertcount = 0;
}
//==========================================================================
//
@ -1467,6 +1472,8 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector)
// note: we always have a valid sidedef and linedef reference when getting here.
this->seg = seg;
vertindex = 0;
vertcount = 0;
if ((seg->sidedef->Flags & WALLF_POLYOBJ) && seg->backsector)
{
@ -1760,6 +1767,9 @@ void GLWall::ProcessLowerMiniseg(seg_t *seg, sector_t * frontsector, sector_t *
float ffh = frontsector->GetPlaneTexZ(sector_t::floor);
float bfh = backsector->GetPlaneTexZ(sector_t::floor);
vertindex = 0;
vertcount = 0;
if (bfh > ffh)
{
this->seg = seg;

View file

@ -60,6 +60,7 @@
#include "gl/textures/gl_material.h"
#include "gl/utility/gl_clock.h"
#include "gl/utility/gl_templates.h"
#include "gl/renderer/gl_quaddrawer.h"
EXTERN_CVAR(Bool, gl_seamless)
@ -167,6 +168,36 @@ void GLWall::SetupLights()
dynlightindex = GLRenderer->mLights->UploadLights(lightdata);
}
//==========================================================================
//
// build the vertices for this wall
//
//==========================================================================
void GLWall::MakeVertices(bool nosplit)
{
if (vertcount == 0)
{
bool split = (gl_seamless && !nosplit && seg->sidedef != NULL && !(seg->sidedef->Flags & WALLF_POLYOBJ) && !(flags & GLWF_NOSPLIT));
FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer();
ptr->Set(glseg.x1, zbottom[0], glseg.y1, tcs[LOLFT].u, tcs[LOLFT].v);
ptr++;
if (split && glseg.fracleft == 0) SplitLeftEdge(ptr);
ptr->Set(glseg.x1, ztop[0], glseg.y1, tcs[UPLFT].u, tcs[UPLFT].v);
ptr++;
if (split && !(flags & GLWF_NOSPLITUPPER)) SplitUpperEdge(ptr);
ptr->Set(glseg.x2, ztop[1], glseg.y2, tcs[UPRGT].u, tcs[UPRGT].v);
ptr++;
if (split && glseg.fracright == 1) SplitRightEdge(ptr);
ptr->Set(glseg.x2, zbottom[1], glseg.y2, tcs[LORGT].u, tcs[LORGT].v);
ptr++;
if (split && !(flags & GLWF_NOSPLITLOWER)) SplitLowerEdge(ptr);
vertcount = GLRenderer->mVBO->GetCount(ptr, &vertindex);
}
}
//==========================================================================
//
@ -175,43 +206,30 @@ void GLWall::SetupLights()
//
//==========================================================================
void GLWall::RenderWall(int textured, unsigned int *store)
void GLWall::RenderWall(int textured)
{
bool split = (gl_seamless && !(textured&RWF_NOSPLIT) && seg->sidedef != NULL && !(seg->sidedef->Flags & WALLF_POLYOBJ) && !(flags & GLWF_NOSPLIT));
if (!(textured & RWF_NORENDER))
gl_RenderState.Apply();
gl_RenderState.ApplyLightIndex(dynlightindex);
if (gl.buffermethod != BM_DEFERRED)
{
gl_RenderState.Apply();
gl_RenderState.ApplyLightIndex(dynlightindex);
MakeVertices(!(textured&RWF_NOSPLIT));
}
// the rest of the code is identical for textured rendering and lights
FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer();
unsigned int count, offset;
ptr->Set(glseg.x1, zbottom[0], glseg.y1, tcs[LOLFT].u, tcs[LOLFT].v);
ptr++;
if (split && glseg.fracleft == 0) SplitLeftEdge(ptr);
ptr->Set(glseg.x1, ztop[0], glseg.y1, tcs[UPLFT].u, tcs[UPLFT].v);
ptr++;
if (split && !(flags & GLWF_NOSPLITUPPER)) SplitUpperEdge(ptr);
ptr->Set(glseg.x2, ztop[1], glseg.y2, tcs[UPRGT].u, tcs[UPRGT].v);
ptr++;
if (split && glseg.fracright == 1) SplitRightEdge(ptr);
ptr->Set(glseg.x2, zbottom[1], glseg.y2, tcs[LORGT].u, tcs[LORGT].v);
ptr++;
if (split && !(flags & GLWF_NOSPLITLOWER)) SplitLowerEdge(ptr);
count = GLRenderer->mVBO->GetCount(ptr, &offset);
if (!(textured & RWF_NORENDER))
else if (vertcount == 0)
{
GLRenderer->mVBO->RenderArray(GL_TRIANGLE_FAN, offset, count);
vertexcount += count;
}
if (store != NULL)
{
store[0] = offset;
store[1] = count;
// in case we get here without valid vertex data and no ability to create them now,
// use the quad drawer as fallback (without edge splitting.)
// This can only happen in one special situation, when a translucent line got split during sorting.
FQuadDrawer qd;
qd.Set(0, glseg.x1, zbottom[0], glseg.y1, tcs[LOLFT].u, tcs[LOLFT].v);
qd.Set(1, glseg.x1, ztop[0], glseg.y1, tcs[UPLFT].u, tcs[UPLFT].v);
qd.Set(2, glseg.x2, ztop[1], glseg.y2, tcs[UPRGT].u, tcs[UPRGT].v);
qd.Set(3, glseg.x2, zbottom[1], glseg.y2, tcs[LORGT].u, tcs[LORGT].v);
qd.Render(GL_TRIANGLE_FAN);
vertexcount += 4;
return;
}
GLRenderer->mVBO->RenderArray(GL_TRIANGLE_FAN, vertindex, vertcount);
vertexcount += vertcount;
}
//==========================================================================

View file

@ -8,7 +8,7 @@ class FBloomExtractShader
public:
void Bind();
FBufferedUniform1i SceneTexture;
FBufferedUniformSampler SceneTexture;
FBufferedUniform1f Exposure;
FBufferedUniform2f Scale;
FBufferedUniform2f Offset;
@ -22,7 +22,7 @@ class FBloomCombineShader
public:
void Bind();
FBufferedUniform1i BloomTexture;
FBufferedUniformSampler BloomTexture;
private:
FShaderProgram mShader;

View file

@ -8,7 +8,7 @@ class FLensShader
public:
void Bind();
FBufferedUniform1i InputTexture;
FBufferedUniformSampler InputTexture;
FBufferedUniform1f AspectRatio;
FBufferedUniform1f Scale;
FBufferedUniform4f LensDistortionCoefficient;

View file

@ -8,7 +8,7 @@ class FPresentShader
public:
void Bind();
FBufferedUniform1i InputTexture;
FBufferedUniformSampler InputTexture;
FBufferedUniform1f InvGamma;
FBufferedUniform1f Contrast;
FBufferedUniform1f Brightness;

View file

@ -125,7 +125,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
vp_comb = "#version 400 core\n#extension GL_ARB_shader_storage_buffer_object : require\n#define SHADER_STORAGE_LIGHTS\n";
}
}
//if (gl.buffermethod == BM_DEFERRED)
if (gl.buffermethod == BM_DEFERRED)
{
vp_comb << "#define USE_QUAD_DRAWER\n";
}

View file

@ -201,6 +201,28 @@ public:
}
};
class FBufferedUniformSampler
{
int mBuffer;
int mIndex;
public:
void Init(GLuint hShader, const GLchar *name)
{
mIndex = glGetUniformLocation(hShader, name);
mBuffer = -1;
}
void Set(int newvalue)
{
if (newvalue != mBuffer)
{
mBuffer = newvalue;
glUniform1i(mIndex, newvalue);
}
}
};
class FShader
{

View file

@ -52,6 +52,12 @@
#include "i_system.h"
#include "doomerrors.h"
FShaderProgram::FShaderProgram()
{
for (int i = 0; i < NumShaderTypes; i++)
mShaders[i] = 0;
}
//==========================================================================
//
// Free shader program resources

View file

@ -6,6 +6,7 @@
class FShaderProgram
{
public:
FShaderProgram();
~FShaderProgram();
enum ShaderType
@ -30,6 +31,9 @@ public:
static void PatchFragShader(FString &code);
private:
FShaderProgram(const FShaderProgram &) = delete;
FShaderProgram &operator=(const FShaderProgram &) = delete;
static FString PatchShader(ShaderType type, const FString &code, const char *defines, int maxGlslVersion);
static void PatchCommon(FString &code);

View file

@ -8,9 +8,9 @@ class FTonemapShader
public:
void Bind();
FBufferedUniform1i SceneTexture;
FBufferedUniformSampler SceneTexture;
FBufferedUniform1f Exposure;
FBufferedUniform1i PaletteLUT;
FBufferedUniformSampler PaletteLUT;
static bool IsPaletteMode();

View file

@ -99,6 +99,11 @@ OpenGLFrameBuffer::OpenGLFrameBuffer(void *hMonitor, int width, int height, int
// If wglSwapIntervalEXT is called after glBindFramebuffer in a frame the setting is not changed!
SetVSync(vid_vsync);
// Make sure all global variables tracking OpenGL context state are reset..
FHardwareTexture::InitGlobalState();
FMaterial::InitGlobalState();
gl_RenderState.Reset();
GLRenderer = new FGLRenderer(this);
memcpy (SourcePalette, GPalette.BaseColors, sizeof(PalEntry)*256);
UpdatePalette ();
@ -305,6 +310,9 @@ void OpenGLFrameBuffer::UpdatePalette()
bb>>=8;
palette_brightness = (rr*77 + gg*143 + bb*35)/255;
if (GLRenderer)
GLRenderer->ClearTonemapPalette();
}
void OpenGLFrameBuffer::GetFlashedPalette (PalEntry pal[256])

View file

@ -204,8 +204,12 @@ void gl_LoadExtensions()
}
else if (gl.version < 3.0f)
{
//if (CheckExtension("GL_NV_GPU_shader4") || CheckExtension("GL_EXT_GPU_shader4")) gl.glslversion = 1.21f; // for pre-3.0 drivers that support capable hardware. Needed for Apple.
//else gl.glslversion = 0;
if (CheckExtension("GL_NV_GPU_shader4") || CheckExtension("GL_EXT_GPU_shader4")) gl.glslversion = 1.21f; // for pre-3.0 drivers that support capable hardware. Needed for Apple.
else
{
gl.buffermethod = BM_CLIENTARRAY;
gl.glslversion = 0;
}
if (!CheckExtension("GL_EXT_packed_float")) gl.flags |= RFL_NO_RGBA16F;
if (!CheckExtension("GL_EXT_packed_depth_stencil")) gl.flags |= RFL_NO_DEPTHSTENCIL;
@ -307,6 +311,7 @@ void gl_LoadExtensions()
FUDGE_FUNC(glDeleteRenderbuffers, EXT);
FUDGE_FUNC(glRenderbufferStorage, EXT);
FUDGE_FUNC(glBindRenderbuffer, EXT);
FUDGE_FUNC(glCheckFramebufferStatus, EXT);
gl_PatchMenu();
}

View file

@ -2447,11 +2447,49 @@ static void LoadExtByName(const char *extensionName)
}
}
/* BEGINNING OF MANUAL CHANGES, DO NOT REMOVE! */
static void ProcExtsFromExtList(void)
static void ProcExtsFromExtString(const char *strExtList)
{
size_t iExtListLen = strlen(strExtList);
const char *strExtListEnd = strExtList + iExtListLen;
const char *strCurrPos = strExtList;
char strWorkBuff[256];
while (*strCurrPos)
{
/*Get the extension at our position.*/
int iStrLen = 0;
const char *strEndStr = strchr(strCurrPos, ' ');
int iStop = 0;
if (strEndStr == NULL)
{
strEndStr = strExtListEnd;
iStop = 1;
}
iStrLen = (int)((ptrdiff_t)strEndStr - (ptrdiff_t)strCurrPos);
if (iStrLen > 255)
return;
strncpy(strWorkBuff, strCurrPos, iStrLen);
strWorkBuff[iStrLen] = '\0';
LoadExtByName(strWorkBuff);
strCurrPos = strEndStr + 1;
if (iStop) break;
}
}
static int ProcExtsFromExtList(void)
{
GLint iLoop;
GLint iNumExtensions = 0;
if (_ptrc_glGetStringi == NULL) return 0;
_ptrc_glGetIntegerv(GL_NUM_EXTENSIONS, &iNumExtensions);
for(iLoop = 0; iLoop < iNumExtensions; iLoop++)
@ -2459,6 +2497,8 @@ static void ProcExtsFromExtList(void)
const char *strExtensionName = (const char *)_ptrc_glGetStringi(GL_EXTENSIONS, iLoop);
LoadExtByName(strExtensionName);
}
return iNumExtensions;
}
int ogl_LoadFunctions()
@ -2469,9 +2509,15 @@ int ogl_LoadFunctions()
_ptrc_glGetIntegerv = (void (CODEGEN_FUNCPTR *)(GLenum, GLint *))IntGetProcAddress("glGetIntegerv");
if(!_ptrc_glGetIntegerv) return ogl_LOAD_FAILED;
_ptrc_glGetStringi = (const GLubyte * (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress("glGetStringi");
if(!_ptrc_glGetStringi) return ogl_LOAD_FAILED;
ProcExtsFromExtList();
if (0 == ProcExtsFromExtList())
{
_ptrc_glGetString = (const GLubyte * (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glGetString");
if (!_ptrc_glGetString) return ogl_LOAD_FAILED;
ProcExtsFromExtString((const char *)_ptrc_glGetString(GL_EXTENSIONS));
}
numFailed = Load_Version_3_3();
if(numFailed == 0)
@ -2480,6 +2526,8 @@ int ogl_LoadFunctions()
return ogl_LOAD_SUCCEEDED + numFailed;
}
/* END OF MANUAL CHANGES, DO NOT REMOVE! */
static int g_major_version = 0;
static int g_minor_version = 0;

View file

@ -48,11 +48,11 @@ private:
public:
static unsigned int lastbound[MAX_TEXTURES];
static int lastactivetexture;
static int max_texturesize;
static int GetTexDimension(int value);
static void InitGlobalState() { for (int i = 0; i < MAX_TEXTURES; i++) lastbound[i] = 0; }
private:
short texwidth, texheight;

View file

@ -669,6 +669,12 @@ static FMaterial *last;
static int lastclamp;
static int lasttrans;
void FMaterial::InitGlobalState()
{
last = nullptr;
lastclamp = 0;
lasttrans = 0;
}
void FMaterial::Bind(int clampmode, int translation)
{

View file

@ -263,6 +263,7 @@ public:
static FMaterial *ValidateTexture(FTextureID no, bool expand, bool trans);
static void ClearLastTexture();
static void InitGlobalState();
};
#endif

View file

@ -166,7 +166,7 @@ void gl_GenerateGlobalBrightmapFromColormap()
for(int i=0;i<256;i++)
{
HasGlobalBrightmap |= GlobalBrightmap.Remap[i] == white;
if (GlobalBrightmap.Remap[i] == white) DPrintf("Marked color %d as fullbright\n",i);
if (GlobalBrightmap.Remap[i] == white) DPrintf(DMSG_NOTIFY, "Marked color %d as fullbright\n",i);
}
}
@ -290,7 +290,7 @@ void FTexture::CreateDefaultBrightmap()
if (GlobalBrightmap.Remap[texbuf[i]] == white)
{
// Create a brightmap
DPrintf("brightmap created for texture '%s'\n", Name.GetChars());
DPrintf(DMSG_NOTIFY, "brightmap created for texture '%s'\n", Name.GetChars());
gl_info.Brightmap = new FBrightmapTexture(this);
gl_info.bBrightmapChecked = 1;
TexMan.AddTexture(gl_info.Brightmap);
@ -298,7 +298,7 @@ void FTexture::CreateDefaultBrightmap()
}
}
// No bright pixels found
DPrintf("No bright pixels found in texture '%s'\n", Name.GetChars());
DPrintf(DMSG_SPAMMY, "No bright pixels found in texture '%s'\n", Name.GetChars());
gl_info.bBrightmapChecked = 1;
}
else

View file

@ -323,7 +323,7 @@ void PacketGet (void)
// Don't show the message for disconnect notifications.
if (c != 2 || TransmitBuffer[0] != PRE_FAKE || TransmitBuffer[1] != PRE_DISCONNECT)
{
DPrintf("Dropped packet: Unknown host (%s:%d)\n", inet_ntoa(fromaddress.sin_addr), fromaddress.sin_port);
DPrintf(DMSG_WARNING, "Dropped packet: Unknown host (%s:%d)\n", inet_ntoa(fromaddress.sin_addr), fromaddress.sin_port);
}
doomcom.remotenode = -1;
return;

View file

@ -1331,12 +1331,12 @@ static int CheckInventory (AActor *activator, const char *type, bool max)
if (info == NULL)
{
Printf ("ACS: I don't know what '%s' is.\n", type);
DPrintf (DMSG_ERROR, "ACS: '%s': Unknown actor class.\n", type);
return 0;
}
else if (!info->IsDescendantOf(RUNTIME_CLASS(AInventory)))
{
Printf ("ACS: '%s' is not an inventory item.\n", type);
DPrintf(DMSG_ERROR, "ACS: '%s' is not an inventory item.\n", type);
return 0;
}
@ -2237,7 +2237,7 @@ bool FBehavior::Init(int lumpnum, FileReader * fr, int len)
}
}
DPrintf ("Loaded %d scripts, %d functions\n", NumScripts, NumFunctions);
DPrintf (DMSG_NOTIFY, "Loaded %d scripts, %d functions\n", NumScripts, NumFunctions);
return true;
}
@ -2824,7 +2824,7 @@ void FBehavior::StaticStartTypedScripts (WORD type, AActor *activator, bool alwa
"Disconnect",
"Return"
};
DPrintf("Starting all scripts of type %d (%s)\n", type,
DPrintf(DMSG_NOTIFY, "Starting all scripts of type %d (%s)\n", type,
type < countof(TypeNames) ? TypeNames[type] : TypeNames[SCRIPT_Lightning - 1]);
for (unsigned int i = 0; i < StaticModules.Size(); ++i)
{
@ -6209,7 +6209,7 @@ int DLevelScript::RunScript ()
activeBehavior = savedActiveBehavior;
// fall through
case PCD_TERMINATE:
DPrintf ("%s finished\n", ScriptPresentation(script).GetChars());
DPrintf (DMSG_NOTIFY, "%s finished\n", ScriptPresentation(script).GetChars());
state = SCRIPT_PleaseRemove;
break;
@ -7646,7 +7646,7 @@ scriptwait:
if (activationline != NULL)
{
activationline->special = 0;
DPrintf("Cleared line special on line %d\n", (int)(activationline - lines));
DPrintf(DMSG_SPAMMY, "Cleared line special on line %d\n", (int)(activationline - lines));
}
break;
@ -8285,7 +8285,7 @@ scriptwait:
line->args[2] = STACK(3);
line->args[3] = STACK(2);
line->args[4] = STACK(1);
DPrintf("Set special on line %d (id %d) to %d(%d,%d,%d,%d,%d)\n",
DPrintf(DMSG_SPAMMY, "Set special on line %d (id %d) to %d(%d,%d,%d,%d,%d)\n",
linenum, STACK(7), specnum, arg0, STACK(4), STACK(3), STACK(2), STACK(1));
}
sp -= 7;
@ -9663,7 +9663,7 @@ DLevelScript::DLevelScript (AActor *who, line_t *where, int num, const ScriptPtr
PutLast();
}
DPrintf("%s started.\n", ScriptPresentation(num).GetChars());
DPrintf(DMSG_SPAMMY, "%s started.\n", ScriptPresentation(num).GetChars());
}
static void SetScriptState (int script, DLevelScript::EScriptState state)
@ -9710,12 +9710,12 @@ void P_DoDeferedScripts ()
case acsdefered_t::defsuspend:
SetScriptState (def->script, DLevelScript::SCRIPT_Suspended);
DPrintf ("Deferred suspend of %s\n", ScriptPresentation(def->script).GetChars());
DPrintf (DMSG_SPAMMY, "Deferred suspend of %s\n", ScriptPresentation(def->script).GetChars());
break;
case acsdefered_t::defterminate:
SetScriptState (def->script, DLevelScript::SCRIPT_PleaseRemove);
DPrintf ("Deferred terminate of %s\n", ScriptPresentation(def->script).GetChars());
DPrintf (DMSG_SPAMMY, "Deferred terminate of %s\n", ScriptPresentation(def->script).GetChars());
break;
}
delete def;
@ -9751,7 +9751,7 @@ static void addDefered (level_info_t *i, acsdefered_t::EType type, int script, c
def->playernum = -1;
}
i->defered = def;
DPrintf ("%s on map %s deferred\n", ScriptPresentation(script).GetChars(), i->MapName.GetChars());
DPrintf (DMSG_SPAMMY, "%s on map %s deferred\n", ScriptPresentation(script).GetChars(), i->MapName.GetChars());
}
}

View file

@ -253,7 +253,7 @@ static bool LoadScriptFile(int lumpnum, FileReader *lump, int numnodes, bool inc
if ((type == 1 && !isbinary) || (type == 2 && isbinary))
{
DPrintf("Incorrect data format for %s.", Wads.GetLumpFullName(lumpnum));
DPrintf(DMSG_ERROR, "Incorrect data format for %s.", Wads.GetLumpFullName(lumpnum));
return false;
}
@ -273,7 +273,7 @@ static bool LoadScriptFile(int lumpnum, FileReader *lump, int numnodes, bool inc
// is exactly 1516 bytes long.
if (numnodes % 1516 != 0)
{
DPrintf("Incorrect data format for %s.", Wads.GetLumpFullName(lumpnum));
DPrintf(DMSG_ERROR, "Incorrect data format for %s.", Wads.GetLumpFullName(lumpnum));
return false;
}
numnodes /= 1516;
@ -283,7 +283,7 @@ static bool LoadScriptFile(int lumpnum, FileReader *lump, int numnodes, bool inc
// And the teaser version has 1488-byte entries.
if (numnodes % 1488 != 0)
{
DPrintf("Incorrect data format for %s.", Wads.GetLumpFullName(lumpnum));
DPrintf(DMSG_ERROR, "Incorrect data format for %s.", Wads.GetLumpFullName(lumpnum));
return false;
}
numnodes /= 1488;

View file

@ -1013,7 +1013,7 @@ bool P_CheckNodes(MapData * map, bool rebuilt, int buildtime)
subsectors, numsubsectors,
vertexes, numvertexes);
endTime = I_FPSTime ();
DPrintf ("BSP generation took %.3f sec (%d segs)\n", (endTime - startTime) * 0.001, numsegs);
DPrintf (DMSG_NOTIFY, "BSP generation took %.3f sec (%d segs)\n", (endTime - startTime) * 0.001, numsegs);
buildtime = endTime - startTime;
}
}
@ -1026,12 +1026,12 @@ bool P_CheckNodes(MapData * map, bool rebuilt, int buildtime)
#endif
if (level.maptype != MAPTYPE_BUILD && gl_cachenodes && buildtime/1000.f >= gl_cachetime)
{
DPrintf("Caching nodes\n");
DPrintf(DMSG_NOTIFY, "Caching nodes\n");
CreateCachedNodes(map);
}
else
{
DPrintf("Not caching nodes (time = %f)\n", buildtime/1000.f);
DPrintf(DMSG_NOTIFY, "Not caching nodes (time = %f)\n", buildtime/1000.f);
}
}

View file

@ -362,7 +362,7 @@ bool AActor::FixMapthingPos()
if (distance < radius)
{
DPrintf("%s at (%f,%f) lies on %s line %td, distance = %f\n",
DPrintf(DMSG_NOTIFY, "%s at (%f,%f) lies on %s line %td, distance = %f\n",
this->GetClass()->TypeName.GetChars(), X(), Y(),
ldef->Delta().X == 0 ? "vertical" : ldef->Delta().Y == 0 ? "horizontal" : "diagonal",
ldef - lines, distance);

View file

@ -1690,7 +1690,7 @@ static void SetMapThingUserData(AActor *actor, unsigned udi)
if (var == NULL || (var->Flags & VARF_Native) || !var->Type->IsKindOf(RUNTIME_CLASS(PBasicType)))
{
DPrintf("%s is not a user variable in class %s\n", varname.GetChars(),
DPrintf(DMSG_WARNING, "%s is not a user variable in class %s\n", varname.GetChars(),
actor->GetClass()->TypeName.GetChars());
}
else
@ -2478,7 +2478,7 @@ int P_DetermineTranslucency (int lumpnum)
if (newcolor2.r == 255) // if black on white results in white it's either
// fully transparent or additive
{
if (developer)
if (developer >= DMSG_NOTIFY)
{
char lumpname[9];
lumpname[8] = 0;
@ -2489,7 +2489,7 @@ int P_DetermineTranslucency (int lumpnum)
return -newcolor.r;
}
if (developer)
if (developer >= DMSG_NOTIFY)
{
char lumpname[9];
lumpname[8] = 0;
@ -3029,7 +3029,7 @@ void P_LoadBlockMap (MapData * map)
Args->CheckParm("-blockmap")
)
{
DPrintf ("Generating BLOCKMAP\n");
DPrintf (DMSG_SPAMMY, "Generating BLOCKMAP\n");
P_CreateBlockMap ();
}
else
@ -3061,7 +3061,7 @@ void P_LoadBlockMap (MapData * map)
if (!P_VerifyBlockMap(count))
{
DPrintf ("Generating BLOCKMAP\n");
DPrintf (DMSG_SPAMMY, "Generating BLOCKMAP\n");
P_CreateBlockMap();
}
@ -3958,7 +3958,7 @@ void P_SetupLevel (const char *lumpname, int position)
subsectors, numsubsectors,
vertexes, numvertexes);
endTime = I_FPSTime ();
DPrintf ("BSP generation took %.3f sec (%d segs)\n", (endTime - startTime) * 0.001, numsegs);
DPrintf (DMSG_NOTIFY, "BSP generation took %.3f sec (%d segs)\n", (endTime - startTime) * 0.001, numsegs);
oldvertextable = builder.GetOldVertexTable();
reloop = true;
}

View file

@ -187,7 +187,7 @@ bool P_ActivateLine (line_t *line, AActor *mo, int side, int activationType, DVe
line->special = 0;
}
// end of changed code
if (developer && buttonSuccess)
if (developer >= DMSG_SPAMMY && buttonSuccess)
{
Printf ("Line special %d activated on line %i\n", special, int(line - lines));
}
@ -359,7 +359,7 @@ bool P_PredictLine(line_t *line, AActor *mo, int side, int activationType)
special = line->special;
// end of changed code
if (developer && buttonSuccess)
if (developer >= DMSG_SPAMMY && buttonSuccess)
{
Printf("Line special %d predicted on line %i\n", special, int(line - lines));
}

View file

@ -43,7 +43,7 @@ extern gamestate_t wipegamestate;
//
// P_CheckTickerPaused
//
// Returns true if the ticker should be paused. In that cause, it also
// Returns true if the ticker should be paused. In that case, it also
// pauses sound effects and possibly music. If the ticker should not be
// paused, then it returns false but does not unpause anything.
//

View file

@ -147,7 +147,7 @@ extern TArray<int> linemap;
void UDMFParserBase::Skip()
{
if (developer) sc.ScriptMessage("Ignoring unknown key \"%s\".", sc.String);
if (developer >= DMSG_WARNING) sc.ScriptMessage("Ignoring unknown UDMF key \"%s\".", sc.String);
if(sc.CheckToken('{'))
{
int level = 1;

View file

@ -2442,7 +2442,7 @@ void P_PlayerThink (player_t *player)
S_ChangeMusic("*");
}
}
DPrintf("MUSINFO change for player %d to %d\n", (int)(player - players), player->MUSINFOactor->args[0]);
DPrintf(DMSG_NOTIFY, "MUSINFO change for player %d to %d\n", (int)(player - players), player->MUSINFOactor->args[0]);
}
}
@ -2829,9 +2829,9 @@ void P_PredictPlayer (player_t *player)
DoLerp = (int)PredictionLast.pos.X != (int)player->mo->X() || (int)PredictionLast.pos.Y != (int)player->mo->Y();
// Aditional Debug information
if (developer && DoLerp)
if (developer >= DMSG_NOTIFY && DoLerp)
{
DPrintf("Lerp! Ltic (%d) && Ptic (%d) | Lx (%f) && Px (%f) | Ly (%f) && Py (%f)\n",
DPrintf(DMSG_NOTIFY, "Lerp! Ltic (%d) && Ptic (%d) | Lx (%f) && Px (%f) | Ly (%f) && Py (%f)\n",
PredictionLast.gametic, i,
(PredictionLast.pos.X), (player->mo->X()),
(PredictionLast.pos.Y), (player->mo->Y()));

View file

@ -148,11 +148,6 @@ CUSTOM_CVAR(Int, vid_renderer, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINIT
}
}
CUSTOM_CVAR(Int, gl_vid_multisample, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
{
Printf("This won't take effect until " GAMENAME " is restarted.\n");
}
EXTERN_CVAR(Bool, gl_smooth_rendered)
@ -1258,7 +1253,7 @@ void I_InitGraphics()
val.Bool = !!Args->CheckParm("-devparm");
ticker.SetGenericRepDefault(val, CVAR_Bool);
Video = new CocoaVideo(gl_vid_multisample);
Video = new CocoaVideo(0);
atterm(I_ShutdownGraphics);
}

View file

@ -272,18 +272,18 @@ void I_SetFPSLimit(int limit)
}
if (limit == 0)
{ // no limit
DPrintf("FPS timer disabled\n");
DPrintf(DMSG_NOTIFY, "FPS timer disabled\n");
}
else
{
FPSLimitTimerEnabled = true;
if(timer_create(CLOCK_REALTIME, &FPSLimitEvent, &FPSLimitTimer) == -1)
Printf("Failed to create FPS limitter event\n");
Printf(DMSG_WARNING, "Failed to create FPS limitter event\n");
itimerspec period = { {0, 0}, {0, 0} };
period.it_value.tv_nsec = period.it_interval.tv_nsec = 1000000000 / limit;
if(timer_settime(FPSLimitTimer, 0, &period, NULL) == -1)
Printf("Failed to set FPS limitter timer\n");
DPrintf("FPS timer set to %u ms\n", (unsigned int) period.it_interval.tv_nsec / 1000000);
Printf(DMSG_WARNING, "Failed to set FPS limitter timer\n");
DPrintf(DMSG_NOTIFY, "FPS timer set to %u ms\n", (unsigned int) period.it_interval.tv_nsec / 1000000);
}
}
#else

View file

@ -54,11 +54,6 @@ EXTERN_CVAR (Bool, cl_capfps)
// PUBLIC DATA DEFINITIONS -------------------------------------------------
CUSTOM_CVAR(Int, gl_vid_multisample, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL )
{
Printf("This won't take effect until " GAMENAME " is restarted.\n");
}
CUSTOM_CVAR(Bool, gl_debug, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
{
Printf("This won't take effect until " GAMENAME " is restarted.\n");
@ -322,17 +317,13 @@ bool SDLGLVideo::InitHardware (bool allowsoftware, int multisample)
SDLGLFB::SDLGLFB (void *, int width, int height, int, int, bool fullscreen)
: DFrameBuffer (width, height)
{
static int localmultisample=-1;
if (localmultisample<0) localmultisample=gl_vid_multisample;
int i;
m_Lock=0;
UpdatePending = false;
if (!static_cast<SDLGLVideo*>(Video)->InitHardware(false, localmultisample))
if (!static_cast<SDLGLVideo*>(Video)->InitHardware(false, 0))
{
vid_renderer = 0;
return;

View file

@ -2341,7 +2341,7 @@ void R_CheckDrawSegs ()
firstdrawseg = drawsegs + firstofs;
ds_p = drawsegs + MaxDrawSegs;
MaxDrawSegs = newdrawsegs;
DPrintf ("MaxDrawSegs increased to %zu\n", MaxDrawSegs);
DPrintf (DMSG_NOTIFY, "MaxDrawSegs increased to %zu\n", MaxDrawSegs);
}
}
@ -2360,7 +2360,7 @@ ptrdiff_t R_NewOpening (ptrdiff_t len)
maxopenings = maxopenings ? maxopenings*2 : 16384;
while ((size_t)lastopening > maxopenings);
openings = (short *)M_Realloc (openings, maxopenings * sizeof(*openings));
DPrintf ("MaxOpenings increased to %zu\n", maxopenings);
DPrintf (DMSG_NOTIFY, "MaxOpenings increased to %zu\n", maxopenings);
}
return res;
}

View file

@ -471,7 +471,7 @@ void FWadFile::SetNamespace(const char *startmarker, const char *endmarker, name
{
// We can't add this to the flats namespace but
// it needs to be flagged for the texture manager.
DPrintf("Marking %s as potential flat\n", Lumps[i].Name);
DPrintf(DMSG_NOTIFY, "Marking %s as potential flat\n", Lumps[i].Name);
Lumps[i].Flags |= LUMPF_MAYBEFLAT;
}
}
@ -517,7 +517,7 @@ void FWadFile::SetNamespace(const char *startmarker, const char *endmarker, name
}
// we found a marked block
DPrintf("Found %s block at (%d-%d)\n", startmarker, markers[start].index, end);
DPrintf(DMSG_NOTIFY, "Found %s block at (%d-%d)\n", startmarker, markers[start].index, end);
for(int j = markers[start].index + 1; j < end; j++)
{
if (Lumps[j].Namespace != ns_global)
@ -534,7 +534,7 @@ void FWadFile::SetNamespace(const char *startmarker, const char *endmarker, name
// ignore sprite lumps smaller than 8 bytes (the smallest possible)
// in size -- this was used by some dmadds wads
// as an 'empty' graphics resource
DPrintf(" Skipped empty sprite %s (lump %d)\n", Lumps[j].Name, j);
DPrintf(DMSG_WARNING, " Skipped empty sprite %s (lump %d)\n", Lumps[j].Name, j);
}
else
{

View file

@ -182,7 +182,7 @@ int FPlayList::SetPosition (int position)
{
Position = position;
}
DPrintf ("Playlist position set to %d\n", Position);
DPrintf (DMSG_NOTIFY, "Playlist position set to %d\n", Position);
return Position;
}
@ -197,7 +197,7 @@ int FPlayList::Advance ()
{
Position = 0;
}
DPrintf ("Playlist advanced to song %d\n", Position);
DPrintf (DMSG_NOTIFY, "Playlist advanced to song %d\n", Position);
return Position;
}
@ -207,7 +207,7 @@ int FPlayList::Backup ()
{
Position = Songs.Size() - 1;
}
DPrintf ("Playlist backed up to song %d\n", Position);
DPrintf (DMSG_NOTIFY, "Playlist backed up to song %d\n", Position);
return Position;
}

View file

@ -553,7 +553,7 @@ void S_UnloadSound (sfxinfo_t *sfx)
GSnd->UnloadSound(sfx->data);
sfx->data.Clear();
sfx->data3d.Clear();
DPrintf("Unloaded sound \"%s\" (%td)\n", sfx->name.GetChars(), sfx - &S_sfx[0]);
DPrintf(DMSG_NOTIFY, "Unloaded sound \"%s\" (%td)\n", sfx->name.GetChars(), sfx - &S_sfx[0]);
}
}
@ -1328,7 +1328,7 @@ sfxinfo_t *S_LoadSound(sfxinfo_t *sfx)
{
if (S_sfx[i].data.isValid() && S_sfx[i].link == sfxinfo_t::NO_LINK && S_sfx[i].lumpnum == sfx->lumpnum)
{
DPrintf ("Linked %s to %s (%d)\n", sfx->name.GetChars(), S_sfx[i].name.GetChars(), i);
DPrintf (DMSG_NOTIFY, "Linked %s to %s (%d)\n", sfx->name.GetChars(), S_sfx[i].name.GetChars(), i);
sfx->link = i;
// This is necessary to avoid using the rolloff settings of the linked sound if its
// settings are different.
@ -1337,7 +1337,7 @@ sfxinfo_t *S_LoadSound(sfxinfo_t *sfx)
}
}
DPrintf("Loading sound \"%s\" (%td)\n", sfx->name.GetChars(), sfx - &S_sfx[0]);
DPrintf(DMSG_NOTIFY, "Loading sound \"%s\" (%td)\n", sfx->name.GetChars(), sfx - &S_sfx[0]);
int size = Wads.LumpLength(sfx->lumpnum);
if (size > 0)
@ -1397,7 +1397,7 @@ static void S_LoadSound3D(sfxinfo_t *sfx)
if(sfx->data3d.isValid())
return;
DPrintf("Loading monoized sound \"%s\" (%td)\n", sfx->name.GetChars(), sfx - &S_sfx[0]);
DPrintf(DMSG_NOTIFY, "Loading monoized sound \"%s\" (%td)\n", sfx->name.GetChars(), sfx - &S_sfx[0]);
int size = Wads.LumpLength(sfx->lumpnum);
if(size <= 0) return;

View file

@ -1044,7 +1044,7 @@ void FScriptPosition::Message (int severity, const char *message, ...) const
{
FString composed;
if ((severity == MSG_DEBUG || severity == MSG_DEBUGLOG) && !developer) return;
if ((severity == MSG_DEBUG || severity == MSG_DEBUGLOG) && developer < DMSG_NOTIFY) return;
if (severity == MSG_OPTERROR)
{
severity = strictdecorate ? MSG_ERROR : MSG_WARNING;

View file

@ -386,7 +386,7 @@ short *SoundRenderer::DecodeSample(int outlen, const void *coded, int sizebytes,
decoder->getInfo(&srate, &chans, &type);
if(chans != ChannelConfig_Mono || type != SampleType_Int16)
{
DPrintf("Sample is not 16-bit mono\n");
DPrintf(DMSG_WARNING, "Sample is not 16-bit mono\n");
delete decoder;
return samples;
}
@ -522,7 +522,7 @@ std::pair<SoundHandle,bool> SoundRenderer::LoadSoundVoc(BYTE *sfxdata, int lengt
break;
default: // Unknown block type
okay = false;
DPrintf ("Unknown VOC block type %i\n", blocktype);
DPrintf (DMSG_ERROR, "Unknown VOC block type %i\n", blocktype);
break;
}
// Move to next block

View file

@ -498,12 +498,12 @@ int FluidSynthMIDIDevice::LoadPatchSets(const char *patches)
}
if (FLUID_FAILED != fluid_synth_sfload(FluidSynth, path, count == 0))
{
DPrintf("Loaded patch set %s.\n", tok);
DPrintf(DMSG_NOTIFY, "Loaded patch set %s.\n", tok);
count++;
}
else
{
DPrintf("Failed to load patch set %s.\n", tok);
DPrintf(DMSG_ERROR, "Failed to load patch set %s.\n", tok);
}
tok = strtok(NULL, delim);
}

View file

@ -376,7 +376,7 @@ bool TimidityPPMIDIDevice::LaunchTimidity ()
return false;
}
DPrintf ("cmd: \x1cG%s\n", CommandLine.GetChars());
DPrintf (DMSG_NOTIFY, "cmd: \x1cG%s\n", CommandLine.GetChars());
#ifdef _WIN32
STARTUPINFO startup = { sizeof(startup), };

View file

@ -143,7 +143,7 @@ XMISong::XMISong (FileReader &reader, EMidiDevice type, const char *args)
memset(Songs, 0, sizeof(*Songs) * NumSongs);
FindXMIDforms(MusHeader, SongLen, Songs);
CurrSong = Songs;
DPrintf("XMI song count: %d\n", NumSongs);
DPrintf(DMSG_SPAMMY, "XMI song count: %d\n", NumSongs);
}
//==========================================================================

View file

@ -747,8 +747,8 @@ OpenALSoundRenderer::OpenALSoundRenderer()
ALCint major=0, minor=0;
alcGetIntegerv(Device, ALC_MAJOR_VERSION, 1, &major);
alcGetIntegerv(Device, ALC_MINOR_VERSION, 1, &minor);
DPrintf(" ALC Version: " TEXTCOLOR_BLUE"%d.%d\n", major, minor);
DPrintf(" ALC Extensions: " TEXTCOLOR_ORANGE"%s\n", alcGetString(Device, ALC_EXTENSIONS));
DPrintf(DMSG_SPAMMY, " ALC Version: " TEXTCOLOR_BLUE"%d.%d\n", major, minor);
DPrintf(DMSG_SPAMMY, " ALC Extensions: " TEXTCOLOR_ORANGE"%s\n", alcGetString(Device, ALC_EXTENSIONS));
TArray<ALCint> attribs;
if(*snd_samplerate > 0)
@ -778,10 +778,10 @@ OpenALSoundRenderer::OpenALSoundRenderer()
}
attribs.Clear();
DPrintf(" Vendor: " TEXTCOLOR_ORANGE"%s\n", alGetString(AL_VENDOR));
DPrintf(" Renderer: " TEXTCOLOR_ORANGE"%s\n", alGetString(AL_RENDERER));
DPrintf(" Version: " TEXTCOLOR_ORANGE"%s\n", alGetString(AL_VERSION));
DPrintf(" Extensions: " TEXTCOLOR_ORANGE"%s\n", alGetString(AL_EXTENSIONS));
DPrintf(DMSG_SPAMMY, " Vendor: " TEXTCOLOR_ORANGE"%s\n", alGetString(AL_VENDOR));
DPrintf(DMSG_SPAMMY, " Renderer: " TEXTCOLOR_ORANGE"%s\n", alGetString(AL_RENDERER));
DPrintf(DMSG_SPAMMY, " Version: " TEXTCOLOR_ORANGE"%s\n", alGetString(AL_VERSION));
DPrintf(DMSG_SPAMMY, " Extensions: " TEXTCOLOR_ORANGE"%s\n", alGetString(AL_EXTENSIONS));
ALC.EXT_EFX = !!alcIsExtensionPresent(Device, "ALC_EXT_EFX");
ALC.EXT_disconnect = !!alcIsExtensionPresent(Device, "ALC_EXT_disconnect");
@ -864,7 +864,7 @@ OpenALSoundRenderer::OpenALSoundRenderer()
return;
}
FreeSfx = Sources;
DPrintf(" Allocated " TEXTCOLOR_BLUE"%u" TEXTCOLOR_NORMAL" sources\n", Sources.Size());
DPrintf(DMSG_NOTIFY, " Allocated " TEXTCOLOR_BLUE"%u" TEXTCOLOR_NORMAL" sources\n", Sources.Size());
WasInWater = false;
if(*snd_efx && ALC.EXT_EFX)
@ -913,10 +913,10 @@ OpenALSoundRenderer::OpenALSoundRenderer()
{
alEffecti(envReverb, AL_EFFECT_TYPE, AL_EFFECT_EAXREVERB);
if(alGetError() == AL_NO_ERROR)
DPrintf(" EAX Reverb found\n");
DPrintf(DMSG_SPAMMY, " EAX Reverb found\n");
alEffecti(envReverb, AL_EFFECT_TYPE, AL_EFFECT_REVERB);
if(alGetError() == AL_NO_ERROR)
DPrintf(" Standard Reverb found\n");
DPrintf(DMSG_SPAMMY, " Standard Reverb found\n");
alDeleteEffects(1, &envReverb);
getALError();
@ -929,7 +929,7 @@ OpenALSoundRenderer::OpenALSoundRenderer()
alFilteri(EnvFilters[0], AL_FILTER_TYPE, AL_FILTER_LOWPASS);
alFilteri(EnvFilters[1], AL_FILTER_TYPE, AL_FILTER_LOWPASS);
if(getALError() == AL_NO_ERROR)
DPrintf(" Lowpass found\n");
DPrintf(DMSG_SPAMMY, " Lowpass found\n");
else
{
alDeleteFilters(2, EnvFilters);
@ -1194,7 +1194,7 @@ std::pair<SoundHandle,bool> OpenALSoundRenderer::LoadSoundRaw(BYTE *sfxdata, int
loopend = length / (channels*bits/8);
ALint loops[2] = { loopstart, loopend };
DPrintf("Setting loop points %d -> %d\n", loops[0], loops[1]);
DPrintf(DMSG_NOTIFY, "Setting loop points %d -> %d\n", loops[0], loops[1]);
alBufferiv(buffer, AL_LOOP_POINTS_SOFT, loops);
getALError();
}
@ -1202,7 +1202,7 @@ std::pair<SoundHandle,bool> OpenALSoundRenderer::LoadSoundRaw(BYTE *sfxdata, int
{
static bool warned = false;
if(!warned)
Printf("Loop points not supported!\n");
Printf(DMSG_WARNING, "Loop points not supported!\n");
warned = true;
}
@ -1867,7 +1867,7 @@ void OpenALSoundRenderer::UpdateListener(SoundListener *listener)
if(env != PrevEnvironment || env->Modified)
{
PrevEnvironment = env;
DPrintf("Reverb Environment %s\n", env->Name);
DPrintf(DMSG_NOTIFY, "Reverb Environment %s\n", env->Name);
if(EnvSlot != 0)
LoadReverb(env);

View file

@ -53,7 +53,7 @@ enum
STAT_BOSSTARGET, // A boss brain target
STAT_LIGHTNING, // The lightning thinker
STAT_DECALTHINKER, // An object that thinks for a decal
UNUSED_STAT_INVENTORY, // An inventory item (value kept for savegame compatibility.)
STAT_INVENTORY, // An inventory item
STAT_LIGHT, // A sector light effect
STAT_LIGHTTRANSFER, // A sector light transfer. These must be ticked after the light effects!!!
STAT_EARTHQUAKE, // Earthquake actors

View file

@ -908,11 +908,12 @@ void DFrameBuffer::DrawRateStuff ()
// Drawing it as a texture does and continues to show how
// well the PalTex shader is working.
static FPaletteTester palette;
int size = screen->GetHeight() < 800 ? 16 * 7 : 16 * 7 * 2;
palette.SetTranslation(vid_showpalette);
DrawTexture(&palette, 0, 0,
DTA_DestWidth, 16*7,
DTA_DestHeight, 16*7,
DTA_DestWidth, size,
DTA_DestHeight, size,
DTA_Masked, false,
TAG_DONE);
}

View file

@ -40,11 +40,6 @@ PFNWGLCREATECONTEXTATTRIBSARBPROC myWglCreateContextAttribsARB;
PFNWGLSWAPINTERVALEXTPROC vsyncfunc;
CUSTOM_CVAR(Int, gl_vid_multisample, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL )
{
Printf("This won't take effect until " GAMENAME " is restarted.\n");
}
CUSTOM_CVAR(Bool, gl_debug, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
{
Printf("This won't take effect until " GAMENAME " is restarted.\n");
@ -911,10 +906,6 @@ IMPLEMENT_ABSTRACT_CLASS(Win32GLFrameBuffer)
Win32GLFrameBuffer::Win32GLFrameBuffer(void *hMonitor, int width, int height, int bits, int refreshHz, bool fullscreen) : BaseWinFB(width, height)
{
static int localmultisample=-1;
if (localmultisample<0) localmultisample=gl_vid_multisample;
m_Width = width;
m_Height = height;
m_Bits = bits;
@ -981,7 +972,7 @@ Win32GLFrameBuffer::Win32GLFrameBuffer(void *hMonitor, int width, int height, in
I_RestoreWindowedPos();
}
if (!static_cast<Win32GLVideo *>(Video)->InitHardware(Window, localmultisample))
if (!static_cast<Win32GLVideo *>(Video)->InitHardware(Window, 0))
{
vid_renderer = 0;
return;

View file

@ -194,7 +194,7 @@ void I_SetFPSLimit(int limit)
CloseHandle(FPSLimitEvent);
FPSLimitEvent = NULL;
}
DPrintf("FPS timer disabled\n");
DPrintf(DMSG_NOTIFY, "FPS timer disabled\n");
}
else
{
@ -203,7 +203,7 @@ void I_SetFPSLimit(int limit)
FPSLimitEvent = CreateEvent(NULL, FALSE, TRUE, NULL);
if (FPSLimitEvent == NULL)
{ // Could not create event, so cannot use timer.
Printf("Failed to create FPS limitter event\n");
Printf(DMSG_WARNING, "Failed to create FPS limitter event\n");
return;
}
}
@ -218,7 +218,7 @@ void I_SetFPSLimit(int limit)
Printf("Failed to create FPS limitter timer\n");
return;
}
DPrintf("FPS timer set to %u ms\n", period);
DPrintf(DMSG_NOTIFY, "FPS timer set to %u ms\n", period);
}
}

View file

@ -1957,6 +1957,7 @@ MSGMNU_TEAMMESSAGES = "Team Messages";
MSGMNU_CENTEREDMESSAGES = "Centered Messages";
MSGMNU_SCREENSHOTMESSAGES = "Screenshot messages";
MSGMNU_LONGSAVEMESSAGES = "Detailed save messages";
MSGMNU_DEVELOPER = "Developer message mode";
// Scoreboard Options
SCRBRDMNU_TITLE = "SCOREBOARD OPTIONS";
@ -2287,6 +2288,10 @@ OPTVAL_SINC = "Sinc";
OPTVAL_NOTEONOFFONLY = "Note on/off only";
OPTVAL_FULLRAMPING = "Full ramping";
OPTVAL_ALLUNACKNOWLEDGED = "All unacknowledged";
OPTVAL_ERRORS = "Errors";
OPTVAL_WARNINGS = "Warnings";
OPTVAL_NOTIFICATIONS = "Notifications";
OPTVAL_EVERYTHING = "Everything";
OPTVAL_FULLSCREENONLY = "Fullscreen only";
// Colors
C_BRICK = "\cabrick";

View file

@ -1131,6 +1131,15 @@ OptionValue MessageLevels
2.0, "$OPTVAL_CRITICALMESSAGES"
}
OptionValue DevMessageLevels
{
0, "$OPTVAL_OFF"
1, "$OPTVAL_ERRORS"
2, "$OPTVAL_WARNINGS"
3, "$OPTVAL_NOTIFICATIONS"
4, "$OPTVAL_EVERYTHING"
}
OptionMenu MessageOptions
{
Title "$MSGMNU_TITLE"
@ -1139,6 +1148,7 @@ OptionMenu MessageOptions
Option "$MSGMNU_SHOWSECRETS", "cl_showsecretmessage", "OnOff"
Option "$MSGMNU_SCALETEXT", "con_scaletext", "ScaleValues"
Option "$MSGMNU_MESSAGELEVEL", "msg", "MessageLevels"
Option "$MSGMNU_DEVELOPER", "developer", "DevMessageLevels"
Option "$MSGMNU_CENTERMESSAGES", "con_centernotify", "OnOff"
StaticText " "
StaticText "$MSGMNU_MESSAGECOLORS", 1