mirror of
https://github.com/blawar/GLideN64.git
synced 2024-07-02 09:03:37 +00:00
Refactor: replace C style OGL_* functions by OGLRender and OGLVideo classes.
OGLRender performs rendering operations. OGLVideo initializes OpenGL and performes operations with graphics context. It has platform-dependent implementations.
This commit is contained in:
parent
f42357bb39
commit
86cde946e9
|
@ -141,7 +141,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(OGL.width), (u32)pow2(OGL.height));
|
||||
glRenderbufferStorage(GL_RENDERBUFFER, format, (u32)pow2(video().getWidth()), (u32)pow2(video().getHeight()));
|
||||
|
||||
m_pCurrent = &buffer;
|
||||
}
|
||||
|
@ -159,14 +159,14 @@ void DepthBufferList::saveBuffer(u32 _address)
|
|||
void DepthBufferList::clearBuffer()
|
||||
{
|
||||
#ifndef GLES2
|
||||
if (!OGL.bImageTexture)
|
||||
if (!video().getRender().isImageTexturesSupported())
|
||||
return;
|
||||
if (m_pCurrent == NULL || m_pCurrent->m_FBO == 0)
|
||||
return;
|
||||
float color[4] = {1.0f, 1.0f, 0.0f, 1.0f};
|
||||
glBindImageTexture(depthImageUnit, 0, 0, GL_FALSE, 0, GL_READ_WRITE, GL_RGBA32F);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_pCurrent->m_FBO);
|
||||
OGL_DrawRect(0,0,VI.width, VI.height, color);
|
||||
video().getRender().drawRect(0,0,VI.width, VI.height, color);
|
||||
glBindImageTexture(depthImageUnit, m_pCurrent->m_pDepthTexture->glName, 0, GL_FALSE, 0, GL_READ_WRITE, GL_RGBA32F);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, frameBufferList().getCurrent()->m_FBO);
|
||||
#endif // GLES2
|
||||
|
|
|
@ -171,6 +171,7 @@ FrameBuffer * FrameBufferList::findTmpBuffer(u32 _address)
|
|||
|
||||
void FrameBufferList::saveBuffer(u32 _address, u16 _format, u16 _size, u16 _width, u16 _height )
|
||||
{
|
||||
OGLVideo & ogl = video();
|
||||
m_drawBuffer = GL_FRAMEBUFFER;
|
||||
if (m_pCurrent != NULL && gDP.colorImage.height > 1) {
|
||||
m_pCurrent->m_endAddress = min(RDRAMSize, m_pCurrent->m_startAddress + (((m_pCurrent->m_width * gDP.colorImage.height) << m_pCurrent->m_size >> 1) - 1));
|
||||
|
@ -185,8 +186,8 @@ void FrameBufferList::saveBuffer(u32 _address, u16 _format, u16 _size, u16 _widt
|
|||
(m_pCurrent->m_width != _width) ||
|
||||
//(current->height != height) ||
|
||||
//(current->size != size) || // TODO FIX ME
|
||||
(m_pCurrent->m_scaleX != OGL.scaleX) ||
|
||||
(m_pCurrent->m_scaleY != OGL.scaleY))
|
||||
(m_pCurrent->m_scaleX != ogl.getScaleX()) ||
|
||||
(m_pCurrent->m_scaleY != ogl.getScaleY()))
|
||||
{
|
||||
removeBuffer(m_pCurrent->m_startAddress);
|
||||
m_pCurrent = NULL;
|
||||
|
@ -195,7 +196,7 @@ void FrameBufferList::saveBuffer(u32 _address, u16 _format, u16 _size, u16 _widt
|
|||
if (m_pCurrent->m_size != _size) {
|
||||
f32 fillColor[4];
|
||||
gDPGetFillColor(fillColor);
|
||||
OGL_ClearColorBuffer(fillColor);
|
||||
ogl.getRender().clearColorBuffer(fillColor);
|
||||
m_pCurrent->m_size = _size;
|
||||
m_pCurrent->m_pTexture->format = _format;
|
||||
m_pCurrent->m_pTexture->size = _size;
|
||||
|
@ -213,12 +214,12 @@ void FrameBufferList::saveBuffer(u32 _address, u16 _format, u16 _size, u16 _widt
|
|||
buffer.m_width = _width;
|
||||
buffer.m_height = _height;
|
||||
buffer.m_size = _size;
|
||||
buffer.m_scaleX = OGL.scaleX;
|
||||
buffer.m_scaleY = OGL.scaleY;
|
||||
buffer.m_scaleX = ogl.getScaleX();
|
||||
buffer.m_scaleY = ogl.getScaleY();
|
||||
buffer.m_fillcolor = 0;
|
||||
|
||||
buffer.m_pTexture->width = (u32)(buffer.m_width * OGL.scaleX);
|
||||
buffer.m_pTexture->height = (u32)(buffer.m_height * OGL.scaleY);
|
||||
buffer.m_pTexture->width = (u32)(buffer.m_width * video().getScaleX());
|
||||
buffer.m_pTexture->height = (u32)(buffer.m_height * video().getScaleY());
|
||||
buffer.m_pTexture->format = _format;
|
||||
buffer.m_pTexture->size = _size;
|
||||
buffer.m_pTexture->clampS = 1;
|
||||
|
@ -328,12 +329,13 @@ void FrameBufferList::renderBuffer(u32 _address)
|
|||
FrameBuffer *pBuffer = findBuffer(_address);
|
||||
if (pBuffer == NULL)
|
||||
return;
|
||||
OGLVideo & ogl = video();
|
||||
GLint srcY0, srcY1, dstY0, dstY1;
|
||||
GLint partHeight = 0;
|
||||
dstY0 = 1;
|
||||
const u32 vStart = _SHIFTR( *REG.VI_V_START, 17, 9 );
|
||||
const u32 vEnd = _SHIFTR( *REG.VI_V_START, 1, 9 );
|
||||
const float viScaleY = OGL.height / (float)VI.vHeight;
|
||||
const float viScaleY = ogl.getHeight() / (float)VI.vHeight;
|
||||
|
||||
if (VI.vStart != vStart)
|
||||
dstY0 += vStart - VI.vStart;
|
||||
|
@ -347,16 +349,16 @@ void FrameBufferList::renderBuffer(u32 _address)
|
|||
}
|
||||
|
||||
// glDisable(GL_SCISSOR_TEST) does not affect glBlitFramebuffer, at least on AMD
|
||||
glScissor( 0, 0, OGL.width, OGL.height );
|
||||
glScissor(0, 0, ogl.getWidth(), ogl.getHeight());
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, pBuffer->m_FBO);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||
//glDrawBuffer( GL_BACK );
|
||||
float clearColor[4] = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||
OGL_ClearColorBuffer(clearColor);
|
||||
ogl.getRender().clearColorBuffer(clearColor);
|
||||
glBlitFramebuffer(
|
||||
0, (GLint)(srcY0*OGL.scaleY), OGL.width, (GLint)(srcY1*OGL.scaleY),
|
||||
0, OGL.heightOffset + (GLint)(dstY0*viScaleY), OGL.width, OGL.heightOffset + (GLint)(dstY1*viScaleY),
|
||||
0, (GLint)(srcY0*ogl.getScaleY()), ogl.getWidth(), (GLint)(srcY1*ogl.getScaleY()),
|
||||
0, ogl.getHeightOffset() + (GLint)(dstY0*viScaleY), ogl.getWidth(), ogl.getHeightOffset() + (GLint)(dstY1*viScaleY),
|
||||
GL_COLOR_BUFFER_BIT, GL_LINEAR
|
||||
);
|
||||
if (partHeight > 0) {
|
||||
|
@ -369,8 +371,8 @@ void FrameBufferList::renderBuffer(u32 _address)
|
|||
dstY1 = dstY0 + partHeight;
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, pBuffer->m_FBO);
|
||||
glBlitFramebuffer(
|
||||
0, (GLint)(srcY0*OGL.scaleY), OGL.width, (GLint)(srcY1*OGL.scaleY),
|
||||
0, OGL.heightOffset + (GLint)(dstY0*viScaleY), OGL.width, OGL.heightOffset + (GLint)(dstY1*viScaleY),
|
||||
0, (GLint)(srcY0*ogl.getScaleY()), ogl.getWidth(), (GLint)(srcY1*ogl.getScaleY()),
|
||||
0, ogl.getHeightOffset() + (GLint)(dstY0*viScaleY), ogl.getWidth(), ogl.getHeightOffset() + (GLint)(dstY1*viScaleY),
|
||||
GL_COLOR_BUFFER_BIT, GL_LINEAR
|
||||
);
|
||||
}
|
||||
|
@ -378,7 +380,7 @@ void FrameBufferList::renderBuffer(u32 _address)
|
|||
glEnable(GL_SCISSOR_TEST);
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_pCurrent->m_FBO);
|
||||
OGL_SwapBuffers();
|
||||
ogl.swapBuffers();
|
||||
gDP.changed |= CHANGED_SCISSOR;
|
||||
}
|
||||
#else
|
||||
|
@ -402,8 +404,9 @@ void FrameBufferList::renderBuffer(u32 _address)
|
|||
const u32 width = pBuffer->m_width;
|
||||
const u32 height = pBuffer->m_height;
|
||||
|
||||
pBuffer->m_pTexture->scaleS = OGL.scaleX / (float)pBuffer->m_pTexture->realWidth;
|
||||
pBuffer->m_pTexture->scaleT = OGL.scaleY / (float)pBuffer->m_pTexture->realHeight;
|
||||
OGLVideo & ogl = video();
|
||||
pBuffer->m_pTexture->scaleS = ogl.getScaleX() / (float)pBuffer->m_pTexture->realWidth;
|
||||
pBuffer->m_pTexture->scaleT = ogl.getScaleY() / (float)pBuffer->m_pTexture->realHeight;
|
||||
pBuffer->m_pTexture->shiftScaleS = 1.0f;
|
||||
pBuffer->m_pTexture->shiftScaleT = 1.0f;
|
||||
pBuffer->m_pTexture->offsetS = 0;
|
||||
|
@ -414,8 +417,8 @@ void FrameBufferList::renderBuffer(u32 _address)
|
|||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
drawBuffer = GL_BACK;
|
||||
OGL_DrawTexturedRect( 0.0f, 0.0f, width, height, 0.0f, 0.0f, width-1.0f, height-1.0f, false );
|
||||
OGL_SwapBuffers();
|
||||
ogl.drawTexturedRect( 0.0f, 0.0f, width, height, 0.0f, 0.0f, width-1.0f, height-1.0f, false );
|
||||
ogl.swapBuffers();
|
||||
drawBuffer = GL_FRAMEBUFFER;
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, m_pCurrent->m_FBO);
|
||||
|
@ -426,8 +429,8 @@ void FrameBufferList::renderBuffer(u32 _address)
|
|||
|
||||
void FrameBuffer_ActivateBufferTexture(s16 t, FrameBuffer *pBuffer)
|
||||
{
|
||||
pBuffer->m_pTexture->scaleS = OGL.scaleX / (float)pBuffer->m_pTexture->realWidth;
|
||||
pBuffer->m_pTexture->scaleT = OGL.scaleY / (float)pBuffer->m_pTexture->realHeight;
|
||||
pBuffer->m_pTexture->scaleS = video().getScaleX() / (float)pBuffer->m_pTexture->realWidth;
|
||||
pBuffer->m_pTexture->scaleT = video().getScaleY() / (float)pBuffer->m_pTexture->realHeight;
|
||||
|
||||
if (gSP.textureTile[t]->shifts > 10)
|
||||
pBuffer->m_pTexture->shiftScaleS = (float)(1 << (16 - gSP.textureTile[t]->shifts));
|
||||
|
@ -463,8 +466,8 @@ void FrameBuffer_ActivateBufferTexture(s16 t, FrameBuffer *pBuffer)
|
|||
|
||||
void FrameBuffer_ActivateBufferTextureBG(s16 t, FrameBuffer *pBuffer )
|
||||
{
|
||||
pBuffer->m_pTexture->scaleS = OGL.scaleX / (float)pBuffer->m_pTexture->realWidth;
|
||||
pBuffer->m_pTexture->scaleT = OGL.scaleY / (float)pBuffer->m_pTexture->realHeight;
|
||||
pBuffer->m_pTexture->scaleS = video().getScaleX() / (float)pBuffer->m_pTexture->realWidth;
|
||||
pBuffer->m_pTexture->scaleT = video().getScaleY() / (float)pBuffer->m_pTexture->realHeight;
|
||||
|
||||
pBuffer->m_pTexture->shiftScaleS = 1.0f;
|
||||
pBuffer->m_pTexture->shiftScaleT = 1.0f;
|
||||
|
@ -542,7 +545,7 @@ void FrameBufferToRDRAM::CopyToRDRAM( u32 address, bool bSync ) {
|
|||
GLuint attachment = GL_COLOR_ATTACHMENT0;
|
||||
glDrawBuffers(1, &attachment);
|
||||
glBlitFramebuffer(
|
||||
0, 0, OGL.width, OGL.height,
|
||||
0, 0, video().getWidth(), video().getHeight(),
|
||||
0, 0, pBuffer->m_width, pBuffer->m_height,
|
||||
GL_COLOR_BUFFER_BIT, GL_LINEAR
|
||||
);
|
||||
|
@ -679,7 +682,7 @@ void DepthBufferToRDRAM::CopyToRDRAM( u32 address) {
|
|||
GLuint attachment = GL_COLOR_ATTACHMENT0;
|
||||
glDrawBuffers(1, &attachment);
|
||||
glBlitFramebuffer(
|
||||
0, 0, OGL.width, OGL.height,
|
||||
0, 0, video().getWidth(), video().getHeight(),
|
||||
0, 0, pBuffer->m_width, pBuffer->m_height,
|
||||
GL_COLOR_BUFFER_BIT, GL_LINEAR
|
||||
);
|
||||
|
@ -845,6 +848,9 @@ void RDRAMtoFrameBuffer::CopyFromRDRAM( u32 _address, bool _bUseAlpha)
|
|||
#else
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, m_PBO);
|
||||
#endif
|
||||
|
||||
OGLVideo & ogl = video();
|
||||
|
||||
#if 0
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
|
@ -855,7 +861,7 @@ void RDRAMtoFrameBuffer::CopyFromRDRAM( u32 _address, bool _bUseAlpha)
|
|||
glDrawBuffers(1, &attachment);
|
||||
glBlitFramebuffer(
|
||||
0, 0, width, height,
|
||||
0, 0, OGL.width, OGL.height,
|
||||
0, 0, ogl.getWidth(), ogl.getHeight(),
|
||||
GL_COLOR_BUFFER_BIT, GL_LINEAR
|
||||
);
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
|
||||
|
@ -881,7 +887,7 @@ void RDRAMtoFrameBuffer::CopyFromRDRAM( u32 _address, bool _bUseAlpha)
|
|||
m_pTexture->offsetT = (float)m_pTexture->height;
|
||||
textureCache().activateTexture(0, m_pTexture);
|
||||
|
||||
OGL_DrawTexturedRect( 0.0f, 0.0f, width, height, 0.0f, 0.0f, width-1.0f, height-1.0f, false );
|
||||
ogl.getRender().drawTexturedRect( 0.0f, 0.0f, width, height, 0.0f, 0.0f, width-1.0f, height-1.0f, false );
|
||||
gSP.changed |= CHANGED_TEXTURE | CHANGED_VIEWPORT;
|
||||
gDP.changed |= CHANGED_COMBINE;
|
||||
#endif
|
||||
|
|
1
GBI.cpp
1
GBI.cpp
|
@ -134,6 +134,7 @@ void GBI_Init()
|
|||
|
||||
void GBI_Destroy()
|
||||
{
|
||||
GBI.current = NULL;
|
||||
while (GBI.bottom)
|
||||
{
|
||||
MicrocodeInfo *newBottom = GBI.bottom->higher;
|
||||
|
|
113
GLSLCombiner.cpp
113
GLSLCombiner.cpp
|
@ -65,7 +65,7 @@ bool check_program_link_status(GLuint obj)
|
|||
static
|
||||
void InitZlutTexture()
|
||||
{
|
||||
if (!OGL.bImageTexture)
|
||||
if (!video().getRender().isImageTexturesSupported())
|
||||
return;
|
||||
|
||||
u16 * zLUT = new u16[0x40000];
|
||||
|
@ -96,7 +96,7 @@ void InitZlutTexture()
|
|||
static
|
||||
void DestroyZlutTexture()
|
||||
{
|
||||
if (!OGL.bImageTexture)
|
||||
if (!video().getRender().isImageTexturesSupported())
|
||||
return;
|
||||
glBindImageTexture(ZlutImageUnit, 0, 0, GL_FALSE, 0, GL_READ_ONLY, GL_R16UI);
|
||||
if (g_zlut_tex > 0) {
|
||||
|
@ -109,7 +109,7 @@ void DestroyZlutTexture()
|
|||
static
|
||||
void InitShadowMapShader()
|
||||
{
|
||||
if (!OGL.bImageTexture)
|
||||
if (!video().getRender().isImageTexturesSupported())
|
||||
return;
|
||||
|
||||
g_paletteCRC256 = 0;
|
||||
|
@ -143,7 +143,7 @@ void InitShadowMapShader()
|
|||
static
|
||||
void DestroyShadowMapShader()
|
||||
{
|
||||
if (!OGL.bImageTexture)
|
||||
if (!video().getRender().isImageTexturesSupported())
|
||||
return;
|
||||
|
||||
glBindImageTexture(TlutImageUnit, 0, 0, GL_FALSE, 0, GL_READ_ONLY, GL_R16UI);
|
||||
|
@ -194,7 +194,7 @@ void InitShaderCombiner()
|
|||
glCompileShader(g_test_alpha_shader_object);
|
||||
assert(check_shader_compile_status(g_test_alpha_shader_object));
|
||||
|
||||
if (OGL.bImageTexture) {
|
||||
if (video().getRender().isImageTexturesSupported()) {
|
||||
g_calc_depth_shader_object = glCreateShader(GL_FRAGMENT_SHADER);
|
||||
glShaderSource(g_calc_depth_shader_object, 1, &depth_compare_shader_float, NULL);
|
||||
glCompileShader(g_calc_depth_shader_object);
|
||||
|
@ -413,7 +413,7 @@ ShaderCombiner::ShaderCombiner(Combiner & _color, Combiner & _alpha, const gDPCo
|
|||
strFragmentShader.append(" gl_FragColor = vec4(color2, alpha2); \n");
|
||||
|
||||
strFragmentShader.append(" if (!alpha_test(gl_FragColor.a)) discard; \n");
|
||||
if (OGL.bImageTexture) {
|
||||
if (video().getRender().isImageTexturesSupported()) {
|
||||
if (config.frameBufferEmulation.N64DepthCompare)
|
||||
strFragmentShader.append(" if (!depth_compare()) discard; \n");
|
||||
else
|
||||
|
@ -458,7 +458,7 @@ ShaderCombiner::ShaderCombiner(Combiner & _color, Combiner & _alpha, const gDPCo
|
|||
if (bUseLod)
|
||||
glAttachShader(m_program, g_calc_lod_shader_object);
|
||||
glAttachShader(m_program, g_test_alpha_shader_object);
|
||||
if (OGL.bImageTexture)
|
||||
if (video().getRender().isImageTexturesSupported())
|
||||
glAttachShader(m_program, g_calc_depth_shader_object);
|
||||
glAttachShader(m_program, g_calc_noise_shader_object);
|
||||
#endif
|
||||
|
@ -560,8 +560,8 @@ void ShaderCombiner::update() {
|
|||
|
||||
_setIUniform(m_uniforms.uTex0, 0, true);
|
||||
_setIUniform(m_uniforms.uTex1, 1, true);
|
||||
_setFUniform(m_uniforms.uScreenWidth, OGL.width, true);
|
||||
_setFUniform(m_uniforms.uScreenHeight, OGL.height, true);
|
||||
_setFUniform(m_uniforms.uScreenWidth, video().getWidth(), true);
|
||||
_setFUniform(m_uniforms.uScreenHeight, video().getHeight(), true);
|
||||
|
||||
updateRenderState(true);
|
||||
updateColors(true);
|
||||
|
@ -572,7 +572,7 @@ void ShaderCombiner::update() {
|
|||
}
|
||||
|
||||
void ShaderCombiner::updateRenderState(bool _bForce) {
|
||||
_setIUniform(m_uniforms.uRenderState, OGL.renderState, _bForce);
|
||||
_setIUniform(m_uniforms.uRenderState, video().getRender().getRenderState(), _bForce);
|
||||
}
|
||||
|
||||
void ShaderCombiner::updateLight(bool _bForce) {
|
||||
|
@ -602,8 +602,8 @@ void ShaderCombiner::updateColors(bool _bForce) {
|
|||
int uCalcLOD = (config.enableLOD && gDP.otherMode.textureLOD == G_TL_LOD) ? 1 : 0;
|
||||
_setIUniform(m_uniforms.uEnableLod, uCalcLOD, _bForce);
|
||||
if (uCalcLOD) {
|
||||
_setFUniform(m_uniforms.uLodXScale, OGL.scaleX, _bForce);
|
||||
_setFUniform(m_uniforms.uLodYScale, OGL.scaleY, _bForce);
|
||||
_setFUniform(m_uniforms.uLodXScale, video().getScaleX(), _bForce);
|
||||
_setFUniform(m_uniforms.uLodYScale, video().getScaleY(), _bForce);
|
||||
_setFUniform(m_uniforms.uMinLod, gDP.primColor.m, _bForce);
|
||||
_setIUniform(m_uniforms.uMaxTile, gSP.texture.level, _bForce);
|
||||
_setIUniform(m_uniforms.uTextureDetail, gDP.otherMode.textureDetail, _bForce);
|
||||
|
@ -685,7 +685,7 @@ void ShaderCombiner::updateFBInfo(bool _bForce) {
|
|||
}
|
||||
|
||||
void ShaderCombiner::updateDepthInfo(bool _bForce) {
|
||||
if (!OGL.bImageTexture)
|
||||
if (!video().getRender().isImageTexturesSupported())
|
||||
return;
|
||||
|
||||
FrameBuffer * pBuffer = frameBufferList().getCurrent();
|
||||
|
@ -719,91 +719,9 @@ void ShaderCombiner::updateAlphaTestInfo(bool _bForce) {
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef GLES2
|
||||
void GLSL_RenderDepth() {
|
||||
if (!OGL.bImageTexture)
|
||||
return;
|
||||
FrameBuffer * pBuffer = frameBufferList().getCurrent();
|
||||
#if 0
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, g_zbuf_fbo);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||
glDrawBuffer( GL_FRONT );
|
||||
glBlitFramebuffer(
|
||||
0, 0, OGL.width, OGL.height,
|
||||
0, OGL.heightOffset, OGL.width, OGL.heightOffset + OGL.height,
|
||||
GL_COLOR_BUFFER_BIT, GL_LINEAR
|
||||
);
|
||||
glDrawBuffer( GL_BACK );
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, pBuffer != NULL ? pBuffer->m_FBO : 0);
|
||||
#else
|
||||
if (pBuffer == NULL || pBuffer->m_pDepthBuffer == NULL)
|
||||
return;
|
||||
glBindImageTexture(depthImageUnit, 0, 0, GL_FALSE, 0, GL_READ_WRITE, GL_RGBA32F);
|
||||
glPushAttrib( GL_ENABLE_BIT | GL_VIEWPORT_BIT );
|
||||
void SetShadowMapCombiner() {
|
||||
|
||||
glActiveTexture( GL_TEXTURE0 );
|
||||
glBindTexture(GL_TEXTURE_2D, pBuffer->m_pDepthBuffer->m_pDepthTexture->glName);
|
||||
// glBindTexture(GL_TEXTURE_2D, g_zlut_tex);
|
||||
|
||||
CombinerInfo::get().setCombine( EncodeCombineMode( 0, 0, 0, TEXEL0, 0, 0, 0, 1, 0, 0, 0, TEXEL0, 0, 0, 0, 1 ) );
|
||||
|
||||
glDisable( GL_BLEND );
|
||||
glDisable( GL_ALPHA_TEST );
|
||||
glDisable( GL_DEPTH_TEST );
|
||||
glDisable( GL_CULL_FACE );
|
||||
glDisable( GL_POLYGON_OFFSET_FILL );
|
||||
|
||||
glMatrixMode( GL_PROJECTION );
|
||||
glLoadIdentity();
|
||||
glOrtho( 0, OGL.width, 0, OGL.height, -1.0f, 1.0f );
|
||||
glViewport( 0, OGL.heightOffset, OGL.width, OGL.height );
|
||||
glDisable( GL_SCISSOR_TEST );
|
||||
|
||||
float u1, v1;
|
||||
|
||||
u1 = 1.0;
|
||||
v1 = 1.0;
|
||||
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||
#ifdef _WINDOWS
|
||||
glDrawBuffer( GL_FRONT );
|
||||
#else
|
||||
glDrawBuffer( GL_BACK );
|
||||
#endif
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f( 0.0f, 0.0f );
|
||||
glVertex2f( 0.0f, 0.0f );
|
||||
|
||||
glTexCoord2f( 0.0f, v1 );
|
||||
glVertex2f( 0.0f, (GLfloat)OGL.height );
|
||||
|
||||
glTexCoord2f( u1, v1 );
|
||||
glVertex2f( (GLfloat)OGL.width, (GLfloat)OGL.height );
|
||||
|
||||
glTexCoord2f( u1, 0.0f );
|
||||
glVertex2f( (GLfloat)OGL.width, 0.0f );
|
||||
glEnd();
|
||||
#ifdef _WINDOWS
|
||||
glDrawBuffer( GL_BACK );
|
||||
#else
|
||||
OGL_SwapBuffers();
|
||||
#endif
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, pBuffer->m_FBO);
|
||||
glBindImageTexture(depthImageUnit, pBuffer->m_pDepthBuffer->m_pDepthTexture->glName, 0, GL_FALSE, 0, GL_READ_WRITE, GL_RGBA32F);
|
||||
|
||||
|
||||
glLoadIdentity();
|
||||
glPopAttrib();
|
||||
|
||||
gSP.changed |= CHANGED_TEXTURE | CHANGED_VIEWPORT;
|
||||
gDP.changed |= CHANGED_COMBINE;
|
||||
#endif
|
||||
}
|
||||
|
||||
void GLS_SetShadowMapCombiner() {
|
||||
|
||||
if (!OGL.bImageTexture)
|
||||
if (!video().getRender().isImageTexturesSupported())
|
||||
return;
|
||||
|
||||
if (g_paletteCRC256 != gDP.paletteCRC256) {
|
||||
|
@ -825,4 +743,3 @@ void GLS_SetShadowMapCombiner() {
|
|||
|
||||
gDP.changed |= CHANGED_COMBINE;
|
||||
}
|
||||
#endif // GLES2
|
||||
|
|
|
@ -105,5 +105,6 @@ private:
|
|||
|
||||
void InitShaderCombiner();
|
||||
void DestroyShaderCombiner();
|
||||
void SetShadowMapCombiner();
|
||||
|
||||
#endif //GLSL_COMBINER_H
|
||||
|
|
|
@ -1,3 +1,2 @@
|
|||
char pluginName[] = "GLideN64 alpha";
|
||||
char * screenDirectory;
|
||||
void (*CheckInterrupts)( void );
|
||||
|
|
|
@ -3,6 +3,5 @@
|
|||
|
||||
extern char pluginName[];
|
||||
extern void (*CheckInterrupts)( void );
|
||||
extern char *screenDirectory;
|
||||
|
||||
#endif // GLIDEN64_H
|
||||
|
|
947
OpenGL.cpp
947
OpenGL.cpp
File diff suppressed because it is too large
Load Diff
198
OpenGL.h
198
OpenGL.h
|
@ -25,92 +25,152 @@
|
|||
|
||||
#include "gSP.h"
|
||||
|
||||
struct GLVertex
|
||||
{
|
||||
float x, y, z, w;
|
||||
float s0, t0, s1, t1;
|
||||
};
|
||||
|
||||
struct GLInfo
|
||||
{
|
||||
#ifdef _WINDOWS
|
||||
HGLRC hRC;
|
||||
HDC hDC;
|
||||
HWND hWnd;
|
||||
HWND hFullscreenWnd;
|
||||
#elif defined(USE_SDL)
|
||||
SDL_Surface *hScreen;
|
||||
#endif // _WINDOWS
|
||||
|
||||
BOOL fullscreen;
|
||||
unsigned int fullscreenWidth, fullscreenHeight, fullscreenBits, fullscreenRefresh;
|
||||
unsigned int width, height, heightOffset;
|
||||
|
||||
float scaleX, scaleY;
|
||||
|
||||
#define INDEXMAP_SIZE 64U
|
||||
#define VERTBUFF_SIZE 256U
|
||||
#define ELEMBUFF_SIZE 1024U
|
||||
|
||||
struct {
|
||||
SPVertex vertices[VERTBUFF_SIZE];
|
||||
GLubyte elements[ELEMBUFF_SIZE];
|
||||
int num;
|
||||
class OGLRender
|
||||
{
|
||||
public:
|
||||
void addTriangle(int _v0, int _v1, int _v2);
|
||||
void drawTriangles();
|
||||
void drawLine(int _v0, int _v1, float _width);
|
||||
void drawRect(int _ulx, int _uly, int _lrx, int _lry, float * _pColor);
|
||||
void drawTexturedRect(
|
||||
float _ulx, float _uly, float _lrx, float _lry,
|
||||
float _uls, float _ult, float _lrs, float _lrt,
|
||||
bool _flip
|
||||
);
|
||||
void clearDepthBuffer();
|
||||
void clearColorBuffer( float * _pColor );
|
||||
|
||||
int getTrianglesCount() const {return triangles.num;}
|
||||
bool isClipped(s32 _v0, s32 _v1, s32 _v2) const
|
||||
{
|
||||
return (triangles.vertices[_v0].clip & triangles.vertices[_v1].clip & triangles.vertices[_v2].clip) != 0;
|
||||
}
|
||||
bool isImageTexturesSupported() const {return m_bImageTexture;}
|
||||
SPVertex & getVertex(u32 _v) {return triangles.vertices[_v];}
|
||||
|
||||
u32 indexmap[INDEXMAP_SIZE];
|
||||
u32 indexmapinv[VERTBUFF_SIZE];
|
||||
u32 indexmap_prev;
|
||||
u32 indexmap_nomap;
|
||||
|
||||
} triangles;
|
||||
|
||||
|
||||
GLVertex rect[4];
|
||||
|
||||
BYTE numTriangles;
|
||||
BYTE numVertices;
|
||||
|
||||
BYTE combiner;
|
||||
enum {
|
||||
fbNone,
|
||||
fbFBO
|
||||
} framebufferMode;
|
||||
enum {
|
||||
enum RENDER_STATE {
|
||||
rsNone = 0,
|
||||
rsTriangle = 1,
|
||||
rsRect = 2,
|
||||
rsTexRect = 3,
|
||||
rsLine = 4
|
||||
} renderState;
|
||||
bool bImageTexture;
|
||||
bool captureScreen;
|
||||
};
|
||||
RENDER_STATE getRenderState() const {return m_renderState;}
|
||||
|
||||
#ifdef __TRIBUFFER_OPT
|
||||
u32 getIndexmap(u32 _v) const {return triangles.indexmap[_v];}
|
||||
u32 getIndexmapNew(u32 _index, u32 _num);
|
||||
void indexmapUndo();
|
||||
#endif // __TRIBUFFER_OPT
|
||||
|
||||
private:
|
||||
OGLRender() : m_bImageTexture(false) {}
|
||||
OGLRender(const OGLRender &);
|
||||
friend class OGLVideo;
|
||||
|
||||
void _initExtensions();
|
||||
void _initStates();
|
||||
void _initData();
|
||||
void _destroyData();
|
||||
|
||||
void _setColorArray() const;
|
||||
void _setTexCoordArrays() const;
|
||||
void _setBlendMode() const;
|
||||
void _updateCullFace() const;
|
||||
void _updateViewport() const;
|
||||
void _updateDepthUpdate() const;
|
||||
void _updateStates() const;
|
||||
|
||||
#ifdef __TRIBUFFER_OPT
|
||||
void _indexmap_init();
|
||||
void _indexmap_clear();
|
||||
u32 _indexmap_findunused(u32 num);
|
||||
#endif
|
||||
|
||||
struct {
|
||||
SPVertex vertices[VERTBUFF_SIZE];
|
||||
GLubyte elements[ELEMBUFF_SIZE];
|
||||
int num;
|
||||
u32 indexmap[INDEXMAP_SIZE];
|
||||
u32 indexmapinv[VERTBUFF_SIZE];
|
||||
u32 indexmap_prev;
|
||||
u32 indexmap_nomap;
|
||||
} triangles;
|
||||
|
||||
struct GLVertex
|
||||
{
|
||||
float x, y, z, w;
|
||||
float s0, t0, s1, t1;
|
||||
};
|
||||
|
||||
RENDER_STATE m_renderState;
|
||||
GLVertex m_rect[4];
|
||||
bool m_bImageTexture;
|
||||
};
|
||||
|
||||
extern GLInfo OGL;
|
||||
class OGLVideo
|
||||
{
|
||||
public:
|
||||
void start();
|
||||
void stop();
|
||||
void swapBuffers();
|
||||
void saveScreenshot();
|
||||
bool changeWindow();
|
||||
void resizeWindow();
|
||||
void setCaptureScreen(const char * const _strDirectory);
|
||||
void setToggleFullscreen() {m_bToggleFullscreen = true;}
|
||||
void readScreen(void **_pDest, long *_pWidth, long *_pHeight );
|
||||
|
||||
void OGL_InitGLFunctions();
|
||||
void OGL_InitData();
|
||||
void OGL_DestroyData();
|
||||
bool OGL_Start();
|
||||
void OGL_Stop();
|
||||
void updateScale();
|
||||
f32 getScaleX() const {return m_scaleX;}
|
||||
f32 getScaleY() const {return m_scaleY;}
|
||||
u32 getWidth() const {return m_width;}
|
||||
u32 getHeight() const {return m_height;}
|
||||
u32 getHeightOffset() const {return m_heightOffset;}
|
||||
bool isFullscreen() const {return m_bFullscreen;}
|
||||
|
||||
void OGL_AddTriangle(int v0, int v1, int v2);
|
||||
void OGL_DrawTriangles();
|
||||
void OGL_DrawTriangle(SPVertex *vertices, int v0, int v1, int v2);
|
||||
void OGL_DrawLine(int v0, int v1, float width);
|
||||
void OGL_DrawRect(int ulx, int uly, int lrx, int lry, float *color);
|
||||
void OGL_DrawTexturedRect(float ulx, float uly, float lrx, float lry, float uls, float ult, float lrs, float lrt, bool flip);
|
||||
void OGL_UpdateScale();
|
||||
void OGL_ClearDepthBuffer();
|
||||
void OGL_ClearColorBuffer( float *color );
|
||||
void OGL_ResizeWindow();
|
||||
void OGL_SaveScreenshot();
|
||||
void OGL_SwapBuffers();
|
||||
void OGL_ReadScreen( void **dest, long *width, long *height );
|
||||
OGLRender & getRender() {return m_render;}
|
||||
|
||||
static OGLVideo & get();
|
||||
|
||||
protected:
|
||||
OGLVideo() :
|
||||
m_bCaptureScreen(false), m_bToggleFullscreen(false), m_bFullscreen(false),
|
||||
m_width(0), m_height(0), m_heightOffset(0), m_scaleX(0), m_scaleY(0), m_strScreenDirectory(NULL)
|
||||
{}
|
||||
|
||||
bool m_bCaptureScreen;
|
||||
bool m_bToggleFullscreen;
|
||||
bool m_bFullscreen;
|
||||
|
||||
u32 m_width, m_height, m_heightOffset;
|
||||
f32 m_scaleX, m_scaleY;
|
||||
|
||||
const char * m_strScreenDirectory;
|
||||
|
||||
OGLRender m_render;
|
||||
|
||||
private:
|
||||
virtual bool _start() = 0;
|
||||
virtual void _stop() = 0;
|
||||
virtual void _swapBuffers() = 0;
|
||||
virtual void _saveScreenshot() = 0;
|
||||
virtual void _changeWindow() = 0;
|
||||
virtual void _resizeWindow() = 0;
|
||||
};
|
||||
|
||||
inline
|
||||
OGLVideo & video()
|
||||
{
|
||||
return OGLVideo::get();
|
||||
}
|
||||
|
||||
void initGLFunctions();
|
||||
bool checkFBO();
|
||||
|
||||
bool isGLError();
|
||||
|
||||
#endif
|
||||
|
|
4
RSP.cpp
4
RSP.cpp
|
@ -124,7 +124,7 @@ LoadLoop:
|
|||
void RSP_ProcessDList()
|
||||
{
|
||||
VI_UpdateSize();
|
||||
OGL_UpdateScale();
|
||||
video().updateScale();
|
||||
|
||||
RSP.PC[0] = *(u32*)&DMEM[0x0FF0];
|
||||
RSP.PCi = 0;
|
||||
|
@ -254,5 +254,5 @@ void RSP_Init()
|
|||
gSP.textureTile[1] = &gDP.tiles[1];
|
||||
// DepthBuffer_Init();
|
||||
GBI_Init();
|
||||
OGL_Start();
|
||||
video().start();
|
||||
}
|
||||
|
|
12
VI.cpp
12
VI.cpp
|
@ -49,10 +49,10 @@ void VI_UpdateScreen()
|
|||
static u32 uNumCurFrameIsShown = 0;
|
||||
glFinish();
|
||||
|
||||
if (OGL.captureScreen) {
|
||||
OGL_SaveScreenshot();
|
||||
OGL.captureScreen = false;
|
||||
}
|
||||
OGLVideo & ogl = video();
|
||||
if (ogl.changeWindow())
|
||||
return;
|
||||
ogl.saveScreenshot();
|
||||
if (((*REG.VI_STATUS)&3) == 0)
|
||||
VI.vStart = VI.vEnd = 0;
|
||||
|
||||
|
@ -64,7 +64,7 @@ void VI_UpdateScreen()
|
|||
FrameBuffer * pBuffer = frameBufferList().findBuffer(*REG.VI_ORIGIN);
|
||||
if (pBuffer == NULL || pBuffer->m_width != *REG.VI_WIDTH) {
|
||||
VI_UpdateSize();
|
||||
OGL_UpdateScale();
|
||||
ogl.updateScale();
|
||||
const u32 size = *REG.VI_STATUS & 3;
|
||||
if (VI.height > 0 && size > G_IM_SIZ_8b && _SHIFTR( *REG.VI_H_START, 0, 10 ) > 0)
|
||||
frameBufferList().saveBuffer( *REG.VI_ORIGIN, G_IM_FMT_RGBA, size, *REG.VI_WIDTH, VI.height );
|
||||
|
@ -90,7 +90,7 @@ void VI_UpdateScreen()
|
|||
}
|
||||
else {
|
||||
if (gSP.changed & CHANGED_COLORBUFFER) {
|
||||
OGL_SwapBuffers();
|
||||
ogl.swapBuffers();
|
||||
gSP.changed &= ~CHANGED_COLORBUFFER;
|
||||
#ifdef DEBUG
|
||||
while (Debug.paused && !Debug.step);
|
||||
|
|
|
@ -20,7 +20,7 @@ void RSP_ThreadProc(std::mutex * _pRspThreadMtx, std::mutex * _pPluginThreadMtx,
|
|||
{
|
||||
_pRspThreadMtx->lock();
|
||||
RSP_Init();
|
||||
OGL_ResizeWindow();
|
||||
video().resizeWindow();
|
||||
assert(!isGLError());
|
||||
|
||||
while (true) {
|
||||
|
@ -36,7 +36,7 @@ void RSP_ThreadProc(std::mutex * _pRspThreadMtx, std::mutex * _pPluginThreadMtx,
|
|||
VI_UpdateScreen();
|
||||
break;
|
||||
case acRomClosed:
|
||||
OGL_Stop();
|
||||
video().stop();
|
||||
GBI_Destroy();
|
||||
*_pCommand = acNone;
|
||||
_pRspThreadMtx->unlock();
|
||||
|
@ -80,7 +80,7 @@ void PluginAPI::RomClosed()
|
|||
delete m_pRspThread;
|
||||
m_pRspThread = NULL;
|
||||
#else
|
||||
OGL_Stop();
|
||||
video().stop();
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
|
@ -99,7 +99,7 @@ void PluginAPI::RomOpen()
|
|||
m_pluginThreadMtx.unlock();
|
||||
#else
|
||||
RSP_Init();
|
||||
OGL_ResizeWindow();
|
||||
video().resizeWindow();
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
|
@ -154,3 +154,8 @@ void PluginAPI::_initiateGFX(const GFX_INFO & _gfxInfo) const {
|
|||
|
||||
CheckInterrupts = _gfxInfo.CheckInterrupts;
|
||||
}
|
||||
|
||||
void PluginAPI::ChangeWindow()
|
||||
{
|
||||
video().setToggleFullscreen();
|
||||
}
|
||||
|
|
|
@ -13,8 +13,7 @@
|
|||
|
||||
void PluginAPI::CaptureScreen(char * _Directory)
|
||||
{
|
||||
screenDirectory = _Directory;
|
||||
OGL.captureScreen = true;
|
||||
video().setCaptureScreen(_Directory);
|
||||
}
|
||||
|
||||
void PluginAPI::DllConfig(HWND _hParent)
|
||||
|
@ -33,5 +32,5 @@ void PluginAPI::GetDllInfo(PLUGIN_INFO * PluginInfo)
|
|||
|
||||
void PluginAPI::ReadScreen(void **_dest, long *_width, long *_height)
|
||||
{
|
||||
OGL_ReadScreen(_dest, _width, _height);
|
||||
video().readScreen(_dest, _width, _height);
|
||||
}
|
||||
|
|
20
gDP.cpp
20
gDP.cpp
|
@ -780,8 +780,8 @@ void gDPFillRDRAM(u32 address, s32 ulx, s32 uly, s32 lrx, s32 lry, u32 width, u3
|
|||
|
||||
void gDPFillRectangle( s32 ulx, s32 uly, s32 lrx, s32 lry )
|
||||
{
|
||||
if (gDP.otherMode.cycleType == G_CYC_FILL)
|
||||
{
|
||||
OGLRender & render = video().getRender();
|
||||
if (gDP.otherMode.cycleType == G_CYC_FILL) {
|
||||
lrx++;
|
||||
lry++;
|
||||
}
|
||||
|
@ -790,29 +790,27 @@ void gDPFillRectangle( s32 ulx, s32 uly, s32 lrx, s32 lry )
|
|||
// If color is not depth clear color, that is most likely the case
|
||||
if (gDP.fillColor.color == DEPTH_CLEAR_COLOR) {
|
||||
gDPFillRDRAM(gDP.colorImage.address, ulx, uly, lrx, lry, gDP.colorImage.width, gDP.colorImage.size, gDP.fillColor.color);
|
||||
OGL_ClearDepthBuffer();
|
||||
render.clearDepthBuffer();
|
||||
return;
|
||||
}
|
||||
} else if (gDP.fillColor.color == DEPTH_CLEAR_COLOR) {
|
||||
depthBufferList().saveBuffer(gDP.colorImage.address);
|
||||
gDPFillRDRAM(gDP.colorImage.address, ulx, uly, lrx, lry, gDP.colorImage.width, gDP.colorImage.size, gDP.fillColor.color);
|
||||
OGL_ClearDepthBuffer();
|
||||
render.clearDepthBuffer();
|
||||
return;
|
||||
}
|
||||
|
||||
f32 fillColor[4];
|
||||
gDPGetFillColor(fillColor);
|
||||
if (gDP.otherMode.cycleType == G_CYC_FILL)
|
||||
{
|
||||
if ((ulx == 0) && (uly == 0) && (lrx == gDP.scissor.lrx) && (lry == gDP.scissor.lry))
|
||||
{
|
||||
if (gDP.otherMode.cycleType == G_CYC_FILL) {
|
||||
if ((ulx == 0) && (uly == 0) && (lrx == gDP.scissor.lrx) && (lry == gDP.scissor.lry)) {
|
||||
gDPFillRDRAM(gDP.colorImage.address, ulx, uly, lrx, lry, gDP.colorImage.width, gDP.colorImage.size, gDP.fillColor.color);
|
||||
OGL_ClearColorBuffer( fillColor );
|
||||
render.clearColorBuffer(fillColor);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
OGL_DrawRect( ulx, uly, lrx, lry, (gDP.otherMode.cycleType == G_CYC_FILL) ? fillColor : &gDP.blendColor.r );
|
||||
render.drawRect(ulx, uly, lrx, lry, (gDP.otherMode.cycleType == G_CYC_FILL) ? fillColor : &gDP.blendColor.r);
|
||||
|
||||
gDP.colorImage.changed = TRUE;
|
||||
if (gDP.otherMode.cycleType == G_CYC_FILL)
|
||||
|
@ -904,7 +902,7 @@ void gDPTextureRectangle( f32 ulx, f32 uly, f32 lrx, f32 lry, s32 tile, f32 s, f
|
|||
tmp = t; t = lrt; lrt = tmp;
|
||||
}
|
||||
|
||||
OGL_DrawTexturedRect( ulx, uly, lrx, lry, s, t, lrs, lrt, (RSP.cmd == G_TEXRECTFLIP));
|
||||
video().getRender().drawTexturedRect( ulx, uly, lrx, lry, s, t, lrs, lrt, (RSP.cmd == G_TEXRECTFLIP));
|
||||
|
||||
gSP.textureTile[0] = textureTileOrg[0];
|
||||
gSP.textureTile[1] = textureTileOrg[1];
|
||||
|
|
70
gSP.h
70
gSP.h
|
@ -18,32 +18,32 @@
|
|||
#define gSPFlushTriangles() \
|
||||
if \
|
||||
( \
|
||||
( \
|
||||
(OGL.triangles.num > 1000) || \
|
||||
( \
|
||||
(RSP.nextCmd != G_NOOP) && \
|
||||
(RSP.nextCmd != G_RDPNOOP) && \
|
||||
(RSP.nextCmd != G_MOVEMEM) && \
|
||||
(RSP.nextCmd != G_ENDDL) && \
|
||||
(RSP.nextCmd != G_DL) && \
|
||||
(RSP.nextCmd != G_VTXCOLORBASE) && \
|
||||
(RSP.nextCmd != G_TRI1) && \
|
||||
(RSP.nextCmd != G_TRI2) && \
|
||||
(RSP.nextCmd != G_TRI4) && \
|
||||
(RSP.nextCmd != G_QUAD) && \
|
||||
(RSP.nextCmd != G_VTX) && \
|
||||
(RSP.nextCmd != G_MTX) \
|
||||
) \
|
||||
) || \
|
||||
( \
|
||||
(RSP.nextCmd != G_TRI1) && \
|
||||
(RSP.nextCmd != G_TRI2) && \
|
||||
(RSP.nextCmd != G_TRI4) && \
|
||||
(RSP.nextCmd != G_QUAD) \
|
||||
) \
|
||||
( \
|
||||
(video().getRender().getTrianglesCount() > 1000) || \
|
||||
( \
|
||||
(RSP.nextCmd != G_NOOP) && \
|
||||
(RSP.nextCmd != G_RDPNOOP) && \
|
||||
(RSP.nextCmd != G_MOVEMEM) && \
|
||||
(RSP.nextCmd != G_ENDDL) && \
|
||||
(RSP.nextCmd != G_DL) && \
|
||||
(RSP.nextCmd != G_VTXCOLORBASE) && \
|
||||
(RSP.nextCmd != G_TRI1) && \
|
||||
(RSP.nextCmd != G_TRI2) && \
|
||||
(RSP.nextCmd != G_TRI4) && \
|
||||
(RSP.nextCmd != G_QUAD) && \
|
||||
(RSP.nextCmd != G_VTX) && \
|
||||
(RSP.nextCmd != G_MTX) \
|
||||
) \
|
||||
) || \
|
||||
( \
|
||||
(RSP.nextCmd != G_TRI1) && \
|
||||
(RSP.nextCmd != G_TRI2) && \
|
||||
(RSP.nextCmd != G_TRI4) && \
|
||||
(RSP.nextCmd != G_QUAD) \
|
||||
) \
|
||||
) \
|
||||
{ \
|
||||
OGL_DrawTriangles(); \
|
||||
video().getRender().drawTriangles(); \
|
||||
}
|
||||
|
||||
#define CLIP_X 0x03
|
||||
|
@ -81,8 +81,8 @@ typedef SPVertex SPTriangle[3];
|
|||
|
||||
struct SPLight
|
||||
{
|
||||
f32 r, g, b;
|
||||
f32 x, y, z;
|
||||
f32 r, g, b;
|
||||
f32 x, y, z;
|
||||
};
|
||||
|
||||
struct gSPInfo
|
||||
|
@ -113,7 +113,7 @@ struct gSPInfo
|
|||
{
|
||||
f32 scales, scalet;
|
||||
s32 level, on, tile;
|
||||
} texture;
|
||||
} texture;
|
||||
|
||||
gDPTile *textureTile[2];
|
||||
|
||||
|
@ -175,7 +175,7 @@ void gSPPopMatrixN( u32 param, u32 num );
|
|||
void gSPSegment( s32 seg, s32 base );
|
||||
void gSPClipRatio( u32 r );
|
||||
void gSPInsertMatrix( u32 where, u32 num );
|
||||
void gSPModifyVertex( u32 vtx, u32 where, u32 val );
|
||||
void gSPModifyVertex(u32 _vtx, u32 _where, u32 _val );
|
||||
void gSPNumLights( s32 n );
|
||||
void gSPLightColor( u32 lightNum, u32 packedColor );
|
||||
void gSPFogFactor( s16 fm, s16 fo );
|
||||
|
@ -204,17 +204,11 @@ void gSPTriangleUnknown();
|
|||
|
||||
void gSP1Triangle(s32 v0, s32 v1, s32 v2);
|
||||
void gSP2Triangles(const s32 v00, const s32 v01, const s32 v02, const s32 flag0,
|
||||
const s32 v10, const s32 v11, const s32 v12, const s32 flag1 );
|
||||
const s32 v10, const s32 v11, const s32 v12, const s32 flag1 );
|
||||
void gSP4Triangles(const s32 v00, const s32 v01, const s32 v02,
|
||||
const s32 v10, const s32 v11, const s32 v12,
|
||||
const s32 v20, const s32 v21, const s32 v22,
|
||||
const s32 v30, const s32 v31, const s32 v32 );
|
||||
|
||||
|
||||
void __indexmap_init();
|
||||
void __indexmap_clear();
|
||||
u32 __indexmap_findunused(u32 num);
|
||||
u32 __indexmap_getnew(u32 index, u32 num);
|
||||
const s32 v10, const s32 v11, const s32 v12,
|
||||
const s32 v20, const s32 v21, const s32 v22,
|
||||
const s32 v30, const s32 v31, const s32 v32 );
|
||||
|
||||
#ifdef __VEC4_OPT
|
||||
extern void (*gSPTransformVertex4)(u32 v, float mtx[4][4]);
|
||||
|
|
|
@ -50,7 +50,13 @@ m64p_error PluginAPI::PluginStartup(m64p_dynlib_handle _CoreLibHandle)
|
|||
|
||||
m64p_error PluginAPI::PluginShutdown()
|
||||
{
|
||||
OGL_Stop();
|
||||
#ifdef RSPTHREAD
|
||||
_callAPICommand(acRomClosed);
|
||||
delete m_pRspThread;
|
||||
m_pRspThread = NULL;
|
||||
#else
|
||||
video().stop();
|
||||
#endif
|
||||
return M64ERR_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -91,18 +97,12 @@ void PluginAPI::SetRenderingCallback(void (*callback)(int))
|
|||
|
||||
void PluginAPI::StartGL()
|
||||
{
|
||||
OGL_Start();
|
||||
}
|
||||
|
||||
void PluginAPI::StopGL()
|
||||
{
|
||||
OGL_Stop();
|
||||
}
|
||||
|
||||
void PluginAPI::ResizeGL(int _width, int _height)
|
||||
{
|
||||
}
|
||||
|
||||
void PluginAPI::ChangeWindow()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -5,23 +5,40 @@
|
|||
#include "../Config.h"
|
||||
|
||||
#ifndef _WINDOWS
|
||||
void OGL_InitGLFunctions()
|
||||
|
||||
void initGLFunctions()
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
void OGL_ResizeWindow()
|
||||
class OGLVideoMupenPlus : public OGLVideo
|
||||
{
|
||||
public:
|
||||
OGLVideoMupenPlus() {}
|
||||
|
||||
private:
|
||||
virtual bool _start();
|
||||
virtual void _stop();
|
||||
virtual void _swapBuffers();
|
||||
virtual void _saveScreenshot();
|
||||
virtual void _resizeWindow();
|
||||
virtual void _changeWindow();
|
||||
};
|
||||
|
||||
OGLVideo & OGLVideo::get()
|
||||
{
|
||||
static OGLVideoMupenPlus video;
|
||||
return video;
|
||||
}
|
||||
|
||||
bool OGL_Start()
|
||||
bool OGLVideoMupenPlus::_start()
|
||||
{
|
||||
if (OGL.fullscreen){
|
||||
OGL.width = config.video.fullscreenWidth;
|
||||
OGL.height = config.video.fullscreenHeight;
|
||||
if (m_bFullscreen){
|
||||
m_width = config.video.fullscreenWidth;
|
||||
m_height = config.video.fullscreenHeight;
|
||||
} else {
|
||||
OGL.width = config.video.windowedWidth;
|
||||
OGL.height = config.video.windowedHeight;
|
||||
m_width = config.video.windowedWidth;
|
||||
m_height = config.video.windowedHeight;
|
||||
}
|
||||
|
||||
CoreVideo_Init();
|
||||
|
@ -30,14 +47,14 @@ bool OGL_Start()
|
|||
CoreVideo_GL_SetAttribute(M64P_GL_BUFFER_SIZE, 16);
|
||||
CoreVideo_GL_SetAttribute(M64P_GL_DEPTH_SIZE, 16);
|
||||
|
||||
printf("(II) Setting video mode %dx%d...\n", OGL.width, OGL.height);
|
||||
if (CoreVideo_SetVideoMode(OGL.width, OGL.height, 0, OGL.fullscreen ? M64VIDEO_FULLSCREEN : M64VIDEO_WINDOWED, (m64p_video_flags) 0) != M64ERR_SUCCESS) {
|
||||
printf("(EE) Error setting videomode %dx%d\n", OGL.width, OGL.height);
|
||||
printf("(II) Setting video mode %dx%d...\n", m_width, m_height);
|
||||
if (CoreVideo_SetVideoMode(m_width, m_height, 0, m_bFullscreen ? M64VIDEO_FULLSCREEN : M64VIDEO_WINDOWED, (m64p_video_flags)0) != M64ERR_SUCCESS) {
|
||||
printf("(EE) Error setting videomode %dx%d\n", m_width, m_height);
|
||||
CoreVideo_Quit();
|
||||
return false;
|
||||
}
|
||||
|
||||
char caption[500];
|
||||
char caption[128];
|
||||
# ifdef _DEBUG
|
||||
sprintf(caption, "GLideN64 debug");
|
||||
# else // _DEBUG
|
||||
|
@ -45,23 +62,41 @@ bool OGL_Start()
|
|||
# endif // _DEBUG
|
||||
CoreVideo_SetCaption(caption);
|
||||
|
||||
OGL_InitData();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void OGL_Stop()
|
||||
void OGLVideoMupenPlus::_stop()
|
||||
{
|
||||
OGL_DestroyData();
|
||||
|
||||
CoreVideo_Quit();
|
||||
}
|
||||
|
||||
void OGL_SwapBuffers()
|
||||
void OGLVideoMupenPlus::_swapBuffers()
|
||||
{
|
||||
CoreVideo_GL_SwapBuffers();
|
||||
}
|
||||
|
||||
void OGL_SaveScreenshot()
|
||||
void OGLVideoMupenPlus::_saveScreenshot()
|
||||
{
|
||||
}
|
||||
|
||||
void OGLVideoMupenPlus::_resizeWindow()
|
||||
{
|
||||
u32 newWidth, newHeight;
|
||||
if (m_bFullscreen) {
|
||||
newWidth = config.video.fullscreenWidth;
|
||||
newHeight = config.video.fullscreenHeight;
|
||||
} else {
|
||||
newWidth = config.video.windowedWidth;
|
||||
newHeight = config.video.windowedHeight;
|
||||
}
|
||||
if (m_width != newWidth || m_height != newHeight) {
|
||||
m_width = newWidth;
|
||||
m_height = newHeight;
|
||||
CoreVideo_ResizeWindow(m_width, m_height);
|
||||
}
|
||||
}
|
||||
|
||||
void OGLVideoMupenPlus::_changeWindow()
|
||||
{
|
||||
CoreVideo_ToggleFullScreen();
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ int PluginAPI::InitiateGFX(const GFX_INFO & _gfxInfo)
|
|||
_initiateGFX(_gfxInfo);
|
||||
|
||||
Config_LoadConfig();
|
||||
OGL.hScreen = NULL;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -7,25 +7,42 @@ void OGL_InitGLFunctions()
|
|||
{
|
||||
}
|
||||
|
||||
void OGL_ResizeWindow()
|
||||
class OGLVideoPosix : public OGLVideo
|
||||
{
|
||||
public:
|
||||
OGLVideoPosix() : hScreen(NULL) {}
|
||||
|
||||
private:
|
||||
virtual bool _start();
|
||||
virtual void _stop();
|
||||
virtual void _swapBuffers();
|
||||
virtual void _saveScreenshot();
|
||||
virtual void _resizeWindow();
|
||||
virtual void _changeWindow();
|
||||
|
||||
#if defined(USE_SDL)
|
||||
SDL_Surface *hScreen;
|
||||
#endif
|
||||
};
|
||||
|
||||
OGLVideo & OGLVideo::get()
|
||||
{
|
||||
static OGLVideoPosix video;
|
||||
return video;
|
||||
}
|
||||
|
||||
bool OGL_Start()
|
||||
bool OGLVideoPosix::_start()
|
||||
{
|
||||
#ifdef USE_SDL
|
||||
// init sdl & gl
|
||||
Uint32 videoFlags = 0;
|
||||
|
||||
if (OGL.fullscreen)
|
||||
{
|
||||
OGL.width = config.video.fullscreenWidth;
|
||||
OGL.height = config.video.fullscreenHeight;
|
||||
}
|
||||
else
|
||||
{
|
||||
OGL.width = config.video.windowedWidth;
|
||||
OGL.height = config.video.windowedHeight;
|
||||
if (m_bFullscreen) {
|
||||
m_width = config.video.fullscreenWidth;
|
||||
m_height = config.video.fullscreenHeight;
|
||||
} else {
|
||||
m_width = config.video.windowedWidth;
|
||||
m_height = config.video.windowedHeight;
|
||||
}
|
||||
|
||||
/* Initialize SDL */
|
||||
|
@ -63,10 +80,10 @@ bool OGL_Start()
|
|||
SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 5 );*/
|
||||
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 ); // 32 bit z-buffer
|
||||
|
||||
printf( "[glN64]: (II) Setting video mode %dx%d...\n", OGL.width, OGL.height );
|
||||
if (!(OGL.hScreen = SDL_SetVideoMode( OGL.width, OGL.height, 0, videoFlags )))
|
||||
printf( "[glN64]: (II) Setting video mode %dx%d...\n", m_width, m_height );
|
||||
if (!(hScreen = SDL_SetVideoMode(m_width, m_height, 0, videoFlags)))
|
||||
{
|
||||
printf( "[glN64]: (EE) Error setting videomode %dx%d: %s\n", OGL.width, OGL.height, SDL_GetError() );
|
||||
printf( "[glN64]: (EE) Error setting videomode %dx%d: %s\n", m_width, m_height, SDL_GetError() );
|
||||
SDL_QuitSubSystem( SDL_INIT_VIDEO );
|
||||
return false;
|
||||
}
|
||||
|
@ -74,22 +91,18 @@ bool OGL_Start()
|
|||
SDL_WM_SetCaption( pluginName, pluginName );
|
||||
#endif // USE_SDL
|
||||
|
||||
OGL_InitData();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void OGL_Stop()
|
||||
void OGLVideoPosix::_stop()
|
||||
{
|
||||
OGL_DestroyData();
|
||||
|
||||
#if defined(USE_SDL)
|
||||
SDL_QuitSubSystem( SDL_INIT_VIDEO );
|
||||
OGL.hScreen = NULL;
|
||||
hScreen = NULL;
|
||||
#endif // _WINDOWS
|
||||
}
|
||||
|
||||
void OGL_SwapBuffers()
|
||||
void OGLVideoPosix::_swapBuffers()
|
||||
{
|
||||
#if defined(USE_SDL)
|
||||
static int frames[5] = { 0, 0, 0, 0, 0 };
|
||||
|
@ -115,6 +128,17 @@ void OGL_SwapBuffers()
|
|||
#endif // USE_SDL
|
||||
}
|
||||
|
||||
void OGL_SaveScreenshot()
|
||||
void OGLVideoPosix::_saveScreenshot()
|
||||
{
|
||||
}
|
||||
|
||||
void OGLVideoPosix::_resizeWindow()
|
||||
{
|
||||
}
|
||||
|
||||
void OGLVideoPosix::_changeWindow()
|
||||
{
|
||||
#if defined(USE_SDL)
|
||||
SDL_WM_ToggleFullScreen( hScreen );
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -3,13 +3,6 @@
|
|||
#include "../GLideN64.h"
|
||||
#include "../OpenGL.h"
|
||||
|
||||
void PluginAPI::ChangeWindow()
|
||||
{
|
||||
#if defined(USE_SDL)
|
||||
SDL_WM_ToggleFullScreen( OGL.hScreen );
|
||||
#endif
|
||||
}
|
||||
|
||||
void PluginAPI::DllAbout(HWND _hParent)
|
||||
{
|
||||
puts( "GLideN64 alpha. Based on Orkin's glN64 v0.4" );
|
||||
|
|
|
@ -187,8 +187,8 @@ void Config_ApplyDlgConfig( HWND hWndDlg )
|
|||
config.frameBufferEmulation.enable = (SendDlgItemMessage( hWndDlg, IDC_FRAMEBUFFER, BM_GETCHECK, NULL, NULL ) == BST_CHECKED);
|
||||
config.enableHWLighting = (SendDlgItemMessage( hWndDlg, IDC_HWLIGHT, BM_GETCHECK, NULL, NULL ) == BST_CHECKED);
|
||||
|
||||
if (!OGL.fullscreen)
|
||||
OGL_ResizeWindow();
|
||||
if (!video().isFullscreen())
|
||||
video().resizeWindow();
|
||||
|
||||
Config_SaveConfig();
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ PFNGLDELETEBUFFERSPROC glDeleteBuffers;
|
|||
PFNGLBINDIMAGETEXTUREPROC glBindImageTexture;
|
||||
PFNGLMEMORYBARRIERPROC glMemoryBarrier;
|
||||
|
||||
void OGL_InitGLFunctions()
|
||||
void initGLFunctions()
|
||||
{
|
||||
glCreateShader = (PFNGLCREATESHADERPROC)wglGetProcAddress("glCreateShader");
|
||||
glCompileShader = (PFNGLCOMPILESHADERPROC)wglGetProcAddress("glCompileShader");
|
||||
|
|
|
@ -11,10 +11,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD dwReason, LPVOID /*lpvReserved*/)
|
|||
{
|
||||
hInstance = hinstDLL;
|
||||
|
||||
if (dwReason == DLL_PROCESS_ATTACH) {
|
||||
if (dwReason == DLL_PROCESS_ATTACH)
|
||||
Config_LoadConfig();
|
||||
OGL.hRC = NULL;
|
||||
OGL.hDC = NULL;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -4,43 +4,30 @@
|
|||
#include "../Config.h"
|
||||
#include "../OpenGL.h"
|
||||
|
||||
void OGL_ResizeWindow()
|
||||
class OGLVideoWindows : public OGLVideo
|
||||
{
|
||||
RECT windowRect, statusRect, toolRect;
|
||||
public:
|
||||
OGLVideoWindows() : hRC(NULL), hDC(NULL) {}
|
||||
|
||||
if (OGL.fullscreen)
|
||||
{
|
||||
OGL.width = config.video.fullscreenWidth;
|
||||
OGL.height = config.video.fullscreenHeight;
|
||||
OGL.heightOffset = 0;
|
||||
private:
|
||||
virtual bool _start();
|
||||
virtual void _stop();
|
||||
virtual void _swapBuffers();
|
||||
virtual void _saveScreenshot();
|
||||
virtual void _resizeWindow();
|
||||
virtual void _changeWindow();
|
||||
|
||||
SetWindowPos( hWnd, NULL, 0, 0, OGL.width, OGL.height, SWP_NOACTIVATE | SWP_NOZORDER | SWP_SHOWWINDOW );
|
||||
}
|
||||
else
|
||||
{
|
||||
OGL.width = config.video.windowedWidth;
|
||||
OGL.height = config.video.windowedHeight;
|
||||
HGLRC hRC;
|
||||
HDC hDC;
|
||||
};
|
||||
|
||||
GetClientRect( hWnd, &windowRect );
|
||||
GetWindowRect( hStatusBar, &statusRect );
|
||||
|
||||
if (hToolBar)
|
||||
GetWindowRect( hToolBar, &toolRect );
|
||||
else
|
||||
toolRect.bottom = toolRect.top = 0;
|
||||
|
||||
OGL.heightOffset = (statusRect.bottom - statusRect.top);
|
||||
windowRect.right = windowRect.left + config.video.windowedWidth - 1;
|
||||
windowRect.bottom = windowRect.top + config.video.windowedHeight - 1 + OGL.heightOffset;
|
||||
|
||||
AdjustWindowRect( &windowRect, GetWindowLong( hWnd, GWL_STYLE ), GetMenu( hWnd ) != NULL );
|
||||
|
||||
SetWindowPos( hWnd, NULL, 0, 0, windowRect.right - windowRect.left + 1,
|
||||
windowRect.bottom - windowRect.top + 1 + toolRect.bottom - toolRect.top + 1, SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE );
|
||||
}
|
||||
OGLVideo & OGLVideo::get()
|
||||
{
|
||||
static OGLVideoWindows video;
|
||||
return video;
|
||||
}
|
||||
|
||||
bool OGL_Start()
|
||||
bool OGLVideoWindows::_start()
|
||||
{
|
||||
int pixelFormat;
|
||||
|
||||
|
@ -68,86 +55,83 @@ bool OGL_Start()
|
|||
if (hWnd == NULL)
|
||||
hWnd = GetActiveWindow();
|
||||
|
||||
if ((OGL.hDC = GetDC( hWnd )) == NULL) {
|
||||
if ((hDC = GetDC( hWnd )) == NULL) {
|
||||
MessageBox( hWnd, "Error while getting a device context!", pluginName, MB_ICONERROR | MB_OK );
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((pixelFormat = ChoosePixelFormat( OGL.hDC, &pfd )) == 0) {
|
||||
if ((pixelFormat = ChoosePixelFormat(hDC, &pfd )) == 0) {
|
||||
MessageBox( hWnd, "Unable to find a suitable pixel format!", pluginName, MB_ICONERROR | MB_OK );
|
||||
OGL_Stop();
|
||||
_stop();
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((SetPixelFormat( OGL.hDC, pixelFormat, &pfd )) == FALSE) {
|
||||
if ((SetPixelFormat(hDC, pixelFormat, &pfd )) == FALSE) {
|
||||
MessageBox( hWnd, "Error while setting pixel format!", pluginName, MB_ICONERROR | MB_OK );
|
||||
OGL_Stop();
|
||||
_stop();
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((OGL.hRC = wglCreateContext( OGL.hDC )) == NULL) {
|
||||
if ((hRC = wglCreateContext(hDC)) == NULL) {
|
||||
MessageBox( hWnd, "Error while creating OpenGL context!", pluginName, MB_ICONERROR | MB_OK );
|
||||
OGL_Stop();
|
||||
_stop();
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((wglMakeCurrent( OGL.hDC, OGL.hRC )) == FALSE) {
|
||||
if ((wglMakeCurrent(hDC, hRC)) == FALSE) {
|
||||
MessageBox( hWnd, "Error while making OpenGL context current!", pluginName, MB_ICONERROR | MB_OK );
|
||||
OGL_Stop();
|
||||
_stop();
|
||||
return false;
|
||||
}
|
||||
|
||||
OGL_InitData();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void OGL_Stop()
|
||||
void OGLVideoWindows::_stop()
|
||||
{
|
||||
OGL_DestroyData();
|
||||
wglMakeCurrent( NULL, NULL );
|
||||
|
||||
if (OGL.hRC) {
|
||||
wglDeleteContext( OGL.hRC );
|
||||
OGL.hRC = NULL;
|
||||
if (hRC != NULL) {
|
||||
wglDeleteContext(hRC);
|
||||
hRC = NULL;
|
||||
}
|
||||
|
||||
if (OGL.hDC) {
|
||||
ReleaseDC( hWnd, OGL.hDC );
|
||||
OGL.hDC = NULL;
|
||||
if (hDC != NULL) {
|
||||
ReleaseDC(hWnd, hDC);
|
||||
hDC = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void OGL_SwapBuffers()
|
||||
void OGLVideoWindows::_swapBuffers()
|
||||
{
|
||||
if (OGL.hDC == NULL)
|
||||
if (hDC == NULL)
|
||||
SwapBuffers( wglGetCurrentDC() );
|
||||
else
|
||||
SwapBuffers( OGL.hDC );
|
||||
SwapBuffers( hDC );
|
||||
}
|
||||
|
||||
void OGL_SaveScreenshot()
|
||||
void OGLVideoWindows::_saveScreenshot()
|
||||
{
|
||||
BITMAPFILEHEADER fileHeader;
|
||||
BITMAPINFOHEADER infoHeader;
|
||||
HANDLE hBitmapFile;
|
||||
|
||||
char *pixelData = (char*)malloc( OGL.width * OGL.height * 3 );
|
||||
char *pixelData = (char*)malloc( m_width * m_height * 3 );
|
||||
|
||||
GLint oldMode;
|
||||
glGetIntegerv( GL_READ_BUFFER, &oldMode );
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
|
||||
glReadBuffer( GL_FRONT );
|
||||
glReadPixels( 0, OGL.heightOffset, OGL.width, OGL.height, GL_BGR_EXT, GL_UNSIGNED_BYTE, pixelData );
|
||||
glReadPixels( 0, m_heightOffset, m_width, m_height, GL_BGR_EXT, GL_UNSIGNED_BYTE, pixelData );
|
||||
glReadBuffer( oldMode );
|
||||
|
||||
infoHeader.biSize = sizeof( BITMAPINFOHEADER );
|
||||
infoHeader.biWidth = OGL.width;
|
||||
infoHeader.biHeight = OGL.height;
|
||||
infoHeader.biWidth = m_width;
|
||||
infoHeader.biHeight = m_height;
|
||||
infoHeader.biPlanes = 1;
|
||||
infoHeader.biBitCount = 24;
|
||||
infoHeader.biCompression = BI_RGB;
|
||||
infoHeader.biSizeImage = OGL.width * OGL.height * 3;
|
||||
infoHeader.biSizeImage = m_width * m_height * 3;
|
||||
infoHeader.biXPelsPerMeter = 0;
|
||||
infoHeader.biYPelsPerMeter = 0;
|
||||
infoHeader.biClrUsed = 0;
|
||||
|
@ -160,20 +144,17 @@ void OGL_SaveScreenshot()
|
|||
|
||||
char filename[256];
|
||||
|
||||
CreateDirectory( screenDirectory, NULL );
|
||||
CreateDirectory( m_strScreenDirectory, NULL );
|
||||
|
||||
int i = 0;
|
||||
do
|
||||
{
|
||||
sprintf( filename, "%sscreen%02i.bmp", screenDirectory, i );
|
||||
i++;
|
||||
do {
|
||||
sprintf(filename, "%sscreen%02i.bmp", m_strScreenDirectory, i++);
|
||||
|
||||
if (i > 99)
|
||||
return;
|
||||
|
||||
hBitmapFile = CreateFile( filename, GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL );
|
||||
}
|
||||
while (hBitmapFile == INVALID_HANDLE_VALUE);
|
||||
} while (hBitmapFile == INVALID_HANDLE_VALUE);
|
||||
|
||||
DWORD written;
|
||||
|
||||
|
@ -184,3 +165,98 @@ void OGL_SaveScreenshot()
|
|||
CloseHandle( hBitmapFile );
|
||||
free( pixelData );
|
||||
}
|
||||
|
||||
void OGLVideoWindows::_changeWindow()
|
||||
{
|
||||
static LONG windowedStyle;
|
||||
static LONG windowedExStyle;
|
||||
static RECT windowedRect;
|
||||
static HMENU windowedMenu;
|
||||
|
||||
if (!m_bFullscreen) {
|
||||
DEVMODE fullscreenMode;
|
||||
memset( &fullscreenMode, 0, sizeof(DEVMODE) );
|
||||
fullscreenMode.dmSize = sizeof(DEVMODE);
|
||||
fullscreenMode.dmPelsWidth = config.video.fullscreenWidth;
|
||||
fullscreenMode.dmPelsHeight = config.video.fullscreenHeight;
|
||||
fullscreenMode.dmBitsPerPel = config.video.fullscreenBits;
|
||||
fullscreenMode.dmDisplayFrequency = config.video.fullscreenRefresh;
|
||||
fullscreenMode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY;
|
||||
|
||||
if (ChangeDisplaySettings( &fullscreenMode, CDS_FULLSCREEN ) != DISP_CHANGE_SUCCESSFUL) {
|
||||
MessageBox( NULL, "Failed to change display mode", pluginName, MB_ICONERROR | MB_OK );
|
||||
return;
|
||||
}
|
||||
|
||||
ShowCursor( FALSE );
|
||||
|
||||
windowedMenu = GetMenu( hWnd );
|
||||
|
||||
if (windowedMenu)
|
||||
SetMenu( hWnd, NULL );
|
||||
|
||||
if (hStatusBar)
|
||||
ShowWindow( hStatusBar, SW_HIDE );
|
||||
|
||||
windowedExStyle = GetWindowLong( hWnd, GWL_EXSTYLE );
|
||||
windowedStyle = GetWindowLong( hWnd, GWL_STYLE );
|
||||
|
||||
SetWindowLong( hWnd, GWL_EXSTYLE, WS_EX_APPWINDOW | WS_EX_TOPMOST );
|
||||
SetWindowLong( hWnd, GWL_STYLE, WS_POPUP );
|
||||
|
||||
GetWindowRect( hWnd, &windowedRect );
|
||||
|
||||
m_bFullscreen = true;
|
||||
_resizeWindow();
|
||||
} else {
|
||||
ChangeDisplaySettings( NULL, 0 );
|
||||
|
||||
ShowCursor( TRUE );
|
||||
|
||||
if (windowedMenu)
|
||||
SetMenu( hWnd, windowedMenu );
|
||||
|
||||
if (hStatusBar)
|
||||
ShowWindow( hStatusBar, SW_SHOW );
|
||||
|
||||
SetWindowLong( hWnd, GWL_STYLE, windowedStyle );
|
||||
SetWindowLong( hWnd, GWL_EXSTYLE, windowedExStyle );
|
||||
SetWindowPos( hWnd, NULL, windowedRect.left, windowedRect.top, 0, 0, SWP_NOZORDER | SWP_NOSIZE );
|
||||
|
||||
m_bFullscreen = false;
|
||||
_resizeWindow();
|
||||
}
|
||||
}
|
||||
|
||||
void OGLVideoWindows::_resizeWindow()
|
||||
{
|
||||
RECT windowRect, statusRect, toolRect;
|
||||
|
||||
if (m_bFullscreen) {
|
||||
m_width = config.video.fullscreenWidth;
|
||||
m_height = config.video.fullscreenHeight;
|
||||
m_heightOffset = 0;
|
||||
|
||||
SetWindowPos( hWnd, NULL, 0, 0, m_width, m_height, SWP_NOACTIVATE | SWP_NOZORDER | SWP_SHOWWINDOW );
|
||||
} else {
|
||||
m_width = config.video.windowedWidth;
|
||||
m_height = config.video.windowedHeight;
|
||||
|
||||
GetClientRect( hWnd, &windowRect );
|
||||
GetWindowRect( hStatusBar, &statusRect );
|
||||
|
||||
if (hToolBar)
|
||||
GetWindowRect( hToolBar, &toolRect );
|
||||
else
|
||||
toolRect.bottom = toolRect.top = 0;
|
||||
|
||||
m_heightOffset = (statusRect.bottom - statusRect.top);
|
||||
windowRect.right = windowRect.left + config.video.windowedWidth - 1;
|
||||
windowRect.bottom = windowRect.top + config.video.windowedHeight - 1 + m_heightOffset;
|
||||
|
||||
AdjustWindowRect( &windowRect, GetWindowLong( hWnd, GWL_STYLE ), GetMenu( hWnd ) != NULL );
|
||||
|
||||
SetWindowPos( hWnd, NULL, 0, 0, windowRect.right - windowRect.left + 1,
|
||||
windowRect.bottom - windowRect.top + 1 + toolRect.bottom - toolRect.top + 1, SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,68 +3,6 @@
|
|||
#include "../GLideN64.h"
|
||||
#include "../OpenGL.h"
|
||||
|
||||
LONG windowedStyle;
|
||||
LONG windowedExStyle;
|
||||
RECT windowedRect;
|
||||
HMENU windowedMenu;
|
||||
|
||||
void PluginAPI::ChangeWindow()
|
||||
{
|
||||
if (!OGL.fullscreen) {
|
||||
DEVMODE fullscreenMode;
|
||||
memset( &fullscreenMode, 0, sizeof(DEVMODE) );
|
||||
fullscreenMode.dmSize = sizeof(DEVMODE);
|
||||
fullscreenMode.dmPelsWidth = OGL.fullscreenWidth;
|
||||
fullscreenMode.dmPelsHeight = OGL.fullscreenHeight;
|
||||
fullscreenMode.dmBitsPerPel = OGL.fullscreenBits;
|
||||
fullscreenMode.dmDisplayFrequency = OGL.fullscreenRefresh;
|
||||
fullscreenMode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY;
|
||||
|
||||
if (ChangeDisplaySettings( &fullscreenMode, CDS_FULLSCREEN ) != DISP_CHANGE_SUCCESSFUL) {
|
||||
MessageBox( NULL, "Failed to change display mode", pluginName, MB_ICONERROR | MB_OK );
|
||||
return;
|
||||
}
|
||||
|
||||
ShowCursor( FALSE );
|
||||
|
||||
windowedMenu = GetMenu( hWnd );
|
||||
|
||||
if (windowedMenu)
|
||||
SetMenu( hWnd, NULL );
|
||||
|
||||
if (hStatusBar)
|
||||
ShowWindow( hStatusBar, SW_HIDE );
|
||||
|
||||
windowedExStyle = GetWindowLong( hWnd, GWL_EXSTYLE );
|
||||
windowedStyle = GetWindowLong( hWnd, GWL_STYLE );
|
||||
|
||||
SetWindowLong( hWnd, GWL_EXSTYLE, WS_EX_APPWINDOW | WS_EX_TOPMOST );
|
||||
SetWindowLong( hWnd, GWL_STYLE, WS_POPUP );
|
||||
|
||||
GetWindowRect( hWnd, &windowedRect );
|
||||
|
||||
OGL.fullscreen = TRUE;
|
||||
OGL_ResizeWindow();
|
||||
} else {
|
||||
ChangeDisplaySettings( NULL, 0 );
|
||||
|
||||
ShowCursor( TRUE );
|
||||
|
||||
if (windowedMenu)
|
||||
SetMenu( hWnd, windowedMenu );
|
||||
|
||||
if (hStatusBar)
|
||||
ShowWindow( hStatusBar, SW_SHOW );
|
||||
|
||||
SetWindowLong( hWnd, GWL_STYLE, windowedStyle );
|
||||
SetWindowLong( hWnd, GWL_EXSTYLE, windowedExStyle );
|
||||
SetWindowPos( hWnd, NULL, windowedRect.left, windowedRect.top, 0, 0, SWP_NOZORDER | SWP_NOSIZE );
|
||||
|
||||
OGL.fullscreen = FALSE;
|
||||
OGL_ResizeWindow();
|
||||
}
|
||||
}
|
||||
|
||||
void PluginAPI::DllAbout(HWND _hParent)
|
||||
{
|
||||
MessageBox(_hParent, "GLideN64 alpha. Based on Orkin's glN64 v0.4", pluginName, MB_OK | MB_ICONINFORMATION );
|
||||
|
|
Loading…
Reference in New Issue
Block a user