mirror of
https://github.com/blawar/GLideN64.git
synced 2024-07-02 09:03:37 +00:00
Switch to non-POT textures.
This commit is contained in:
parent
83945d5dbd
commit
887504c301
|
@ -62,8 +62,8 @@ void DepthBuffer::initDepthTexture(FrameBuffer * _pBuffer)
|
|||
m_pDepthTexture->maskT = 0;
|
||||
m_pDepthTexture->mirrorS = 0;
|
||||
m_pDepthTexture->mirrorT = 0;
|
||||
m_pDepthTexture->realWidth = (u32)pow2( m_pDepthTexture->width );
|
||||
m_pDepthTexture->realHeight = (u32)pow2( m_pDepthTexture->height );
|
||||
m_pDepthTexture->realWidth = m_pDepthTexture->width;
|
||||
m_pDepthTexture->realHeight = m_pDepthTexture->height;
|
||||
m_pDepthTexture->textureBytes = m_pDepthTexture->realWidth * m_pDepthTexture->realHeight * 4 * 4; // Width*Height*RGBA*sizeof(GL_RGBA32F)
|
||||
textureCache().addFrameBufferTextureSize(m_pDepthTexture->textureBytes);
|
||||
|
||||
|
@ -143,7 +143,7 @@ void DepthBufferList::saveBuffer(u32 _address)
|
|||
if (pFrameBuffer != NULL)
|
||||
glRenderbufferStorage(GL_RENDERBUFFER, format, pFrameBuffer->m_pTexture->realWidth, pFrameBuffer->m_pTexture->realHeight);
|
||||
else
|
||||
glRenderbufferStorage(GL_RENDERBUFFER, format, (u32)pow2(video().getWidth()), (u32)pow2(video().getHeight()));
|
||||
glRenderbufferStorage(GL_RENDERBUFFER, format, video().getWidth(), video().getHeight());
|
||||
|
||||
m_pCurrent = &buffer;
|
||||
}
|
||||
|
|
|
@ -255,8 +255,8 @@ void FrameBufferList::saveBuffer(u32 _address, u16 _format, u16 _size, u16 _widt
|
|||
buffer.m_pTexture->maskT = 0;
|
||||
buffer.m_pTexture->mirrorS = 0;
|
||||
buffer.m_pTexture->mirrorT = 0;
|
||||
buffer.m_pTexture->realWidth = (u32)pow2( buffer.m_pTexture->width );
|
||||
buffer.m_pTexture->realHeight = (u32)pow2( buffer.m_pTexture->height );
|
||||
buffer.m_pTexture->realWidth = buffer.m_pTexture->width;
|
||||
buffer.m_pTexture->realHeight = buffer.m_pTexture->height;
|
||||
buffer.m_pTexture->textureBytes = buffer.m_pTexture->realWidth * buffer.m_pTexture->realHeight * 4;
|
||||
textureCache().addFrameBufferTextureSize(buffer.m_pTexture->textureBytes);
|
||||
|
||||
|
|
46
Textures.cpp
46
Textures.cpp
|
@ -490,19 +490,24 @@ void _calcTileSizes(u32 _t, TileSizes & _sizes, gDPTile * _pLoadTile)
|
|||
_sizes.width = width;
|
||||
_sizes.height = height;
|
||||
|
||||
if (pTile->clamps)
|
||||
_sizes.realWidth = pow2(_sizes.clampWidth);
|
||||
else if (pTile->mirrors)
|
||||
_sizes.realWidth = _sizes.maskWidth << 1;
|
||||
if (pTile->clamps != 0)
|
||||
_sizes.realWidth = _sizes.clampWidth;
|
||||
else if (pTile->mirrors + pTile->masks != 0)
|
||||
_sizes.realWidth = _sizes.maskWidth;
|
||||
else
|
||||
_sizes.realWidth = pow2(_sizes.width);
|
||||
_sizes.realWidth = _sizes.width;
|
||||
|
||||
if (pTile->clampt)
|
||||
_sizes.realHeight = pow2(_sizes.clampHeight);
|
||||
else if (pTile->mirrort)
|
||||
_sizes.realHeight = _sizes.maskHeight << 1;
|
||||
if (pTile->clampt != 0)
|
||||
_sizes.realHeight = _sizes.clampHeight;
|
||||
else if (pTile->mirrort + pTile->maskt != 0)
|
||||
_sizes.realHeight = _sizes.maskHeight;
|
||||
else
|
||||
_sizes.realHeight = pow2(_sizes.height);
|
||||
_sizes.realHeight = _sizes.height;
|
||||
|
||||
if (gSP.texture.level > gSP.texture.tile) {
|
||||
_sizes.realWidth = pow2(_sizes.realWidth);
|
||||
_sizes.realHeight = pow2(_sizes.realHeight);
|
||||
}
|
||||
}
|
||||
|
||||
void TextureCache::_loadBackground(CachedTexture *pTexture)
|
||||
|
@ -577,7 +582,12 @@ void TextureCache::_loadBackground(CachedTexture *pTexture)
|
|||
}
|
||||
}
|
||||
|
||||
glTexImage2D( GL_TEXTURE_2D, 0, glInternalFormat, pTexture->realWidth, pTexture->realHeight, 0, GL_RGBA, glType, pDest );
|
||||
GLint curUnpackAlignment;
|
||||
glGetIntegerv(GL_UNPACK_ALIGNMENT, &curUnpackAlignment);
|
||||
if (pTexture->realWidth % 2 != 0 && glInternalFormat != GL_RGBA)
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 2);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, glInternalFormat, pTexture->realWidth, pTexture->realHeight, 0, GL_RGBA, glType, pDest);
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, curUnpackAlignment);
|
||||
free(pDest);
|
||||
}
|
||||
|
||||
|
@ -643,6 +653,9 @@ void TextureCache::_load(u32 _tile , CachedTexture *_pTexture)
|
|||
|
||||
line = tmptex.line;
|
||||
|
||||
GLint curUnpackAlignment;
|
||||
glGetIntegerv(GL_UNPACK_ALIGNMENT, &curUnpackAlignment);
|
||||
|
||||
while (true) {
|
||||
if (tmptex.maskS > 0) {
|
||||
clampSClamp = tmptex.clampS ? tmptex.clampWidth - 1 : (tmptex.mirrorS ? (tmptex.width << 1) - 1 : tmptex.width - 1);
|
||||
|
@ -735,6 +748,8 @@ void TextureCache::_load(u32 _tile , CachedTexture *_pTexture)
|
|||
}
|
||||
}
|
||||
}
|
||||
if (tmptex.realWidth % 2 != 0 && glInternalFormat != GL_RGBA)
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 2);
|
||||
glTexImage2D(GL_TEXTURE_2D, mipLevel, glInternalFormat, tmptex.realWidth, tmptex.realHeight, 0, GL_RGBA, glType, pDest);
|
||||
if (mipLevel == maxLevel)
|
||||
break;
|
||||
|
@ -759,6 +774,7 @@ void TextureCache::_load(u32 _tile , CachedTexture *_pTexture)
|
|||
tmptex.realHeight >>= 1;
|
||||
_pTexture->textureBytes += (tmptex.realWidth * tmptex.realHeight) << sizeShift;
|
||||
};
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, curUnpackAlignment);
|
||||
free(pDest);
|
||||
}
|
||||
|
||||
|
@ -837,8 +853,8 @@ void TextureCache::activateTexture(u32 _t, CachedTexture *_pTexture)
|
|||
|
||||
|
||||
// Set clamping modes
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, _pTexture->clampS ? GL_CLAMP_TO_EDGE : GL_REPEAT );
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, _pTexture->clampT ? GL_CLAMP_TO_EDGE : GL_REPEAT );
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, _pTexture->clampS ? GL_CLAMP_TO_EDGE : _pTexture->mirrorS ? GL_MIRRORED_REPEAT : GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, _pTexture->clampT ? GL_CLAMP_TO_EDGE : _pTexture->mirrorT ? GL_MIRRORED_REPEAT : GL_REPEAT);
|
||||
|
||||
_pTexture->lastDList = RSP.DList;
|
||||
|
||||
|
@ -905,8 +921,8 @@ void TextureCache::_updateBackground()
|
|||
pCurrent->palette = gSP.bgImage.palette;
|
||||
pCurrent->maskS = 0;
|
||||
pCurrent->maskT = 0;
|
||||
pCurrent->mirrorS = 1;
|
||||
pCurrent->mirrorT = 1;
|
||||
pCurrent->mirrorS = 0;
|
||||
pCurrent->mirrorT = 0;
|
||||
pCurrent->clampS = 0;
|
||||
pCurrent->clampT = 0;
|
||||
pCurrent->line = 0;
|
||||
|
|
Loading…
Reference in New Issue
Block a user