mirror of
https://github.com/ZDoom/qzdoom-gpl.git
synced 2024-12-12 21:22:22 +00:00
Add bgra support to OS X target
This commit is contained in:
parent
b9d7a98aec
commit
4f635983fc
4 changed files with 28 additions and 10 deletions
|
@ -249,7 +249,7 @@ private:
|
||||||
class CocoaFrameBuffer : public DFrameBuffer
|
class CocoaFrameBuffer : public DFrameBuffer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CocoaFrameBuffer(int width, int height, bool fullscreen);
|
CocoaFrameBuffer(int width, int height, bool bgra, bool fullscreen);
|
||||||
~CocoaFrameBuffer();
|
~CocoaFrameBuffer();
|
||||||
|
|
||||||
virtual bool Lock(bool buffer);
|
virtual bool Lock(bool buffer);
|
||||||
|
@ -536,7 +536,7 @@ DFrameBuffer* CocoaVideo::CreateFrameBuffer(const int width, const int height, c
|
||||||
|
|
||||||
if (NULL != old)
|
if (NULL != old)
|
||||||
{
|
{
|
||||||
if (width == m_width && height == m_height)
|
if (width == m_width && height == m_height && bgra == old->IsBgra())
|
||||||
{
|
{
|
||||||
SetMode(width, height, fullscreen, vid_hidpi);
|
SetMode(width, height, fullscreen, vid_hidpi);
|
||||||
return old;
|
return old;
|
||||||
|
@ -553,7 +553,7 @@ DFrameBuffer* CocoaVideo::CreateFrameBuffer(const int width, const int height, c
|
||||||
delete old;
|
delete old;
|
||||||
}
|
}
|
||||||
|
|
||||||
CocoaFrameBuffer* fb = new CocoaFrameBuffer(width, height, fullscreen);
|
CocoaFrameBuffer* fb = new CocoaFrameBuffer(width, height, bgra, fullscreen);
|
||||||
fb->SetFlash(flashColor, flashAmount);
|
fb->SetFlash(flashColor, flashAmount);
|
||||||
|
|
||||||
SetMode(width, height, fullscreen, vid_hidpi);
|
SetMode(width, height, fullscreen, vid_hidpi);
|
||||||
|
@ -772,8 +772,8 @@ CocoaVideo* CocoaVideo::GetInstance()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CocoaFrameBuffer::CocoaFrameBuffer(int width, int height, bool fullscreen)
|
CocoaFrameBuffer::CocoaFrameBuffer(int width, int height, bool bgra, bool fullscreen)
|
||||||
: DFrameBuffer(width, height, false)
|
: DFrameBuffer(width, height, bgra)
|
||||||
, m_needPaletteUpdate(false)
|
, m_needPaletteUpdate(false)
|
||||||
, m_gamma(0.0f)
|
, m_gamma(0.0f)
|
||||||
, m_needGammaUpdate(false)
|
, m_needGammaUpdate(false)
|
||||||
|
@ -867,8 +867,18 @@ void CocoaFrameBuffer::Update()
|
||||||
FlipCycles.Reset();
|
FlipCycles.Reset();
|
||||||
BlitCycles.Clock();
|
BlitCycles.Clock();
|
||||||
|
|
||||||
GPfx.Convert(MemBuffer, Pitch, m_pixelBuffer, Width * BYTES_PER_PIXEL,
|
if (IsBgra())
|
||||||
Width, Height, FRACUNIT, FRACUNIT, 0, 0);
|
{
|
||||||
|
for (int y = 0; y < Height; y++)
|
||||||
|
{
|
||||||
|
memcpy((uint32_t*)m_pixelBuffer + y * Width, (uint32_t*)MemBuffer + y * Pitch, Width * BYTES_PER_PIXEL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GPfx.Convert(MemBuffer, Pitch, m_pixelBuffer, Width * BYTES_PER_PIXEL,
|
||||||
|
Width, Height, FRACUNIT, FRACUNIT, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
FlipCycles.Clock();
|
FlipCycles.Clock();
|
||||||
Flip();
|
Flip();
|
||||||
|
@ -1000,8 +1010,10 @@ void CocoaFrameBuffer::Flip()
|
||||||
static const GLenum format = GL_ABGR_EXT;
|
static const GLenum format = GL_ABGR_EXT;
|
||||||
#endif // __LITTLE_ENDIAN__
|
#endif // __LITTLE_ENDIAN__
|
||||||
|
|
||||||
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
|
if (IsBgra())
|
||||||
Width, Height, 0, format, GL_UNSIGNED_BYTE, m_pixelBuffer);
|
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8, Width, Height, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, m_pixelBuffer);
|
||||||
|
else
|
||||||
|
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8, Width, Height, 0, format, GL_UNSIGNED_BYTE, m_pixelBuffer);
|
||||||
|
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||||
|
|
|
@ -984,7 +984,6 @@ void R_RenderViewToCanvas (AActor *actor, DCanvas *canvas,
|
||||||
|
|
||||||
if (r_swtruecolor != canvas->IsBgra())
|
if (r_swtruecolor != canvas->IsBgra())
|
||||||
{
|
{
|
||||||
r_swtruecolor = canvas->IsBgra();
|
|
||||||
R_InitColumnDrawers();
|
R_InitColumnDrawers();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,6 +58,7 @@ void R_InitRenderer();
|
||||||
|
|
||||||
void FSoftwareRenderer::Init()
|
void FSoftwareRenderer::Init()
|
||||||
{
|
{
|
||||||
|
r_swtruecolor = screen->IsBgra();
|
||||||
R_InitRenderer();
|
R_InitRenderer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -129,6 +129,12 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms)
|
||||||
static short bottomclipper[MAXWIDTH], topclipper[MAXWIDTH];
|
static short bottomclipper[MAXWIDTH], topclipper[MAXWIDTH];
|
||||||
const BYTE *translation = NULL;
|
const BYTE *translation = NULL;
|
||||||
|
|
||||||
|
if (r_swtruecolor != IsBgra())
|
||||||
|
{
|
||||||
|
r_swtruecolor = IsBgra();
|
||||||
|
R_InitColumnDrawers();
|
||||||
|
}
|
||||||
|
|
||||||
if (parms.masked)
|
if (parms.masked)
|
||||||
{
|
{
|
||||||
spanptr = &spans;
|
spanptr = &spans;
|
||||||
|
|
Loading…
Reference in a new issue