mirror of
https://github.com/jenshemprich/MacGLide.git
synced 2024-06-02 09:41:28 +00:00
optimised enabling/disabling the clipping state
This commit is contained in:
parent
a0c5ddcb75
commit
6f7f3b5a91
|
@ -599,8 +599,20 @@ void RenderDrawTriangles_impl( void )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
OGLRender.NumberOfTriangles = 0;
|
OGLRender.NumberOfTriangles = 0;
|
||||||
|
// Render the front buffer after each triangle sequence
|
||||||
|
// (However, rendering each triangle seperately would be more correct)
|
||||||
|
if (Glide.State.RenderBuffer == GR_BUFFER_FRONTBUFFER)
|
||||||
|
{
|
||||||
|
glFlush();
|
||||||
|
}
|
||||||
s_Framebuffer.SetRenderBufferChanged();
|
s_Framebuffer.SetRenderBufferChanged();
|
||||||
|
// Clipping is turned off here per default to save the state-change call
|
||||||
|
// for unclipped triangles. Usally this never triggers, so it's called
|
||||||
|
// once per triangle sequence.
|
||||||
|
// This allows for one call per triangle sequence + one call per clipped
|
||||||
|
// triangle instead of one call for any (even unclipped) triangle
|
||||||
|
SetClipVerticesState(false);
|
||||||
|
|
||||||
VERIFY_ACTIVE_TEXTURE_UNIT(OpenGL.ColorAlphaUnit1);
|
VERIFY_ACTIVE_TEXTURE_UNIT(OpenGL.ColorAlphaUnit1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@ bool s_bUpdateColorInvertState = false;
|
||||||
bool s_bUpdateAlphaInvertState = false;
|
bool s_bUpdateAlphaInvertState = false;
|
||||||
bool s_bUpdateConstantColorValueState = false;
|
bool s_bUpdateConstantColorValueState = false;
|
||||||
bool s_bUpdateConstantColorValue4State = false;
|
bool s_bUpdateConstantColorValue4State = false;
|
||||||
|
//bool s_bUpdateClipVerticesState = false;
|
||||||
|
|
||||||
bool s_bForceChromaKeyAndAlphaStateUpdate = false;
|
bool s_bForceChromaKeyAndAlphaStateUpdate = false;
|
||||||
|
|
||||||
|
@ -1584,7 +1585,12 @@ void SetClipVerticesState_Update(bool clip_vertices)
|
||||||
OpenGL.ClipVerticesEnabledState = clip_vertices;
|
OpenGL.ClipVerticesEnabledState = clip_vertices;
|
||||||
if (InternalConfig.EXT_clip_volume_hint)
|
if (InternalConfig.EXT_clip_volume_hint)
|
||||||
{
|
{
|
||||||
RenderDrawTriangles();
|
// If clipping is about to be turned off we have to render
|
||||||
|
// any triangles to be rendered with clipping turned on
|
||||||
|
if (!OpenGL.ClipVerticesEnabledState)
|
||||||
|
{
|
||||||
|
RenderDrawTriangles();
|
||||||
|
}
|
||||||
glHint(GL_CLIP_VOLUME_CLIPPING_HINT_EXT, clip_vertices ? GL_DONT_CARE : GL_FASTEST);
|
glHint(GL_CLIP_VOLUME_CLIPPING_HINT_EXT, clip_vertices ? GL_DONT_CARE : GL_FASTEST);
|
||||||
#ifdef OPENGL_DEBUG
|
#ifdef OPENGL_DEBUG
|
||||||
GlideMsg("OpenGL.ClipVerticesEnabledState = %s\n", clip_vertices ? "GL_DONT_CARE" : "GL_FASTEST");
|
GlideMsg("OpenGL.ClipVerticesEnabledState = %s\n", clip_vertices ? "GL_DONT_CARE" : "GL_FASTEST");
|
||||||
|
|
|
@ -22,6 +22,7 @@ extern bool s_bUpdateColorInvertState;
|
||||||
extern bool s_bUpdateAlphaInvertState;
|
extern bool s_bUpdateAlphaInvertState;
|
||||||
extern bool s_bUpdateConstantColorValueState;
|
extern bool s_bUpdateConstantColorValueState;
|
||||||
extern bool s_bUpdateConstantColorValue4State;
|
extern bool s_bUpdateConstantColorValue4State;
|
||||||
|
//extern bool s_bUpdateClipVerticesState;
|
||||||
|
|
||||||
extern bool s_bForceChromaKeyAndAlphaStateUpdate;
|
extern bool s_bForceChromaKeyAndAlphaStateUpdate;
|
||||||
|
|
||||||
|
@ -178,16 +179,21 @@ inline void SetConstantColorValue4State()
|
||||||
s_bUpdateConstantColorValue4State = true;
|
s_bUpdateConstantColorValue4State = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//inline void SetClipVerticesState()
|
||||||
|
//{
|
||||||
|
// s_bUpdateClipVerticesState = true;
|
||||||
|
//}
|
||||||
|
|
||||||
// Also called from FrameBuffer class
|
// Also called from FrameBuffer class
|
||||||
extern void SetClipVerticesState_Update(bool clip_vertices);
|
extern void SetClipVerticesState_Update(bool clip_vertices);
|
||||||
|
|
||||||
// Needs to be called before adding a triangle, line or point
|
// Needs to be called before adding a triangle, line or point
|
||||||
inline void SetClipVerticesState(bool clip)
|
inline void SetClipVerticesState(bool clip)
|
||||||
{
|
{
|
||||||
bool clip_vertices = clip || OpenGL.Clipping;
|
const bool clip_vertices = clip || OpenGL.Clipping;
|
||||||
// Triggers very seldomly (because grDrawXXXWithClip() is used very seldom)
|
// Triggers very seldomly (because grDrawXXXWithClip() is used very seldom)
|
||||||
// As a result this method is designed for cause the least cost when not being triggered
|
// As a result this method is designed for cause the least cost when not being triggered
|
||||||
if (clip_vertices != OpenGL.ClipVerticesEnabledState)
|
if (clip_vertices != OpenGL.ClipVerticesEnabledState)
|
||||||
{
|
{
|
||||||
SetClipVerticesState_Update(clip_vertices);
|
SetClipVerticesState_Update(clip_vertices);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,9 @@
|
||||||
#include "GLRender.h"
|
#include "GLRender.h"
|
||||||
#include "GLRenderUpdateState.h"
|
#include "GLRenderUpdateState.h"
|
||||||
|
|
||||||
|
//#define RENDER_FRONTBUFFER_IMMMEDIATE if (Glide.State.RenderBuffer == GR_BUFFER_FRONTBUFFER){RenderDrawTriangles();glFlush();}
|
||||||
|
#define RENDER_FRONTBUFFER_IMMMEDIATE
|
||||||
|
|
||||||
//*************************************************
|
//*************************************************
|
||||||
//* Draws a Triangle on the screen
|
//* Draws a Triangle on the screen
|
||||||
//*************************************************
|
//*************************************************
|
||||||
|
@ -23,15 +26,9 @@ grDrawTriangle( const GrVertex *a, const GrVertex *b, const GrVertex *c )
|
||||||
GlideMsg( "grDrawTriangle( ---, ---, --- )\n" );
|
GlideMsg( "grDrawTriangle( ---, ---, --- )\n" );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SetClipVerticesState(false);
|
// SetClipVerticesState(false);
|
||||||
|
|
||||||
RenderAddTriangle( a, b, c, true );
|
RenderAddTriangle( a, b, c, true );
|
||||||
|
RENDER_FRONTBUFFER_IMMMEDIATE
|
||||||
if ( Glide.State.RenderBuffer == GR_BUFFER_FRONTBUFFER )
|
|
||||||
{
|
|
||||||
RenderDrawTriangles( );
|
|
||||||
glFlush( );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//*************************************************
|
//*************************************************
|
||||||
|
@ -44,17 +41,12 @@ grDrawPlanarPolygonVertexList( int nVertices, const GrVertex vlist[] )
|
||||||
GlideMsg("grDrawPlanarPolygonVertexList( %d, --- )\n", nVertices );
|
GlideMsg("grDrawPlanarPolygonVertexList( %d, --- )\n", nVertices );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SetClipVerticesState(false);
|
// SetClipVerticesState(false);
|
||||||
|
|
||||||
for ( int i = 2; i < nVertices; i++ )
|
for ( int i = 2; i < nVertices; i++ )
|
||||||
{
|
{
|
||||||
RenderAddTriangle( &vlist[ 0 ], &vlist[ i - 1 ], &vlist[ i ], true );
|
RenderAddTriangle( &vlist[ 0 ], &vlist[ i - 1 ], &vlist[ i ], true );
|
||||||
}
|
}
|
||||||
if ( Glide.State.RenderBuffer == GR_BUFFER_FRONTBUFFER )
|
RENDER_FRONTBUFFER_IMMMEDIATE
|
||||||
{
|
|
||||||
RenderDrawTriangles( );
|
|
||||||
glFlush( );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//*************************************************
|
//*************************************************
|
||||||
|
@ -67,9 +59,9 @@ grDrawLine( const GrVertex *a, const GrVertex *b )
|
||||||
GlideMsg("grDrawLine( ---, --- )\n");
|
GlideMsg("grDrawLine( ---, --- )\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SetClipVerticesState(false);
|
// SetClipVerticesState(false);
|
||||||
|
|
||||||
RenderAddLine( a, b, true );
|
RenderAddLine( a, b, true );
|
||||||
|
RENDER_FRONTBUFFER_IMMMEDIATE
|
||||||
}
|
}
|
||||||
|
|
||||||
//*************************************************
|
//*************************************************
|
||||||
|
@ -82,9 +74,9 @@ grDrawPoint( const GrVertex *a )
|
||||||
GlideMsg( "grDrawPoint( --- )\n" );
|
GlideMsg( "grDrawPoint( --- )\n" );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SetClipVerticesState(false);
|
// SetClipVerticesState(false);
|
||||||
|
|
||||||
RenderAddPoint( a, true );
|
RenderAddPoint( a, true );
|
||||||
|
RENDER_FRONTBUFFER_IMMMEDIATE
|
||||||
}
|
}
|
||||||
|
|
||||||
//*************************************************
|
//*************************************************
|
||||||
|
@ -97,8 +89,7 @@ grDrawPolygon( int nverts, const int ilist[], const GrVertex vlist[] )
|
||||||
GlideMsg( "grDrawPolygon( %d, ---, --- )\n" );
|
GlideMsg( "grDrawPolygon( %d, ---, --- )\n" );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SetClipVerticesState(false);
|
// SetClipVerticesState(false);
|
||||||
|
|
||||||
for ( int i = 2; i < nverts; i++ )
|
for ( int i = 2; i < nverts; i++ )
|
||||||
{
|
{
|
||||||
RenderAddTriangle( &vlist[ ilist[ 0 ] ],
|
RenderAddTriangle( &vlist[ ilist[ 0 ] ],
|
||||||
|
@ -106,12 +97,7 @@ grDrawPolygon( int nverts, const int ilist[], const GrVertex vlist[] )
|
||||||
&vlist[ ilist[ i ] ],
|
&vlist[ ilist[ i ] ],
|
||||||
true );
|
true );
|
||||||
}
|
}
|
||||||
|
RENDER_FRONTBUFFER_IMMMEDIATE
|
||||||
if ( Glide.State.RenderBuffer == GR_BUFFER_FRONTBUFFER )
|
|
||||||
{
|
|
||||||
RenderDrawTriangles( );
|
|
||||||
glFlush( );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//*************************************************
|
//*************************************************
|
||||||
|
@ -124,8 +110,7 @@ grDrawPlanarPolygon( int nverts, const int ilist[], const GrVertex vlist[] )
|
||||||
GlideMsg( "grDrawPlanarPolygon( %d, ---, --- )\n", nverts );
|
GlideMsg( "grDrawPlanarPolygon( %d, ---, --- )\n", nverts );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SetClipVerticesState(false);
|
// SetClipVerticesState(false);
|
||||||
|
|
||||||
for ( int i = 2; i < nverts; i++ )
|
for ( int i = 2; i < nverts; i++ )
|
||||||
{
|
{
|
||||||
RenderAddTriangle( &vlist[ ilist[ 0 ] ],
|
RenderAddTriangle( &vlist[ ilist[ 0 ] ],
|
||||||
|
@ -133,12 +118,7 @@ grDrawPlanarPolygon( int nverts, const int ilist[], const GrVertex vlist[] )
|
||||||
&vlist[ ilist[ i ] ],
|
&vlist[ ilist[ i ] ],
|
||||||
true );
|
true );
|
||||||
}
|
}
|
||||||
|
RENDER_FRONTBUFFER_IMMMEDIATE
|
||||||
if ( Glide.State.RenderBuffer == GR_BUFFER_FRONTBUFFER )
|
|
||||||
{
|
|
||||||
RenderDrawTriangles( );
|
|
||||||
glFlush( );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//*************************************************
|
//*************************************************
|
||||||
|
@ -151,8 +131,7 @@ grDrawPolygonVertexList( int nVertices, const GrVertex vlist[] )
|
||||||
GlideMsg( "grDrawPolygonVertexList( %d, --- )\n", nVertices );
|
GlideMsg( "grDrawPolygonVertexList( %d, --- )\n", nVertices );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SetClipVerticesState(false);
|
// SetClipVerticesState(false);
|
||||||
|
|
||||||
for ( int i = 2; i < nVertices; i++ )
|
for ( int i = 2; i < nVertices; i++ )
|
||||||
{
|
{
|
||||||
RenderAddTriangle( &vlist[ 0 ],
|
RenderAddTriangle( &vlist[ 0 ],
|
||||||
|
@ -160,11 +139,7 @@ grDrawPolygonVertexList( int nVertices, const GrVertex vlist[] )
|
||||||
&vlist[ i ],
|
&vlist[ i ],
|
||||||
true );
|
true );
|
||||||
}
|
}
|
||||||
if ( Glide.State.RenderBuffer == GR_BUFFER_FRONTBUFFER )
|
RENDER_FRONTBUFFER_IMMMEDIATE
|
||||||
{
|
|
||||||
RenderDrawTriangles( );
|
|
||||||
glFlush( );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FX_ENTRY void FX_CALL
|
FX_ENTRY void FX_CALL
|
||||||
|
@ -176,14 +151,8 @@ guAADrawTriangleWithClip( const GrVertex *a, const GrVertex *b,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SetClipVerticesState(true);
|
SetClipVerticesState(true);
|
||||||
|
|
||||||
RenderAddTriangle( a, b, c, false );
|
RenderAddTriangle( a, b, c, false );
|
||||||
|
RENDER_FRONTBUFFER_IMMMEDIATE
|
||||||
if ( Glide.State.RenderBuffer == GR_BUFFER_FRONTBUFFER )
|
|
||||||
{
|
|
||||||
RenderDrawTriangles( );
|
|
||||||
glFlush( );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FX_ENTRY void FX_CALL
|
FX_ENTRY void FX_CALL
|
||||||
|
@ -196,14 +165,8 @@ guDrawTriangleWithClip( const GrVertex *a,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SetClipVerticesState(true);
|
SetClipVerticesState(true);
|
||||||
|
|
||||||
RenderAddTriangle( a, b, c, false );
|
RenderAddTriangle( a, b, c, false );
|
||||||
|
RENDER_FRONTBUFFER_IMMMEDIATE
|
||||||
if ( Glide.State.RenderBuffer == GR_BUFFER_FRONTBUFFER )
|
|
||||||
{
|
|
||||||
RenderDrawTriangles( );
|
|
||||||
glFlush( );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FX_ENTRY void FX_CALL
|
FX_ENTRY void FX_CALL
|
||||||
|
@ -214,7 +177,6 @@ guDrawPolygonVertexListWithClip( int nVertices, const GrVertex vlist[] )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SetClipVerticesState(true);
|
SetClipVerticesState(true);
|
||||||
|
|
||||||
for ( int i = 2; i < nVertices; i++ )
|
for ( int i = 2; i < nVertices; i++ )
|
||||||
{
|
{
|
||||||
RenderAddTriangle( &vlist[ 0 ],
|
RenderAddTriangle( &vlist[ 0 ],
|
||||||
|
@ -222,11 +184,7 @@ guDrawPolygonVertexListWithClip( int nVertices, const GrVertex vlist[] )
|
||||||
&vlist[ i ],
|
&vlist[ i ],
|
||||||
false );
|
false );
|
||||||
}
|
}
|
||||||
if ( Glide.State.RenderBuffer == GR_BUFFER_FRONTBUFFER )
|
RENDER_FRONTBUFFER_IMMMEDIATE
|
||||||
{
|
|
||||||
RenderDrawTriangles( );
|
|
||||||
glFlush( );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FX_ENTRY void FX_CALL
|
FX_ENTRY void FX_CALL
|
||||||
|
@ -236,69 +194,57 @@ grAADrawLine( const GrVertex *a, const GrVertex *b )
|
||||||
GlideMsg( "grAADrawLine( ---, --- )\n" );
|
GlideMsg( "grAADrawLine( ---, --- )\n" );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SetClipVerticesState(false);
|
// SetClipVerticesState(false);
|
||||||
|
RenderAddLine( a, b, true );
|
||||||
RenderAddLine( a, b, true );
|
RENDER_FRONTBUFFER_IMMMEDIATE
|
||||||
}
|
}
|
||||||
|
|
||||||
FX_ENTRY void FX_CALL
|
FX_ENTRY void FX_CALL
|
||||||
grAADrawPoint(const GrVertex *a )
|
grAADrawPoint(const GrVertex *a )
|
||||||
{
|
{
|
||||||
#ifdef OGL_CRITICAL
|
#ifdef OGL_CRITICAL
|
||||||
GlideMsg("grAADrawPoint( --- )\n");
|
GlideMsg("grAADrawPoint( --- )\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SetClipVerticesState(false);
|
// SetClipVerticesState(false);
|
||||||
|
RenderAddPoint( a, true );
|
||||||
RenderAddPoint( a, true );
|
RENDER_FRONTBUFFER_IMMMEDIATE
|
||||||
}
|
}
|
||||||
|
|
||||||
FX_ENTRY void FX_CALL
|
FX_ENTRY void FX_CALL
|
||||||
grAADrawPolygon( const int nverts, const int ilist[], const GrVertex vlist[] )
|
grAADrawPolygon( const int nverts, const int ilist[], const GrVertex vlist[] )
|
||||||
{
|
{
|
||||||
#ifdef OGL_CRITICAL
|
#ifdef OGL_CRITICAL
|
||||||
GlideMsg( "grAADrawPolygon( %d, ---, --- )\n", nverts );
|
GlideMsg( "grAADrawPolygon( %d, ---, --- )\n", nverts );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SetClipVerticesState(false);
|
// SetClipVerticesState(false);
|
||||||
|
for ( int i = 2; i < nverts; i++ )
|
||||||
for ( int i = 2; i < nverts; i++ )
|
{
|
||||||
{
|
RenderAddTriangle( &vlist[ ilist[ 0 ] ],
|
||||||
RenderAddTriangle( &vlist[ ilist[ 0 ] ],
|
&vlist[ ilist[ i - 1 ] ],
|
||||||
&vlist[ ilist[ i - 1 ] ],
|
&vlist[ ilist[ i ] ],
|
||||||
&vlist[ ilist[ i ] ],
|
true );
|
||||||
true );
|
}
|
||||||
}
|
RENDER_FRONTBUFFER_IMMMEDIATE
|
||||||
|
|
||||||
if ( Glide.State.RenderBuffer == GR_BUFFER_FRONTBUFFER )
|
|
||||||
{
|
|
||||||
RenderDrawTriangles( );
|
|
||||||
glFlush( );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FX_ENTRY void FX_CALL
|
FX_ENTRY void FX_CALL
|
||||||
grAADrawPolygonVertexList( const int nverts, const GrVertex vlist[] )
|
grAADrawPolygonVertexList( const int nverts, const GrVertex vlist[] )
|
||||||
{
|
{
|
||||||
#ifdef OGL_CRITICAL
|
#ifdef OGL_CRITICAL
|
||||||
GlideMsg( "grAADrawPolygonVertexList( %d, --- )\n", nverts );
|
GlideMsg( "grAADrawPolygonVertexList( %d, --- )\n", nverts );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SetClipVerticesState(false);
|
// SetClipVerticesState(false);
|
||||||
|
for ( int i = 2; i < nverts; i++ )
|
||||||
for ( int i = 2; i < nverts; i++ )
|
{
|
||||||
{
|
RenderAddTriangle( &vlist[ 0 ],
|
||||||
RenderAddTriangle( &vlist[ 0 ],
|
&vlist[ i - 1 ],
|
||||||
&vlist[ i - 1 ],
|
&vlist[ i ],
|
||||||
&vlist[ i ],
|
true );
|
||||||
true );
|
}
|
||||||
}
|
RENDER_FRONTBUFFER_IMMMEDIATE
|
||||||
|
|
||||||
if ( Glide.State.RenderBuffer == GR_BUFFER_FRONTBUFFER )
|
|
||||||
{
|
|
||||||
RenderDrawTriangles( );
|
|
||||||
glFlush( );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FX_ENTRY void FX_CALL
|
FX_ENTRY void FX_CALL
|
||||||
|
@ -310,13 +256,7 @@ grAADrawTriangle( const GrVertex *a, const GrVertex *b, const GrVertex *c,
|
||||||
ab_antialias, bc_antialias, ca_antialias );
|
ab_antialias, bc_antialias, ca_antialias );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SetClipVerticesState(false);
|
// SetClipVerticesState(false);
|
||||||
|
RenderAddTriangle( a, b, c, true );
|
||||||
RenderAddTriangle( a, b, c, true );
|
RENDER_FRONTBUFFER_IMMMEDIATE
|
||||||
|
|
||||||
if ( Glide.State.RenderBuffer == GR_BUFFER_FRONTBUFFER )
|
|
||||||
{
|
|
||||||
RenderDrawTriangles( );
|
|
||||||
glFlush( );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user