2019-10-20 08:07:12 +02:00
|
|
|
/*
|
|
|
|
** gl_texture.cpp
|
|
|
|
** high level GL texture interface
|
|
|
|
**
|
|
|
|
**---------------------------------------------------------------------------
|
|
|
|
** Copyright 2019 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.
|
|
|
|
**
|
|
|
|
** 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.
|
|
|
|
**---------------------------------------------------------------------------
|
|
|
|
**
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
|
2019-10-20 08:02:45 +02:00
|
|
|
#include "palette.h"
|
2013-05-15 02:17:17 +00:00
|
|
|
#include "build.h"
|
|
|
|
#include "polymost.h"
|
2019-10-10 23:29:13 +02:00
|
|
|
#include "textures.h"
|
|
|
|
#include "bitmap.h"
|
2019-11-05 23:35:38 +01:00
|
|
|
#include "v_font.h"
|
2020-05-23 14:40:54 +02:00
|
|
|
#include "palettecontainer.h"
|
2019-10-10 23:29:13 +02:00
|
|
|
#include "../../glbackend/glbackend.h"
|
2020-05-27 22:54:20 +02:00
|
|
|
#include "texturemanager.h"
|
2020-05-29 15:55:08 +02:00
|
|
|
#include "v_video.h"
|
2019-03-01 08:51:50 +00:00
|
|
|
|
2019-10-18 11:37:07 +02:00
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// Retrieve the texture to be used.
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
2020-08-14 21:18:14 +02:00
|
|
|
// Test CVARs.
|
|
|
|
#ifdef _DEBUG
|
|
|
|
CVAR(Int, fixpalette, -1, 0)
|
|
|
|
CVAR(Int, fixpalswap, -1, 0)
|
|
|
|
#endif
|
|
|
|
|
2020-09-13 21:08:10 +02:00
|
|
|
bool GLInstance::SetTexture(int picnum, FGameTexture* tex, int paletteid, int sampler, bool notindexed)
|
2020-05-29 21:53:28 +02:00
|
|
|
{
|
2020-08-14 21:18:14 +02:00
|
|
|
#ifdef _DEBUG
|
|
|
|
int basepal = GetTranslationType(paletteid) - Translation_Remap;
|
|
|
|
int translation = GetTranslationIndex(paletteid);
|
|
|
|
int usepalette = fixpalette >= 0 ? fixpalette : basepal;
|
|
|
|
int usepalswap = fixpalswap >= 0 ? fixpalswap : translation;
|
|
|
|
paletteid = TRANSLATION(Translation_Remap + usepalette, usepalswap);
|
|
|
|
#endif
|
|
|
|
|
2020-05-30 21:45:17 +02:00
|
|
|
TexturePick texpick;
|
|
|
|
if (!PickTexture(picnum, tex, paletteid, texpick)) return false;
|
2020-05-29 21:53:28 +02:00
|
|
|
|
2020-05-30 21:45:17 +02:00
|
|
|
int TextureType = (texpick.translation & 0x80000000) ? TT_INDEXED : TT_TRUECOLOR;
|
2020-05-31 23:08:56 +02:00
|
|
|
if (TextureType == TT_INDEXED)
|
|
|
|
{
|
2020-06-07 10:15:31 +02:00
|
|
|
sampler = sampler + CLAMP_NOFILTER - CLAMP_NONE;
|
2020-05-31 23:08:56 +02:00
|
|
|
}
|
2019-10-17 21:44:34 +02:00
|
|
|
|
|
|
|
|
2020-05-30 21:45:17 +02:00
|
|
|
// This is intentionally the same value for both parameters. The shader does not use the same uniform for modulation and overlay colors.
|
2020-06-11 18:40:53 +02:00
|
|
|
SetTinting(texpick.tintFlags, texpick.tintColor, texpick.tintColor);
|
2020-06-15 20:09:49 +02:00
|
|
|
int lookuppal = texpick.translation & 0x7fffffff;
|
|
|
|
SetPalswap(GetTranslationIndex(lookuppal));
|
2020-05-30 20:33:59 +02:00
|
|
|
|
2020-06-11 18:40:53 +02:00
|
|
|
SetBasepalTint(texpick.basepalTint);
|
2020-05-30 21:45:17 +02:00
|
|
|
auto &mat = renderState.mMaterial;
|
2020-09-13 23:14:44 +02:00
|
|
|
int flags = (TextureType == TT_INDEXED) ? CTF_Indexed : 0;
|
2020-09-10 20:52:40 +02:00
|
|
|
mat.mMaterial = FMaterial::ValidateTexture(texpick.texture, flags); // todo allow scaling
|
2020-05-30 21:45:17 +02:00
|
|
|
mat.mClampMode = sampler;
|
|
|
|
mat.mTranslation = texpick.translation;
|
2020-09-12 21:23:14 +02:00
|
|
|
mat.mOverrideShader = -1;
|
2020-05-30 21:45:17 +02:00
|
|
|
mat.mChanged = true;
|
2020-05-29 23:33:26 +02:00
|
|
|
GLInterface.SetAlphaThreshold(tex->alphaThreshold);
|
2019-10-18 19:06:57 +02:00
|
|
|
return true;
|
2019-10-17 21:44:34 +02:00
|
|
|
}
|
2017-06-27 02:24:34 +00:00
|
|
|
|
2019-11-05 23:35:38 +01:00
|
|
|
//===========================================================================
|
|
|
|
//
|
2020-05-29 15:55:08 +02:00
|
|
|
// stand-ins for the texture system. Nothing of this is used right now, but needs to be present to satisfy the linker
|
2019-11-05 23:35:38 +01:00
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
2020-05-24 21:19:33 +02:00
|
|
|
void InitBuildTiles()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
TArray<UserShaderDesc> usershaders;
|
2020-05-31 10:24:04 +02:00
|
|
|
|
|
|
|
void UpdateVRModes(bool considerQuadBuffered = true)
|
|
|
|
{
|
|
|
|
// should update the menu.
|
|
|
|
}
|