removed all GL 2.x code.
After thinking about it for a day or so I believe it's the best option to remove all compatibility code because it's a major obstacle for a transition to a core profile.
This commit is contained in:
parent
d5dceb6874
commit
2925c96b59
24 changed files with 310 additions and 809 deletions
|
|
@ -85,7 +85,6 @@ FGLTexture::FGLTexture(FTexture * tx, bool expandpatches)
|
|||
for(int i=0;i<5;i++) gltexture[i]=NULL;
|
||||
HiresLump=-1;
|
||||
hirestexture = NULL;
|
||||
currentwarp = 0;
|
||||
bHasColorkey = false;
|
||||
bIsTransparent = -1;
|
||||
bExpand = expandpatches;
|
||||
|
|
@ -186,84 +185,6 @@ void FGLTexture::Clean(bool all)
|
|||
}
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// FGLTex::WarpBuffer
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
BYTE *FGLTexture::WarpBuffer(BYTE *buffer, int Width, int Height, int warp)
|
||||
{
|
||||
if (Width > 256 || Height > 256) return buffer;
|
||||
|
||||
DWORD *in = (DWORD*)buffer;
|
||||
DWORD *out = (DWORD*)new BYTE[4*Width*Height];
|
||||
float Speed = static_cast<FWarpTexture*>(tex)->GetSpeed();
|
||||
|
||||
static_cast<FWarpTexture*>(tex)->GenTime = r_FrameTime;
|
||||
|
||||
static DWORD linebuffer[256]; // anything larger will bring down performance so it is excluded above.
|
||||
DWORD timebase = DWORD(r_FrameTime*Speed*23/28);
|
||||
int xsize = Width;
|
||||
int ysize = Height;
|
||||
int xmask = xsize - 1;
|
||||
int ymask = ysize - 1;
|
||||
int ds_xbits;
|
||||
int i,x;
|
||||
|
||||
if (warp == 1)
|
||||
{
|
||||
for(ds_xbits=-1,i=Width; i; i>>=1, ds_xbits++);
|
||||
|
||||
for (x = xsize-1; x >= 0; x--)
|
||||
{
|
||||
int yt, yf = (finesine[(timebase+(x+17)*128)&FINEMASK]>>13) & ymask;
|
||||
const DWORD *source = in + x;
|
||||
DWORD *dest = out + x;
|
||||
for (yt = ysize; yt; yt--, yf = (yf+1)&ymask, dest += xsize)
|
||||
{
|
||||
*dest = *(source+(yf<<ds_xbits));
|
||||
}
|
||||
}
|
||||
timebase = DWORD(r_FrameTime*Speed*32/28);
|
||||
int y;
|
||||
for (y = ysize-1; y >= 0; y--)
|
||||
{
|
||||
int xt, xf = (finesine[(timebase+y*128)&FINEMASK]>>13) & xmask;
|
||||
DWORD *source = out + (y<<ds_xbits);
|
||||
DWORD *dest = linebuffer;
|
||||
for (xt = xsize; xt; xt--, xf = (xf+1)&xmask)
|
||||
{
|
||||
*dest++ = *(source+xf);
|
||||
}
|
||||
memcpy (out+y*xsize, linebuffer, xsize*sizeof(DWORD));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int ybits;
|
||||
for(ybits=-1,i=ysize; i; i>>=1, ybits++);
|
||||
|
||||
DWORD timebase = (r_FrameTime * Speed * 40 / 28);
|
||||
for (x = xsize-1; x >= 0; x--)
|
||||
{
|
||||
for (int y = ysize-1; y >= 0; y--)
|
||||
{
|
||||
int xt = (x + 128
|
||||
+ ((finesine[(y*128 + timebase*5 + 900) & 8191]*2)>>FRACBITS)
|
||||
+ ((finesine[(x*256 + timebase*4 + 300) & 8191]*2)>>FRACBITS)) & xmask;
|
||||
int yt = (y + 128
|
||||
+ ((finesine[(y*128 + timebase*3 + 700) & 8191]*2)>>FRACBITS)
|
||||
+ ((finesine[(x*256 + timebase*4 + 1200) & 8191]*2)>>FRACBITS)) & ymask;
|
||||
const DWORD *source = in + (xt << ybits) + yt;
|
||||
DWORD *dest = out + (x << ybits) + y;
|
||||
*dest = *source;
|
||||
}
|
||||
}
|
||||
}
|
||||
delete [] buffer;
|
||||
return (BYTE*)out;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
|
|
@ -271,7 +192,7 @@ BYTE *FGLTexture::WarpBuffer(BYTE *buffer, int Width, int Height, int warp)
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
unsigned char * FGLTexture::CreateTexBuffer(int translation, int & w, int & h, bool expand, FTexture *hirescheck, int warp, bool alphatexture)
|
||||
unsigned char * FGLTexture::CreateTexBuffer(int translation, int & w, int & h, bool expand, FTexture *hirescheck, bool alphatexture)
|
||||
{
|
||||
unsigned char * buffer;
|
||||
int W, H;
|
||||
|
|
@ -329,21 +250,9 @@ unsigned char * FGLTexture::CreateTexBuffer(int translation, int & w, int & h, b
|
|||
bIsTransparent = 0;
|
||||
}
|
||||
|
||||
if (warp != 0)
|
||||
{
|
||||
buffer = WarpBuffer(buffer, W, H, warp);
|
||||
}
|
||||
// [BB] The hqnx upsampling (not the scaleN one) destroys partial transparency, don't upsamle textures using it.
|
||||
// Also don't upsample warped textures.
|
||||
else //if (bIsTransparent != 1)
|
||||
{
|
||||
// [BB] Potentially upsample the buffer.
|
||||
buffer = gl_CreateUpsampledTextureBuffer ( tex, buffer, W, H, w, h, bIsTransparent || alphatexture);
|
||||
}
|
||||
currentwarp = warp;
|
||||
currentwarptime = gl_frameMS;
|
||||
|
||||
return buffer;
|
||||
// [BB] Potentially upsample the buffer.
|
||||
return gl_CreateUpsampledTextureBuffer ( tex, buffer, W, H, w, h, bIsTransparent || alphatexture);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -387,7 +296,7 @@ bool FGLTexture::CreatePatch()
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
const FHardwareTexture *FGLTexture::Bind(int texunit, int clampmode, int translation, FTexture *hirescheck, int warp)
|
||||
const FHardwareTexture *FGLTexture::Bind(int texunit, int clampmode, int translation, FTexture *hirescheck)
|
||||
{
|
||||
int usebright = false;
|
||||
|
||||
|
|
@ -414,15 +323,8 @@ const FHardwareTexture *FGLTexture::Bind(int texunit, int clampmode, int transla
|
|||
|
||||
if (hwtex)
|
||||
{
|
||||
if ((warp != 0 || currentwarp != warp) && currentwarptime != gl_frameMS)
|
||||
{
|
||||
// must recreate the texture
|
||||
Clean(true);
|
||||
hwtex = CreateTexture(clampmode);
|
||||
}
|
||||
|
||||
// Texture has become invalid - this is only for special textures, not the regular warping, which is handled above
|
||||
else if ((warp == 0 && !tex->bHasCanvas && !tex->bWarped) && tex->CheckModified())
|
||||
// Texture has become invalid
|
||||
if ((!tex->bHasCanvas && !tex->bWarped) && tex->CheckModified())
|
||||
{
|
||||
Clean(true);
|
||||
hwtex = CreateTexture(clampmode);
|
||||
|
|
@ -439,7 +341,7 @@ const FHardwareTexture *FGLTexture::Bind(int texunit, int clampmode, int transla
|
|||
|
||||
if (!tex->bHasCanvas)
|
||||
{
|
||||
buffer = CreateTexBuffer(translation, w, h, false, hirescheck, warp);
|
||||
buffer = CreateTexBuffer(translation, w, h, false, hirescheck);
|
||||
tex->ProcessData(buffer, w, h, false);
|
||||
}
|
||||
if (!hwtex->CreateTexture(buffer, w, h, true, texunit, translation))
|
||||
|
|
@ -464,7 +366,7 @@ const FHardwareTexture *FGLTexture::Bind(int texunit, int clampmode, int transla
|
|||
// Binds a sprite to the renderer
|
||||
//
|
||||
//===========================================================================
|
||||
const FHardwareTexture * FGLTexture::BindPatch(int texunit, int translation, int warp, bool alphatexture)
|
||||
const FHardwareTexture * FGLTexture::BindPatch(int texunit, int translation, bool alphatexture)
|
||||
{
|
||||
bool usebright = false;
|
||||
int transparm = translation;
|
||||
|
|
@ -474,15 +376,8 @@ const FHardwareTexture * FGLTexture::BindPatch(int texunit, int translation, int
|
|||
|
||||
if (CreatePatch())
|
||||
{
|
||||
if (warp != 0 || currentwarp != warp)
|
||||
{
|
||||
// must recreate the texture
|
||||
Clean(true);
|
||||
CreatePatch();
|
||||
}
|
||||
|
||||
// Texture has become invalid - this is only for special textures, not the regular warping, which is handled above
|
||||
else if ((warp == 0 && !tex->bHasCanvas && !tex->bWarped) && tex->CheckModified())
|
||||
if ((!tex->bHasCanvas && !tex->bWarped) && tex->CheckModified())
|
||||
{
|
||||
Clean(true);
|
||||
CreatePatch();
|
||||
|
|
@ -495,7 +390,7 @@ const FHardwareTexture * FGLTexture::BindPatch(int texunit, int translation, int
|
|||
int w, h;
|
||||
|
||||
// Create this texture
|
||||
unsigned char * buffer = CreateTexBuffer(translation, w, h, bExpand, NULL, warp, alphatexture);
|
||||
unsigned char * buffer = CreateTexBuffer(translation, w, h, bExpand, NULL, alphatexture);
|
||||
tex->ProcessData(buffer, w, h, true);
|
||||
if (!glpatch->CreateTexture(buffer, w, h, false, texunit, translation, alphatexture))
|
||||
{
|
||||
|
|
@ -625,7 +520,7 @@ FMaterial::FMaterial(FTexture * tx, bool forceexpand)
|
|||
{
|
||||
expanded = false;
|
||||
}
|
||||
else if (gl.hasGLSL())
|
||||
else
|
||||
{
|
||||
if (tx->gl_info.shaderindex >= FIRST_USER_SHADER)
|
||||
{
|
||||
|
|
@ -671,7 +566,7 @@ FMaterial::FMaterial(FTexture * tx, bool forceexpand)
|
|||
tex = tx;
|
||||
|
||||
tx->gl_info.mExpanded = expanded;
|
||||
FTexture *basetex = tx->GetRedirect(!gl.hasGLSL());
|
||||
FTexture *basetex = tx->GetRedirect(false);
|
||||
if (!expanded && !basetex->gl_info.mExpanded && basetex->UseType != FTexture::TEX_Sprite)
|
||||
{
|
||||
// check if the texture is just a simple redirect to a patch
|
||||
|
|
@ -842,13 +737,13 @@ void FMaterial::Bind(int clampmode, int translation, int overrideshader)
|
|||
int maxbound = 0;
|
||||
bool allowhires = tex->xScale == FRACUNIT && tex->yScale == FRACUNIT;
|
||||
|
||||
int softwarewarp = gl_RenderState.SetupShader(shaderindex, tex->gl_info.shaderspeed);
|
||||
gl_RenderState.SetupShader(shaderindex, tex->gl_info.shaderspeed);
|
||||
|
||||
if (tex->bHasCanvas || tex->bWarped) clampmode = 0;
|
||||
else if (clampmode != -1) clampmode &= 3;
|
||||
else clampmode = 4;
|
||||
|
||||
const FHardwareTexture *gltexture = mBaseLayer->Bind(0, clampmode, translation, allowhires? tex:NULL, softwarewarp);
|
||||
const FHardwareTexture *gltexture = mBaseLayer->Bind(0, clampmode, translation, allowhires? tex:NULL);
|
||||
if (gltexture != NULL && shaderindex > 0 && overrideshader == 0)
|
||||
{
|
||||
for(unsigned i=0;i<mTextureLayers.Size();i++)
|
||||
|
|
@ -864,7 +759,7 @@ void FMaterial::Bind(int clampmode, int translation, int overrideshader)
|
|||
{
|
||||
layer = mTextureLayers[i].texture;
|
||||
}
|
||||
layer->gl_info.SystemTexture->Bind(i+1, clampmode, 0, NULL, false);
|
||||
layer->gl_info.SystemTexture->Bind(i+1, clampmode, 0, NULL);
|
||||
maxbound = i+1;
|
||||
}
|
||||
}
|
||||
|
|
@ -889,13 +784,13 @@ void FMaterial::BindPatch(int translation, int overrideshader, bool alphatexture
|
|||
int shaderindex = overrideshader > 0? overrideshader : mShaderIndex;
|
||||
int maxbound = 0;
|
||||
|
||||
int softwarewarp = gl_RenderState.SetupShader(shaderindex, tex->gl_info.shaderspeed);
|
||||
gl_RenderState.SetupShader(shaderindex, tex->gl_info.shaderspeed);
|
||||
|
||||
const FHardwareTexture *glpatch = mBaseLayer->BindPatch(0, translation, softwarewarp, alphatexture);
|
||||
const FHardwareTexture *glpatch = mBaseLayer->BindPatch(0, translation, alphatexture);
|
||||
// The only multitexture effect usable on sprites is the brightmap.
|
||||
if (glpatch != NULL && shaderindex == 3)
|
||||
{
|
||||
mTextureLayers[0].texture->gl_info.SystemTexture->BindPatch(1, 0, 0, false);
|
||||
mTextureLayers[0].texture->gl_info.SystemTexture->BindPatch(1, 0, false);
|
||||
maxbound = 1;
|
||||
}
|
||||
// unbind everything from the last texture that's still active
|
||||
|
|
@ -1013,7 +908,7 @@ void FMaterial::BindToFrameBuffer()
|
|||
if (mBaseLayer->gltexture[0] == NULL)
|
||||
{
|
||||
// must create the hardware texture first
|
||||
mBaseLayer->Bind(0, 0, 0, NULL, 0);
|
||||
mBaseLayer->Bind(0, 0, 0, NULL);
|
||||
FHardwareTexture::Unbind(0);
|
||||
}
|
||||
mBaseLayer->gltexture[0]->BindToFrameBuffer();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue