mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-28 15:02:01 +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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
//#include <direct.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
@ -20,20 +19,12 @@
|
|||
#endif
|
||||
#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/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
//GL headers
|
||||
#include "gl_load.h"
|
||||
#include "gl_load/gl_load.h"
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#include <OpenGL/OpenGL.h>
|
||||
|
|
|
@ -120,7 +120,7 @@ bool OpenGLFrameBuffer::WipeStartScreen(int type)
|
|||
}
|
||||
|
||||
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");
|
||||
GLRenderer->mSamplerManager->Bind(0, CLAMP_NOFILTER, -1);
|
||||
GLRenderer->mSamplerManager->Bind(1, CLAMP_NONE, -1);
|
||||
|
@ -167,7 +167,7 @@ bool OpenGLFrameBuffer::WipeStartScreen(int type)
|
|||
void OpenGLFrameBuffer::WipeEndScreen()
|
||||
{
|
||||
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");
|
||||
GLRenderer->mSamplerManager->Bind(0, CLAMP_NOFILTER, -1);
|
||||
glFinish();
|
||||
|
@ -511,7 +511,7 @@ bool OpenGLFrameBuffer::Wiper_Burn::Run(int ticks, OpenGLFrameBuffer *fb)
|
|||
}
|
||||
|
||||
if (BurnTexture != NULL) delete BurnTexture;
|
||||
BurnTexture = new FHardwareTexture(WIDTH, HEIGHT, true);
|
||||
BurnTexture = new FHardwareTexture(true);
|
||||
|
||||
// Update the burn texture with the new burn data
|
||||
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
|
||||
|
@ -96,8 +96,8 @@ void FHardwareTexture::Resize(int width, int height, unsigned char *src_data, un
|
|||
TArray<BoxPrecalc> vPrecalcs(height, true);
|
||||
TArray<BoxPrecalc> hPrecalcs(width, true);
|
||||
|
||||
ResampleBoxPrecalc(vPrecalcs, texheight);
|
||||
ResampleBoxPrecalc(hPrecalcs, texwidth);
|
||||
ResampleBoxPrecalc(vPrecalcs, sheight);
|
||||
ResampleBoxPrecalc(hPrecalcs, swidth);
|
||||
|
||||
int averaged_pixels, averaged_alpha, src_pixel_index;
|
||||
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)
|
||||
{
|
||||
// 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];
|
||||
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)
|
||||
{
|
||||
w=texwidth;
|
||||
h=abs(texheight);
|
||||
rw = GetTexDimension (w);
|
||||
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));
|
||||
if (scaledbuffer)
|
||||
{
|
||||
Resize(rw, rh, buffer, scaledbuffer);
|
||||
Resize(w, h, rw, rh, buffer, scaledbuffer);
|
||||
deletebuffer=true;
|
||||
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);
|
||||
|
||||
if (deletebuffer) free(buffer);
|
||||
|
@ -227,11 +228,9 @@ unsigned int FHardwareTexture::CreateTexture(unsigned char * buffer, int w, int
|
|||
// Creates a texture
|
||||
//
|
||||
//===========================================================================
|
||||
FHardwareTexture::FHardwareTexture(int _width, int _height, bool nocompression)
|
||||
FHardwareTexture::FHardwareTexture(bool nocompression)
|
||||
{
|
||||
forcenocompression = nocompression;
|
||||
texwidth=_width;
|
||||
texheight=_height;
|
||||
|
||||
glDefTex.glTexID = 0;
|
||||
glDefTex.translation = 0;
|
||||
|
|
|
@ -60,7 +60,7 @@ public:
|
|||
|
||||
private:
|
||||
|
||||
short texwidth, texheight;
|
||||
short texwidth = 0, texheight = 0;
|
||||
bool forcenocompression;
|
||||
|
||||
TranslatedTexture glDefTex;
|
||||
|
@ -70,10 +70,10 @@ private:
|
|||
TranslatedTexture * GetTexID(int translation);
|
||||
|
||||
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:
|
||||
FHardwareTexture(int w, int h, bool nocompress);
|
||||
FHardwareTexture(bool nocompress);
|
||||
~FHardwareTexture();
|
||||
|
||||
static void Unbind(int texunit);
|
||||
|
|
|
@ -69,7 +69,6 @@ FGLTexture::FGLTexture(FTexture * tx, bool expandpatches)
|
|||
tex = tx;
|
||||
|
||||
mHwTexture = NULL;
|
||||
bExpandFlag = expandpatches;
|
||||
lastSampler = 254;
|
||||
lastTranslation = -1;
|
||||
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 (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;
|
||||
}
|
||||
|
@ -627,7 +626,7 @@ void FMaterial::Bind(int clampmode, int translation)
|
|||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -738,7 +737,7 @@ void FMaterial::BindToFrameBuffer()
|
|||
if (mBaseLayer->mHwTexture == NULL)
|
||||
{
|
||||
// must create the hardware texture first
|
||||
mBaseLayer->Bind(0, 0, 0, NULL);
|
||||
mBaseLayer->Bind(0, 0, 0, 0);
|
||||
FHardwareTexture::Unbind(0);
|
||||
ClearLastTexture();
|
||||
}
|
||||
|
|
|
@ -1353,8 +1353,6 @@ unsigned char * FTexture::CreateTexBuffer(int translation, int & w, int & h, int
|
|||
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)
|
||||
{
|
||||
buffer = LoadHiresTexture(&w, &h);
|
||||
|
|
Loading…
Reference in a new issue