summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorMatthew Parlane <parlane@gmail.com>2013-01-08 20:27:34 +1300
committerMatthew Parlane <parlane@gmail.com>2013-01-08 20:27:34 +1300
commit0ec7ef4b9905cbeb10f523097fbff3da50ede4f1 (patch)
treec4e8259084901e51b6d1294e6faf5e3ba1ae7152 /Source
parent9f13e69be46b07c64bedb9b225f06fb8f738bb7e (diff)
parent1d44d3baf5cc0702b9e042687d63c5a72fd0f6b0 (diff)
Merge branch 'master' into gdbstub
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/Common/Src/MathUtil.h2
-rw-r--r--Source/Core/Core/Src/HW/GCPad.cpp8
-rw-r--r--Source/Core/Core/Src/HW/GCPadEmu.cpp15
-rw-r--r--Source/Core/Core/Src/HW/GCPadEmu.h1
-rw-r--r--Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE.cpp6
-rw-r--r--Source/Core/Core/Src/PowerPC/PPCAnalyst.cpp16
-rw-r--r--Source/Core/DolphinWX/resources/dolphin-emu.desktop9
-rw-r--r--Source/Core/InputCommon/Src/ControllerInterface/DInput/DInputJoystick.cpp6
-rw-r--r--Source/Core/VideoCommon/Src/BPFunctions.cpp2
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/FramebufferManager.cpp85
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/NativeVertexFormat.cpp37
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/RasterFont.cpp232
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/RasterFont.h22
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/Render.cpp274
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp93
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/TextureCache.h3
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/TextureConverter.cpp112
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/VertexManager.cpp3
-rw-r--r--Source/Plugins/Plugin_VideoSoftware/Src/SWRenderer.cpp5
19 files changed, 282 insertions, 649 deletions
diff --git a/Source/Core/Common/Src/MathUtil.h b/Source/Core/Common/Src/MathUtil.h
index c5f613ada1..a6290ff602 100644
--- a/Source/Core/Common/Src/MathUtil.h
+++ b/Source/Core/Common/Src/MathUtil.h
@@ -117,8 +117,6 @@ struct Rectangle
Rectangle(T theLeft, T theTop, T theRight, T theBottom)
: left(theLeft), top(theTop), right(theRight), bottom(theBottom)
{ }
-
- bool operator==(const Rectangle& r) { return left==r.left && top==r.top && right==r.right && bottom==r.bottom; }
T GetWidth() const { return abs(right - left); }
T GetHeight() const { return abs(bottom - top); }
diff --git a/Source/Core/Core/Src/HW/GCPad.cpp b/Source/Core/Core/Src/HW/GCPad.cpp
index 61b666af12..68ba3ab88a 100644
--- a/Source/Core/Core/Src/HW/GCPad.cpp
+++ b/Source/Core/Core/Src/HW/GCPad.cpp
@@ -105,6 +105,10 @@ void Rumble(u8 _numPAD, unsigned int _uType, unsigned int _uStrength)
{
((GCPad*)g_plugin.controllers[ _numPAD ])->SetOutput(255);
}
+ else
+ {
+ ((GCPad*)g_plugin.controllers[ _numPAD ])->SetOutput(0);
+ }
}
}
@@ -123,9 +127,9 @@ void Motor(u8 _numPAD, unsigned int _uType, unsigned int _uStrength)
{
// TODO: this has potential to not stop rumble if user is messing with GUI at the perfect time
// set rumble
- if (_uType == 06)
+ if (_uType == 6)
{
- ((GCPad*)g_plugin.controllers[ _numPAD ])->SetOutput(_uStrength);
+ ((GCPad*)g_plugin.controllers[ _numPAD ])->SetMotor(_uStrength);
}
}
}
diff --git a/Source/Core/Core/Src/HW/GCPadEmu.cpp b/Source/Core/Core/Src/HW/GCPadEmu.cpp
index 5233ed2877..a2c0c2afa9 100644
--- a/Source/Core/Core/Src/HW/GCPadEmu.cpp
+++ b/Source/Core/Core/Src/HW/GCPadEmu.cpp
@@ -130,15 +130,26 @@ void GCPad::GetInput(SPADStatus* const pad)
}
}
-void GCPad::SetOutput(const u8 on)
+void GCPad::SetMotor(const u8 on)
{
+ float state = (float)on / 255;
+ float force = abs(state - 0.5) * 2;
+ if (state < 0.5)
+ force = -force;
+
// only rumble if window has focus or background input is enabled
if (Host_RendererHasFocus() || m_options[0].settings[0]->value)
- m_rumble->controls[0]->control_ref->State((float)on / 255);
+ m_rumble->controls[0]->control_ref->State(force);
else
m_rumble->controls[0]->control_ref->State(0);
}
+void GCPad::SetOutput(const u8 on)
+{
+ // only rumble if window has focus or background input is enabled
+ m_rumble->controls[0]->control_ref->State(on && (Host_RendererHasFocus() || m_options[0].settings[0]->value));
+}
+
void GCPad::LoadDefaults(const ControllerInterface& ciface)
{
#define set_control(group, num, str) (group)->controls[num]->control_ref->expression = (str)
diff --git a/Source/Core/Core/Src/HW/GCPadEmu.h b/Source/Core/Core/Src/HW/GCPadEmu.h
index cf0940245e..e57e6b0b68 100644
--- a/Source/Core/Core/Src/HW/GCPadEmu.h
+++ b/Source/Core/Core/Src/HW/GCPadEmu.h
@@ -29,6 +29,7 @@ public:
GCPad(const unsigned int index);
void GetInput(SPADStatus* const pad);
void SetOutput(const u8 on);
+ void SetMotor(const u8 on);
bool GetMicButton() const;
diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE.cpp
index 47737326f4..c5ea6fcb06 100644
--- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE.cpp
+++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE.cpp
@@ -253,15 +253,15 @@ void DoState(PointerWrap &p)
u32 i;
for (i=0; i<IPC_MAX_FDS; i++)
{
- u32 exists;
+ u32 exists = 0;
p.Do(exists);
if (exists)
{
- u32 isHw;
+ u32 isHw = 0;
p.Do(isHw);
if (isHw)
{
- u32 hwId;
+ u32 hwId = 0;
p.Do(hwId);
g_FdMap[i] = AccessDeviceByID(hwId);
}
diff --git a/Source/Core/Core/Src/PowerPC/PPCAnalyst.cpp b/Source/Core/Core/Src/PowerPC/PPCAnalyst.cpp
index ddfec1c328..fa9f278c29 100644
--- a/Source/Core/Core/Src/PowerPC/PPCAnalyst.cpp
+++ b/Source/Core/Core/Src/PowerPC/PPCAnalyst.cpp
@@ -246,17 +246,13 @@ bool CanSwapAdjacentOps(const CodeOp &a, const CodeOp &b)
return false;
}
- // For now, only integer ops acceptable.
- switch (b_info->type) {
- case OPTYPE_INTEGER:
- case OPTYPE_LOAD:
- case OPTYPE_STORE:
- //case OPTYPE_LOADFP:
- //case OPTYPE_STOREFP:
- break;
- default:
+ // For now, only integer ops acceptable. Any instruction which can raise an
+ // interrupt is *not* a possible swap candidate: see [1] for an example of
+ // a crash caused by this error.
+ //
+ // [1] https://code.google.com/p/dolphin-emu/issues/detail?id=5864#c7
+ if (b_info->type != OPTYPE_INTEGER)
return false;
- }
// Check that we have no register collisions.
// That is, check that none of b's outputs matches any of a's inputs,
diff --git a/Source/Core/DolphinWX/resources/dolphin-emu.desktop b/Source/Core/DolphinWX/resources/dolphin-emu.desktop
new file mode 100644
index 0000000000..f201f07f22
--- /dev/null
+++ b/Source/Core/DolphinWX/resources/dolphin-emu.desktop
@@ -0,0 +1,9 @@
+[Desktop Entry]
+Version=1.0
+Type=Application
+Name=Dolphin Emulator
+Comment=A Wii/GameCube Emulator
+Icon=dolphin-emu
+Exec=dolphin-emu
+Categories=Game;
+
diff --git a/Source/Core/InputCommon/Src/ControllerInterface/DInput/DInputJoystick.cpp b/Source/Core/InputCommon/Src/ControllerInterface/DInput/DInputJoystick.cpp
index b7ac3bf82e..af6ee7e77c 100644
--- a/Source/Core/InputCommon/Src/ControllerInterface/DInput/DInputJoystick.cpp
+++ b/Source/Core/InputCommon/Src/ControllerInterface/DInput/DInputJoystick.cpp
@@ -535,11 +535,7 @@ ControlState Joystick::Hat::GetState() const
void Joystick::ForceConstant::SetState(const ControlState state)
{
- float force = abs(state - 0.5) * 2;
- if (state < 0.5)
- force = -force;
-
- const LONG new_val = LONG(10000 * force);
+ const LONG new_val = LONG(10000 * state);
LONG &val = params.lMagnitude;
if (val != new_val)
diff --git a/Source/Core/VideoCommon/Src/BPFunctions.cpp b/Source/Core/VideoCommon/Src/BPFunctions.cpp
index b9a76ba7b6..cddeae3000 100644
--- a/Source/Core/VideoCommon/Src/BPFunctions.cpp
+++ b/Source/Core/VideoCommon/Src/BPFunctions.cpp
@@ -236,7 +236,7 @@ bool GetConfig(const int &type)
case CONFIG_DISABLEFOG:
return g_ActiveConfig.bDisableFog;
case CONFIG_SHOWEFBREGIONS:
- return g_ActiveConfig.bShowEFBCopyRegions;
+ return false;
default:
PanicAlert("GetConfig Error: Unknown Config Type!");
return false;
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/FramebufferManager.cpp b/Source/Plugins/Plugin_VideoOGL/Src/FramebufferManager.cpp
index e7fb7ad7b7..0e37c3adb6 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/FramebufferManager.cpp
+++ b/Source/Plugins/Plugin_VideoOGL/Src/FramebufferManager.cpp
@@ -17,7 +17,6 @@
#include "Globals.h"
#include "FramebufferManager.h"
-#include "VertexShaderGen.h"
#include "TextureConverter.h"
#include "Render.h"
@@ -28,11 +27,6 @@ namespace OGL
extern bool s_bHaveFramebufferBlit; // comes from Render.cpp. ugly.
-static GLuint s_VBO = 0;
-static GLuint s_VAO = 0;
-static MathUtil::Rectangle<float> s_cached_sourcerc;
-static MathUtil::Rectangle<float> s_cached_drawrc;
-
int FramebufferManager::m_targetWidth;
int FramebufferManager::m_targetHeight;
int FramebufferManager::m_msaaSamples;
@@ -59,15 +53,6 @@ FramebufferManager::FramebufferManager(int targetWidth, int targetHeight, int ms
m_resolvedDepthTexture = 0;
m_xfbFramebuffer = 0;
- s_cached_sourcerc.bottom = -1;
- s_cached_sourcerc.left = -1;
- s_cached_sourcerc.right = -1;
- s_cached_sourcerc.top = -1;
- s_cached_drawrc.bottom = -1;
- s_cached_drawrc.left = -1;
- s_cached_drawrc.right = -1;
- s_cached_drawrc.top = -1;
-
m_targetWidth = targetWidth;
m_targetHeight = targetHeight;
@@ -184,28 +169,7 @@ FramebufferManager::FramebufferManager(int targetWidth, int targetHeight, int ms
// Create XFB framebuffer; targets will be created elsewhere.
glGenFramebuffersEXT(1, &m_xfbFramebuffer);
-
- // Generate VBO & VAO - and initialize the VAO for "Draw"
- glGenBuffers(1, &s_VBO);
- glGenVertexArrays(1, &s_VAO);
- glBindBuffer(GL_ARRAY_BUFFER, s_VBO);
- glBindVertexArray(s_VAO);
-
- glEnableClientState(GL_VERTEX_ARRAY);
- glVertexPointer(2, GL_FLOAT, 6*sizeof(GLfloat), NULL);
-
- glClientActiveTexture(GL_TEXTURE0);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glTexCoordPointer(2, GL_FLOAT, 6*sizeof(GLfloat), (GLfloat*)NULL+2);
-
- glClientActiveTexture(GL_TEXTURE1);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glTexCoordPointer(2, GL_FLOAT, 6*sizeof(GLfloat), (GLfloat*)NULL+4);
-
- // TODO: this after merging with graphic_update
- glBindVertexArray(0);
- glBindBuffer(GL_ARRAY_BUFFER, 0);
-
+
// EFB framebuffer is currently bound, make sure to clear its alpha value to 1.f
glViewport(0, 0, m_targetWidth, m_targetHeight);
glScissor(0, 0, m_targetWidth, m_targetHeight);
@@ -217,8 +181,6 @@ FramebufferManager::FramebufferManager(int targetWidth, int targetHeight, int ms
FramebufferManager::~FramebufferManager()
{
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
- glDeleteBuffers(1, &s_VBO);
- glDeleteVertexArrays(1, &s_VAO);
GLuint glObj[3];
@@ -343,35 +305,24 @@ void XFBSource::Draw(const MathUtil::Rectangle<float> &sourcerc,
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, texture);
- if(!(s_cached_sourcerc == sourcerc) || !(s_cached_drawrc == drawrc)) {
- GLfloat vertices[] = {
- drawrc.left, drawrc.bottom,
- sourcerc.left, sourcerc.bottom,
- 0.0f, 0.0f,
- drawrc.left, drawrc.top,
- sourcerc.left, sourcerc.top,
- 0.0f, 1.0f,
- drawrc.right, drawrc.top,
- sourcerc.right, sourcerc.top,
- 1.0f, 1.0f,
- drawrc.right, drawrc.bottom,
- sourcerc.right, sourcerc.bottom,
- 1.0f, 0.0f
- };
- glBindBuffer(GL_ARRAY_BUFFER, s_VBO);
- glBufferData(GL_ARRAY_BUFFER, 2*4*3*sizeof(GLfloat), vertices, GL_STREAM_DRAW);
-
- s_cached_sourcerc = sourcerc;
- s_cached_drawrc = drawrc;
- }
+ glBegin(GL_QUADS);
+ glTexCoord2f(sourcerc.left, sourcerc.bottom);
+ glMultiTexCoord2fARB(GL_TEXTURE1, 0, 0);
+ glVertex2f(drawrc.left, drawrc.bottom);
+
+ glTexCoord2f(sourcerc.left, sourcerc.top);
+ glMultiTexCoord2fARB(GL_TEXTURE1, 0, 1);
+ glVertex2f(drawrc.left, drawrc.top);
+
+ glTexCoord2f(sourcerc.right, sourcerc.top);
+ glMultiTexCoord2fARB(GL_TEXTURE1, 1, 1);
+ glVertex2f(drawrc.right, drawrc.top);
+
+ glTexCoord2f(sourcerc.right, sourcerc.bottom);
+ glMultiTexCoord2fARB(GL_TEXTURE1, 1, 0);
+ glVertex2f(drawrc.right, drawrc.bottom);
+ glEnd();
- glBindVertexArray(s_VAO);
- glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
-
- // TODO: this after merging with graphic_update
- glBindVertexArray(0);
- glBindBuffer(GL_ARRAY_BUFFER, 0);
-
GL_REPORT_ERRORD();
}
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/NativeVertexFormat.cpp b/Source/Plugins/Plugin_VideoOGL/Src/NativeVertexFormat.cpp
index a435be0dca..ae20649433 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/NativeVertexFormat.cpp
+++ b/Source/Plugins/Plugin_VideoOGL/Src/NativeVertexFormat.cpp
@@ -27,9 +27,8 @@
#define COMPILED_CODE_SIZE 4096
-// TODO: Use this again for performance, but without VAO we never know exactly the last configuration
-static u32 s_prevcomponents; // previous state set
-
+// TODO: this guy is never initialized
+u32 s_prevcomponents; // previous state set
/*
#ifdef _WIN32
#ifdef _M_IX86
@@ -65,6 +64,7 @@ public:
virtual void Initialize(const PortableVertexDeclaration &_vtx_decl);
virtual void SetupVertexPointers();
+ virtual void EnableComponents(u32 components);
};
namespace OGL
@@ -187,7 +187,6 @@ void GLVertexFormat::SetupVertexPointers() {
#ifdef USE_JIT
((void (*)())(void*)m_compiledCode)();
#else
-
glVertexPointer(3, GL_FLOAT, vtx_decl.stride, VertexManager::s_pBaseBufferPointer);
if (vtx_decl.num_normals >= 1) {
glNormalPointer(VarToGL(vtx_decl.normal_gl_type), vtx_decl.stride, (void *)(VertexManager::s_pBaseBufferPointer + vtx_decl.normal_offset[0]));
@@ -220,32 +219,34 @@ void GLVertexFormat::SetupVertexPointers() {
glVertexAttribPointer(SHADER_POSMTX_ATTRIB, 4, GL_UNSIGNED_BYTE, GL_FALSE, vtx_decl.stride, (void *)(VertexManager::s_pBaseBufferPointer + vtx_decl.posmtx_offset));
}
#endif
+}
- if (s_prevcomponents != m_components)
+void GLVertexFormat::EnableComponents(u32 components)
+{
+ if (s_prevcomponents != components)
{
- // vertices
- glEnableClientState(GL_VERTEX_ARRAY);
+ VertexManager::Flush();
// matrices
- if ((m_components & VB_HAS_POSMTXIDX) != (s_prevcomponents & VB_HAS_POSMTXIDX))
+ if ((components & VB_HAS_POSMTXIDX) != (s_prevcomponents & VB_HAS_POSMTXIDX))
{
- if (m_components & VB_HAS_POSMTXIDX)
+ if (components & VB_HAS_POSMTXIDX)
glEnableVertexAttribArray(SHADER_POSMTX_ATTRIB);
else
glDisableVertexAttribArray(SHADER_POSMTX_ATTRIB);
}
// normals
- if ((m_components & VB_HAS_NRM0) != (s_prevcomponents & VB_HAS_NRM0))
+ if ((components & VB_HAS_NRM0) != (s_prevcomponents & VB_HAS_NRM0))
{
- if (m_components & VB_HAS_NRM0)
+ if (components & VB_HAS_NRM0)
glEnableClientState(GL_NORMAL_ARRAY);
else
glDisableClientState(GL_NORMAL_ARRAY);
}
- if ((m_components & VB_HAS_NRM1) != (s_prevcomponents & VB_HAS_NRM1))
+ if ((components & VB_HAS_NRM1) != (s_prevcomponents & VB_HAS_NRM1))
{
- if (m_components & VB_HAS_NRM1) {
+ if (components & VB_HAS_NRM1) {
glEnableVertexAttribArray(SHADER_NORM1_ATTRIB);
glEnableVertexAttribArray(SHADER_NORM2_ATTRIB);
}
@@ -258,9 +259,9 @@ void GLVertexFormat::SetupVertexPointers() {
// color
for (int i = 0; i < 2; ++i)
{
- if ((m_components & (VB_HAS_COL0 << i)) != (s_prevcomponents & (VB_HAS_COL0 << i)))
+ if ((components & (VB_HAS_COL0 << i)) != (s_prevcomponents & (VB_HAS_COL0 << i)))
{
- if (m_components & (VB_HAS_COL0 << i))
+ if (components & (VB_HAS_COL0 << i))
glEnableClientState(i ? GL_SECONDARY_COLOR_ARRAY : GL_COLOR_ARRAY);
else
glDisableClientState(i ? GL_SECONDARY_COLOR_ARRAY : GL_COLOR_ARRAY);
@@ -270,16 +271,16 @@ void GLVertexFormat::SetupVertexPointers() {
// tex
for (int i = 0; i < 8; ++i)
{
- if ((m_components & (VB_HAS_UV0 << i)) != (s_prevcomponents & (VB_HAS_UV0 << i)))
+ if ((components & (VB_HAS_UV0 << i)) != (s_prevcomponents & (VB_HAS_UV0 << i)))
{
glClientActiveTexture(GL_TEXTURE0 + i);
- if (m_components & (VB_HAS_UV0 << i))
+ if (components & (VB_HAS_UV0 << i))
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
else
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
}
- s_prevcomponents = m_components;
+ s_prevcomponents = components;
}
}
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/RasterFont.cpp b/Source/Plugins/Plugin_VideoOGL/Src/RasterFont.cpp
index 95c99ac78c..da53fae6d5 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/RasterFont.cpp
+++ b/Source/Plugins/Plugin_VideoOGL/Src/RasterFont.cpp
@@ -17,16 +17,12 @@
#include "GLUtil.h"
+#include <string.h>
+
#include "RasterFont.h"
// globals
-
-static const u32 char_width = 8;
-static const u32 char_height = 13;
-static const u32 char_offset = 32;
-static const u32 char_count = 95;
-
-const u8 rasters[char_count][char_height] = {
+const GLubyte rasters[][13] = {
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x36, 0x36, 0x36},
@@ -124,160 +120,104 @@ const u8 rasters[char_count][char_height] = {
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x8f, 0xf1, 0x60, 0x00, 0x00, 0x00}
};
-static const char *s_vertex_shader =
- "attribute vec2 vertexPosition;\n"
- "attribute vec2 texturePosition;\n"
- "varying vec2 tpos;\n"
- "void main(void) {\n"
- " gl_Position = vec4(vertexPosition,0,1);\n"
- " tpos = texturePosition;\n"
- "}\n";
-
-static const char *s_fragment_shader =
- "#extension GL_ARB_texture_rectangle : enable\n"
- "uniform sampler2DRect textureSampler;\n"
- "uniform vec4 color;\n"
- "varying vec2 tpos;\n"
- "void main(void) {\n"
- " gl_FragColor = texture2DRect(textureSampler,tpos) * color;\n"
- "}\n";
-
RasterFont::RasterFont()
{
- // generate the texture
- glGenTextures(1, &texture);
- glBindTexture(GL_TEXTURE_RECTANGLE, texture);
- u32* texture_data = new u32[char_width*char_count*char_height];
- for(u32 y=0; y<char_height; y++) {
- for(u32 c=0; c<char_count; c++) {
- for(u32 x=0; x<char_width; x++) {
- bool pixel = rasters[c][y] & (1<<(char_width-x-1));
- texture_data[char_width*char_count*y+char_width*c+x] = pixel ? -1 : 0;
- }
- }
+ // set GL modes
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+ // create the raster font
+ fontOffset = glGenLists(128);
+ for (int i = 32; i < 127; i++) {
+ glNewList(i + fontOffset, GL_COMPILE);
+ glBitmap(8, 13, 0.0f, 2.0f, 10.0f, 0.0f, rasters[i - 32]);
+ glEndList();
}
- glTexImage2D(GL_TEXTURE_RECTANGLE, 0, GL_RGBA, char_width*char_count, char_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, texture_data);
- delete [] texture_data;
-
- // generate shader
- shader_program = OpenGL_CompileProgram(s_vertex_shader, s_fragment_shader);
-
- // bound uniforms
- glUseProgram(shader_program);
- glUniform1i(glGetUniformLocation(shader_program,"textureSampler"), 0); // GL_TEXTURE0
- uniform_color_id = glGetUniformLocation(shader_program,"color");
- glUniform4f(uniform_color_id, 1, 1, 1, 1);
- cached_color = -1;
- glUseProgram(0);
-
- // generate VBO & VAO
- glGenBuffers(1, &VBO);
- glGenVertexArrays(1, &VAO);
- glBindBuffer(GL_ARRAY_BUFFER, VBO);
- glBindVertexArray(VAO);
- glEnableVertexAttribArray(glGetAttribLocation(shader_program, "vertexPosition"));
- glVertexAttribPointer(glGetAttribLocation(shader_program, "vertexPosition"), 2, GL_FLOAT, 0, sizeof(GLfloat)*4, NULL);
- glEnableVertexAttribArray(glGetAttribLocation(shader_program, "texturePosition"));
- glVertexAttribPointer(glGetAttribLocation(shader_program, "texturePosition"), 2, GL_FLOAT, 0, sizeof(GLfloat)*4, (GLfloat*)NULL+2);
-
- // TODO: this after merging with graphic_update
- glBindVertexArray(0);
- glBindBuffer(GL_ARRAY_BUFFER, 0);
+
+ temp_buffer = new char[TEMP_BUFFER_SIZE];
}
RasterFont::~RasterFont()
{
- glDeleteTextures(1, &texture);
- glDeleteBuffers(1, &VBO);
- glDeleteVertexArrays(1, &VAO);
- glDeleteProgram(shader_program);
+ glDeleteLists(fontOffset, 128);
+ delete [] temp_buffer;
}
-void RasterFont::printMultilineText(const char *text, double start_x, double start_y, double z, int bbWidth, int bbHeight, u32 color)
+void RasterFont::printString(const char *s, double x, double y, double z)
{
- int length = (int)strlen(text);
+ int length = (int)strlen(s);
if (!length)
- return; // nothing to do
-
- glBindVertexArray(VAO);
- glBindBuffer(GL_ARRAY_BUFFER, VBO);
- glBufferData(GL_ARRAY_BUFFER, length*4*6*sizeof(GLfloat), NULL, GL_STREAM_DRAW);
- GLfloat *vertices = (GLfloat*)glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
-
- int usage = 0;
- GLfloat delta_x = 2*char_width/GLfloat(bbWidth);
- GLfloat delta_y = 2*char_height/GLfloat(bbHeight);
- GLfloat border_x = 1*2/GLfloat(bbWidth);
- GLfloat border_y = 2*2/GLfloat(bbHeight);
-
- GLfloat x = start_x;
- GLfloat y = start_y;
-
- for(int i=0; i<length; i++) {
- u8 c = text[i];
-
- if(c == '\n') {
+ return;
+ if (length >= TEMP_BUFFER_SIZE)
+ length = TEMP_BUFFER_SIZE - 1;
+
+ // Sanitize string to avoid GL errors.
+ char *s2 = temp_buffer;
+ memcpy(s2, s, length);
+ s2[length] = 0;
+ for (int i = 0; i < length; i++) {
+ if (s2[i] < 32 || s2[i] > 126)
+ s2[i] = '!';
+ }
+
+ // go to the right spot
+ glRasterPos3d(x, y, z);
+ GL_REPORT_ERRORD();
+
+ glPushAttrib (GL_LIST_BIT);
+ glListBase(fontOffset);
+ glCallLists((GLsizei)strlen(s2), GL_UNSIGNED_BYTE, (GLubyte *) s2);
+ GL_REPORT_ERRORD();
+ glPopAttrib();
+ GL_REPORT_ERRORD();
+}
+
+void RasterFont::printCenteredString(const char *s, double y, int screen_width, double z)
+{
+ int length = (int)strlen(s);
+ int x = (int)(screen_width/2.0 - (length/2.0)*char_width);
+ printString(s, x, y, z);
+}
+
+void RasterFont::printMultilineText(const char *text, double start_x, double start_y, double z, int bbWidth, int bbHeight)
+{
+ double x = start_x;
+ double y = start_y;
+ char temp[1024];
+ char *t = temp;
+ while (*text)
+ {
+ if (*text == '\n')
+ {
+ *t = 0;
+ printString(temp, x, y, z);
+ y -= char_height * 2.0f / bbHeight;
x = start_x;
- y -= delta_y + border_y;
- continue;
+ t = temp;
}
-
- // do not print spaces, they can be skipped easyly
- if(c == ' ') {
- x += delta_x + border_x;
- continue;
+ else if (*text == '\r')
+ {
+ t = temp;
}
-
- if(c < char_offset || c >= char_count+char_offset) continue;
-
- vertices[usage++] = x;
- vertices[usage++] = y;
- vertices[usage++] = (c-char_offset)*char_width;
- vertices[usage++] = 0;
-
- vertices[usage++] = x+delta_x;
- vertices[usage++] = y;
- vertices[usage++] = (c-char_offset+1)*char_width;
- vertices[usage++] = 0;
-
- vertices[usage++] = x+delta_x;
- vertices[usage++] = y+delta_y;
- vertices[usage++] = (c-char_offset+1)*char_width;
- vertices[usage++] = char_height;
-
- vertices[usage++] = x;
- vertices[usage++] = y;
- vertices[usage++] = (c-char_offset)*char_width;
- vertices[usage++] = 0;
-
- vertices[usage++] = x+delta_x;
- vertices[usage++] = y+delta_y;
- vertices[usage++] = (c-char_offset+1)*char_width;
- vertices[usage++] = char_height;
-
- vertices[usage++] = x;
- vertices[usage++] = y+delta_y;
- vertices[usage++] = (c-char_offset)*char_width;
- vertices[usage++] = char_height;
-
- x += delta_x + border_x;
+ else if (*text == '\t')
+ {
+ //todo: add tabs every something like 4*char_width
+ *t = 0;
+ int cpos = (int)strlen(temp);
+ int newpos = (cpos + 4) & (~3);
+ printString(temp, x, y, z);
+ x = start_x + (char_width*newpos) * 2.0f / bbWidth;
+ t = temp;
+ *t++ = ' ';
+ }
+ else
+ *t++ = *text;
+
+ text++;
}
- glUnmapBuffer(GL_ARRAY_BUFFER);
- glUseProgram(shader_program);
-
- if(color != cached_color) {
- glUniform4f(uniform_color_id, ((color>>16)&0xff)/255.f,((color>>8)&0xff)/255.f,((color>>0)&0xff)/255.f,((color>>24)&0xff)/255.f);
- cached_color = color;
+ // ????
+ if (t != text)
+ {
+ *t = 0;
+ printString(temp, x, y, z);
}
-
- glActiveTexture(GL_TEXTURE0);
- glBindTexture(GL_TEXTURE_RECTANGLE, texture);
- glDrawArrays(GL_TRIANGLES, 0, usage/4);
-
- // TODO: this after merging with graphic_update
- glBindVertexArray(0);
- glBindBuffer(GL_ARRAY_BUFFER, 0);
-
- glUseProgram(0);
}
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/RasterFont.h b/Source/Plugins/Plugin_VideoOGL/Src/RasterFont.h
index fcbfdfff61..3ebc684dd0 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/RasterFont.h
+++ b/Source/Plugins/Plugin_VideoOGL/Src/RasterFont.h
@@ -23,16 +23,20 @@ public:
RasterFont();
~RasterFont(void);
static int debug;
-
- void printMultilineText(const char *text, double x, double y, double z, int bbWidth, int bbHeight, u32 color);
+
+ // some useful constants
+ enum {char_width = 10};
+ enum {char_height = 15};
+
+ // and the happy helper functions
+ void printString(const char *s, double x, double y, double z=0.0);
+ void printCenteredString(const char *s, double y, int screen_width, double z=0.0);
+
+ void printMultilineText(const char *text, double x, double y, double z, int bbWidth, int bbHeight);
private:
-
- u32 VBO;
- u32 VAO;
- u32 texture;
- u32 shader_program;
- u32 uniform_color_id;
- u32 cached_color;
+ int fontOffset;
+ char *temp_buffer;
+ enum {TEMP_BUFFER_SIZE = 64 * 1024};
};
#endif // _RASTERFONT_H_
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp
index a2d0a94ee3..e2fff07b10 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp
+++ b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp
@@ -107,14 +107,10 @@ namespace OGL
// Declarations and definitions
// ----------------------------
-static int s_fps = 0;
-static GLuint s_ShowEFBCopyRegions_VBO = 0;
-static GLuint s_ShowEFBCopyRegions_VAO = 0;
-static GLuint s_Swap_VBO = 0;
-static GLuint s_Swap_VAO[2];
-static TargetRectangle s_cached_targetRc;
+int s_fps=0;
-static RasterFont* s_pfont = NULL;
+
+RasterFont* s_pfont = NULL;
// 1 for no MSAA. Use s_MSAASamples > 1 to check for MSAA.
static int s_MSAASamples = 1;
@@ -130,9 +126,9 @@ static std::thread scrshotThread;
#endif
// EFB cache related
-static const u32 EFB_CACHE_RECT_SIZE = 64; // Cache 64x64 blocks.
-static const u32 EFB_CACHE_WIDTH = (EFB_WIDTH + EFB_CACHE_RECT_SIZE - 1) / EFB_CACHE_RECT_SIZE; // round up
-static const u32 EFB_CACHE_HEIGHT = (EFB_HEIGHT + EFB_CACHE_RECT_SIZE - 1) / EFB_CACHE_RECT_SIZE;
+const u32 EFB_CACHE_RECT_SIZE = 64; // Cache 64x64 blocks.
+const u32 EFB_CACHE_WIDTH = (EFB_WIDTH + EFB_CACHE_RECT_SIZE - 1) / EFB_CACHE_RECT_SIZE; // round up
+const u32 EFB_CACHE_HEIGHT = (EFB_HEIGHT + EFB_CACHE_RECT_SIZE - 1) / EFB_CACHE_RECT_SIZE;
static bool s_efbCacheValid[2][EFB_CACHE_WIDTH * EFB_CACHE_HEIGHT];
static std::vector<u32> s_efbCache[2][EFB_CACHE_WIDTH * EFB_CACHE_HEIGHT]; // 2 for PEEK_Z and PEEK_COLOR
@@ -255,16 +251,7 @@ Renderer::Renderer()
OSDInternalH = 0;
s_fps=0;
- s_ShowEFBCopyRegions_VBO = 0;
- s_Swap_VBO = 0;
s_blendMode = 0;
-
- // should be invalid, so there will be an upload on the first call
- s_cached_targetRc.bottom = -1;
- s_cached_targetRc.top = -1;
- s_cached_targetRc.left = -1;
- s_cached_targetRc.right = -1;
-
InitFPSCounter();
@@ -325,13 +312,6 @@ Renderer::Renderer()
bSuccess = false;
}
- if (!GLEW_ARB_vertex_array_object)
- {
- ERROR_LOG(VIDEO, "GPU: OGL ERROR: Need GL_ARB_vertex_array_object.\n"
- "GPU: Does your video card support OpenGL 3.0?");
- bSuccess = false;
- }
-
s_bHaveFramebufferBlit = strstr(ptoken, "GL_EXT_framebuffer_blit") != NULL;
s_bHaveCoverageMSAA = strstr(ptoken, "GL_NV_framebuffer_multisample_coverage") != NULL;
@@ -471,46 +451,17 @@ Renderer::Renderer()
cgGLSetDebugMode(GL_FALSE);
#endif
#endif
-
- // creating buffers
- glGenBuffers(1, &s_ShowEFBCopyRegions_VBO);
- glGenVertexArrays(1, &s_ShowEFBCopyRegions_VAO);
- glBindBuffer(GL_ARRAY_BUFFER, s_ShowEFBCopyRegions_VBO);
- glBindVertexArray( s_ShowEFBCopyRegions_VAO );
- glEnableClientState(GL_COLOR_ARRAY);
- glColorPointer (3, GL_FLOAT, sizeof(GLfloat)*5, (GLfloat*)NULL+2);
- glEnableClientState(GL_VERTEX_ARRAY);
- glVertexPointer(2, GL_FLOAT, sizeof(GLfloat)*5, NULL);
-
- glGenBuffers(1, &s_Swap_VBO);
- glGenVertexArrays(2, s_Swap_VAO);
- glBindBuffer(GL_ARRAY_BUFFER, s_Swap_VBO);
- glBindVertexArray(s_Swap_VAO[0]);
- glEnableClientState(GL_VERTEX_ARRAY);
- glVertexPointer(3, GL_FLOAT, 7*sizeof(GLfloat), NULL);
- glClientActiveTexture(GL_TEXTURE0);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glTexCoordPointer(2, GL_FLOAT, 7*sizeof(GLfloat), (GLfloat*)NULL+3);
-
- glBindVertexArray(s_Swap_VAO[1]);
- glEnableClientState(GL_VERTEX_ARRAY);
- glVertexPointer(3, GL_FLOAT, 7*sizeof(GLfloat), NULL);
- glClientActiveTexture(GL_TEXTURE0);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glTexCoordPointer(2, GL_FLOAT, 7*sizeof(GLfloat), (GLfloat*)NULL+3);
- glClientActiveTexture(GL_TEXTURE1);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glTexCoordPointer(2, GL_FLOAT, 7*sizeof(GLfloat), (GLfloat*)NULL+5);
-
- // TODO: this after merging with graphic_update
- glBindVertexArray(0);
- glBindBuffer(GL_ARRAY_BUFFER, 0);
-
+
glStencilFunc(GL_ALWAYS, 0, 0);
glBlendFunc(GL_ONE, GL_ONE);
glViewport(0, 0, GetTargetWidth(), GetTargetHeight()); // Reset The Current Viewport
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+
glShadeModel(GL_SMOOTH);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClearDepth(1.0f);
@@ -527,6 +478,11 @@ Renderer::Renderer()
glBlendColorEXT(0, 0, 0, 0.5f);
glClearDepth(1.0f);
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+
// legacy multitexturing: select texture channel only.
glActiveTexture(GL_TEXTURE0);
glClientActiveTexture(GL_TEXTURE0);
@@ -542,13 +498,6 @@ Renderer::~Renderer()
{
g_Config.bRunning = false;
UpdateActiveConfig();
-
- glDeleteBuffers(1, &s_ShowEFBCopyRegions_VBO);
- glDeleteVertexArrays(1, &s_ShowEFBCopyRegions_VAO);
- glDeleteBuffers(1, &s_Swap_VBO);
- glDeleteVertexArrays(2, s_Swap_VAO);
- s_ShowEFBCopyRegions_VBO = 0;
-
delete s_pfont;
s_pfont = 0;
@@ -596,15 +545,9 @@ void Renderer::DrawDebugInfo()
// Set Line Size
glLineWidth(3.0f);
- // 2*Coords + 3*Color
- glBindBuffer(GL_ARRAY_BUFFER, s_ShowEFBCopyRegions_VBO);
- glBufferData(GL_ARRAY_BUFFER, stats.efb_regions.size() * sizeof(GLfloat) * (2+3)*2*6, NULL, GL_STREAM_DRAW);
- GLfloat *Vertices = (GLfloat*)glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
+ glBegin(GL_LINES);
// Draw EFB copy regions rectangles
- int a = 0;
- GLfloat color[3] = {0.0f, 1.0f, 1.0f};
-
for (std::vector<EFBRectangle>::const_iterator it = stats.efb_regions.begin();
it != stats.efb_regions.end(); ++it)
{
@@ -615,97 +558,22 @@ void Renderer::DrawDebugInfo()
GLfloat x2 = (GLfloat) -1.0f + ((GLfloat)it->right / halfWidth);
GLfloat y2 = (GLfloat) 1.0f - ((GLfloat)it->bottom / halfHeight);
- Vertices[a++] = x;
- Vertices[a++] = y;
- Vertices[a++] = color[0];
- Vertices[a++] = color[1];
- Vertices[a++] = color[2];
-
- Vertices[a++] = x2;
- Vertices[a++] = y;
- Vertices[a++] = color[0];
- Vertices[a++] = color[1];
- Vertices[a++] = color[2];
-
-
- Vertices[a++] = x2;
- Vertices[a++] = y;
- Vertices[a++] = color[0];
- Vertices[a++] = color[1];
- Vertices[a++] = color[2];
-
- Vertices[a++] = x2;
- Vertices[a++] = y2;
- Vertices[a++] = color[0];
- Vertices[a++] = color[1];
- Vertices[a++] = color[2];
-
-
- Vertices[a++] = x2;
- Vertices[a++] = y2;
- Vertices[a++] = color[0];
- Vertices[a++] = color[1];
- Vertices[a++] = color[2];
-
- Vertices[a++] = x;
- Vertices[a++] = y2;
- Vertices[a++] = color[0];
- Vertices[a++] = color[1];
- Vertices[a++] = color[2];
-
-
- Vertices[a++] = x;
- Vertices[a++] = y2;
- Vertices[a++] = color[0];
- Vertices[a++] = color[1];
- Vertices[a++] = color[2];
-
- Vertices[a++] = x;
- Vertices[a++] = y;
- Vertices[a++] = color[0];
- Vertices[a++] = color[1];
- Vertices[a++] = color[2];
-
-
- Vertices[a++] = x;
- Vertices[a++] = y;
- Vertices[a++] = color[0];
- Vertices[a++] = color[1];
- Vertices[a++] = color[2];
-
- Vertices[a++] = x2;
- Vertices[a++] = y2;
- Vertices[a++] = color[0];
- Vertices[a++] = color[1];
- Vertices[a++] = color[2];
-
-
- Vertices[a++] = x2;
- Vertices[a++] = y;
- Vertices[a++] = color[0];
- Vertices[a++] = color[1];
- Vertices[a++] = color[2];
-
- Vertices[a++] = x;
- Vertices[a++] = y2;
- Vertices[a++] = color[0];
- Vertices[a++] = color[1];
- Vertices[a++] = color[2];
-
- // TO DO: build something nicer here
- GLfloat temp = color[0];
- color[0] = color[1];
- color[1] = color[2];
- color[2] = temp;
+ // Draw shadow of rect
+ glColor3f(0.0f, 0.0f, 0.0f);
+ glVertex2f(x, y - 0.01); glVertex2f(x2, y - 0.01);
+ glVertex2f(x, y2 - 0.01); glVertex2f(x2, y2 - 0.01);
+ glVertex2f(x + 0.005, y); glVertex2f(x + 0.005, y2);
+ glVertex2f(x2 + 0.005, y); glVertex2f(x2 + 0.005, y2);
+
+ // Draw rect
+ glColor3f(0.0f, 1.0f, 1.0f);
+ glVertex2f(x, y); glVertex2f(x2, y);
+ glVertex2f(x, y2); glVertex2f(x2, y2);
+ glVertex2f(x, y); glVertex2f(x, y2);
+ glVertex2f(x2, y); glVertex2f(x2, y2);
}
- glUnmapBuffer(GL_ARRAY_BUFFER);
-
- glBindVertexArray( s_ShowEFBCopyRegions_VAO );
- glDrawArrays(GL_LINES, 0, stats.efb_regions.size() * 2*6);
-
- // TODO: this after merging with graphic_update
- glBindVertexArray(0);
- glBindBuffer(GL_ARRAY_BUFFER, 0);
+
+ glEnd();
// Restore Line Size
glLineWidth(lSize);
@@ -733,13 +601,16 @@ void Renderer::RenderText(const char *text, int left, int top, u32 color)
const int nBackbufferWidth = (int)GLInterface->GetBackBufferWidth();
const int nBackbufferHeight = (int)GLInterface->GetBackBufferHeight();
+ glColor4f(((color>>16) & 0xff)/255.0f, ((color>> 8) & 0xff)/255.0f,
+ ((color>> 0) & 0xff)/255.0f, ((color>>24) & 0xFF)/255.0f);
+
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
s_pfont->printMultilineText(text,
left * 2.0f / (float)nBackbufferWidth - 1,
1 - top * 2.0f / (float)nBackbufferHeight,
- 0, nBackbufferWidth, nBackbufferHeight, color);
+ 0, nBackbufferWidth, nBackbufferHeight);
GL_REPORT_ERRORD();
@@ -1264,42 +1135,43 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
// Render to the real buffer now.
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); // switch to the window backbuffer
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, read_texture);
-
- if(!( s_cached_targetRc == targetRc)) {
- GLfloat vertices[] = {
- -1.0f, -1.0f, 1.0f,
- (GLfloat)targetRc.left, (GLfloat)targetRc.bottom,
- 0.0f, 0.0f,
-
- -1.0f, 1.0f, 1.0f,
- (GLfloat)targetRc.left, (GLfloat)targetRc.top,
- 0.0f, 1.0f,
-
- 1.0f, 1.0f, 1.0f,
- (GLfloat)targetRc.right, (GLfloat)targetRc.top,
- 1.0f, 1.0f,
-
- 1.0f, -1.0f, 1.0f,
- (GLfloat)targetRc.right, (GLfloat)targetRc.bottom,
- 1.0f, 0.0f
- };
-
- glBindBuffer(GL_ARRAY_BUFFER, s_Swap_VBO);
- glBufferData(GL_ARRAY_BUFFER, 4*7*sizeof(GLfloat), vertices, GL_STREAM_DRAW);
-
- s_cached_targetRc = targetRc;
- }
-
- glBindVertexArray(s_Swap_VAO[applyShader]);
- glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
-
-
- // TODO: this after merging with graphic_update
- glBindVertexArray(0);
- glBindBuffer(GL_ARRAY_BUFFER, 0);
-
- if(applyShader)
+ if (applyShader)
+ {
+ glBegin(GL_QUADS);
+ glTexCoord2f(targetRc.left, targetRc.bottom);
+ glMultiTexCoord2fARB(GL_TEXTURE1, 0, 0);
+ glVertex2f(-1, -1);
+
+ glTexCoord2f(targetRc.left, targetRc.top);
+ glMultiTexCoord2fARB(GL_TEXTURE1, 0, 1);
+ glVertex2f(-1, 1);
+
+ glTexCoord2f(targetRc.right, targetRc.top);
+ glMultiTexCoord2fARB(GL_TEXTURE1, 1, 1);
+ glVertex2f( 1, 1);
+
+ glTexCoord2f(targetRc.right, targetRc.bottom);
+ glMultiTexCoord2fARB(GL_TEXTURE1, 1, 0);
+ glVertex2f( 1, -1);
+ glEnd();
PixelShaderCache::DisableShader();
+ }
+ else
+ {
+ glBegin(GL_QUADS);
+ glTexCoord2f(targetRc.left, targetRc.bottom);
+ glVertex2f(-1, -1);
+
+ glTexCoord2f(targetRc.left, targetRc.top);
+ glVertex2f(-1, 1);
+
+ glTexCoord2f(targetRc.right, targetRc.top);
+ glVertex2f( 1, 1);
+
+ glTexCoord2f(targetRc.right, targetRc.bottom);
+ glVertex2f( 1, -1);
+ glEnd();
+ }
}
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0);
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp b/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp
index d90f651a82..7a62131f90 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp
+++ b/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp
@@ -56,13 +56,6 @@
namespace OGL
{
-struct VBOCache {
- GLuint vbo;
- GLuint vao;
- TargetRectangle targetSource;
-};
-static std::map<u64,VBOCache> s_VBO;
-
static u32 s_TempFramebuffer = 0;
static const GLint c_MinLinearFilter[8] = {
@@ -113,8 +106,6 @@ TextureCache::TCacheEntry::~TCacheEntry()
TextureCache::TCacheEntry::TCacheEntry()
{
glGenTextures(1, &texture);
- currmode.hex = 0;
- currmode1.hex = 0;
GL_REPORT_ERRORD();
}
@@ -127,9 +118,7 @@ void TextureCache::TCacheEntry::Bind(unsigned int stage)
// TODO: is this already done somewhere else?
TexMode0 &tm0 = bpmem.tex[stage >> 2].texMode0[stage & 3];
TexMode1 &tm1 = bpmem.tex[stage >> 2].texMode1[stage & 3];
-
- if(currmode.hex != tm0.hex || currmode1.hex != tm1.hex)
- SetTextureParameters(tm0, tm1);
+ SetTextureParameters(tm0, tm1);
}
bool TextureCache::TCacheEntry::Save(const char filename[], unsigned int level)
@@ -315,57 +304,13 @@ void TextureCache::TCacheEntry::FromRenderTarget(u32 dstAddr, unsigned int dstFo
GL_REPORT_ERRORD();
TargetRectangle targetSource = g_renderer->ConvertEFBRectangle(srcRect);
- GL_REPORT_ERRORD();
-
- // should be unique enough, if not, vbo will "only" be uploaded to much
- u64 targetSourceHash = u64(targetSource.left)<<48 | u64(targetSource.top)<<32 | u64(targetSource.right)<<16 | u64(targetSource.bottom);
- std::map<u64, VBOCache>::iterator vbo_it = s_VBO.find(targetSourceHash);
-
- if(vbo_it == s_VBO.end()) {
- VBOCache item;
- item.targetSource.bottom = -1;
- item.targetSource.top = -1;
- item.targetSource.left = -1;
- item.targetSource.right = -1;
- glGenBuffers(1, &item.vbo);
- glGenVertexArrays(1, &item.vao);
-
- glBindBuffer(GL_ARRAY_BUFFER, item.vbo);
- glBindVertexArray(item.vao);
-
- glEnableClientState(GL_VERTEX_ARRAY);
- glVertexPointer(2, GL_FLOAT, sizeof(GLfloat)*4, 0);
-
- glClientActiveTexture(GL_TEXTURE0);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glTexCoordPointer(2, GL_FLOAT, sizeof(GLfloat)*4, (GLfloat*)NULL + 2);
-
- vbo_it = s_VBO.insert(std::pair<u64,VBOCache>(targetSourceHash, item)).first;
- }
- if(!(vbo_it->second.targetSource == targetSource)) {
- GLfloat vertices[] = {
- -1.f, 1.f,
- (GLfloat)targetSource.left, (GLfloat)targetSource.bottom,
- -1.f, -1.f,
- (GLfloat)targetSource.left, (GLfloat)targetSource.top,
- 1.f, -1.f,
- (GLfloat)targetSource.right, (GLfloat)targetSource.top,
- 1.f, 1.f,
- (GLfloat)targetSource.right, (GLfloat)targetSource.bottom
- };
-
- glBindBuffer(GL_ARRAY_BUFFER, vbo_it->second.vbo);
- glBufferData(GL_ARRAY_BUFFER, 4*4*sizeof(GLfloat), vertices, GL_STREAM_DRAW);
-
- vbo_it->second.targetSource = targetSource;
- }
-
- glBindVertexArray(vbo_it->second.vao);
- glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
-
- // TODO: this after merging with graphic_update
- glBindVertexArray(0);
- glBindBuffer(GL_ARRAY_BUFFER, 0);
+
+ glBegin(GL_QUADS);
+ glTexCoord2f((GLfloat)targetSource.left, (GLfloat)targetSource.bottom); glVertex2f(-1, 1);
+ glTexCoord2f((GLfloat)targetSource.left, (GLfloat)targetSource.top ); glVertex2f(-1, -1);
+ glTexCoord2f((GLfloat)targetSource.right, (GLfloat)targetSource.top ); glVertex2f( 1, -1);
+ glTexCoord2f((GLfloat)targetSource.right, (GLfloat)targetSource.bottom); glVertex2f( 1, 1);
+ glEnd();
GL_REPORT_ERRORD();
@@ -412,9 +357,6 @@ void TextureCache::TCacheEntry::FromRenderTarget(u32 dstAddr, unsigned int dstFo
void TextureCache::TCacheEntry::SetTextureParameters(const TexMode0 &newmode, const TexMode1 &newmode1)
{
- currmode = newmode;
- currmode1 = newmode1;
-
// TODO: not used anywhere
TexMode0 mode = newmode;
//mode1 = newmode1;
@@ -446,24 +388,13 @@ void TextureCache::TCacheEntry::SetTextureParameters(const TexMode0 &newmode, co
(float)(1 << g_ActiveConfig.iMaxAnisotropy));
}
-TextureCache::TextureCache()
-{
-}
-
-
TextureCache::~TextureCache()
{
- for(std::map<u64, VBOCache>::iterator it = s_VBO.begin(); it != s_VBO.end(); it++) {
- glDeleteBuffers(1, &it->second.vbo);
- glDeleteVertexArrays(1, &it->second.vao);
- }
- s_VBO.clear();
-
- if (s_TempFramebuffer)
+ if (s_TempFramebuffer)
{
- glDeleteFramebuffersEXT(1, (GLuint*)&s_TempFramebuffer);
- s_TempFramebuffer = 0;
- }
+ glDeleteFramebuffersEXT(1, (GLuint*)&s_TempFramebuffer);
+ s_TempFramebuffer = 0;
+ }
}
void TextureCache::DisableStage(unsigned int stage)
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.h b/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.h
index dc560e098b..30f44b797d 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.h
+++ b/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.h
@@ -32,7 +32,6 @@ namespace OGL
class TextureCache : public ::TextureCache
{
public:
- TextureCache();
static void DisableStage(unsigned int stage);
private:
@@ -67,8 +66,6 @@ private:
private:
void SetTextureParameters(const TexMode0 &newmode, const TexMode1 &newmode1);
- TexMode0 currmode;
- TexMode1 currmode1;
};
~TextureCache();
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/TextureConverter.cpp b/Source/Plugins/Plugin_VideoOGL/Src/TextureConverter.cpp
index 54a2e2464c..c73d3abdbf 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/TextureConverter.cpp
+++ b/Source/Plugins/Plugin_VideoOGL/Src/TextureConverter.cpp
@@ -57,14 +57,6 @@ static FRAGMENTSHADER s_yuyvToRgbProgram;
const u32 NUM_ENCODING_PROGRAMS = 64;
static FRAGMENTSHADER s_encodingPrograms[NUM_ENCODING_PROGRAMS];
-static GLuint s_encode_VBO = 0;
-static GLuint s_encode_VAO = 0;
-static GLuint s_decode_VBO = 0;
-static GLuint s_decode_VAO = 0;
-static TargetRectangle s_cached_sourceRc;
-static int s_cached_srcWidth = 0;
-static int s_cached_srcHeight = 0;
-
void CreateRgbToYuyvProgram()
{
// Output is BGRA because that is slightly faster than RGBA.
@@ -148,40 +140,9 @@ FRAGMENTSHADER &GetOrCreateEncodingShader(u32 format)
void Init()
{
glGenFramebuffersEXT(1, &s_texConvFrameBuffer);
-
- glGenBuffers(1, &s_encode_VBO );
- glGenVertexArrays(1, &s_encode_VAO );
- glBindBuffer(GL_ARRAY_BUFFER, s_encode_VBO );
- glBindVertexArray( s_encode_VAO );
- glEnableClientState(GL_VERTEX_ARRAY);
- glVertexPointer(2, GL_FLOAT, 4*sizeof(GLfloat), NULL);
- glClientActiveTexture(GL_TEXTURE0);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glTexCoordPointer(2, GL_FLOAT, 4*sizeof(GLfloat), (GLfloat*)NULL + 2);
- s_cached_sourceRc.top = -1;
- s_cached_sourceRc.bottom = -1;
- s_cached_sourceRc.left = -1;
- s_cached_sourceRc.right = -1;
-
- glGenBuffers(1, &s_decode_VBO );
- glGenVertexArrays(1, &s_decode_VAO );
- glBindBuffer(GL_ARRAY_BUFFER, s_decode_VBO );
- glBindVertexArray( s_decode_VAO );
- s_cached_srcWidth = -1;
- s_cached_srcHeight = -1;
- glEnableClientState(GL_VERTEX_ARRAY);
- glVertexPointer(2, GL_FLOAT, sizeof(GLfloat)*4, NULL);
- glClientActiveTexture(GL_TEXTURE0);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glTexCoordPointer(2, GL_FLOAT, sizeof(GLfloat)*4, (GLfloat*)NULL+2);
-
- // TODO: this after merging with graphic_update
- glBindVertexArray(0);
- glBindBuffer(GL_ARRAY_BUFFER, 0);
glGenRenderbuffersEXT(1, &s_dstRenderBuffer);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, s_dstRenderBuffer);
-
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA, renderBufferWidth, renderBufferHeight);
s_srcTextureWidth = 0;
@@ -201,10 +162,6 @@ void Shutdown()
glDeleteTextures(1, &s_srcTexture);
glDeleteRenderbuffersEXT(1, &s_dstRenderBuffer);
glDeleteFramebuffersEXT(1, &s_texConvFrameBuffer);
- glDeleteBuffers(1, &s_encode_VBO );
- glDeleteVertexArrays(1, &s_encode_VAO );
- glDeleteBuffers(1, &s_decode_VBO );
- glDeleteVertexArrays(1, &s_decode_VAO );
s_rgbToYuyvProgram.Destroy();
s_yuyvToRgbProgram.Destroy();
@@ -256,31 +213,13 @@ void EncodeToRamUsingShader(FRAGMENTSHADER& shader, GLuint srcTexture, const Tar
PixelShaderCache::SetCurrentShader(shader.glprogid);
- GL_REPORT_ERRORD();
- if(!(s_cached_sourceRc == sourceRc)) {
- GLfloat vertices[] = {
- -1.f, -1.f,
- (float)sourceRc.left, (float)sourceRc.top,
- -1.f, 1.f,
- (float)sourceRc.left, (float)sourceRc.bottom,
- 1.f, 1.f,
- (float)sourceRc.right, (float)sourceRc.bottom,
- 1.f, -1.f,
- (float)sourceRc.right, (float)sourceRc.top
- };
- glBindBuffer(GL_ARRAY_BUFFER, s_encode_VBO );
- glBufferData(GL_ARRAY_BUFFER, 4*4*sizeof(GLfloat), vertices, GL_STREAM_DRAW);
-
- s_cached_sourceRc = sourceRc;
- }
-
- glBindVertexArray( s_encode_VAO );
- glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
-
- // TODO: this after merging with graphic_update
- glBindVertexArray(0);
- glBindBuffer(GL_ARRAY_BUFFER, 0);
-
+ // Draw...
+ glBegin(GL_QUADS);
+ glTexCoord2f((float)sourceRc.left, (float)sourceRc.top); glVertex2f(-1,-1);
+ glTexCoord2f((float)sourceRc.left, (float)sourceRc.bottom); glVertex2f(-1,1);
+ glTexCoord2f((float)sourceRc.right, (float)sourceRc.bottom); glVertex2f(1,1);
+ glTexCoord2f((float)sourceRc.right, (float)sourceRc.top); glVertex2f(1,-1);
+ glEnd();
GL_REPORT_ERRORD();
// .. and then read back the results.
@@ -436,39 +375,18 @@ void DecodeToTexture(u32 xfbAddr, int srcWidth, int srcHeight, GLuint destTextur
PixelShaderCache::SetCurrentShader(s_yuyvToRgbProgram.glprogid);
GL_REPORT_ERRORD();
-
- if(s_cached_srcHeight != srcHeight || s_cached_srcWidth != srcWidth) {
- GLfloat vertices[] = {
- 1.f, -1.f,
- (float)srcFmtWidth, (float)srcHeight,
- 1.f, 1.f,
- (float)srcFmtWidth, 0.f,
- -1.f, 1.f,
- 0.f, 0.f,
- -1.f, -1.f,
- 0.f, (float)srcHeight
- };
-
- glBindBuffer(GL_ARRAY_BUFFER, s_decode_VBO );
- glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat)*4*4, vertices, GL_STREAM_DRAW);
-
- s_cached_srcHeight = srcHeight;
- s_cached_srcWidth = srcWidth;
- }
-
- glBindVertexArray( s_decode_VAO );
- glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
-
- // TODO: this after merging with graphic_update
- glBindVertexArray(0);
- glBindBuffer(GL_ARRAY_BUFFER, 0);
-
- GL_REPORT_ERRORD();
+
+ glBegin(GL_QUADS);
+ glTexCoord2f((float)srcFmtWidth, (float)srcHeight); glVertex2f(1,-1);
+ glTexCoord2f((float)srcFmtWidth, 0); glVertex2f(1,1);
+ glTexCoord2f(0, 0); glVertex2f(-1,1);
+ glTexCoord2f(0, (float)srcHeight); glVertex2f(-1,-1);
+ glEnd();
// reset state
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_RECTANGLE_ARB, 0, 0);
- TextureCache::DisableStage(0);
+ TextureCache::DisableStage(0);
VertexShaderManager::SetViewportChanged();
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/VertexManager.cpp b/Source/Plugins/Plugin_VideoOGL/Src/VertexManager.cpp
index 3725d87add..501c4969e5 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/VertexManager.cpp
+++ b/Source/Plugins/Plugin_VideoOGL/Src/VertexManager.cpp
@@ -64,6 +64,9 @@ VertexManager::VertexManager()
// max_Index_size = MAXIBUFFERSIZE;
//
//GL_REPORT_ERRORD();
+
+ glEnableClientState(GL_VERTEX_ARRAY);
+ GL_REPORT_ERRORD();
}
void VertexManager::CreateDeviceObjects()
diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/SWRenderer.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/SWRenderer.cpp
index d2f77cd256..49739b7f6e 100644
--- a/Source/Plugins/Plugin_VideoSoftware/Src/SWRenderer.cpp
+++ b/Source/Plugins/Plugin_VideoSoftware/Src/SWRenderer.cpp
@@ -96,11 +96,12 @@ void SWRenderer::RenderText(const char* pstr, int left, int top, u32 color)
#ifndef USE_GLES
int nBackbufferWidth = (int)GLInterface->GetBackBufferWidth();
int nBackbufferHeight = (int)GLInterface->GetBackBufferHeight();
-
+ glColor4f(((color>>16) & 0xff)/255.0f, ((color>> 8) & 0xff)/255.0f,
+ ((color>> 0) & 0xff)/255.0f, ((color>>24) & 0xFF)/255.0f);
s_pfont->printMultilineText(pstr,
left * 2.0f / (float)nBackbufferWidth - 1,
1 - top * 2.0f / (float)nBackbufferHeight,
- 0, nBackbufferWidth, nBackbufferHeight, color);
+ 0, nBackbufferWidth, nBackbufferHeight);
#endif
}