better reset 3d code. fix boneheaded mistake which caused alpha blending never to be enabled.

This commit is contained in:
zeromus 2008-09-14 18:50:16 +00:00
parent c1435f875b
commit 8ee198006f
5 changed files with 33 additions and 8 deletions

View File

@ -540,6 +540,7 @@ void NDS_Reset( void)
GPU_Reset(MainScreen.gpu, 0); GPU_Reset(MainScreen.gpu, 0);
GPU_Reset(SubScreen.gpu, 1); GPU_Reset(SubScreen.gpu, 1);
gfx3d_reset();
gpu3D->NDS_3D_Reset(); gpu3D->NDS_3D_Reset();
SPU_Reset(); SPU_Reset();

View File

@ -28,6 +28,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <assert.h> #include <assert.h>
#include <debug.h>
bool (*oglrender_init)() = 0; bool (*oglrender_init)() = 0;
bool (*oglrender_beginOpenGL)() = 0; bool (*oglrender_beginOpenGL)() = 0;
@ -239,12 +240,17 @@ static void Reset()
{ {
int i; int i;
//reset the texture cache
memset(&texcache,0,sizeof(texcache)); memset(&texcache,0,sizeof(texcache));
texcache_count=0; texcache_count=0;
for (i = 0; i < MAX_TEXTURE; i++) for (i = 0; i < MAX_TEXTURE; i++)
texcache[i].id=oglTempTextureID[i]; texcache[i].id=oglTempTextureID[i];
texcache_start=0; texcache_start=0;
texcache_stop=MAX_TEXTURE<<1; texcache_stop=MAX_TEXTURE<<1;
//clear the framebuffers
memset(GPU_screenStencil,0,sizeof(GPU_screenStencil));
memset(GPU_screen3D,0,sizeof(GPU_screen3D));
} }
static char Init(void) static char Init(void)
@ -780,7 +786,7 @@ void setTexture(unsigned int format, unsigned int texpal)
texcache[i].sizeX, texcache[i].sizeY, 0, texcache[i].sizeX, texcache[i].sizeY, 0,
GL_RGBA, GL_UNSIGNED_BYTE, texMAP); GL_RGBA, GL_UNSIGNED_BYTE, texMAP);
//DebugDumpTexture(i); DebugDumpTexture(i);
//============================================================================================ //============================================================================================
@ -869,7 +875,6 @@ static void BeginRenderPoly()
} }
} }
} else { } else {
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, texEnv[envMode]);
xglEnable(GL_STENCIL_TEST); xglEnable(GL_STENCIL_TEST);
if(stencilStateSet!=2) { if(stencilStateSet!=2) {
stencilStateSet=2; stencilStateSet=2;
@ -879,6 +884,8 @@ static void BeginRenderPoly()
} }
} }
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, texEnv[envMode]);
//handle toon rendering //handle toon rendering
#ifdef _WIN32 #ifdef _WIN32
if(glUseProgram) { if(glUseProgram) {

View File

@ -187,9 +187,16 @@ static void makeTables() {
void gfx3d_init() void gfx3d_init()
{ {
twiddleLists();
makeTables(); makeTables();
gfx3d_reset();
}
void gfx3d_reset()
{
gfx3d = GFX3D();
listTwiddle = 1;
twiddleLists();
MatrixStackSetMaxSize(&mtxStack[0], 1); // Projection stack MatrixStackSetMaxSize(&mtxStack[0], 1); // Projection stack
MatrixStackSetMaxSize(&mtxStack[1], 31); // Coordinate stack MatrixStackSetMaxSize(&mtxStack[1], 31); // Coordinate stack
@ -1426,16 +1433,16 @@ void gfx3d_Control(unsigned long v)
else gfx3d.shading = GFX3D::TOON; else gfx3d.shading = GFX3D::TOON;
if((v>>2)&1) gfx3d.enableAlphaTest = true; if((v>>2)&1) gfx3d.enableAlphaTest = true;
gfx3d.enableAlphaTest = false; else gfx3d.enableAlphaTest = false;
if((v>>3)&1) gfx3d.enableAlphaBlending = true; if((v>>3)&1) gfx3d.enableAlphaBlending = true;
gfx3d.enableAlphaBlending = false; else gfx3d.enableAlphaBlending = false;
if((v>>4)&1) gfx3d.enableAntialiasing = true; if((v>>4)&1) gfx3d.enableAntialiasing = true;
gfx3d.enableAntialiasing = false; else gfx3d.enableAntialiasing = false;
if((v>>5)&1) gfx3d.enableEdgeMarking = true; if((v>>5)&1) gfx3d.enableEdgeMarking = true;
gfx3d.enableEdgeMarking = false; else gfx3d.enableEdgeMarking = false;
//other junk //other junk

View File

@ -24,6 +24,7 @@
#include "types.h" #include "types.h"
void gfx3d_init(); void gfx3d_init();
void gfx3d_reset();
struct POLY { struct POLY {
int type; //tri or quad int type; //tri or quad

View File

@ -23,6 +23,9 @@
#include <windows.h> #include <windows.h>
#include <stdio.h> #include <stdio.h>
#include <fcntl.h>
#include <io.h>
///////////////////////////////////////////////////////////////// Console ///////////////////////////////////////////////////////////////// Console
#ifdef BETA_VERSION #ifdef BETA_VERSION
@ -55,6 +58,12 @@ void OpenConsole()
SetConsoleOutputCP(GetACP()); SetConsoleOutputCP(GetACP());
printlog("DeSmuME v%s BETA\n",VERSION); printlog("DeSmuME v%s BETA\n",VERSION);
printlog("- compiled: %s %s\n\n",__DATE__,__TIME__); printlog("- compiled: %s %s\n\n",__DATE__,__TIME__);
//redirect stdio
long lStdHandle = (long)GetStdHandle(STD_OUTPUT_HANDLE);
int hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
FILE *fp = _fdopen( hConHandle, "w" );
*stdout = *fp;
} }
void CloseConsole() { void CloseConsole() {