1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-02 09:03:37 +00:00
GLideN64/VI.cpp

81 lines
1.8 KiB
C++
Raw Normal View History

2013-04-21 14:28:50 +00:00
#include "GLideN64.h"
#include "Types.h"
#include "VI.h"
#include "OpenGL.h"
#include "N64.h"
#include "gSP.h"
#include "gDP.h"
#include "RSP.h"
#include "FrameBuffer.h"
#include "Debug.h"
VIInfo VI;
void VI_UpdateSize()
{
f32 xScale = _FIXED2FLOAT( _SHIFTR( *REG.VI_X_SCALE, 0, 12 ), 10 );
f32 xOffset = _FIXED2FLOAT( _SHIFTR( *REG.VI_X_SCALE, 16, 12 ), 10 );
f32 yScale = _FIXED2FLOAT( _SHIFTR( *REG.VI_Y_SCALE, 0, 12 ), 10 );
f32 yOffset = _FIXED2FLOAT( _SHIFTR( *REG.VI_Y_SCALE, 16, 12 ), 10 );
u32 hEnd = _SHIFTR( *REG.VI_H_START, 0, 10 );
u32 hStart = _SHIFTR( *REG.VI_H_START, 16, 10 );
// These are in half-lines, so shift an extra bit
u32 vEnd = _SHIFTR( *REG.VI_V_START, 1, 9 );
u32 vStart = _SHIFTR( *REG.VI_V_START, 17, 9 );
VI.width = (hEnd - hStart) * xScale;
VI.height = (vEnd - vStart) * yScale * 1.0126582f;
if (VI.width == 0.0f) VI.width = 320.0f;
if (VI.height == 0.0f) VI.height = 240.0f;
}
void VI_UpdateScreen()
{
glFinish();
if (OGL.frameBufferTextures)
{
2013-06-01 13:10:30 +00:00
//FrameBuffer *current = FrameBuffer_FindBuffer( *REG.VI_ORIGIN );
2013-06-01 13:10:30 +00:00
if ((*REG.VI_ORIGIN != VI.lastOrigin) && gDP.colorImage.changed)
{
2013-06-01 13:10:30 +00:00
/*
if (gDP.colorImage.changed)
{
FrameBuffer_SaveBuffer( gDP.colorImage.address, gDP.colorImage.size, gDP.colorImage.width, gDP.colorImage.height );
gDP.colorImage.changed = FALSE;
}
2013-06-01 13:10:30 +00:00
*/
FrameBuffer_RenderBuffer( *REG.VI_ORIGIN );
gDP.colorImage.changed = FALSE;
VI.lastOrigin = *REG.VI_ORIGIN;
#ifdef DEBUG
while (Debug.paused && !Debug.step);
Debug.step = FALSE;
#endif
}
}
else
{
if (gSP.changed & CHANGED_COLORBUFFER)
{
#ifndef __LINUX__
SwapBuffers( OGL.hDC );
#else
OGL_SwapBuffers();
#endif
gSP.changed &= ~CHANGED_COLORBUFFER;
#ifdef DEBUG
while (Debug.paused && !Debug.step);
Debug.step = FALSE;
#endif
}
}
glFinish();
}