mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-11 07:12:16 +00:00
- moved the BarShader textures into the texture manager so that ZScript can use them. ZScript only knows about TextureIDs, but those require the texture to be handled by the texture manager.
This commit is contained in:
parent
bb04eea996
commit
bc95e5180d
4 changed files with 146 additions and 81 deletions
|
@ -1190,6 +1190,7 @@ set (PCH_SOURCES
|
|||
textures/rawpagetexture.cpp
|
||||
textures/emptytexture.cpp
|
||||
textures/backdroptexture.cpp
|
||||
textures/shadertexture.cpp
|
||||
textures/texture.cpp
|
||||
textures/texturemanager.cpp
|
||||
textures/tgatexture.cpp
|
||||
|
|
|
@ -2032,7 +2032,7 @@ class CommandDrawShader : public SBarInfoCommand
|
|||
|
||||
void Draw(const SBarInfoMainBlock *block, const DSBarInfo *statusBar)
|
||||
{
|
||||
statusBar->DrawGraphic(&shaders[(vertical<<1) + reverse], x, y, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets(), false, false, 0, true, width, height);
|
||||
statusBar->DrawGraphic(shaders[(vertical<<1) + reverse], x, y, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets(), false, false, 0, true, width, height);
|
||||
}
|
||||
void Parse(FScanner &sc, bool fullScreenOffsets)
|
||||
{
|
||||
|
@ -2063,6 +2063,10 @@ class CommandDrawShader : public SBarInfoCommand
|
|||
}
|
||||
GetCoordinates(sc, fullScreenOffsets, x, y);
|
||||
sc.MustGetToken(';');
|
||||
shaders[0] = TexMan.FindTexture("BarShaderHF");
|
||||
shaders[1] = TexMan.FindTexture("BarShaderHR");
|
||||
shaders[2] = TexMan.FindTexture("BarShaderVF");
|
||||
shaders[3] = TexMan.FindTexture("BarShaderVR");
|
||||
}
|
||||
protected:
|
||||
bool vertical;
|
||||
|
@ -2072,87 +2076,8 @@ class CommandDrawShader : public SBarInfoCommand
|
|||
SBarInfoCoordinate x;
|
||||
SBarInfoCoordinate y;
|
||||
private:
|
||||
class FBarShader : public FTexture
|
||||
{
|
||||
public:
|
||||
FBarShader(bool vertical, bool reverse)
|
||||
{
|
||||
int i;
|
||||
|
||||
Width = vertical ? 2 : 256;
|
||||
Height = vertical ? 256 : 2;
|
||||
CalcBitSize();
|
||||
|
||||
// Fill the column/row with shading values.
|
||||
// Vertical shaders have have minimum alpha at the top
|
||||
// and maximum alpha at the bottom, unless flipped by
|
||||
// setting reverse to true. Horizontal shaders are just
|
||||
// the opposite.
|
||||
if (vertical)
|
||||
{
|
||||
if (!reverse)
|
||||
{
|
||||
for (i = 0; i < 256; ++i)
|
||||
{
|
||||
Pixels[i] = i;
|
||||
Pixels[256+i] = i;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < 256; ++i)
|
||||
{
|
||||
Pixels[i] = 255 - i;
|
||||
Pixels[256+i] = 255 -i;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!reverse)
|
||||
{
|
||||
for (i = 0; i < 256; ++i)
|
||||
{
|
||||
Pixels[i*2] = 255 - i;
|
||||
Pixels[i*2+1] = 255 - i;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < 256; ++i)
|
||||
{
|
||||
Pixels[i*2] = i;
|
||||
Pixels[i*2+1] = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
DummySpan[0].TopOffset = 0;
|
||||
DummySpan[0].Length = vertical ? 256 : 2;
|
||||
DummySpan[1].TopOffset = 0;
|
||||
DummySpan[1].Length = 0;
|
||||
}
|
||||
const uint8_t *GetColumn(unsigned int column, const Span **spans_out)
|
||||
{
|
||||
if (spans_out != NULL)
|
||||
{
|
||||
*spans_out = DummySpan;
|
||||
}
|
||||
return Pixels + ((column & WidthMask) << HeightBits);
|
||||
}
|
||||
const uint8_t *GetPixels() { return Pixels; }
|
||||
void Unload() {}
|
||||
private:
|
||||
uint8_t Pixels[512];
|
||||
Span DummySpan[2];
|
||||
};
|
||||
|
||||
static FBarShader shaders[4];
|
||||
};
|
||||
|
||||
CommandDrawShader::FBarShader CommandDrawShader::shaders[4] =
|
||||
{
|
||||
FBarShader(false, false), FBarShader(false, true),
|
||||
FBarShader(true, false), FBarShader(true, true)
|
||||
FTexture *shaders[4];
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
133
src/textures/shadertexture.cpp
Normal file
133
src/textures/shadertexture.cpp
Normal file
|
@ -0,0 +1,133 @@
|
|||
/*
|
||||
** shadertexture.cpp
|
||||
**
|
||||
** simple shader gradient textures, used by the status bars.
|
||||
**
|
||||
**---------------------------------------------------------------------------
|
||||
** Copyright 2008 Braden Obrzut
|
||||
** Copyright 2017 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.
|
||||
**---------------------------------------------------------------------------
|
||||
**
|
||||
*/
|
||||
|
||||
#include "doomtype.h"
|
||||
#include "doomstat.h"
|
||||
#include "d_player.h"
|
||||
#include "templates.h"
|
||||
#include "menu/menu.h"
|
||||
#include "colormatcher.h"
|
||||
#include "textures/textures.h"
|
||||
#include "w_wad.h"
|
||||
#include "v_font.h"
|
||||
#include "v_video.h"
|
||||
#include "g_level.h"
|
||||
#include "gi.h"
|
||||
#include "r_defs.h"
|
||||
#include "r_state.h"
|
||||
#include "r_data/r_translate.h"
|
||||
|
||||
|
||||
class FBarShader : public FTexture
|
||||
{
|
||||
public:
|
||||
FBarShader(bool vertical, bool reverse)
|
||||
{
|
||||
int i;
|
||||
|
||||
Name.Format("BarShader%c%c", vertical ? 'v' : 'h', reverse ? 'r' : 'f');
|
||||
Width = vertical ? 2 : 256;
|
||||
Height = vertical ? 256 : 2;
|
||||
CalcBitSize();
|
||||
|
||||
// Fill the column/row with shading values.
|
||||
// Vertical shaders have have minimum alpha at the top
|
||||
// and maximum alpha at the bottom, unless flipped by
|
||||
// setting reverse to true. Horizontal shaders are just
|
||||
// the opposite.
|
||||
if (vertical)
|
||||
{
|
||||
if (!reverse)
|
||||
{
|
||||
for (i = 0; i < 256; ++i)
|
||||
{
|
||||
Pixels[i] = i;
|
||||
Pixels[256+i] = i;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < 256; ++i)
|
||||
{
|
||||
Pixels[i] = 255 - i;
|
||||
Pixels[256+i] = 255 -i;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!reverse)
|
||||
{
|
||||
for (i = 0; i < 256; ++i)
|
||||
{
|
||||
Pixels[i*2] = 255 - i;
|
||||
Pixels[i*2+1] = 255 - i;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < 256; ++i)
|
||||
{
|
||||
Pixels[i*2] = i;
|
||||
Pixels[i*2+1] = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
DummySpan[0].TopOffset = 0;
|
||||
DummySpan[0].Length = vertical ? 256 : 2;
|
||||
DummySpan[1].TopOffset = 0;
|
||||
DummySpan[1].Length = 0;
|
||||
}
|
||||
const uint8_t *GetColumn(unsigned int column, const Span **spans_out)
|
||||
{
|
||||
if (spans_out != NULL)
|
||||
{
|
||||
*spans_out = DummySpan;
|
||||
}
|
||||
return Pixels + ((column & WidthMask) << HeightBits);
|
||||
}
|
||||
const uint8_t *GetPixels() { return Pixels; }
|
||||
void Unload() {}
|
||||
private:
|
||||
uint8_t Pixels[512];
|
||||
Span DummySpan[2];
|
||||
};
|
||||
|
||||
|
||||
FTexture *CreateShaderTexture(bool vertical, bool reverse)
|
||||
{
|
||||
return new FBarShader(vertical, reverse);
|
||||
}
|
|
@ -977,6 +977,7 @@ void FTextureManager::SortTexturesByType(int start, int end)
|
|||
//
|
||||
//==========================================================================
|
||||
FTexture *GetBackdropTexture();
|
||||
FTexture *CreateShaderTexture(bool, bool);
|
||||
|
||||
void FTextureManager::Init()
|
||||
{
|
||||
|
@ -988,7 +989,12 @@ void FTextureManager::Init()
|
|||
|
||||
// Texture 0 is a dummy texture used to indicate "no texture"
|
||||
AddTexture (new FDummyTexture);
|
||||
// some special textures used in the game.
|
||||
AddTexture(GetBackdropTexture());
|
||||
AddTexture(CreateShaderTexture(false, false));
|
||||
AddTexture(CreateShaderTexture(false, true));
|
||||
AddTexture(CreateShaderTexture(true, false));
|
||||
AddTexture(CreateShaderTexture(true, true));
|
||||
|
||||
int wadcnt = Wads.GetNumWads();
|
||||
for(int i = 0; i< wadcnt; i++)
|
||||
|
|
Loading…
Reference in a new issue