Skip to content

Commit

Permalink
Added more render control options, wireframe option works, added more…
Browse files Browse the repository at this point in the history
… hacks.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@988 8ced0084-cf51-0410-be5f-012b33b47a6e
  • Loading branch information
omegadox committed Oct 28, 2008
1 parent 09a0b34 commit 46f0dd8
Show file tree
Hide file tree
Showing 8 changed files with 173 additions and 28 deletions.
17 changes: 11 additions & 6 deletions Source/Plugins/Plugin_VideoOGL/Src/BPStructs.cpp
Expand Up @@ -54,9 +54,8 @@ static const GLenum glDestFactors[8] = {
GL_ZERO, GL_ONE, GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR,
GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA
};

static const GLenum glCmpFuncs[8] = {
GL_NEVER, GL_LESS, GL_EQUAL, GL_LEQUAL, GL_GREATER, GL_NOTEQUAL, GL_GEQUAL, GL_ALWAYS
GL_NEVER, GL_LESS, GL_EQUAL, GL_LEQUAL, GL_GREATER, GL_NOTEQUAL, GL_GEQUAL, GL_ALWAYS };
};

static const GLenum glLogicOpCodes[16] = {
Expand Down Expand Up @@ -90,7 +89,7 @@ void BPWritten(int addr, int changes, int newval)
bpmem.genMode.numindstages, bpmem.genMode.zfreeze);

// none, ccw, cw, ccw
if (bpmem.genMode.cullmode>0) {
if (bpmem.genMode.cullmode>0 && !g_Config.bDisableCulling) {
glEnable(GL_CULL_FACE);
glFrontFace(bpmem.genMode.cullmode == 2 ? GL_CCW : GL_CW);
}
Expand Down Expand Up @@ -441,13 +440,18 @@ void BPWritten(int addr, int changes, int newval)
(int)((bpmem.copyTexSrcXY.y * MValueY + (bpmem.copyTexSrcWH.y + 1) * MValueY))
};

UPE_Copy PE_copy;
PE_copy.Hex = bpmem.triggerEFBCopy;
UPE_Copy PE_copy;
PE_copy.Hex = bpmem.triggerEFBCopy;

if (PE_copy.copy_to_xfb == 0) {
if(g_Config.bEBFToTextureDisable) {
glViewport(rc.left,rc.bottom,rc.right,rc.top);
glScissor(rc.left,rc.bottom,rc.right,rc.top);
}
else
// EFB to texture
// for some reason it sets bpmem.zcontrol.pixel_format to PIXELFMT_Z24 every time a zbuffer format is given as a dest to GXSetTexCopyDst
TextureMngr::CopyRenderTargetToTexture(bpmem.copyTexDest<<5, bpmem.zcontrol.pixel_format==PIXELFMT_Z24, PE_copy.intensity_fmt>0,
TextureMngr::CopyRenderTargetToTexture(bpmem.copyTexDest<<5, bpmem.zcontrol.pixel_format==PIXELFMT_Z24, PE_copy.intensity_fmt>0,
(PE_copy.target_pixel_format/2)+((PE_copy.target_pixel_format&1)*8), PE_copy.half_scale>0, &rc);
}
else {
Expand Down Expand Up @@ -486,6 +490,7 @@ void BPWritten(int addr, int changes, int newval)
if (bpmem.blendmode.colorupdate || bpmem.blendmode.alphaupdate) {
u32 clearColor = (bpmem.clearcolorAR << 16) | bpmem.clearcolorGB;
glClearColor(((clearColor>>16) & 0xff)*(1/255.0f),

((clearColor>>8 ) & 0xff)*(1/255.0f),
((clearColor>>0 ) & 0xff)*(1/255.0f),
((clearColor>>24) & 0xff)*(1/255.0f));
Expand Down
14 changes: 14 additions & 0 deletions Source/Plugins/Plugin_VideoOGL/Src/Config.cpp
Expand Up @@ -67,13 +67,20 @@ void Config::Load()
iniFile.Get("Settings", "TexFmtOverlayEnable", &bTexFmtOverlayEnable, 0);
iniFile.Get("Settings", "TexFmtOverlayCenter", &bTexFmtOverlayCenter, 0);
iniFile.Get("Settings", "UseXFB", &bUseXFB, 0);
iniFile.Get("Settings", "WireFrame", &bWireFrame, 0);
iniFile.Get("Settings", "DisableLighting", &bDisableLighting, 0);
iniFile.Get("Settings", "DisableTexturing", &bDisableTexturing, 0);
iniFile.Get("Settings", "DisableCulling", &bDisableCulling, 0);

iniFile.Get("Enhancements", "ForceFiltering", &bForceFiltering, 0);
iniFile.Get("Enhancements", "ForceMaxAniso", &bForceMaxAniso, 0);
iniFile.Get("Enhancements", "StretchToFit", &bStretchToFit, false);
iniFile.Get("Enhancements", "KeepAR", &bKeepAR, false);

iniFile.Get("Hacks", "InvertDepth", &bInvertDepth, 0);
iniFile.Get("Hacks", "ProjectionHax1", &bProjectionHax1, 0);
iniFile.Get("Hacks", "ProjectionHax2", &bProjectionHax2, 0);
iniFile.Get("Hacks", "EFBToTextureDisable", &bEBFToTextureDisable, 0);
}

void Config::Save()
Expand All @@ -96,13 +103,20 @@ void Config::Save()
iniFile.Set("Settings", "TexFmtOverlayEnable", bTexFmtOverlayEnable);
iniFile.Set("Settings", "TexFmtOverlayCenter", bTexFmtOverlayCenter);
iniFile.Set("Settings", "UseXFB", bUseXFB);
iniFile.Set("Settings", "Wireframe", bWireFrame);
iniFile.Set("Settings", "DisableLighting", bDisableLighting);
iniFile.Set("Settings", "DisableTexturing", bDisableTexturing);
iniFile.Set("Settings", "DisableCulling", bDisableCulling);

iniFile.Set("Enhancements", "ForceFiltering", bForceFiltering);
iniFile.Set("Enhancements", "ForceMaxAniso", bForceMaxAniso);
iniFile.Set("Enhancements", "StretchToFit", bStretchToFit);
iniFile.Set("Enhancements", "KeepAR", bKeepAR);

iniFile.Set("Hacks", "InvertDepth", bInvertDepth);
iniFile.Set("Hacks", "ProjectionHax1", bProjectionHax1);
iniFile.Set("Hacks", "ProjectionHax2", bProjectionHax2);
iniFile.Set("Hacks", "EFBToTextureDisable", bEBFToTextureDisable);

iniFile.Save("gfx_opengl.ini");
}
10 changes: 8 additions & 2 deletions Source/Plugins/Plugin_VideoOGL/Src/Config.h
Expand Up @@ -51,23 +51,29 @@ struct Config

// Render
bool bUseXFB;
bool bWireFrame;
bool bDisableLighting;
bool bDisableTexturing;
bool bDisableCulling;

// Utility
char texDumpPath[280];
bool bDumpTextures;

// Hacks
bool bInvertDepth;
bool bProjectionHax1;
bool bProjectionHax2;
bool bEBFToTextureDisable;

int iLog; // CONF_ bits
int iSaveTargetId;

//currently unused:
int iCompileDLsLevel;
bool bWireFrame;
bool bShowShaderErrors;
};

extern Config g_Config;

#endif // _CONFIG_H
#endif // _CONFIG_H
69 changes: 65 additions & 4 deletions Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.cpp
Expand Up @@ -45,6 +45,12 @@ BEGIN_EVENT_TABLE(ConfigDialog,wxDialog)
EVT_CHECKBOX(ID_USEXFB,ConfigDialog::UseXFBChange)
EVT_CHECKBOX(ID_DUMPTEXTURES,ConfigDialog::DumpTexturesChange)
EVT_CHECKBOX(ID_INVERTDEPTH,ConfigDialog::InvertDepth)
EVT_CHECKBOX(ID_PROJECTIONHAX1,ConfigDialog::ProjectionHax1)
EVT_CHECKBOX(ID_PROJECTIONHAX2,ConfigDialog::ProjectionHax2)
EVT_CHECKBOX(ID_DISABLELIGHTING,ConfigDialog::DisableLighting)
EVT_CHECKBOX(ID_DISABLETEXTURING,ConfigDialog::DisableTexturing)
EVT_CHECKBOX(ID_EFBTOTEXTUREDISABLE,ConfigDialog::EFBToTextureDisable)
EVT_CHECKBOX(ID_DISABLECULLING,ConfigDialog::DisableCulling)
EVT_DIRPICKER_CHANGED(ID_TEXTUREPATH,ConfigDialog::TexturePathChange)
END_EVENT_TABLE()

Expand Down Expand Up @@ -162,12 +168,24 @@ void ConfigDialog::CreateGUIControls()
m_TexFmtCenter->Enable(m_TexFmtOverlay->IsChecked());

// Page 4 "Render"
m_UseXFB = new wxCheckBox(m_PageRender, ID_USEXFB, wxT("Use XFB"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_UseXFB = new wxCheckBox(m_PageRender, ID_USEXFB, wxT("Use External Framebuffer (XFB)"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_UseXFB->SetValue(g_Config.bUseXFB);

m_Wireframe = new wxCheckBox(m_PageRender, ID_WIREFRAME, wxT("Wireframe"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
//m_Wireframe->SetValue(g_Config.bWireFrame);
m_Wireframe->Enable(false);
m_Wireframe = new wxCheckBox(m_PageRender, ID_WIREFRAME, wxT("Enable Wireframe"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_Wireframe->SetValue(g_Config.bWireFrame);
m_Wireframe->Enable(true);

m_DisableLighting = new wxCheckBox(m_PageRender, ID_DISABLELIGHTING, wxT("Disable Material Lighting"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_DisableLighting->SetValue(g_Config.bDisableLighting);
m_DisableLighting->Enable(true);

m_DisableTexturing = new wxCheckBox(m_PageRender, ID_DISABLETEXTURING, wxT("Disable Texturing"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_DisableTexturing->SetValue(g_Config.bDisableTexturing);
m_DisableTexturing->Enable(true);

m_DisableCulling = new wxCheckBox(m_PageRender, ID_DISABLECULLING, wxT("Disable Culling"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_DisableCulling->SetValue(g_Config.bDisableCulling);
m_DisableCulling->Enable(true);

// Page 5 "Utility"
m_DumpTextures = new wxCheckBox(m_PageUtility, ID_DUMPTEXTURES, wxT("Dump textures to:"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
Expand All @@ -181,6 +199,18 @@ void ConfigDialog::CreateGUIControls()
m_InvertDepth->Enable(true);
m_InvertDepth->SetValue(g_Config.bInvertDepth);

m_EFBToTextureDisable = new wxCheckBox(m_PageHacks, ID_EFBTOTEXTUREDISABLE, wxT("Disable copy EFB to texture"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_EFBToTextureDisable->Enable(true);
m_EFBToTextureDisable->SetValue(g_Config.bEBFToTextureDisable);

m_ProjectionHax1 = new wxCheckBox(m_PageHacks, ID_PROJECTIONHAX1, wxT("Projection before R945"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_ProjectionHax1->Enable(true);
m_ProjectionHax1->SetValue(g_Config.bProjectionHax1);

m_ProjectionHax2 = new wxCheckBox(m_PageHacks, ID_PROJECTIONHAX2, wxT("Projection hack of R844"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_ProjectionHax2->Enable(true);
m_ProjectionHax2->SetValue(g_Config.bProjectionHax2);

//Put options in sizers within the notebook
wxGridBagSizer* sPage1;
sPage1 = new wxGridBagSizer(0, 0);
Expand Down Expand Up @@ -226,6 +256,9 @@ void ConfigDialog::CreateGUIControls()
sPage4->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED);
sPage4->Add(m_UseXFB, wxGBPosition(0, 0), wxGBSpan(1, 1), wxALL, 5);
sPage4->Add(m_Wireframe, wxGBPosition(1, 0), wxGBSpan(1, 2), wxALL, 5);
sPage4->Add(m_DisableLighting, wxGBPosition(2, 0), wxGBSpan(1, 2), wxALL, 5);
sPage4->Add(m_DisableTexturing, wxGBPosition(3, 0), wxGBSpan(1, 2), wxALL, 5);
sPage4->Add(m_DisableCulling, wxGBPosition(4, 0), wxGBSpan(1, 2), wxALL, 5);
m_PageRender->SetSizer(sPage4);
sPage4->Layout();

Expand All @@ -243,6 +276,9 @@ void ConfigDialog::CreateGUIControls()
sPage6->SetFlexibleDirection(wxBOTH);
sPage6->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED);
sPage6->Add(m_InvertDepth, wxGBPosition(0, 0), wxGBSpan(1, 2), wxALL, 5);
sPage6->Add(m_EFBToTextureDisable, wxGBPosition(1, 0), wxGBSpan(1, 2), wxALL, 5);
sPage6->Add(m_ProjectionHax1, wxGBPosition(2, 0), wxGBSpan(1, 2), wxALL, 5);
sPage6->Add(m_ProjectionHax2, wxGBPosition(3, 0), wxGBSpan(1, 2), wxALL, 5);
m_PageHacks->SetSizer(sPage6);
sPage6->Layout();

Expand Down Expand Up @@ -392,3 +428,28 @@ void ConfigDialog::InvertDepth(wxCommandEvent& event)
{
g_Config.bInvertDepth = m_InvertDepth->IsChecked();
}
void ConfigDialog::ProjectionHax1(wxCommandEvent& event)
{
g_Config.bProjectionHax1 = m_ProjectionHax1->IsChecked();
}
void ConfigDialog::ProjectionHax2(wxCommandEvent& event)
{
g_Config.bProjectionHax2 = m_ProjectionHax2->IsChecked();
}

void ConfigDialog::DisableLighting(wxCommandEvent &event)
{
g_Config.bDisableLighting = m_DisableLighting->IsChecked();
}
void ConfigDialog::DisableTexturing(wxCommandEvent &event)
{
g_Config.bDisableTexturing = m_DisableTexturing->IsChecked();
}
void ConfigDialog::EFBToTextureDisable(wxCommandEvent &event)
{
g_Config.bEBFToTextureDisable = m_EFBToTextureDisable->IsChecked();
}
void ConfigDialog::DisableCulling(wxCommandEvent &event)
{
g_Config.bDisableCulling = m_DisableCulling->IsChecked();
}
18 changes: 18 additions & 0 deletions Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.h
Expand Up @@ -72,13 +72,19 @@ class ConfigDialog : public wxDialog
// Render
void WireframeCheck(wxCommandEvent& event);
void UseXFBChange(wxCommandEvent& event);
void DisableLighting(wxCommandEvent& event);
void DisableTexturing(wxCommandEvent& event);
void DisableCulling(wxCommandEvent& event);

// Util
void DumpTexturesChange(wxCommandEvent& event);
void TexturePathChange(wxFileDirPickerEvent& event);

// Hacks
void InvertDepth(wxCommandEvent& event);
void ProjectionHax1(wxCommandEvent& event);
void ProjectionHax2(wxCommandEvent& event);
void EFBToTextureDisable(wxCommandEvent& event);

private:

Expand All @@ -103,7 +109,13 @@ class ConfigDialog : public wxDialog
wxComboBox *m_FullscreenCB;
wxCheckBox *m_RenderToMainWindow;
wxCheckBox *m_Fullscreen;
wxCheckBox *m_DisableLighting;
wxCheckBox *m_DisableTexturing;
wxCheckBox *m_InvertDepth;
wxCheckBox *m_ProjectionHax1;
wxCheckBox *m_ProjectionHax2;
wxCheckBox *m_EFBToTextureDisable;
wxCheckBox *m_DisableCulling;
wxPanel *m_PageGeneral;
wxPanel *m_PageEnhancements;
wxPanel *m_PageInformation;
Expand Down Expand Up @@ -142,6 +154,12 @@ class ConfigDialog : public wxDialog
ID_FULLSCREEN,
ID_NOTEBOOK,
ID_INVERTDEPTH,
ID_PROJECTIONHAX1,
ID_PROJECTIONHAX2,
ID_DISABLELIGHTING,
ID_DISABLETEXTURING,
ID_EFBTOTEXTUREDISABLE,
ID_DISABLECULLING,
ID_PAGEGENERAL,
ID_PAGEENHANCEMENTS,
ID_PAGEINFORMATION,
Expand Down
6 changes: 5 additions & 1 deletion Source/Plugins/Plugin_VideoOGL/Src/Render.cpp
Expand Up @@ -705,19 +705,23 @@ void Renderer::Swap(const TRectangle& rc)

// texture map s_RenderTargets[s_curtarget] onto the main buffer
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, s_RenderTargets[s_nCurTarget]);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, s_RenderTargets[s_nCurTarget]);
TextureMngr::EnableTexRECT(0);
// disable all other stages
for(int i = 1; i < 8; ++i) TextureMngr::DisableStage(i);
GL_REPORT_ERRORD();

glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glBegin(GL_QUADS);
glTexCoord2f(0, 0); glVertex2f(-1,-1);
glTexCoord2f(0, (float)GetTargetHeight()); glVertex2f(-1,1);
glTexCoord2f((float)GetTargetWidth(), (float)GetTargetHeight()); glVertex2f(1,1);
glTexCoord2f((float)GetTargetWidth(), 0); glVertex2f(1,-1);
glEnd();

if (g_Config.bWireFrame)
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);

glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0);
TextureMngr::DisableStage(0);

Expand Down
41 changes: 30 additions & 11 deletions Source/Plugins/Plugin_VideoOGL/Src/VertexManager.cpp
Expand Up @@ -342,18 +342,37 @@ void EnableComponents(u32 components)
}

// tex
for (int i = 0; i < 8; ++i) {
if ((components & (VB_HAS_UV0 << i)) != (s_prevcomponents & (VB_HAS_UV0 << i))) {
glClientActiveTexture(GL_TEXTURE0 + i);
if (components & (VB_HAS_UV0 << i))
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
else
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
}
if (!g_Config.bDisableTexturing) {
for (int i = 0; i < 8; ++i) {
if ((components & (VB_HAS_UV0 << i)) != (s_prevcomponents & (VB_HAS_UV0 << i))) {
glClientActiveTexture(GL_TEXTURE0 + i);
if (components & (VB_HAS_UV0 << i))
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
else
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
}
}
else // Disable Texturing
{
for (int i = 0; i < 8; ++i) {
glClientActiveTexture(GL_TEXTURE0 + i);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
}


s_prevcomponents = components;
}
// Disable Lighting
// TODO - move to better spot
if (g_Config.bDisableLighting) {
for (int i = 0; i < xfregs.nNumChans; i++)
{
xfregs.colChans[i].alpha.enablelighting = false;
xfregs.colChans[i].color.enablelighting = false;
}
}
s_prevcomponents = components;
}
}

} // namespace

0 comments on commit 46f0dd8

Please sign in to comment.