mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-10 23:01:59 +00:00
- fixed last commit.
This commit is contained in:
parent
0ae371f3ce
commit
0127a71974
7 changed files with 20 additions and 33 deletions
|
@ -625,7 +625,7 @@ void FGLRenderer::CreateTonemapPalette()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mTonemapPalette = new FHardwareTexture(512, 512, true);
|
mTonemapPalette = new FHardwareTexture(true);
|
||||||
mTonemapPalette->CreateTexture(&lut[0], 512, 512, 0, false, 0, "mTonemapPalette");
|
mTonemapPalette->CreateTexture(&lut[0], 512, 512, 0, false, 0, "mTonemapPalette");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
//#include <direct.h>
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
@ -20,20 +19,12 @@
|
||||||
#endif
|
#endif
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#define F_OK 0 /* Check for file existence */
|
|
||||||
#define W_OK 2 /* Check for write permission */
|
|
||||||
#define R_OK 4 /* Check for read permission */
|
|
||||||
#include <io.h>
|
|
||||||
#else
|
|
||||||
#include <unistd.h>
|
|
||||||
#endif
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
//GL headers
|
//GL headers
|
||||||
#include "gl_load.h"
|
#include "gl_load/gl_load.h"
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
#include <OpenGL/OpenGL.h>
|
#include <OpenGL/OpenGL.h>
|
||||||
|
|
|
@ -120,7 +120,7 @@ bool OpenGLFrameBuffer::WipeStartScreen(int type)
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto &viewport = GLRenderer->mScreenViewport;
|
const auto &viewport = GLRenderer->mScreenViewport;
|
||||||
wipestartscreen = new FHardwareTexture(viewport.width, viewport.height, true);
|
wipestartscreen = new FHardwareTexture(true);
|
||||||
wipestartscreen->CreateTexture(NULL, viewport.width, viewport.height, 0, false, 0, "WipeStartScreen");
|
wipestartscreen->CreateTexture(NULL, viewport.width, viewport.height, 0, false, 0, "WipeStartScreen");
|
||||||
GLRenderer->mSamplerManager->Bind(0, CLAMP_NOFILTER, -1);
|
GLRenderer->mSamplerManager->Bind(0, CLAMP_NOFILTER, -1);
|
||||||
GLRenderer->mSamplerManager->Bind(1, CLAMP_NONE, -1);
|
GLRenderer->mSamplerManager->Bind(1, CLAMP_NONE, -1);
|
||||||
|
@ -167,7 +167,7 @@ bool OpenGLFrameBuffer::WipeStartScreen(int type)
|
||||||
void OpenGLFrameBuffer::WipeEndScreen()
|
void OpenGLFrameBuffer::WipeEndScreen()
|
||||||
{
|
{
|
||||||
const auto &viewport = GLRenderer->mScreenViewport;
|
const auto &viewport = GLRenderer->mScreenViewport;
|
||||||
wipeendscreen = new FHardwareTexture(viewport.width, viewport.height, true);
|
wipeendscreen = new FHardwareTexture(true);
|
||||||
wipeendscreen->CreateTexture(NULL, viewport.width, viewport.height, 0, false, 0, "WipeEndScreen");
|
wipeendscreen->CreateTexture(NULL, viewport.width, viewport.height, 0, false, 0, "WipeEndScreen");
|
||||||
GLRenderer->mSamplerManager->Bind(0, CLAMP_NOFILTER, -1);
|
GLRenderer->mSamplerManager->Bind(0, CLAMP_NOFILTER, -1);
|
||||||
glFinish();
|
glFinish();
|
||||||
|
@ -511,7 +511,7 @@ bool OpenGLFrameBuffer::Wiper_Burn::Run(int ticks, OpenGLFrameBuffer *fb)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BurnTexture != NULL) delete BurnTexture;
|
if (BurnTexture != NULL) delete BurnTexture;
|
||||||
BurnTexture = new FHardwareTexture(WIDTH, HEIGHT, true);
|
BurnTexture = new FHardwareTexture(true);
|
||||||
|
|
||||||
// Update the burn texture with the new burn data
|
// Update the burn texture with the new burn data
|
||||||
uint8_t rgb_buffer[WIDTH*HEIGHT*4];
|
uint8_t rgb_buffer[WIDTH*HEIGHT*4];
|
||||||
|
|
|
@ -85,7 +85,7 @@ static void ResampleBoxPrecalc(TArray<BoxPrecalc>& boxes, int oldDim)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FHardwareTexture::Resize(int width, int height, unsigned char *src_data, unsigned char *dst_data)
|
void FHardwareTexture::Resize(int swidth, int sheight, int width, int height, unsigned char *src_data, unsigned char *dst_data)
|
||||||
{
|
{
|
||||||
|
|
||||||
// This function implements a simple pre-blur/box averaging method for
|
// This function implements a simple pre-blur/box averaging method for
|
||||||
|
@ -96,8 +96,8 @@ void FHardwareTexture::Resize(int width, int height, unsigned char *src_data, un
|
||||||
TArray<BoxPrecalc> vPrecalcs(height, true);
|
TArray<BoxPrecalc> vPrecalcs(height, true);
|
||||||
TArray<BoxPrecalc> hPrecalcs(width, true);
|
TArray<BoxPrecalc> hPrecalcs(width, true);
|
||||||
|
|
||||||
ResampleBoxPrecalc(vPrecalcs, texheight);
|
ResampleBoxPrecalc(vPrecalcs, sheight);
|
||||||
ResampleBoxPrecalc(hPrecalcs, texwidth);
|
ResampleBoxPrecalc(hPrecalcs, swidth);
|
||||||
|
|
||||||
int averaged_pixels, averaged_alpha, src_pixel_index;
|
int averaged_pixels, averaged_alpha, src_pixel_index;
|
||||||
double sum_r, sum_g, sum_b, sum_a;
|
double sum_r, sum_g, sum_b, sum_a;
|
||||||
|
@ -122,7 +122,7 @@ void FHardwareTexture::Resize(int width, int height, unsigned char *src_data, un
|
||||||
for (int i = hPrecalc.boxStart; i <= hPrecalc.boxEnd; ++i)
|
for (int i = hPrecalc.boxStart; i <= hPrecalc.boxEnd; ++i)
|
||||||
{
|
{
|
||||||
// Calculate the actual index in our source pixels
|
// Calculate the actual index in our source pixels
|
||||||
src_pixel_index = j * texwidth + i;
|
src_pixel_index = j * swidth + i;
|
||||||
|
|
||||||
int a = src_data[src_pixel_index * 4 + 3];
|
int a = src_data[src_pixel_index * 4 + 3];
|
||||||
if (a > 0) // do not use color from fully transparent pixels
|
if (a > 0) // do not use color from fully transparent pixels
|
||||||
|
@ -179,8 +179,6 @@ unsigned int FHardwareTexture::CreateTexture(unsigned char * buffer, int w, int
|
||||||
|
|
||||||
if (!buffer)
|
if (!buffer)
|
||||||
{
|
{
|
||||||
w=texwidth;
|
|
||||||
h=abs(texheight);
|
|
||||||
rw = GetTexDimension (w);
|
rw = GetTexDimension (w);
|
||||||
rh = GetTexDimension (h);
|
rh = GetTexDimension (h);
|
||||||
|
|
||||||
|
@ -201,12 +199,15 @@ unsigned int FHardwareTexture::CreateTexture(unsigned char * buffer, int w, int
|
||||||
unsigned char * scaledbuffer=(unsigned char *)calloc(4,rw * (rh+1));
|
unsigned char * scaledbuffer=(unsigned char *)calloc(4,rw * (rh+1));
|
||||||
if (scaledbuffer)
|
if (scaledbuffer)
|
||||||
{
|
{
|
||||||
Resize(rw, rh, buffer, scaledbuffer);
|
Resize(w, h, rw, rh, buffer, scaledbuffer);
|
||||||
deletebuffer=true;
|
deletebuffer=true;
|
||||||
buffer=scaledbuffer;
|
buffer=scaledbuffer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// store the physical size.
|
||||||
|
texwidth = rw;
|
||||||
|
texheight = rh;
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, texformat, rw, rh, 0, GL_BGRA, GL_UNSIGNED_BYTE, buffer);
|
glTexImage2D(GL_TEXTURE_2D, 0, texformat, rw, rh, 0, GL_BGRA, GL_UNSIGNED_BYTE, buffer);
|
||||||
|
|
||||||
if (deletebuffer) free(buffer);
|
if (deletebuffer) free(buffer);
|
||||||
|
@ -227,11 +228,9 @@ unsigned int FHardwareTexture::CreateTexture(unsigned char * buffer, int w, int
|
||||||
// Creates a texture
|
// Creates a texture
|
||||||
//
|
//
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
FHardwareTexture::FHardwareTexture(int _width, int _height, bool nocompression)
|
FHardwareTexture::FHardwareTexture(bool nocompression)
|
||||||
{
|
{
|
||||||
forcenocompression = nocompression;
|
forcenocompression = nocompression;
|
||||||
texwidth=_width;
|
|
||||||
texheight=_height;
|
|
||||||
|
|
||||||
glDefTex.glTexID = 0;
|
glDefTex.glTexID = 0;
|
||||||
glDefTex.translation = 0;
|
glDefTex.translation = 0;
|
||||||
|
|
|
@ -60,7 +60,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
short texwidth, texheight;
|
short texwidth = 0, texheight = 0;
|
||||||
bool forcenocompression;
|
bool forcenocompression;
|
||||||
|
|
||||||
TranslatedTexture glDefTex;
|
TranslatedTexture glDefTex;
|
||||||
|
@ -70,10 +70,10 @@ private:
|
||||||
TranslatedTexture * GetTexID(int translation);
|
TranslatedTexture * GetTexID(int translation);
|
||||||
|
|
||||||
int GetDepthBuffer();
|
int GetDepthBuffer();
|
||||||
void Resize(int width, int height, unsigned char *src_data, unsigned char *dst_data);
|
void Resize(int swidth, int sheight, int width, int height, unsigned char *src_data, unsigned char *dst_data);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FHardwareTexture(int w, int h, bool nocompress);
|
FHardwareTexture(bool nocompress);
|
||||||
~FHardwareTexture();
|
~FHardwareTexture();
|
||||||
|
|
||||||
static void Unbind(int texunit);
|
static void Unbind(int texunit);
|
||||||
|
|
|
@ -69,7 +69,6 @@ FGLTexture::FGLTexture(FTexture * tx, bool expandpatches)
|
||||||
tex = tx;
|
tex = tx;
|
||||||
|
|
||||||
mHwTexture = NULL;
|
mHwTexture = NULL;
|
||||||
bExpandFlag = expandpatches;
|
|
||||||
lastSampler = 254;
|
lastSampler = 254;
|
||||||
lastTranslation = -1;
|
lastTranslation = -1;
|
||||||
tex->gl_info.SystemTexture[expandpatches] = this;
|
tex->gl_info.SystemTexture[expandpatches] = this;
|
||||||
|
@ -131,7 +130,7 @@ FHardwareTexture *FGLTexture::CreateHwTexture()
|
||||||
if (tex->UseType==ETextureType::Null) return NULL; // Cannot register a NULL texture
|
if (tex->UseType==ETextureType::Null) return NULL; // Cannot register a NULL texture
|
||||||
if (mHwTexture == NULL)
|
if (mHwTexture == NULL)
|
||||||
{
|
{
|
||||||
mHwTexture = new FHardwareTexture(tex->GetWidth() + bExpandFlag*2, tex->GetHeight() + bExpandFlag*2, tex->gl_info.bNoCompress);
|
mHwTexture = new FHardwareTexture(tex->gl_info.bNoCompress);
|
||||||
}
|
}
|
||||||
return mHwTexture;
|
return mHwTexture;
|
||||||
}
|
}
|
||||||
|
@ -627,7 +626,7 @@ void FMaterial::Bind(int clampmode, int translation)
|
||||||
{
|
{
|
||||||
layer = mTextureLayers[i].texture;
|
layer = mTextureLayers[i].texture;
|
||||||
}
|
}
|
||||||
layer->gl_info.SystemTexture[mExpanded]->Bind(i+1, clampmode, 0, NULL);
|
layer->gl_info.SystemTexture[mExpanded]->Bind(i+1, clampmode, 0, 0);
|
||||||
maxbound = i+1;
|
maxbound = i+1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -738,7 +737,7 @@ void FMaterial::BindToFrameBuffer()
|
||||||
if (mBaseLayer->mHwTexture == NULL)
|
if (mBaseLayer->mHwTexture == NULL)
|
||||||
{
|
{
|
||||||
// must create the hardware texture first
|
// must create the hardware texture first
|
||||||
mBaseLayer->Bind(0, 0, 0, NULL);
|
mBaseLayer->Bind(0, 0, 0, 0);
|
||||||
FHardwareTexture::Unbind(0);
|
FHardwareTexture::Unbind(0);
|
||||||
ClearLastTexture();
|
ClearLastTexture();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1353,8 +1353,6 @@ unsigned char * FTexture::CreateTexBuffer(int translation, int & w, int & h, int
|
||||||
int isTransparent = -1;
|
int isTransparent = -1;
|
||||||
|
|
||||||
|
|
||||||
// Textures that are already scaled in the texture lump will not get replaced
|
|
||||||
// by hires textures
|
|
||||||
if ((flags & CTF_CheckHires) && translation != STRange_AlphaTexture)
|
if ((flags & CTF_CheckHires) && translation != STRange_AlphaTexture)
|
||||||
{
|
{
|
||||||
buffer = LoadHiresTexture(&w, &h);
|
buffer = LoadHiresTexture(&w, &h);
|
||||||
|
|
Loading…
Reference in a new issue