Skip to content

Commit 8b71d6d

Browse files
committed
Put scissoring back in.
Tidy up.
1 parent a3ab20c commit 8b71d6d

File tree

2 files changed

+12
-18
lines changed

2 files changed

+12
-18
lines changed

source/platform/renderers/OpenGL/OpenGL.cpp

+12-17
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include <Gwork/PlatformTypes.h>
1010

1111
#include <GLFW/glfw3.h>
12-
//#include <GL/glew.h>
1312
#include <math.h>
1413

1514
//#define STBI_ASSERT(x) // comment in for no asserts
@@ -83,7 +82,7 @@ namespace Gwk
8382

8483
// OpenGL origin is bottom-left. Gwork origin is top-left.
8584
m_vertices[ m_vertNum ].x = float(x);
86-
m_vertices[ m_vertNum ].y = m_viewRect.h - float(y);
85+
m_vertices[ m_vertNum ].y = float(m_viewRect.h - y);
8786
m_vertices[ m_vertNum ].u = u;
8887
m_vertices[ m_vertNum ].v = v;
8988
m_vertices[ m_vertNum ].r = m_color.r;
@@ -122,22 +121,22 @@ namespace Gwk
122121
void OpenGL::StartClip()
123122
{
124123
Flush();
125-
// Gwk::Rect rect = ClipRegion();
126-
// // OpenGL's coords are from the bottom left
127-
// // so we need to translate them here.
128-
// {
129-
// GLint view[4];
130-
// glGetIntegerv(GL_VIEWPORT, &view[0]);
131-
// rect.y = view[3] - (rect.y + rect.h);
132-
// }
133-
// glScissor(rect.x*Scale(), rect.y*Scale(), rect.w*Scale(), rect.h*Scale());
134-
// glEnable(GL_SCISSOR_TEST);
124+
Gwk::Rect rect = ClipRegion();
125+
// OpenGL's coords are from the bottom left
126+
// so we need to translate them here.
127+
{
128+
GLint view[4];
129+
glGetIntegerv(GL_VIEWPORT, &view[0]);
130+
rect.y = view[3] - (rect.y + rect.h);
131+
}
132+
glScissor(rect.x*Scale(), rect.y*Scale(), rect.w*Scale(), rect.h*Scale());
133+
glEnable(GL_SCISSOR_TEST);
135134
}
136135

137136
void OpenGL::EndClip()
138137
{
139138
Flush();
140-
// glDisable(GL_SCISSOR_TEST);
139+
glDisable(GL_SCISSOR_TEST);
141140
}
142141

143142
void OpenGL::DrawTexturedRect(Gwk::Texture* texture, Gwk::Rect rect,
@@ -196,11 +195,7 @@ namespace Gwk
196195
glBindTexture(GL_TEXTURE_2D, *pglTexture);
197196
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
198197
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
199-
//#ifdef FREEIMAGE_BIGENDIAN
200198
GLenum format = GL_RGBA;
201-
//#else
202-
// GLenum format = GL_BGRA;
203-
//#endif
204199
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texture->width, texture->height, 0, format,
205200
GL_UNSIGNED_BYTE, (const GLvoid*)data);
206201

source/samples/OpenGL/OpenGLSample.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
# include <Gwork/Renderers/OpenGL.h>
1818
#endif
1919
#include <GLFW/glfw3.h>
20-
//#include <GL/glew.h>
2120

2221

2322
static Gwk::Input::GLFW GworkInput;

0 commit comments

Comments
 (0)