<commit_before>//**************************************************************
//*            OpenGLide - Glide to OpenGL Wrapper
//*             http://openglide.sourceforge.net
//*
//*                     Other Functions
//*
//*         OpenGLide is OpenSource under LGPL license
//*              Originaly made by <NAME>
//*      Modified by <NAME> (http://www.glidos.net)
//**************************************************************

#include "GlOgl.h"


// Error Function variable
extern void (*ExternErrorFunction)(const char *string, FxBool fatal);


//*************************************************
//* Sets the External Error Function to call if
//* Glides Generates and Error
//*************************************************
DLLEXPORT void __stdcall
grErrorSetCallback( void (*function)(const char *string, FxBool fatal) )
{
#ifdef DONE
    GlideMsg( "grErrorSetCallback( --- )\n" );
#endif

    ExternErrorFunction = function;
}

//*************************************************
//* Sets the Cull Mode
//*************************************************
DLLEXPORT void __stdcall
grCullMode( GrCullMode_t mode )
{
#ifdef DONE
    GlideMsg( "grCullMode( %d )\n", mode );
#endif

    RenderDrawTriangles( );

    Glide.State.CullMode = mode;

    switch ( Glide.State.CullMode )
    {
    case GR_CULL_DISABLE:
        glDisable( GL_CULL_FACE );
        glCullFace( GL_BACK );  // This will be called in initialization
        break;

    case GR_CULL_NEGATIVE:
        glEnable( GL_CULL_FACE );
        if ( Glide.State.OriginInformation == GR_ORIGIN_LOWER_LEFT )
        {
            glFrontFace( GL_CCW );
        }
        else
        {
            glFrontFace( GL_CW );
        }
        break;

    case GR_CULL_POSITIVE:
        glEnable( GL_CULL_FACE );
        if ( Glide.State.OriginInformation == GR_ORIGIN_LOWER_LEFT )
        {
            glFrontFace( GL_CW );
        }
        else
        {
            glFrontFace( GL_CCW );
        }
        break;
    }

#ifdef OPENGL_DEBUG
    GLErro( "grCullMode" );
#endif
}

//*************************************************
//* Set the size and location of the hardware clipping window
//*************************************************
DLLEXPORT void __stdcall 
grClipWindow( FxU32 minx, FxU32 miny, FxU32 maxx, FxU32 maxy )
{
#ifdef PARTDONE
    GlideMsg("grClipWindow( %d, %d, %d, %d )\n", minx, miny, maxx, maxy );
#endif

    RenderDrawTriangles( );

    Glide.State.ClipMinX = minx;
    Glide.State.ClipMaxX = maxx;
    Glide.State.ClipMinY = miny;
    Glide.State.ClipMaxY = maxy;
}

//----------------------------------------------------------------
DLLEXPORT void __stdcall 
grDisableAllEffects( void )
{
#ifdef PARTDONE
    GlideMsg("grDisableAllEffects()\n");
#endif

    grAlphaBlendFunction( GR_BLEND_ONE, GR_BLEND_ZERO, GR_BLEND_ONE, GR_BLEND_ZERO );
    grAlphaTestFunction( GR_CMP_ALWAYS );
    grChromakeyMode( GR_CHROMAKEY_DISABLE );
    grDepthBufferMode( GR_DEPTHBUFFER_DISABLE );
    grFogMode( GR_FOG_DISABLE );
}

//----------------------------------------------------------------
DLLEXPORT void __stdcall
grResetTriStats( void )
{
#ifdef NOTDONE
    GlideMsg("grResetTriStats\n");
#endif
}

//----------------------------------------------------------------
DLLEXPORT void __stdcall
grTriStats( FxU32 *trisProcessed, FxU32 *trisDrawn )
{<commit_msg>Sorted out how to do clipping at last.<commit_after>//**************************************************************
//*            OpenGLide - Glide to OpenGL Wrapper
//*             http://openglide.sourceforge.net
//*
//*                     Other Functions
//*
//*         OpenGLide is OpenSource under LGPL license
//*              Originaly made by <NAME>
//*      Modified by <NAME> (http://www.glidos.net)
//**************************************************************

#include "GlOgl.h"


// Error Function variable
extern void (*ExternErrorFunction)(const char *string, FxBool fatal);


//*************************************************
//* Sets the External Error Function to call if
//* Glides Generates and Error
//*************************************************
DLLEXPORT void __stdcall
grErrorSetCallback( void (*function)(const char *string, FxBool fatal) )
{
#ifdef DONE
    GlideMsg( "grErrorSetCallback( --- )\n" );
#endif

    ExternErrorFunction = function;
}

//*************************************************
//* Sets the Cull Mode
//*************************************************
DLLEXPORT void __stdcall
grCullMode( GrCullMode_t mode )
{
#ifdef DONE
    GlideMsg( "grCullMode( %d )\n", mode );
#endif

    RenderDrawTriangles( );

    Glide.State.CullMode = mode;

    switch ( Glide.State.CullMode )
    {
    case GR_CULL_DISABLE:
        glDisable( GL_CULL_FACE );
        glCullFace( GL_BACK );  // This will be called in initialization
        break;

    case GR_CULL_NEGATIVE:
        glEnable( GL_CULL_FACE );
        if ( Glide.State.OriginInformation == GR_ORIGIN_LOWER_LEFT )
        {
            glFrontFace( GL_CCW );
        }
        else
        {
            glFrontFace( GL_CW );
        }
        break;

    case GR_CULL_POSITIVE:
        glEnable( GL_CULL_FACE );
        if ( Glide.State.OriginInformation == GR_ORIGIN_LOWER_LEFT )
        {
            glFrontFace( GL_CW );
        }
        else
        {
            glFrontFace( GL_CCW );
        }
        break;
    }

#ifdef OPENGL_DEBUG
    GLErro( "grCullMode" );
#endif
}

//*************************************************
//* Set the size and location of the hardware clipping window
//*************************************************
DLLEXPORT void __stdcall 
grClipWindow( FxU32 minx, FxU32 miny, FxU32 maxx, FxU32 maxy )
{
#ifdef PARTDONE
    GlideMsg("grClipWindow( %d, %d, %d, %d )\n", minx, miny, maxx, maxy );
#endif

    RenderDrawTriangles( );

    Glide.State.ClipMinX = minx;
    Glide.State.ClipMaxX = maxx;
    Glide.State.ClipMinY = miny;
    Glide.State.ClipMaxY = maxy;

    glMatrixMode( GL_PROJECTION );
    glLoadIdentity();

    if ( Glide.State.OriginInformation == GR_ORIGIN_LOWER_LEFT )
    {
        glOrtho( minx, maxx, miny, maxy, OpenGL.ZNear, OpenGL.ZFar );
        glViewport( minx, miny, maxx - minx, maxy - miny ); 
    }
    else
    {
        glOrtho( minx, maxx, maxy, miny, OpenGL.ZNear, OpenGL.ZFar );
        glViewport( minx, OpenGL.WindowHeight - maxy, maxx - minx, maxy - miny ); 
    }


    glMatrixMode( GL_MODELVIEW );
}

//----------------------------------------------------------------
DLLEXPORT void __stdcall 
grDisableAllEffects( void )
{
#ifdef PARTDONE
    GlideMsg("grDisableAllEffects()\n");
#endif

    grAlphaBlendFunction( GR_BLEND_ONE, GR_BLEND_ZERO, GR_BLEND_ONE, GR_BLEND_ZERO );
    grAlphaTestFunction( GR_CMP_ALWAYS );
    grChromakeyMode( GR_CHROMAKEY_DISABLE );
    grDepthBufferMode( GR_DEPTHBUFFER_DISABLE );
    grFogMode( GR_FOG_DISABLE );
}

//----------------------------------------------------------------
DLLEXPORT void __stdcall
grResetTriStats( void )
{
#ifdef NOTDONE
    GlideMsg("grResetTriStats\n");
#endif
}

//----------------------------------------------------------------
DLLEXPORT void __stdcall
grTriStats( FxU32 *trisProcessed, FxU32 *trisDrawn )
{
{'fraction_non_alphanumeric': 0.26094182825484763, 'fraction_numerical': 0.0033240997229916896, 'mean_word_length': 2.459990416866315, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1008589', 'n_tokens_mistral': 2305, 'n_tokens_neox': 2213, 'n_words': 475}