Browse Source

Replace glBegin/glEnd

ToGLES3
nillerusr 3 years ago
parent
commit
e8dd3cece3
  1. 12
      appframework/glmdisplaydb_linuxwin.inl
  2. 4
      engine/sys_mainwind.cpp
  3. 1
      public/appframework/ilaunchermgr.h
  4. 7
      public/togl/rendermechanism.h
  5. 8
      public/togles/linuxwin/glfuncs.h
  6. 12
      togles/linuxwin/cglmtex.cpp
  7. 13
      togles/linuxwin/glentrypoints.cpp
  8. 30
      togles/linuxwin/glmgr.cpp

12
appframework/glmdisplaydb_linuxwin.inl

@ -45,7 +45,7 @@ void GLMRendererInfo::Init( GLMRendererInfoFields *info ) @@ -45,7 +45,7 @@ void GLMRendererInfo::Init( GLMRendererInfoFields *info )
// If you haven't created a GL context by now (and initialized gGL), you're about to crash.
m_info.m_hasMixedAttachmentSizes = gGL->m_bHave_GL_ARB_framebuffer_object;
m_info.m_hasMixedAttachmentSizes = gGL->m_bHave_GL_EXT_framebuffer_object;
m_info.m_hasBGRA = gGL->m_bHave_GL_EXT_vertex_array_bgra;
// !!! FIXME: what do these do on the Mac?
@ -64,8 +64,15 @@ void GLMRendererInfo::Init( GLMRendererInfoFields *info ) @@ -64,8 +64,15 @@ void GLMRendererInfo::Init( GLMRendererInfoFields *info )
m_info.m_hasNativeClipVertexMode = true;
}
#ifdef TOGLES
m_info.m_hasOcclusionQuery = true;
m_info.m_hasFramebufferBlit = true;
m_info.m_hasUniformBuffers = true;
#else
m_info.m_hasOcclusionQuery = gGL->m_bHave_GL_ARB_occlusion_query;
m_info.m_hasFramebufferBlit = gGL->m_bHave_GL_EXT_framebuffer_blit || gGL->m_bHave_GL_ARB_framebuffer_object;
m_info.m_hasUniformBuffers = gGL->m_bHave_GL_ARB_uniform_buffer;
#endif
GLint nMaxAniso = 0;
gGL->glGetIntegerv( GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &nMaxAniso );
@ -88,8 +95,7 @@ void GLMRendererInfo::Init( GLMRendererInfoFields *info ) @@ -88,8 +95,7 @@ void GLMRendererInfo::Init( GLMRendererInfoFields *info )
m_info.m_hasBindableUniforms = false;
}
}
m_info.m_hasUniformBuffers = gGL->m_bHave_GL_ARB_uniform_buffer;
m_info.m_hasPerfPackage1 = true; // this flag is Mac-specific. We do slower things if you don't have Mac OS X 10.x.y or later. Linux always does the fast path!
//-------------------------------------------------------------------

4
engine/sys_mainwind.cpp

@ -915,7 +915,11 @@ bool CGame::CreateGameWindow( void ) @@ -915,7 +915,11 @@ bool CGame::CreateGameWindow( void )
if ( IsOpenGL() )
{
#ifdef TOGLES
V_strcat( windowName, " - OpenGLES", sizeof( windowName ) );
#else
V_strcat( windowName, " - OpenGL", sizeof( windowName ) );
#endif
}
#if PIX_ENABLE || defined( PIX_INSTRUMENTATION )

1
public/appframework/ilaunchermgr.h

@ -16,6 +16,7 @@ @@ -16,6 +16,7 @@
#include "appframework/IAppSystem.h"
#if defined( DX_TO_GL_ABSTRACTION )
#include "togl/linuxwin/glmgrbasics.h"
#include "togl/linuxwin/glmdisplay.h"

7
public/togl/rendermechanism.h

@ -22,6 +22,11 @@ @@ -22,6 +22,11 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
#ifdef TOGLES
#include "togles/rendermechanism.h"
#else
#ifndef RENDERMECHANISM_H
#define RENDERMECHANISM_H
@ -71,3 +76,5 @@ @@ -71,3 +76,5 @@
#endif // defined(DX_TO_GL_ABSTRACTION)
#endif // RENDERMECHANISM_H
#endif

8
public/togles/linuxwin/glfuncs.h

@ -28,7 +28,6 @@ GL_FUNC(OpenGL,true,GLenum,glGetError,(void),()) @@ -28,7 +28,6 @@ GL_FUNC(OpenGL,true,GLenum,glGetError,(void),())
GL_FUNC_VOID(OpenGL,true,glActiveTexture,(GLenum a),(a))
GL_FUNC_VOID(OpenGL,true,glAlphaFunc,(GLenum a,GLclampf b),(a,b))
GL_FUNC_VOID(OpenGL,true,glAttachShader,(GLuint a, GLuint b),(a,b))
GL_FUNC_VOID(OpenGL,true,glBegin,(GLenum a),(a))
GL_FUNC_VOID(OpenGL,true,glBindAttribLocation,(GLuint a,GLuint b,const GLchar *c),(a,b,c))
GL_FUNC_VOID(OpenGL,true,glBindBuffer,(GLenum a,GLuint b),(a,b))
GL_FUNC_VOID(OpenGL,true,glBindProgram,(GLenum a,GLuint b),(a,b))
@ -73,7 +72,6 @@ GL_FUNC_VOID(OpenGL,true,glDrawRangeElementsBaseVertex,(GLenum a,GLuint b,GLuint @@ -73,7 +72,6 @@ GL_FUNC_VOID(OpenGL,true,glDrawRangeElementsBaseVertex,(GLenum a,GLuint b,GLuint
#endif
GL_FUNC_VOID(OpenGL,true,glEnable,(GLenum a),(a))
GL_FUNC_VOID(OpenGL,true,glEnableVertexAttribArray,(GLuint a),(a))
GL_FUNC_VOID(OpenGL,true,glEnd,(void),())
GL_FUNC_VOID(OpenGL,true,glFinish,(void),())
GL_FUNC_VOID(OpenGL,true,glFlush,(void),())
GL_FUNC_VOID(OpenGL,true,glFrontFace,(GLenum a),(a))
@ -94,13 +92,11 @@ GL_FUNC(OpenGL,true,GLint,glGetUniformLocation,(GLuint a,const GLchar *b),(a,b)) @@ -94,13 +92,11 @@ GL_FUNC(OpenGL,true,GLint,glGetUniformLocation,(GLuint a,const GLchar *b),(a,b))
GL_FUNC(OpenGL,true,GLboolean,glIsEnabled,(GLenum a),(a))
GL_FUNC(OpenGL,true,GLboolean,glIsTexture,(GLuint a),(a))
GL_FUNC_VOID(OpenGL,true,glLinkProgram,(GLuint a),(a))
//GL_FUNC(OpenGL,true,GLvoid*,glMapBufferARB,(GLenum a,GLenum b),(a,b))
GL_FUNC_VOID(OpenGL,true,glOrtho,(GLdouble a,GLdouble b,GLdouble c,GLdouble d,GLdouble e,GLdouble f),(a,b,c,d,e,f))
GL_FUNC_VOID(OpenGL,true,glPixelStorei,(GLenum a,GLint b),(a,b))
GL_FUNC_VOID(OpenGL,true,glPolygonMode,(GLenum a,GLenum b),(a,b))
GL_FUNC_VOID(OpenGL,true,glPolygonOffset,(GLfloat a,GLfloat b),(a,b))
GL_FUNC_VOID(OpenGL,true,glPopAttrib,(void),())
//GL_FUNC_VOID(OpenGL,true,glProgramStringARB,(GLenum a,GLenum b,GLsizei c,const GLvoid *d),(a,b,c,d))
GL_FUNC_VOID(OpenGL,true,glPushAttrib,(GLbitfield a),(a))
GL_FUNC_VOID(OpenGL,true,glReadBuffer,(GLenum a),(a))
GL_FUNC_VOID(OpenGL,true,glScissor,(GLint a,GLint b,GLsizei c,GLsizei d),(a,b,c,d))
@ -116,7 +112,6 @@ GL_FUNC_VOID(OpenGL,true,glTexParameteri,(GLenum a,GLenum b,GLint c),(a,b,c)) @@ -116,7 +112,6 @@ GL_FUNC_VOID(OpenGL,true,glTexParameteri,(GLenum a,GLenum b,GLint c),(a,b,c))
GL_FUNC_VOID(OpenGL,true,glTexSubImage2D,(GLenum a,GLint b,GLint c,GLint d,GLsizei e,GLsizei f,GLenum g,GLenum h,const GLvoid *i),(a,b,c,d,e,f,g,h,i))
GL_FUNC_VOID(OpenGL,true,glUniform1f,(GLint a,GLfloat b),(a,b))
GL_FUNC_VOID(OpenGL,true,glUniform1i,(GLint a,GLint b),(a,b))
GL_FUNC_VOID(OpenGL,true,glUniform1iARB,(GLint a,GLint b),(a,b))
GL_FUNC_VOID(OpenGL,true,glUniform4fv,(GLint a,GLsizei b,const GLfloat *c),(a,b,c))
GL_FUNC(OpenGL,true,GLboolean,glUnmapBuffer,(GLenum a),(a))
GL_FUNC_VOID(OpenGL,true,glUseProgram,(GLuint a),(a))
@ -187,9 +182,6 @@ GL_FUNC_VOID(OpenGL,false,glFlushMappedBufferRange,(GLenum a,GLintptr b,GLsizeip @@ -187,9 +182,6 @@ GL_FUNC_VOID(OpenGL,false,glFlushMappedBufferRange,(GLenum a,GLintptr b,GLsizeip
GL_EXT(GL_ARB_vertex_buffer_object,-1,-1)
GL_FUNC_VOID(OpenGL,true,glBufferSubData,(GLenum a,GLintptr b,GLsizeiptr c,const GLvoid *d),(a,b,c,d))
GL_EXT(GL_ARB_occlusion_query,-1,-1)
GL_FUNC_VOID(GL_ARB_occlusion_query,false,glBeginQueryARB,(GLenum a,GLuint b),(a,b))
GL_FUNC_VOID(GL_ARB_occlusion_query,false,glEndQueryARB,(GLenum a),(a))
GL_FUNC_VOID(GL_ARB_occlusion_query,false,glGetQueryObjectivARB,(GLuint a,GLenum b,GLint *c),(a,b,c))
GL_FUNC_VOID(OpenGL,false,glGetQueryObjectuiv,(GLuint a,GLenum b,GLuint *c),(a,b,c))
GL_EXT(GL_APPLE_texture_range,-1,-1)
GL_FUNC_VOID(GL_APPLE_texture_range,false,glTextureRangeAPPLE,(GLenum a,GLsizei b,void *c),(a,b,c))

12
togles/linuxwin/cglmtex.cpp

@ -891,9 +891,6 @@ CGLMTex::CGLMTex( GLMContext *ctx, GLMTexLayout *layout, uint levels, const char @@ -891,9 +891,6 @@ CGLMTex::CGLMTex( GLMContext *ctx, GLMTexLayout *layout, uint levels, const char
{
printf("\n minimizing storage for tex '%s' [%s] ", m_debugLabel?m_debugLabel:"-", m_layout->m_layoutSummary );
}
if (gGL->m_bHave_GL_APPLE_texture_range)
gGL->glTexParameteri( m_layout->m_key.m_texGLTarget, GL_TEXTURE_MINIMIZE_STORAGE_APPLE, 1 );
}
// after a lot of pain with texture completeness...
@ -1359,10 +1356,6 @@ void CGLMTex::WriteTexels( GLMTexLockDesc *desc, bool writeWholeSlice, bool noDa @@ -1359,10 +1356,6 @@ void CGLMTex::WriteTexels( GLMTexLockDesc *desc, bool writeWholeSlice, bool noDa
// set up the client storage now, one way or another
// If this extension isn't supported, we just end up with two copies of the texture, one in the GL and one in app memory.
// So it's safe to just go on as if this extension existed and hold the possibly-unnecessary extra RAM.
if (gGL->m_bHave_GL_APPLE_client_storage)
{
gGL->glPixelStorei( GL_UNPACK_CLIENT_STORAGE_APPLE, m_texClientStorage );
}
switch( target )
{
@ -1509,11 +1502,6 @@ void CGLMTex::WriteTexels( GLMTexLockDesc *desc, bool writeWholeSlice, bool noDa @@ -1509,11 +1502,6 @@ void CGLMTex::WriteTexels( GLMTexLockDesc *desc, bool writeWholeSlice, bool noDa
break;
}
if (gGL->m_bHave_GL_APPLE_client_storage)
{
gGL->glPixelStorei( GL_UNPACK_CLIENT_STORAGE_APPLE, GL_FALSE );
}
if ( expandTemp )
{
free( expandTemp );

13
togles/linuxwin/glentrypoints.cpp

@ -379,18 +379,6 @@ COpenGLEntryPoints::COpenGLEntryPoints() @@ -379,18 +379,6 @@ COpenGLEntryPoints::COpenGLEntryPoints()
// !!! FIXME: hint Apple's drivers and not because we rely on the
// !!! FIXME: functionality. If so, just remove this check (and the
// !!! FIXME: GL_NV_fence code entirely).
#ifndef ANDROID // HACK
if ((m_bHave_OpenGL) && ((!m_bHave_GL_NV_fence) && (!m_bHave_GL_ARB_sync) && (!m_bHave_GL_APPLE_fence)))
{
// Error( "Required OpenGL extension \"GL_NV_fence\", \"GL_ARB_sync\", or \"GL_APPLE_fence\" is not supported. Please upgrade your OpenGL driver." );
}
#endif
// same extension, different name.
if (m_bHave_GL_EXT_vertex_array_bgra || m_bHave_GL_ARB_vertex_array_bgra)
{
m_bHave_GL_EXT_vertex_array_bgra = m_bHave_GL_ARB_vertex_array_bgra = true;
}
// GL_ARB_framebuffer_object is a superset of GL_EXT_framebuffer_object,
// (etc) but if you don't call in through the ARB entry points, you won't
@ -400,6 +388,7 @@ COpenGLEntryPoints::COpenGLEntryPoints() @@ -400,6 +388,7 @@ COpenGLEntryPoints::COpenGLEntryPoints()
m_bHave_GL_EXT_framebuffer_object = true;
m_bHave_GL_EXT_framebuffer_blit = true;
m_bHave_GL_EXT_framebuffer_multisample = true;
m_bHave_GL_ARB_occlusion_query = true;
glBindFramebuffer.Force(glBindFramebuffer.Pointer());
glBindRenderbuffer.Force(glBindRenderbuffer.Pointer());

30
togles/linuxwin/glmgr.cpp

@ -1456,22 +1456,22 @@ void GLMContext::BlitTex( CGLMTex *srcTex, GLMRect *srcRect, int srcFace, int sr @@ -1456,22 +1456,22 @@ void GLMContext::BlitTex( CGLMTex *srcTex, GLMRect *srcRect, int srcFace, int sr
// immediate mode is fine
float topv = 1.0;
float botv = 0.0;
gGL->glBegin(GL_QUADS);
gGL->glTexCoord2f ( 0.0, botv );
gGL->glVertex3f ( -1.0, -1.0, 0.0 );
gGL->glTexCoord2f ( 1.0, botv );
gGL->glVertex3f ( 1.0, -1.0, 0.0 );
gGL->glTexCoord2f ( 1.0, topv );
gGL->glVertex3f ( 1.0, 1.0, 0.0 );
const float topv = 1.0;
const float botv = 0.0;
gGL->glTexCoord2f ( 0.0, topv );
gGL->glVertex3f ( -1.0, 1.0, 0.0 );
gGL->glEnd();
const float verts[] = {-1.f, -1.f, 1.f, -1.f, 1.f, 1.f, -1.f, 1.f};
const float verts_tex[] = {0.f, botv, 1.f, botv, 1.f, topv, 0.f, topv};
gGL->glEnableClientState(GL_VERTEX_ARRAY);
gGL->glEnableClientState(GL_TEXTURE_COORD_ARRAY);
gGL->glVertexPointer(2, GL_FLOAT, 0, verts);
gGL->glTexCoordPointer(2, GL_FLOAT, 0, verts_tex);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
gGL->glDisableClientState(GL_VERTEX_ARRAY);
gGL->glDisableClientState(GL_TEXTURE_COORD_ARRAY);
gGL->glBindTexture( GL_TEXTURE_2D, 0 );

Loading…
Cancel
Save