/* Generated by Cython 0.13 on Thu Feb  3 21:37:14 2011 */

#define PY_SSIZE_T_CLEAN
#include "Python.h"
#ifndef Py_PYTHON_H
    #error Python headers needed to compile C extensions, please install development version of Python.
#else

#include <stddef.h> /* For offsetof */
#ifndef offsetof
#define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
#endif

#if !defined(WIN32) && !defined(MS_WINDOWS)
  #ifndef __stdcall
    #define __stdcall
  #endif
  #ifndef __cdecl
    #define __cdecl
  #endif
  #ifndef __fastcall
    #define __fastcall
  #endif
#endif

#ifndef DL_IMPORT
  #define DL_IMPORT(t) t
#endif
#ifndef DL_EXPORT
  #define DL_EXPORT(t) t
#endif

#ifndef PY_LONG_LONG
  #define PY_LONG_LONG LONG_LONG
#endif

#if PY_VERSION_HEX < 0x02040000
  #define METH_COEXIST 0
  #define PyDict_CheckExact(op) (Py_TYPE(op) == &PyDict_Type)
  #define PyDict_Contains(d,o)   PySequence_Contains(d,o)
#endif

#if PY_VERSION_HEX < 0x02050000
  typedef int Py_ssize_t;
  #define PY_SSIZE_T_MAX INT_MAX
  #define PY_SSIZE_T_MIN INT_MIN
  #define PY_FORMAT_SIZE_T ""
  #define PyInt_FromSsize_t(z) PyInt_FromLong(z)
  #define PyInt_AsSsize_t(o)   PyInt_AsLong(o)
  #define PyNumber_Index(o)    PyNumber_Int(o)
  #define PyIndex_Check(o)     PyNumber_Check(o)
  #define PyErr_WarnEx(category, message, stacklevel) PyErr_Warn(category, message)
#endif

#if PY_VERSION_HEX < 0x02060000
  #define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt)
  #define Py_TYPE(ob)   (((PyObject*)(ob))->ob_type)
  #define Py_SIZE(ob)   (((PyVarObject*)(ob))->ob_size)
  #define PyVarObject_HEAD_INIT(type, size) \
          PyObject_HEAD_INIT(type) size,
  #define PyType_Modified(t)

  typedef struct {
     void *buf;
     PyObject *obj;
     Py_ssize_t len;
     Py_ssize_t itemsize;
     int readonly;
     int ndim;
     char *format;
     Py_ssize_t *shape;
     Py_ssize_t *strides;
     Py_ssize_t *suboffsets;
     void *internal;
  } Py_buffer;

  #define PyBUF_SIMPLE 0
  #define PyBUF_WRITABLE 0x0001
  #define PyBUF_FORMAT 0x0004
  #define PyBUF_ND 0x0008
  #define PyBUF_STRIDES (0x0010 | PyBUF_ND)
  #define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES)
  #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES)
  #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES)
  #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES)

#endif

#if PY_MAJOR_VERSION < 3
  #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
#else
  #define __Pyx_BUILTIN_MODULE_NAME "builtins"
#endif

#if PY_MAJOR_VERSION >= 3
  #define Py_TPFLAGS_CHECKTYPES 0
  #define Py_TPFLAGS_HAVE_INDEX 0
#endif

#if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3)
  #define Py_TPFLAGS_HAVE_NEWBUFFER 0
#endif

#if PY_MAJOR_VERSION >= 3
  #define PyBaseString_Type            PyUnicode_Type
  #define PyStringObject               PyUnicodeObject
  #define PyString_Type                PyUnicode_Type
  #define PyString_Check               PyUnicode_Check
  #define PyString_CheckExact          PyUnicode_CheckExact
#endif

#if PY_VERSION_HEX < 0x02060000
  #define PyBytesObject                PyStringObject
  #define PyBytes_Type                 PyString_Type
  #define PyBytes_Check                PyString_Check
  #define PyBytes_CheckExact           PyString_CheckExact
  #define PyBytes_FromString           PyString_FromString
  #define PyBytes_FromStringAndSize    PyString_FromStringAndSize
  #define PyBytes_FromFormat           PyString_FromFormat
  #define PyBytes_DecodeEscape         PyString_DecodeEscape
  #define PyBytes_AsString             PyString_AsString
  #define PyBytes_AsStringAndSize      PyString_AsStringAndSize
  #define PyBytes_Size                 PyString_Size
  #define PyBytes_AS_STRING            PyString_AS_STRING
  #define PyBytes_GET_SIZE             PyString_GET_SIZE
  #define PyBytes_Repr                 PyString_Repr
  #define PyBytes_Concat               PyString_Concat
  #define PyBytes_ConcatAndDel         PyString_ConcatAndDel
  #define PySet_Check(obj)             PyObject_TypeCheck(obj, &PySet_Type)
  #define PyFrozenSet_Check(obj)       PyObject_TypeCheck(obj, &PyFrozenSet_Type)
#endif

#ifndef PySet_CheckExact
#  define PySet_CheckExact(obj)          (Py_TYPE(obj) == &PySet_Type)
#endif

#if PY_MAJOR_VERSION >= 3
  #define PyInt_Type                   PyLong_Type
  #define PyInt_Check(op)              PyLong_Check(op)
  #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
  #define PyInt_FromString             PyLong_FromString
  #define PyInt_FromUnicode            PyLong_FromUnicode
  #define PyInt_FromLong               PyLong_FromLong
  #define PyInt_FromSize_t             PyLong_FromSize_t
  #define PyInt_FromSsize_t            PyLong_FromSsize_t
  #define PyInt_AsLong                 PyLong_AsLong
  #define PyInt_AS_LONG                PyLong_AS_LONG
  #define PyInt_AsSsize_t              PyLong_AsSsize_t
  #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
  #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
#endif

#if PY_MAJOR_VERSION >= 3
  #define PyBoolObject PyLongObject
#endif


#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
#else
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceDivide(x,y)
#endif

#if PY_MAJOR_VERSION >= 3
  #define PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
#endif

#if PY_VERSION_HEX < 0x02050000
  #define __Pyx_GetAttrString(o,n)   PyObject_GetAttrString((o),((char *)(n)))
  #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),((char *)(n)),(a))
  #define __Pyx_DelAttrString(o,n)   PyObject_DelAttrString((o),((char *)(n)))
#else
  #define __Pyx_GetAttrString(o,n)   PyObject_GetAttrString((o),(n))
  #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),(n),(a))
  #define __Pyx_DelAttrString(o,n)   PyObject_DelAttrString((o),(n))
#endif

#if PY_VERSION_HEX < 0x02050000
  #define __Pyx_NAMESTR(n) ((char *)(n))
  #define __Pyx_DOCSTR(n)  ((char *)(n))
#else
  #define __Pyx_NAMESTR(n) (n)
  #define __Pyx_DOCSTR(n)  (n)
#endif

#ifdef __cplusplus
#define __PYX_EXTERN_C extern "C"
#else
#define __PYX_EXTERN_C extern
#endif

#if defined(WIN32) || defined(MS_WINDOWS)
#define _USE_MATH_DEFINES
#endif
#include <math.h>
#define __PYX_HAVE_API__renpy__display__glenviron_fixed
#include "glcompat.h"

/* inline attribute */
#ifndef CYTHON_INLINE
  #if defined(__GNUC__)
    #define CYTHON_INLINE __inline__
  #elif defined(_MSC_VER)
    #define CYTHON_INLINE __inline
  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define CYTHON_INLINE inline
  #else
    #define CYTHON_INLINE 
  #endif
#endif

/* unused attribute */
#ifndef CYTHON_UNUSED
# if defined(__GNUC__)
#   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
#     define CYTHON_UNUSED __attribute__ ((__unused__)) 
#   else
#     define CYTHON_UNUSED
#   endif
# elif defined(__ICC) || defined(__INTEL_COMPILER)
#   define CYTHON_UNUSED __attribute__ ((__unused__)) 
# else
#   define CYTHON_UNUSED 
# endif
#endif

typedef struct {PyObject **p; char *s; const long n; const char* encoding; const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; /*proto*/


/* Type Conversion Predeclarations */

#define __Pyx_PyBytes_FromUString(s) PyBytes_FromString((char*)s)
#define __Pyx_PyBytes_AsUString(s)   ((unsigned char*) PyBytes_AsString(s))

#define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False))
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x);

static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*);

#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))


#ifdef __GNUC__
/* Test for GCC > 2.95 */
#if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)) 
#define likely(x)   __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
#else /* __GNUC__ > 2 ... */
#define likely(x)   (x)
#define unlikely(x) (x)
#endif /* __GNUC__ > 2 ... */
#else /* __GNUC__ */
#define likely(x)   (x)
#define unlikely(x) (x)
#endif /* __GNUC__ */
    
static PyObject *__pyx_m;
static PyObject *__pyx_b;
static PyObject *__pyx_empty_tuple;
static PyObject *__pyx_empty_bytes;
static int __pyx_lineno;
static int __pyx_clineno = 0;
static const char * __pyx_cfilenm= __FILE__;
static const char *__pyx_filename;


static const char *__pyx_f[] = {
  "glenviron_fixed.pyx",
  "gl.pxd",
};

/* Type declarations */

#ifndef CYTHON_REFNANNY
  #define CYTHON_REFNANNY 0
#endif

#if CYTHON_REFNANNY
  typedef struct {
    void (*INCREF)(void*, PyObject*, int);
    void (*DECREF)(void*, PyObject*, int);
    void (*GOTREF)(void*, PyObject*, int);
    void (*GIVEREF)(void*, PyObject*, int);
    void* (*SetupContext)(const char*, int, const char*);
    void (*FinishContext)(void**);
  } __Pyx_RefNannyAPIStruct;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
  static __Pyx_RefNannyAPIStruct * __Pyx_RefNannyImportAPI(const char *modname) {
    PyObject *m = NULL, *p = NULL;
    void *r = NULL;
    m = PyImport_ImportModule((char *)modname);
    if (!m) goto end;
    p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
    if (!p) goto end;
    r = PyLong_AsVoidPtr(p);
  end:
    Py_XDECREF(p);
    Py_XDECREF(m);
    return (__Pyx_RefNannyAPIStruct *)r;
  }
  #define __Pyx_RefNannySetupContext(name)           void *__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
  #define __Pyx_RefNannyFinishContext()           __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
  #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r);} } while(0)
#else
  #define __Pyx_RefNannySetupContext(name)
  #define __Pyx_RefNannyFinishContext()
  #define __Pyx_INCREF(r) Py_INCREF(r)
  #define __Pyx_DECREF(r) Py_DECREF(r)
  #define __Pyx_GOTREF(r)
  #define __Pyx_GIVEREF(r)
  #define __Pyx_XDECREF(r) Py_XDECREF(r)
#endif /* CYTHON_REFNANNY */
#define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);} } while(0)
#define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r);} } while(0)

static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/

static void __Pyx_RaiseDoubleKeywordsError(
    const char* func_name, PyObject* kw_name); /*proto*/

static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
    Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/

static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],     PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,     const char* function_name); /*proto*/

static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);

static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);

static PyObject *__Pyx_UnpackItem(PyObject *, Py_ssize_t index); /*proto*/
static int __Pyx_EndUnpack(PyObject *, Py_ssize_t expected); /*proto*/

static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/

static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name, const char *modname); /*proto*/

static CYTHON_INLINE GLenum __Pyx_PyInt_from_py_GLenum(PyObject *);

static CYTHON_INLINE GLint __Pyx_PyInt_from_py_GLint(PyObject *);

static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_GLenum(GLenum);

static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *);

static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *);

static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject *);

static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject *);

static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject *);

static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject *);

static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject *);

static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject *);

static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject *);

static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject *);

static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject *);

static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject *);

static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject *);

static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject *);

static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *);

static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *);

static CYTHON_INLINE int __Pyx_StrEq(const char *, const char *); /*proto*/

static void __Pyx_AddTraceback(const char *funcname); /*proto*/

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
/* Module declarations from renpy.display.gl */

static CYTHON_INLINE PyObject *__pyx_f_5renpy_7display_2gl_gl_check(PyObject *); /*proto*/
/* Module declarations from renpy.display.glenviron_fixed */

#define __Pyx_MODULE_NAME "renpy.display.glenviron_fixed"
int __pyx_module_is_main_renpy__display__glenviron_fixed = 0;

/* Implementation of renpy.display.glenviron_fixed */
static char __pyx_k_18[] = "GL error 0x%X at %s";
static char __pyx_k_19[] = "renpy.display.glenviron";
static char __pyx_k_20[] = "*";
static char __pyx_k_21[] = "\n    This is an OpenGL environment that uses the fixed-function pipeline.\n\n    It requires ARB_texture_env_combine and ARB_texture_env_crossbar to\n    work.\n    ";
static char __pyx_k_22[] = "FixedFunctionEnviron";
static char __pyx_k_23[] = "FixedFunctionEnviron.deinit (line 63)";
static char __pyx_k_24[] = "FixedFunctionEnviron.disable (line 70)";
static char __pyx_k__log[] = "log";
static char __pyx_k__BLIT[] = "BLIT";
static char __pyx_k__NONE[] = "NONE";
static char __pyx_k__blit[] = "blit";
static char __pyx_k__info[] = "info";
static char __pyx_k__init[] = "init";
static char __pyx_k__last[] = "last";
static char __pyx_k__ramp[] = "ramp";
static char __pyx_k__self[] = "self";
static char __pyx_k__unit[] = "unit";
static char __pyx_k__BLEND[] = "BLEND";
static char __pyx_k__blend[] = "blend";
static char __pyx_k__renpy[] = "renpy";
static char __pyx_k__deinit[] = "deinit";
static char __pyx_k__enable[] = "enable";
static char __pyx_k__Environ[] = "Environ";
static char __pyx_k__disable[] = "disable";
static char __pyx_k____main__[] = "__main__";
static char __pyx_k____test__[] = "__test__";
static char __pyx_k__fraction[] = "fraction";
static char __pyx_k__last_ramp[] = "last_ramp";
static char __pyx_k__IMAGEBLEND[] = "IMAGEBLEND";
static char __pyx_k__alpha_arg0[] = "alpha_arg0";
static char __pyx_k__alpha_arg1[] = "alpha_arg1";
static char __pyx_k__alpha_arg2[] = "alpha_arg2";
static char __pyx_k__color_arg0[] = "color_arg0";
static char __pyx_k__color_arg1[] = "color_arg1";
static char __pyx_k__color_arg2[] = "color_arg2";
static char __pyx_k__imageblend[] = "imageblend";
static char __pyx_k__ramp_setup[] = "ramp_setup";
static char __pyx_k__alpha_scale[] = "alpha_scale";
static char __pyx_k__color_scale[] = "color_scale";
static char __pyx_k__combine_mode[] = "combine_mode";
static char __pyx_k__last_ramplen[] = "last_ramplen";
static char __pyx_k__alpha_source0[] = "alpha_source0";
static char __pyx_k__alpha_source1[] = "alpha_source1";
static char __pyx_k__alpha_source2[] = "alpha_source2";
static char __pyx_k__color_source0[] = "color_source0";
static char __pyx_k__color_source1[] = "color_source1";
static char __pyx_k__color_source2[] = "color_source2";
static char __pyx_k__alpha_function[] = "alpha_function";
static char __pyx_k__color_function[] = "color_function";
static PyObject *__pyx_kp_s_18;
static PyObject *__pyx_n_s_19;
static PyObject *__pyx_n_s_20;
static PyObject *__pyx_kp_s_21;
static PyObject *__pyx_n_s_22;
static PyObject *__pyx_kp_u_23;
static PyObject *__pyx_kp_u_24;
static PyObject *__pyx_n_s__BLEND;
static PyObject *__pyx_n_s__BLIT;
static PyObject *__pyx_n_s__Environ;
static PyObject *__pyx_n_s__IMAGEBLEND;
static PyObject *__pyx_n_s__NONE;
static PyObject *__pyx_n_s____main__;
static PyObject *__pyx_n_s____test__;
static PyObject *__pyx_n_s__alpha_arg0;
static PyObject *__pyx_n_s__alpha_arg1;
static PyObject *__pyx_n_s__alpha_arg2;
static PyObject *__pyx_n_s__alpha_function;
static PyObject *__pyx_n_s__alpha_scale;
static PyObject *__pyx_n_s__alpha_source0;
static PyObject *__pyx_n_s__alpha_source1;
static PyObject *__pyx_n_s__alpha_source2;
static PyObject *__pyx_n_s__blend;
static PyObject *__pyx_n_s__blit;
static PyObject *__pyx_n_s__color_arg0;
static PyObject *__pyx_n_s__color_arg1;
static PyObject *__pyx_n_s__color_arg2;
static PyObject *__pyx_n_s__color_function;
static PyObject *__pyx_n_s__color_scale;
static PyObject *__pyx_n_s__color_source0;
static PyObject *__pyx_n_s__color_source1;
static PyObject *__pyx_n_s__color_source2;
static PyObject *__pyx_n_s__combine_mode;
static PyObject *__pyx_n_s__deinit;
static PyObject *__pyx_n_s__disable;
static PyObject *__pyx_n_s__enable;
static PyObject *__pyx_n_s__fraction;
static PyObject *__pyx_n_s__imageblend;
static PyObject *__pyx_n_s__info;
static PyObject *__pyx_n_s__init;
static PyObject *__pyx_n_s__last;
static PyObject *__pyx_n_s__last_ramp;
static PyObject *__pyx_n_s__last_ramplen;
static PyObject *__pyx_n_s__log;
static PyObject *__pyx_n_s__ramp;
static PyObject *__pyx_n_s__ramp_setup;
static PyObject *__pyx_n_s__renpy;
static PyObject *__pyx_n_s__self;
static PyObject *__pyx_n_s__unit;
static PyObject *__pyx_int_0;
static PyObject *__pyx_int_8;
static PyObject *__pyx_int_neg_1;
static PyObject *__pyx_int_16;
static PyObject *__pyx_int_32;
static PyObject *__pyx_int_64;
static PyObject *__pyx_int_128;
static PyObject *__pyx_int_256;
static PyObject *__pyx_k_1;
static PyObject *__pyx_k_2;
static PyObject *__pyx_k_3;
static PyObject *__pyx_k_4;
static PyObject *__pyx_k_5;
static PyObject *__pyx_k_6;
static PyObject *__pyx_k_7;
static PyObject *__pyx_k_8;
static PyObject *__pyx_k_9;
static PyObject *__pyx_k_10;
static PyObject *__pyx_k_11;
static PyObject *__pyx_k_12;
static PyObject *__pyx_k_13;
static PyObject *__pyx_k_14;
static PyObject *__pyx_k_15;
static PyObject *__pyx_k_16;
static PyObject *__pyx_k_17;

/* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":34
 *     """
 * 
 *     def init(self):             # <<<<<<<<<<<<<<
 * 
 *         # The last blend environ used.
 */

static PyObject *__pyx_pf_5renpy_7display_15glenviron_fixed_20FixedFunctionEnviron_init(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_5renpy_7display_15glenviron_fixed_20FixedFunctionEnviron_init = {__Pyx_NAMESTR("init"), (PyCFunction)__pyx_pf_5renpy_7display_15glenviron_fixed_20FixedFunctionEnviron_init, METH_O, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pf_5renpy_7display_15glenviron_fixed_20FixedFunctionEnviron_init(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  __Pyx_RefNannySetupContext("init");
  __pyx_self = __pyx_self;

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":37
 * 
 *         # The last blend environ used.
 *         self.last = NONE             # <<<<<<<<<<<<<<
 * 
 *         # The last ramp length asked for.
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__NONE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__last, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":40
 * 
 *         # The last ramp length asked for.
 *         self.last_ramp = -1             # <<<<<<<<<<<<<<
 * 
 *         # The last ramplen actually used.
 */
  if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__last_ramp, __pyx_int_neg_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":43
 * 
 *         # The last ramplen actually used.
 *         self.last_ramplen = -1             # <<<<<<<<<<<<<<
 * 
 *         # A table that maps ramp lengths to the setup of the fixed-function
 */
  if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__last_ramplen, __pyx_int_neg_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":54
 *             # unit 2 scale,
 * 
 *             (256, 1.0, GL_REPLACE, 1.0),             # <<<<<<<<<<<<<<
 *             (128, 1.0, GL_REPLACE, 2.0),
 *             (64, 1.0, GL_REPLACE, 4.0),
 */
  __pyx_t_1 = PyFloat_FromDouble(1.0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyInt_FromLong(GL_REPLACE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyFloat_FromDouble(1.0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_256);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_int_256);
  __Pyx_GIVEREF(__pyx_int_256);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 3, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":55
 * 
 *             (256, 1.0, GL_REPLACE, 1.0),
 *             (128, 1.0, GL_REPLACE, 2.0),             # <<<<<<<<<<<<<<
 *             (64, 1.0, GL_REPLACE, 4.0),
 *             (32, 1.0, GL_ADD, 4.0),
 */
  __pyx_t_3 = PyFloat_FromDouble(1.0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyInt_FromLong(GL_REPLACE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyFloat_FromDouble(2.0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_int_128);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_int_128);
  __Pyx_GIVEREF(__pyx_int_128);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_3 = 0;
  __pyx_t_2 = 0;
  __pyx_t_1 = 0;

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":56
 *             (256, 1.0, GL_REPLACE, 1.0),
 *             (128, 1.0, GL_REPLACE, 2.0),
 *             (64, 1.0, GL_REPLACE, 4.0),             # <<<<<<<<<<<<<<
 *             (32, 1.0, GL_ADD, 4.0),
 *             (16, 2.0, GL_ADD, 4.0),
 */
  __pyx_t_1 = PyFloat_FromDouble(1.0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyInt_FromLong(GL_REPLACE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyFloat_FromDouble(4.0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = PyTuple_New(4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_64);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_int_64);
  __Pyx_GIVEREF(__pyx_int_64);
  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":57
 *             (128, 1.0, GL_REPLACE, 2.0),
 *             (64, 1.0, GL_REPLACE, 4.0),
 *             (32, 1.0, GL_ADD, 4.0),             # <<<<<<<<<<<<<<
 *             (16, 2.0, GL_ADD, 4.0),
 *             (8, 4.0, GL_ADD, 4.0),
 */
  __pyx_t_3 = PyFloat_FromDouble(1.0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyInt_FromLong(GL_ADD); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyFloat_FromDouble(4.0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = PyTuple_New(4); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_INCREF(__pyx_int_32);
  PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_int_32);
  __Pyx_GIVEREF(__pyx_int_32);
  PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_7, 3, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_3 = 0;
  __pyx_t_2 = 0;
  __pyx_t_1 = 0;

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":58
 *             (64, 1.0, GL_REPLACE, 4.0),
 *             (32, 1.0, GL_ADD, 4.0),
 *             (16, 2.0, GL_ADD, 4.0),             # <<<<<<<<<<<<<<
 *             (8, 4.0, GL_ADD, 4.0),
 *             ]
 */
  __pyx_t_1 = PyFloat_FromDouble(2.0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyInt_FromLong(GL_ADD); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyFloat_FromDouble(4.0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_8 = PyTuple_New(4); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_INCREF(__pyx_int_16);
  PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_int_16);
  __Pyx_GIVEREF(__pyx_int_16);
  PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_8, 3, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":59
 *             (32, 1.0, GL_ADD, 4.0),
 *             (16, 2.0, GL_ADD, 4.0),
 *             (8, 4.0, GL_ADD, 4.0),             # <<<<<<<<<<<<<<
 *             ]
 * 
 */
  __pyx_t_3 = PyFloat_FromDouble(4.0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyInt_FromLong(GL_ADD); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyFloat_FromDouble(4.0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_9 = PyTuple_New(4); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_INCREF(__pyx_int_8);
  PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_int_8);
  __Pyx_GIVEREF(__pyx_int_8);
  PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_9, 3, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_3 = 0;
  __pyx_t_2 = 0;
  __pyx_t_1 = 0;
  __pyx_t_1 = PyList_New(6); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  PyList_SET_ITEM(__pyx_t_1, 1, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  PyList_SET_ITEM(__pyx_t_1, 2, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  PyList_SET_ITEM(__pyx_t_1, 3, __pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_7);
  PyList_SET_ITEM(__pyx_t_1, 4, __pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_8);
  PyList_SET_ITEM(__pyx_t_1, 5, __pyx_t_9);
  __Pyx_GIVEREF(__pyx_t_9);
  __pyx_t_4 = 0;
  __pyx_t_5 = 0;
  __pyx_t_6 = 0;
  __pyx_t_7 = 0;
  __pyx_t_8 = 0;
  __pyx_t_9 = 0;

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":47
 *         # A table that maps ramp lengths to the setup of the fixed-function
 *         # units.
 *         self.ramp_setup = [             # <<<<<<<<<<<<<<
 *             # Fields are:
 *             # ramp length,
 */
  if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__ramp_setup, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("renpy.display.glenviron_fixed.FixedFunctionEnviron.init");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":63
 * 
 * 
 *     def deinit(self):             # <<<<<<<<<<<<<<
 *         """
 *         Called before changing the GL context.
 */

static PyObject *__pyx_pf_5renpy_7display_15glenviron_fixed_20FixedFunctionEnviron_deinit(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_5renpy_7display_15glenviron_fixed_20FixedFunctionEnviron_deinit[] = "\n        Called before changing the GL context.\n        ";
static PyMethodDef __pyx_mdef_5renpy_7display_15glenviron_fixed_20FixedFunctionEnviron_deinit = {__Pyx_NAMESTR("deinit"), (PyCFunction)__pyx_pf_5renpy_7display_15glenviron_fixed_20FixedFunctionEnviron_deinit, METH_O, __Pyx_DOCSTR(__pyx_doc_5renpy_7display_15glenviron_fixed_20FixedFunctionEnviron_deinit)};
static PyObject *__pyx_pf_5renpy_7display_15glenviron_fixed_20FixedFunctionEnviron_deinit(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannySetupContext("deinit");
  __pyx_self = __pyx_self;

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":68
 *         """
 * 
 *         return             # <<<<<<<<<<<<<<
 * 
 *     def disable(self, unit):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":70
 *         return
 * 
 *     def disable(self, unit):             # <<<<<<<<<<<<<<
 *         """
 *         Disables the given texture combiner.
 */

static PyObject *__pyx_pf_5renpy_7display_15glenviron_fixed_20FixedFunctionEnviron_disable(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5renpy_7display_15glenviron_fixed_20FixedFunctionEnviron_disable[] = "\n        Disables the given texture combiner.\n        ";
static PyMethodDef __pyx_mdef_5renpy_7display_15glenviron_fixed_20FixedFunctionEnviron_disable = {__Pyx_NAMESTR("disable"), (PyCFunction)__pyx_pf_5renpy_7display_15glenviron_fixed_20FixedFunctionEnviron_disable, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_5renpy_7display_15glenviron_fixed_20FixedFunctionEnviron_disable)};
static PyObject *__pyx_pf_5renpy_7display_15glenviron_fixed_20FixedFunctionEnviron_disable(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_unit = 0;
  PyObject *__pyx_r = NULL;
  GLenum __pyx_t_1;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__unit,0};
  __Pyx_RefNannySetupContext("disable");
  __pyx_self = __pyx_self;
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[2] = {0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__unit);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("disable", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "disable") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_self = values[0];
    __pyx_v_unit = values[1];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
    __pyx_v_unit = PyTuple_GET_ITEM(__pyx_args, 1);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("disable", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("renpy.display.glenviron_fixed.FixedFunctionEnviron.disable");
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":75
 *         """
 * 
 *         glActiveTextureARB(unit)             # <<<<<<<<<<<<<<
 *         glDisable(GL_TEXTURE_2D)
 * 
 */
  __pyx_t_1 = __Pyx_PyInt_from_py_GLenum(__pyx_v_unit); if (unlikely((__pyx_t_1 == (GLenum)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  glActiveTextureARB(__pyx_t_1);

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":76
 * 
 *         glActiveTextureARB(unit)
 *         glDisable(GL_TEXTURE_2D)             # <<<<<<<<<<<<<<
 * 
 *     def combine_mode(self, unit,
 */
  glDisable(GL_TEXTURE_2D);

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("renpy.display.glenviron_fixed.FixedFunctionEnviron.disable");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":78
 *         glDisable(GL_TEXTURE_2D)
 * 
 *     def combine_mode(self, unit,             # <<<<<<<<<<<<<<
 *                      color_function=GL_MODULATE,
 *                      color_arg0=GL_TEXTURE,
 */

static PyObject *__pyx_pf_5renpy_7display_15glenviron_fixed_20FixedFunctionEnviron_combine_mode(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_5renpy_7display_15glenviron_fixed_20FixedFunctionEnviron_combine_mode = {__Pyx_NAMESTR("combine_mode"), (PyCFunction)__pyx_pf_5renpy_7display_15glenviron_fixed_20FixedFunctionEnviron_combine_mode, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pf_5renpy_7display_15glenviron_fixed_20FixedFunctionEnviron_combine_mode(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_unit = 0;
  PyObject *__pyx_v_color_function = 0;
  PyObject *__pyx_v_color_arg0 = 0;
  PyObject *__pyx_v_color_arg1 = 0;
  PyObject *__pyx_v_color_arg2 = 0;
  PyObject *__pyx_v_color_source0 = 0;
  PyObject *__pyx_v_color_source1 = 0;
  PyObject *__pyx_v_color_source2 = 0;
  PyObject *__pyx_v_color_scale = 0;
  PyObject *__pyx_v_alpha_function = 0;
  PyObject *__pyx_v_alpha_arg0 = 0;
  PyObject *__pyx_v_alpha_arg1 = 0;
  PyObject *__pyx_v_alpha_arg2 = 0;
  PyObject *__pyx_v_alpha_source0 = 0;
  PyObject *__pyx_v_alpha_source1 = 0;
  PyObject *__pyx_v_alpha_source2 = 0;
  PyObject *__pyx_v_alpha_scale = 0;
  PyObject *__pyx_v_enable = 0;
  PyObject *__pyx_r = NULL;
  GLenum __pyx_t_1;
  int __pyx_t_2;
  GLint __pyx_t_3;
  GLfloat __pyx_t_4;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__unit,&__pyx_n_s__color_function,&__pyx_n_s__color_arg0,&__pyx_n_s__color_arg1,&__pyx_n_s__color_arg2,&__pyx_n_s__color_source0,&__pyx_n_s__color_source1,&__pyx_n_s__color_source2,&__pyx_n_s__color_scale,&__pyx_n_s__alpha_function,&__pyx_n_s__alpha_arg0,&__pyx_n_s__alpha_arg1,&__pyx_n_s__alpha_arg2,&__pyx_n_s__alpha_source0,&__pyx_n_s__alpha_source1,&__pyx_n_s__alpha_source2,&__pyx_n_s__alpha_scale,&__pyx_n_s__enable,0};
  __Pyx_RefNannySetupContext("combine_mode");
  __pyx_self = __pyx_self;
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[19] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
    values[2] = __pyx_k_1;
    values[3] = __pyx_k_2;
    values[4] = __pyx_k_3;
    values[5] = __pyx_k_4;
    values[6] = __pyx_k_5;
    values[7] = __pyx_k_6;
    values[8] = __pyx_k_7;
    values[9] = __pyx_k_8;
    values[10] = __pyx_k_9;
    values[11] = __pyx_k_10;
    values[12] = __pyx_k_11;
    values[13] = __pyx_k_12;
    values[14] = __pyx_k_13;
    values[15] = __pyx_k_14;
    values[16] = __pyx_k_15;
    values[17] = __pyx_k_16;
    values[18] = __pyx_k_17;
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case 19: values[18] = PyTuple_GET_ITEM(__pyx_args, 18);
      case 18: values[17] = PyTuple_GET_ITEM(__pyx_args, 17);
      case 17: values[16] = PyTuple_GET_ITEM(__pyx_args, 16);
      case 16: values[15] = PyTuple_GET_ITEM(__pyx_args, 15);
      case 15: values[14] = PyTuple_GET_ITEM(__pyx_args, 14);
      case 14: values[13] = PyTuple_GET_ITEM(__pyx_args, 13);
      case 13: values[12] = PyTuple_GET_ITEM(__pyx_args, 12);
      case 12: values[11] = PyTuple_GET_ITEM(__pyx_args, 11);
      case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
      case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
      case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
      case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
      case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
      case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
      case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__unit);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("combine_mode", 0, 2, 19, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      if (kw_args > 0) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__color_function);
        if (value) { values[2] = value; kw_args--; }
      }
      case  3:
      if (kw_args > 0) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__color_arg0);
        if (value) { values[3] = value; kw_args--; }
      }
      case  4:
      if (kw_args > 0) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__color_arg1);
        if (value) { values[4] = value; kw_args--; }
      }
      case  5:
      if (kw_args > 0) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__color_arg2);
        if (value) { values[5] = value; kw_args--; }
      }
      case  6:
      if (kw_args > 0) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__color_source0);
        if (value) { values[6] = value; kw_args--; }
      }
      case  7:
      if (kw_args > 0) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__color_source1);
        if (value) { values[7] = value; kw_args--; }
      }
      case  8:
      if (kw_args > 0) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__color_source2);
        if (value) { values[8] = value; kw_args--; }
      }
      case  9:
      if (kw_args > 0) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__color_scale);
        if (value) { values[9] = value; kw_args--; }
      }
      case 10:
      if (kw_args > 0) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__alpha_function);
        if (value) { values[10] = value; kw_args--; }
      }
      case 11:
      if (kw_args > 0) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__alpha_arg0);
        if (value) { values[11] = value; kw_args--; }
      }
      case 12:
      if (kw_args > 0) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__alpha_arg1);
        if (value) { values[12] = value; kw_args--; }
      }
      case 13:
      if (kw_args > 0) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__alpha_arg2);
        if (value) { values[13] = value; kw_args--; }
      }
      case 14:
      if (kw_args > 0) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__alpha_source0);
        if (value) { values[14] = value; kw_args--; }
      }
      case 15:
      if (kw_args > 0) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__alpha_source1);
        if (value) { values[15] = value; kw_args--; }
      }
      case 16:
      if (kw_args > 0) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__alpha_source2);
        if (value) { values[16] = value; kw_args--; }
      }
      case 17:
      if (kw_args > 0) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__alpha_scale);
        if (value) { values[17] = value; kw_args--; }
      }
      case 18:
      if (kw_args > 0) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__enable);
        if (value) { values[18] = value; kw_args--; }
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "combine_mode") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_self = values[0];
    __pyx_v_unit = values[1];
    __pyx_v_color_function = values[2];
    __pyx_v_color_arg0 = values[3];
    __pyx_v_color_arg1 = values[4];
    __pyx_v_color_arg2 = values[5];
    __pyx_v_color_source0 = values[6];
    __pyx_v_color_source1 = values[7];
    __pyx_v_color_source2 = values[8];
    __pyx_v_color_scale = values[9];
    __pyx_v_alpha_function = values[10];
    __pyx_v_alpha_arg0 = values[11];
    __pyx_v_alpha_arg1 = values[12];
    __pyx_v_alpha_arg2 = values[13];
    __pyx_v_alpha_source0 = values[14];
    __pyx_v_alpha_source1 = values[15];
    __pyx_v_alpha_source2 = values[16];
    __pyx_v_alpha_scale = values[17];
    __pyx_v_enable = values[18];
  } else {
    __pyx_v_color_function = __pyx_k_1;
    __pyx_v_color_arg0 = __pyx_k_2;
    __pyx_v_color_arg1 = __pyx_k_3;
    __pyx_v_color_arg2 = __pyx_k_4;
    __pyx_v_color_source0 = __pyx_k_5;
    __pyx_v_color_source1 = __pyx_k_6;
    __pyx_v_color_source2 = __pyx_k_7;
    __pyx_v_color_scale = __pyx_k_8;
    __pyx_v_alpha_function = __pyx_k_9;
    __pyx_v_alpha_arg0 = __pyx_k_10;
    __pyx_v_alpha_arg1 = __pyx_k_11;
    __pyx_v_alpha_arg2 = __pyx_k_12;
    __pyx_v_alpha_source0 = __pyx_k_13;
    __pyx_v_alpha_source1 = __pyx_k_14;
    __pyx_v_alpha_source2 = __pyx_k_15;
    __pyx_v_alpha_scale = __pyx_k_16;
    __pyx_v_enable = __pyx_k_17;
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case 19:
      __pyx_v_enable = PyTuple_GET_ITEM(__pyx_args, 18);
      case 18:
      __pyx_v_alpha_scale = PyTuple_GET_ITEM(__pyx_args, 17);
      case 17:
      __pyx_v_alpha_source2 = PyTuple_GET_ITEM(__pyx_args, 16);
      case 16:
      __pyx_v_alpha_source1 = PyTuple_GET_ITEM(__pyx_args, 15);
      case 15:
      __pyx_v_alpha_source0 = PyTuple_GET_ITEM(__pyx_args, 14);
      case 14:
      __pyx_v_alpha_arg2 = PyTuple_GET_ITEM(__pyx_args, 13);
      case 13:
      __pyx_v_alpha_arg1 = PyTuple_GET_ITEM(__pyx_args, 12);
      case 12:
      __pyx_v_alpha_arg0 = PyTuple_GET_ITEM(__pyx_args, 11);
      case 11:
      __pyx_v_alpha_function = PyTuple_GET_ITEM(__pyx_args, 10);
      case 10:
      __pyx_v_color_scale = PyTuple_GET_ITEM(__pyx_args, 9);
      case  9:
      __pyx_v_color_source2 = PyTuple_GET_ITEM(__pyx_args, 8);
      case  8:
      __pyx_v_color_source1 = PyTuple_GET_ITEM(__pyx_args, 7);
      case  7:
      __pyx_v_color_source0 = PyTuple_GET_ITEM(__pyx_args, 6);
      case  6:
      __pyx_v_color_arg2 = PyTuple_GET_ITEM(__pyx_args, 5);
      case  5:
      __pyx_v_color_arg1 = PyTuple_GET_ITEM(__pyx_args, 4);
      case  4:
      __pyx_v_color_arg0 = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3:
      __pyx_v_color_function = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2:
      __pyx_v_unit = PyTuple_GET_ITEM(__pyx_args, 1);
      __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("combine_mode", 0, 2, 19, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("renpy.display.glenviron_fixed.FixedFunctionEnviron.combine_mode");
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":98
 * 
 * 
 *         glActiveTextureARB(unit)             # <<<<<<<<<<<<<<
 * 
 *         if enable:
 */
  __pyx_t_1 = __Pyx_PyInt_from_py_GLenum(__pyx_v_unit); if (unlikely((__pyx_t_1 == (GLenum)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  glActiveTextureARB(__pyx_t_1);

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":100
 *         glActiveTextureARB(unit)
 * 
 *         if enable:             # <<<<<<<<<<<<<<
 *             glEnable(GL_TEXTURE_2D)
 *         else:
 */
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_enable); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_2) {

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":101
 * 
 *         if enable:
 *             glEnable(GL_TEXTURE_2D)             # <<<<<<<<<<<<<<
 *         else:
 *             glDisable(GL_TEXTURE_2D)
 */
    glEnable(GL_TEXTURE_2D);
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":103
 *             glEnable(GL_TEXTURE_2D)
 *         else:
 *             glDisable(GL_TEXTURE_2D)             # <<<<<<<<<<<<<<
 * 
 *         glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB)
 */
    glDisable(GL_TEXTURE_2D);
  }
  __pyx_L6:;

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":105
 *             glDisable(GL_TEXTURE_2D)
 * 
 *         glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB)             # <<<<<<<<<<<<<<
 *         glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, color_function)
 *         glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, alpha_function)
 */
  glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":106
 * 
 *         glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB)
 *         glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, color_function)             # <<<<<<<<<<<<<<
 *         glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, alpha_function)
 * 
 */
  __pyx_t_3 = __Pyx_PyInt_from_py_GLint(__pyx_v_color_function); if (unlikely((__pyx_t_3 == (GLint)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, __pyx_t_3);

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":107
 *         glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB)
 *         glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, color_function)
 *         glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, alpha_function)             # <<<<<<<<<<<<<<
 * 
 *         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, color_arg0)
 */
  __pyx_t_3 = __Pyx_PyInt_from_py_GLint(__pyx_v_alpha_function); if (unlikely((__pyx_t_3 == (GLint)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, __pyx_t_3);

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":109
 *         glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, alpha_function)
 * 
 *         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, color_arg0)             # <<<<<<<<<<<<<<
 *         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, color_source0)
 *         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, color_arg1)
 */
  __pyx_t_3 = __Pyx_PyInt_from_py_GLint(__pyx_v_color_arg0); if (unlikely((__pyx_t_3 == (GLint)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, __pyx_t_3);

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":110
 * 
 *         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, color_arg0)
 *         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, color_source0)             # <<<<<<<<<<<<<<
 *         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, color_arg1)
 *         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, color_source1)
 */
  __pyx_t_3 = __Pyx_PyInt_from_py_GLint(__pyx_v_color_source0); if (unlikely((__pyx_t_3 == (GLint)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, __pyx_t_3);

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":111
 *         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, color_arg0)
 *         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, color_source0)
 *         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, color_arg1)             # <<<<<<<<<<<<<<
 *         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, color_source1)
 *         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_ARB, color_arg2)
 */
  __pyx_t_3 = __Pyx_PyInt_from_py_GLint(__pyx_v_color_arg1); if (unlikely((__pyx_t_3 == (GLint)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, __pyx_t_3);

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":112
 *         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, color_source0)
 *         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, color_arg1)
 *         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, color_source1)             # <<<<<<<<<<<<<<
 *         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_ARB, color_arg2)
 *         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_ARB, color_source2)
 */
  __pyx_t_3 = __Pyx_PyInt_from_py_GLint(__pyx_v_color_source1); if (unlikely((__pyx_t_3 == (GLint)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, __pyx_t_3);

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":113
 *         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, color_arg1)
 *         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, color_source1)
 *         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_ARB, color_arg2)             # <<<<<<<<<<<<<<
 *         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_ARB, color_source2)
 * 
 */
  __pyx_t_3 = __Pyx_PyInt_from_py_GLint(__pyx_v_color_arg2); if (unlikely((__pyx_t_3 == (GLint)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_ARB, __pyx_t_3);

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":114
 *         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, color_source1)
 *         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_ARB, color_arg2)
 *         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_ARB, color_source2)             # <<<<<<<<<<<<<<
 * 
 *         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, alpha_arg0)
 */
  __pyx_t_3 = __Pyx_PyInt_from_py_GLint(__pyx_v_color_source2); if (unlikely((__pyx_t_3 == (GLint)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_ARB, __pyx_t_3);

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":116
 *         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_ARB, color_source2)
 * 
 *         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, alpha_arg0)             # <<<<<<<<<<<<<<
 *         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, alpha_source0)
 *         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_ARB, alpha_arg1)
 */
  __pyx_t_3 = __Pyx_PyInt_from_py_GLint(__pyx_v_alpha_arg0); if (unlikely((__pyx_t_3 == (GLint)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, __pyx_t_3);

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":117
 * 
 *         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, alpha_arg0)
 *         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, alpha_source0)             # <<<<<<<<<<<<<<
 *         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_ARB, alpha_arg1)
 *         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_ARB, alpha_source1)
 */
  __pyx_t_3 = __Pyx_PyInt_from_py_GLint(__pyx_v_alpha_source0); if (unlikely((__pyx_t_3 == (GLint)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, __pyx_t_3);

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":118
 *         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, alpha_arg0)
 *         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, alpha_source0)
 *         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_ARB, alpha_arg1)             # <<<<<<<<<<<<<<
 *         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_ARB, alpha_source1)
 *         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_ALPHA_ARB, alpha_arg2)
 */
  __pyx_t_3 = __Pyx_PyInt_from_py_GLint(__pyx_v_alpha_arg1); if (unlikely((__pyx_t_3 == (GLint)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_ARB, __pyx_t_3);

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":119
 *         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, alpha_source0)
 *         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_ARB, alpha_arg1)
 *         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_ARB, alpha_source1)             # <<<<<<<<<<<<<<
 *         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_ALPHA_ARB, alpha_arg2)
 *         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_ALPHA_ARB, alpha_source2)
 */
  __pyx_t_3 = __Pyx_PyInt_from_py_GLint(__pyx_v_alpha_source1); if (unlikely((__pyx_t_3 == (GLint)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_ARB, __pyx_t_3);

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":120
 *         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_ARB, alpha_arg1)
 *         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_ARB, alpha_source1)
 *         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_ALPHA_ARB, alpha_arg2)             # <<<<<<<<<<<<<<
 *         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_ALPHA_ARB, alpha_source2)
 * 
 */
  __pyx_t_3 = __Pyx_PyInt_from_py_GLint(__pyx_v_alpha_arg2); if (unlikely((__pyx_t_3 == (GLint)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_ALPHA_ARB, __pyx_t_3);

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":121
 *         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_ARB, alpha_source1)
 *         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_ALPHA_ARB, alpha_arg2)
 *         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_ALPHA_ARB, alpha_source2)             # <<<<<<<<<<<<<<
 * 
 *         glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, color_scale)
 */
  __pyx_t_3 = __Pyx_PyInt_from_py_GLint(__pyx_v_alpha_source2); if (unlikely((__pyx_t_3 == (GLint)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_ALPHA_ARB, __pyx_t_3);

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":123
 *         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_ALPHA_ARB, alpha_source2)
 * 
 *         glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, color_scale)             # <<<<<<<<<<<<<<
 *         glTexEnvf(GL_TEXTURE_ENV, GL_ALPHA_SCALE, alpha_scale)
 * 
 */
  __pyx_t_4 = __pyx_PyFloat_AsDouble(__pyx_v_color_scale); if (unlikely((__pyx_t_4 == (GLfloat)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, __pyx_t_4);

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":124
 * 
 *         glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, color_scale)
 *         glTexEnvf(GL_TEXTURE_ENV, GL_ALPHA_SCALE, alpha_scale)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_4 = __pyx_PyFloat_AsDouble(__pyx_v_alpha_scale); if (unlikely((__pyx_t_4 == (GLfloat)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  glTexEnvf(GL_TEXTURE_ENV, GL_ALPHA_SCALE, __pyx_t_4);

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("renpy.display.glenviron_fixed.FixedFunctionEnviron.combine_mode");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":127
 * 
 * 
 *     def blit(self):             # <<<<<<<<<<<<<<
 * 
 *         if self.last != BLIT:
 */

static PyObject *__pyx_pf_5renpy_7display_15glenviron_fixed_20FixedFunctionEnviron_blit(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_5renpy_7display_15glenviron_fixed_20FixedFunctionEnviron_blit = {__Pyx_NAMESTR("blit"), (PyCFunction)__pyx_pf_5renpy_7display_15glenviron_fixed_20FixedFunctionEnviron_blit, METH_O, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pf_5renpy_7display_15glenviron_fixed_20FixedFunctionEnviron_blit(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("blit");
  __pyx_self = __pyx_self;

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":129
 *     def blit(self):
 * 
 *         if self.last != BLIT:             # <<<<<<<<<<<<<<
 * 
 *             # Set unit 0 to modulate.
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__last); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__BLIT); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_t_2, Py_NE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_4) {

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":133
 *             # Set unit 0 to modulate.
 * 
 *             self.combine_mode(GL_TEXTURE0_ARB,             # <<<<<<<<<<<<<<
 *                               color_function=GL_MODULATE,
 *                               alpha_function=GL_MODULATE)
 */
    __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__combine_mode); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = PyInt_FromLong(GL_TEXTURE0_ARB); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":134
 * 
 *             self.combine_mode(GL_TEXTURE0_ARB,
 *                               color_function=GL_MODULATE,             # <<<<<<<<<<<<<<
 *                               alpha_function=GL_MODULATE)
 * 
 */
    __pyx_t_5 = PyInt_FromLong(GL_MODULATE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__color_function), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":135
 *             self.combine_mode(GL_TEXTURE0_ARB,
 *                               color_function=GL_MODULATE,
 *                               alpha_function=GL_MODULATE)             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_5 = PyInt_FromLong(GL_MODULATE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__alpha_function), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyEval_CallObjectWithKeywords(__pyx_t_3, __pyx_t_1, ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":139
 * 
 *             # Disable units 1, 2 and 3.
 *             self.disable(GL_TEXTURE1_ARB)             # <<<<<<<<<<<<<<
 *             self.disable(GL_TEXTURE2_ARB)
 *             self.disable(GL_TEXTURE3_ARB)
 */
    __pyx_t_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__disable); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_2 = PyInt_FromLong(GL_TEXTURE1_ARB); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(__pyx_t_5, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":140
 *             # Disable units 1, 2 and 3.
 *             self.disable(GL_TEXTURE1_ARB)
 *             self.disable(GL_TEXTURE2_ARB)             # <<<<<<<<<<<<<<
 *             self.disable(GL_TEXTURE3_ARB)
 * 
 */
    __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__disable); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyInt_FromLong(GL_TEXTURE2_ARB); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":141
 *             self.disable(GL_TEXTURE1_ARB)
 *             self.disable(GL_TEXTURE2_ARB)
 *             self.disable(GL_TEXTURE3_ARB)             # <<<<<<<<<<<<<<
 * 
 *             self.last = BLIT
 */
    __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__disable); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = PyInt_FromLong(GL_TEXTURE3_ARB); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_5 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":143
 *             self.disable(GL_TEXTURE3_ARB)
 * 
 *             self.last = BLIT             # <<<<<<<<<<<<<<
 * 
 *     def blend(self, fraction):
 */
    __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__BLIT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__last, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("renpy.display.glenviron_fixed.FixedFunctionEnviron.blit");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":145
 *             self.last = BLIT
 * 
 *     def blend(self, fraction):             # <<<<<<<<<<<<<<
 * 
 *         if self.last != BLEND:
 */

static PyObject *__pyx_pf_5renpy_7display_15glenviron_fixed_20FixedFunctionEnviron_blend(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_5renpy_7display_15glenviron_fixed_20FixedFunctionEnviron_blend = {__Pyx_NAMESTR("blend"), (PyCFunction)__pyx_pf_5renpy_7display_15glenviron_fixed_20FixedFunctionEnviron_blend, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pf_5renpy_7display_15glenviron_fixed_20FixedFunctionEnviron_blend(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_fraction = 0;
  float *__pyx_v_fractions;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  float __pyx_t_6;
  float __pyx_t_7;
  float __pyx_t_8;
  float __pyx_t_9;
  float __pyx_t_10[4];
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__fraction,0};
  __Pyx_RefNannySetupContext("blend");
  __pyx_self = __pyx_self;
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[2] = {0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__fraction);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("blend", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "blend") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_self = values[0];
    __pyx_v_fraction = values[1];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
    __pyx_v_fraction = PyTuple_GET_ITEM(__pyx_args, 1);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("blend", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("renpy.display.glenviron_fixed.FixedFunctionEnviron.blend");
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":147
 *     def blend(self, fraction):
 * 
 *         if self.last != BLEND:             # <<<<<<<<<<<<<<
 * 
 *             # Get texture 0.
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__last); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__BLEND); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_t_2, Py_NE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_4) {

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":150
 * 
 *             # Get texture 0.
 *             self.combine_mode(GL_TEXTURE0_ARB,             # <<<<<<<<<<<<<<
 *                               color_function=GL_REPLACE,
 *                               alpha_function=GL_REPLACE)
 */
    __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__combine_mode); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = PyInt_FromLong(GL_TEXTURE0_ARB); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":151
 *             # Get texture 0.
 *             self.combine_mode(GL_TEXTURE0_ARB,
 *                               color_function=GL_REPLACE,             # <<<<<<<<<<<<<<
 *                               alpha_function=GL_REPLACE)
 * 
 */
    __pyx_t_5 = PyInt_FromLong(GL_REPLACE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__color_function), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":152
 *             self.combine_mode(GL_TEXTURE0_ARB,
 *                               color_function=GL_REPLACE,
 *                               alpha_function=GL_REPLACE)             # <<<<<<<<<<<<<<
 * 
 *             # Use interpolate to combine texture 0 with texture 1, as
 */
    __pyx_t_5 = PyInt_FromLong(GL_REPLACE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__alpha_function), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyEval_CallObjectWithKeywords(__pyx_t_3, __pyx_t_1, ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":156
 *             # Use interpolate to combine texture 0 with texture 1, as
 *             # controlled by the constant of texture unit 1.
 *             self.combine_mode(GL_TEXTURE1_ARB,             # <<<<<<<<<<<<<<
 *                               color_function=GL_INTERPOLATE_ARB,
 *                               color_arg0=GL_TEXTURE1_ARB,
 */
    __pyx_t_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__combine_mode); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_2 = PyInt_FromLong(GL_TEXTURE1_ARB); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":157
 *             # controlled by the constant of texture unit 1.
 *             self.combine_mode(GL_TEXTURE1_ARB,
 *                               color_function=GL_INTERPOLATE_ARB,             # <<<<<<<<<<<<<<
 *                               color_arg0=GL_TEXTURE1_ARB,
 *                               color_arg1=GL_TEXTURE0_ARB,
 */
    __pyx_t_3 = PyInt_FromLong(GL_INTERPOLATE_ARB); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__color_function), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":158
 *             self.combine_mode(GL_TEXTURE1_ARB,
 *                               color_function=GL_INTERPOLATE_ARB,
 *                               color_arg0=GL_TEXTURE1_ARB,             # <<<<<<<<<<<<<<
 *                               color_arg1=GL_TEXTURE0_ARB,
 *                               alpha_function=GL_INTERPOLATE_ARB,
 */
    __pyx_t_3 = PyInt_FromLong(GL_TEXTURE1_ARB); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__color_arg0), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":159
 *                               color_function=GL_INTERPOLATE_ARB,
 *                               color_arg0=GL_TEXTURE1_ARB,
 *                               color_arg1=GL_TEXTURE0_ARB,             # <<<<<<<<<<<<<<
 *                               alpha_function=GL_INTERPOLATE_ARB,
 *                               alpha_arg0=GL_TEXTURE1_ARB,
 */
    __pyx_t_3 = PyInt_FromLong(GL_TEXTURE0_ARB); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__color_arg1), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":160
 *                               color_arg0=GL_TEXTURE1_ARB,
 *                               color_arg1=GL_TEXTURE0_ARB,
 *                               alpha_function=GL_INTERPOLATE_ARB,             # <<<<<<<<<<<<<<
 *                               alpha_arg0=GL_TEXTURE1_ARB,
 *                               alpha_arg1=GL_TEXTURE0_ARB)
 */
    __pyx_t_3 = PyInt_FromLong(GL_INTERPOLATE_ARB); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__alpha_function), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":161
 *                               color_arg1=GL_TEXTURE0_ARB,
 *                               alpha_function=GL_INTERPOLATE_ARB,
 *                               alpha_arg0=GL_TEXTURE1_ARB,             # <<<<<<<<<<<<<<
 *                               alpha_arg1=GL_TEXTURE0_ARB)
 * 
 */
    __pyx_t_3 = PyInt_FromLong(GL_TEXTURE1_ARB); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__alpha_arg0), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":162
 *                               alpha_function=GL_INTERPOLATE_ARB,
 *                               alpha_arg0=GL_TEXTURE1_ARB,
 *                               alpha_arg1=GL_TEXTURE0_ARB)             # <<<<<<<<<<<<<<
 * 
 *             # Combine the interpolated result with the primary color, to
 */
    __pyx_t_3 = PyInt_FromLong(GL_TEXTURE0_ARB); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__alpha_arg1), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyEval_CallObjectWithKeywords(__pyx_t_5, __pyx_t_1, ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":166
 *             # Combine the interpolated result with the primary color, to
 *             # allow for tinting and alpha adjustments.
 *             self.combine_mode(GL_TEXTURE2_ARB,             # <<<<<<<<<<<<<<
 *                               color_function=GL_MODULATE,
 *                               color_arg0=GL_PREVIOUS_ARB,
 */
    __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__combine_mode); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = PyInt_FromLong(GL_TEXTURE2_ARB); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":167
 *             # allow for tinting and alpha adjustments.
 *             self.combine_mode(GL_TEXTURE2_ARB,
 *                               color_function=GL_MODULATE,             # <<<<<<<<<<<<<<
 *                               color_arg0=GL_PREVIOUS_ARB,
 *                               color_arg1=GL_PRIMARY_COLOR_ARB,
 */
    __pyx_t_5 = PyInt_FromLong(GL_MODULATE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__color_function), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":168
 *             self.combine_mode(GL_TEXTURE2_ARB,
 *                               color_function=GL_MODULATE,
 *                               color_arg0=GL_PREVIOUS_ARB,             # <<<<<<<<<<<<<<
 *                               color_arg1=GL_PRIMARY_COLOR_ARB,
 *                               alpha_function=GL_MODULATE,
 */
    __pyx_t_5 = PyInt_FromLong(GL_PREVIOUS_ARB); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__color_arg0), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":169
 *                               color_function=GL_MODULATE,
 *                               color_arg0=GL_PREVIOUS_ARB,
 *                               color_arg1=GL_PRIMARY_COLOR_ARB,             # <<<<<<<<<<<<<<
 *                               alpha_function=GL_MODULATE,
 *                               alpha_arg0=GL_PREVIOUS_ARB,
 */
    __pyx_t_5 = PyInt_FromLong(GL_PRIMARY_COLOR_ARB); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__color_arg1), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":170
 *                               color_arg0=GL_PREVIOUS_ARB,
 *                               color_arg1=GL_PRIMARY_COLOR_ARB,
 *                               alpha_function=GL_MODULATE,             # <<<<<<<<<<<<<<
 *                               alpha_arg0=GL_PREVIOUS_ARB,
 *                               alpha_arg1=GL_PRIMARY_COLOR_ARB,
 */
    __pyx_t_5 = PyInt_FromLong(GL_MODULATE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__alpha_function), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":171
 *                               color_arg1=GL_PRIMARY_COLOR_ARB,
 *                               alpha_function=GL_MODULATE,
 *                               alpha_arg0=GL_PREVIOUS_ARB,             # <<<<<<<<<<<<<<
 *                               alpha_arg1=GL_PRIMARY_COLOR_ARB,
 *                               enable=False)
 */
    __pyx_t_5 = PyInt_FromLong(GL_PREVIOUS_ARB); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__alpha_arg0), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":172
 *                               alpha_function=GL_MODULATE,
 *                               alpha_arg0=GL_PREVIOUS_ARB,
 *                               alpha_arg1=GL_PRIMARY_COLOR_ARB,             # <<<<<<<<<<<<<<
 *                               enable=False)
 * 
 */
    __pyx_t_5 = PyInt_FromLong(GL_PRIMARY_COLOR_ARB); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__alpha_arg1), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":173
 *                               alpha_arg0=GL_PREVIOUS_ARB,
 *                               alpha_arg1=GL_PRIMARY_COLOR_ARB,
 *                               enable=False)             # <<<<<<<<<<<<<<
 * 
 *             # Disable texture unit 3.
 */
    __pyx_t_5 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__enable), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyEval_CallObjectWithKeywords(__pyx_t_3, __pyx_t_1, ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":176
 * 
 *             # Disable texture unit 3.
 *             self.disable(GL_TEXTURE3_ARB)             # <<<<<<<<<<<<<<
 * 
 *             self.last = BLEND
 */
    __pyx_t_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__disable); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_2 = PyInt_FromLong(GL_TEXTURE3_ARB); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(__pyx_t_5, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":178
 *             self.disable(GL_TEXTURE3_ARB)
 * 
 *             self.last = BLEND             # <<<<<<<<<<<<<<
 * 
 *         cdef float *fractions = [ fraction, fraction, fraction, fraction ]
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__BLEND); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__last, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":180
 *             self.last = BLEND
 * 
 *         cdef float *fractions = [ fraction, fraction, fraction, fraction ]             # <<<<<<<<<<<<<<
 * 
 *         glActiveTextureARB(GL_TEXTURE1_ARB)
 */
  __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_v_fraction); if (unlikely((__pyx_t_6 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_7 = __pyx_PyFloat_AsDouble(__pyx_v_fraction); if (unlikely((__pyx_t_7 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = __pyx_PyFloat_AsDouble(__pyx_v_fraction); if (unlikely((__pyx_t_8 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_9 = __pyx_PyFloat_AsDouble(__pyx_v_fraction); if (unlikely((__pyx_t_9 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_10[0] = __pyx_t_6;
  __pyx_t_10[1] = __pyx_t_7;
  __pyx_t_10[2] = __pyx_t_8;
  __pyx_t_10[3] = __pyx_t_9;
  __pyx_v_fractions = __pyx_t_10;

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":182
 *         cdef float *fractions = [ fraction, fraction, fraction, fraction ]
 * 
 *         glActiveTextureARB(GL_TEXTURE1_ARB)             # <<<<<<<<<<<<<<
 *         glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, fractions)
 * 
 */
  glActiveTextureARB(GL_TEXTURE1_ARB);

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":183
 * 
 *         glActiveTextureARB(GL_TEXTURE1_ARB)
 *         glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, fractions)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, __pyx_v_fractions);

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("renpy.display.glenviron_fixed.FixedFunctionEnviron.blend");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":187
 * 
 * 
 *     def imageblend(self, fraction, ramp):             # <<<<<<<<<<<<<<
 * 
 *         if self.last != IMAGEBLEND or self.last_ramp != ramp:
 */

static PyObject *__pyx_pf_5renpy_7display_15glenviron_fixed_20FixedFunctionEnviron_imageblend(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_5renpy_7display_15glenviron_fixed_20FixedFunctionEnviron_imageblend = {__Pyx_NAMESTR("imageblend"), (PyCFunction)__pyx_pf_5renpy_7display_15glenviron_fixed_20FixedFunctionEnviron_imageblend, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pf_5renpy_7display_15glenviron_fixed_20FixedFunctionEnviron_imageblend(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_fraction = 0;
  PyObject *__pyx_v_ramp = 0;
  PyObject *__pyx_v_i;
  PyObject *__pyx_v_ramplen;
  PyObject *__pyx_v_t0scale;
  PyObject *__pyx_v_t1function;
  PyObject *__pyx_v_t1scale;
  double __pyx_v_start;
  PyObject *__pyx_v_end;
  PyObject *__pyx_v_offset;
  int __pyx_v_function;
  float *__pyx_v_offsets;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  Py_ssize_t __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  float __pyx_t_11;
  float __pyx_t_12;
  float __pyx_t_13;
  float __pyx_t_14;
  float __pyx_t_15[4];
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__fraction,&__pyx_n_s__ramp,0};
  __Pyx_RefNannySetupContext("imageblend");
  __pyx_self = __pyx_self;
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[3] = {0,0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__fraction);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("imageblend", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__ramp);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("imageblend", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "imageblend") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_self = values[0];
    __pyx_v_fraction = values[1];
    __pyx_v_ramp = values[2];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
    __pyx_v_fraction = PyTuple_GET_ITEM(__pyx_args, 1);
    __pyx_v_ramp = PyTuple_GET_ITEM(__pyx_args, 2);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("imageblend", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("renpy.display.glenviron_fixed.FixedFunctionEnviron.imageblend");
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_v_i = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_ramplen = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_t0scale = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_t1function = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_t1scale = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_end = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_offset = Py_None; __Pyx_INCREF(Py_None);

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":189
 *     def imageblend(self, fraction, ramp):
 * 
 *         if self.last != IMAGEBLEND or self.last_ramp != ramp:             # <<<<<<<<<<<<<<
 * 
 *             # Figure out the details of the ramp.
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__last); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__IMAGEBLEND); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_t_2, Py_NE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!__pyx_t_4) {
    __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__last_ramp); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = PyObject_RichCompare(__pyx_t_3, __pyx_v_ramp, Py_NE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_6 = __pyx_t_5;
  } else {
    __pyx_t_6 = __pyx_t_4;
  }
  if (__pyx_t_6) {

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":192
 * 
 *             # Figure out the details of the ramp.
 *             for i in self.ramp_setup:             # <<<<<<<<<<<<<<
 *                 ramplen, t0scale, t1function, t1scale = i
 * 
 */
    __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__ramp_setup); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    if (PyList_CheckExact(__pyx_t_2) || PyTuple_CheckExact(__pyx_t_2)) {
      __pyx_t_7 = 0; __pyx_t_3 = __pyx_t_2; __Pyx_INCREF(__pyx_t_3);
    } else {
      __pyx_t_7 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    for (;;) {
      if (likely(PyList_CheckExact(__pyx_t_3))) {
        if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_3)) break;
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_2); __pyx_t_7++;
      } else if (likely(PyTuple_CheckExact(__pyx_t_3))) {
        if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_2); __pyx_t_7++;
      } else {
        __pyx_t_2 = PyIter_Next(__pyx_t_3);
        if (!__pyx_t_2) {
          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          break;
        }
        __Pyx_GOTREF(__pyx_t_2);
      }
      __Pyx_DECREF(__pyx_v_i);
      __pyx_v_i = __pyx_t_2;
      __pyx_t_2 = 0;

      /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":193
 *             # Figure out the details of the ramp.
 *             for i in self.ramp_setup:
 *                 ramplen, t0scale, t1function, t1scale = i             # <<<<<<<<<<<<<<
 * 
 *                 # We round the ramplen down, unless we're below the
 */
      if (PyTuple_CheckExact(__pyx_v_i) && likely(PyTuple_GET_SIZE(__pyx_v_i) == 4)) {
        PyObject* tuple = __pyx_v_i;
        __pyx_t_2 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_2);
        __pyx_t_1 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_1);
        __pyx_t_8 = PyTuple_GET_ITEM(tuple, 2); __Pyx_INCREF(__pyx_t_8);
        __pyx_t_9 = PyTuple_GET_ITEM(tuple, 3); __Pyx_INCREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_v_ramplen);
        __pyx_v_ramplen = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_v_t0scale);
        __pyx_v_t0scale = __pyx_t_1;
        __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_v_t1function);
        __pyx_v_t1function = __pyx_t_8;
        __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_v_t1scale);
        __pyx_v_t1scale = __pyx_t_9;
        __pyx_t_9 = 0;
      } else {
        __pyx_t_10 = PyObject_GetIter(__pyx_v_i); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_2 = __Pyx_UnpackItem(__pyx_t_10, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_1 = __Pyx_UnpackItem(__pyx_t_10, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_8 = __Pyx_UnpackItem(__pyx_t_10, 2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_9 = __Pyx_UnpackItem(__pyx_t_10, 3); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_9);
        if (__Pyx_EndUnpack(__pyx_t_10, 4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_DECREF(__pyx_v_ramplen);
        __pyx_v_ramplen = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_v_t0scale);
        __pyx_v_t0scale = __pyx_t_1;
        __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_v_t1function);
        __pyx_v_t1function = __pyx_t_8;
        __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_v_t1scale);
        __pyx_v_t1scale = __pyx_t_9;
        __pyx_t_9 = 0;
      }

      /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":197
 *                 # We round the ramplen down, unless we're below the
 *                 # smallest size, in which case we increase it.
 *                 if ramplen <= ramp:             # <<<<<<<<<<<<<<
 *                     break
 * 
 */
      __pyx_t_9 = PyObject_RichCompare(__pyx_v_ramplen, __pyx_v_ramp, Py_LE); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      if (__pyx_t_6) {

        /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":198
 *                 # smallest size, in which case we increase it.
 *                 if ramplen <= ramp:
 *                     break             # <<<<<<<<<<<<<<
 * 
 *             # Unit 0 loads in the control image, and adds/subtracts an
 */
        goto __pyx_L8_break;
        goto __pyx_L9;
      }
      __pyx_L9:;
    }
    __pyx_L8_break:;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":205
 *             #
 *             # It multiplies this result by up to 4.
 *             self.combine_mode(GL_TEXTURE0_ARB,             # <<<<<<<<<<<<<<
 *                               color_function=GL_SUBTRACT_ARB,
 *                               alpha_function=GL_SUBTRACT_ARB,
 */
    __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__combine_mode); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_9 = PyInt_FromLong(GL_TEXTURE0_ARB); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_9);
    __pyx_t_9 = 0;
    __pyx_t_9 = PyDict_New(); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_9));

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":206
 *             # It multiplies this result by up to 4.
 *             self.combine_mode(GL_TEXTURE0_ARB,
 *                               color_function=GL_SUBTRACT_ARB,             # <<<<<<<<<<<<<<
 *                               alpha_function=GL_SUBTRACT_ARB,
 *                               color_arg1=GL_CONSTANT_ARB,
 */
    __pyx_t_1 = PyInt_FromLong(GL_SUBTRACT_ARB); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (PyDict_SetItem(__pyx_t_9, ((PyObject *)__pyx_n_s__color_function), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":207
 *             self.combine_mode(GL_TEXTURE0_ARB,
 *                               color_function=GL_SUBTRACT_ARB,
 *                               alpha_function=GL_SUBTRACT_ARB,             # <<<<<<<<<<<<<<
 *                               color_arg1=GL_CONSTANT_ARB,
 *                               alpha_arg1=GL_CONSTANT_ARB,
 */
    __pyx_t_1 = PyInt_FromLong(GL_SUBTRACT_ARB); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (PyDict_SetItem(__pyx_t_9, ((PyObject *)__pyx_n_s__alpha_function), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":208
 *                               color_function=GL_SUBTRACT_ARB,
 *                               alpha_function=GL_SUBTRACT_ARB,
 *                               color_arg1=GL_CONSTANT_ARB,             # <<<<<<<<<<<<<<
 *                               alpha_arg1=GL_CONSTANT_ARB,
 *                               color_scale=t0scale,
 */
    __pyx_t_1 = PyInt_FromLong(GL_CONSTANT_ARB); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (PyDict_SetItem(__pyx_t_9, ((PyObject *)__pyx_n_s__color_arg1), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":209
 *                               alpha_function=GL_SUBTRACT_ARB,
 *                               color_arg1=GL_CONSTANT_ARB,
 *                               alpha_arg1=GL_CONSTANT_ARB,             # <<<<<<<<<<<<<<
 *                               color_scale=t0scale,
 *                               alpha_scale=t0scale)
 */
    __pyx_t_1 = PyInt_FromLong(GL_CONSTANT_ARB); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (PyDict_SetItem(__pyx_t_9, ((PyObject *)__pyx_n_s__alpha_arg1), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":210
 *                               color_arg1=GL_CONSTANT_ARB,
 *                               alpha_arg1=GL_CONSTANT_ARB,
 *                               color_scale=t0scale,             # <<<<<<<<<<<<<<
 *                               alpha_scale=t0scale)
 * 
 */
    if (PyDict_SetItem(__pyx_t_9, ((PyObject *)__pyx_n_s__color_scale), __pyx_v_t0scale) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":211
 *                               alpha_arg1=GL_CONSTANT_ARB,
 *                               color_scale=t0scale,
 *                               alpha_scale=t0scale)             # <<<<<<<<<<<<<<
 * 
 *             # Unit 1 will multiply the result of stage 1 by up to 8.
 */
    if (PyDict_SetItem(__pyx_t_9, ((PyObject *)__pyx_n_s__alpha_scale), __pyx_v_t0scale) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = PyEval_CallObjectWithKeywords(__pyx_t_3, __pyx_t_8, ((PyObject *)__pyx_t_9)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":217
 *             # It also takes the first source texture, but we don't
 *             # access it directly yet.
 *             self.combine_mode(GL_TEXTURE1_ARB,             # <<<<<<<<<<<<<<
 *                               color_function=t1function,
 *                               alpha_function=t1function,
 */
    __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__combine_mode); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_9 = PyInt_FromLong(GL_TEXTURE1_ARB); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_9);
    __pyx_t_9 = 0;
    __pyx_t_9 = PyDict_New(); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_9));

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":218
 *             # access it directly yet.
 *             self.combine_mode(GL_TEXTURE1_ARB,
 *                               color_function=t1function,             # <<<<<<<<<<<<<<
 *                               alpha_function=t1function,
 *                               color_arg0=GL_PREVIOUS_ARB,
 */
    if (PyDict_SetItem(__pyx_t_9, ((PyObject *)__pyx_n_s__color_function), __pyx_v_t1function) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":219
 *             self.combine_mode(GL_TEXTURE1_ARB,
 *                               color_function=t1function,
 *                               alpha_function=t1function,             # <<<<<<<<<<<<<<
 *                               color_arg0=GL_PREVIOUS_ARB,
 *                               color_arg1=GL_PREVIOUS_ARB,
 */
    if (PyDict_SetItem(__pyx_t_9, ((PyObject *)__pyx_n_s__alpha_function), __pyx_v_t1function) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":220
 *                               color_function=t1function,
 *                               alpha_function=t1function,
 *                               color_arg0=GL_PREVIOUS_ARB,             # <<<<<<<<<<<<<<
 *                               color_arg1=GL_PREVIOUS_ARB,
 *                               alpha_arg0=GL_PREVIOUS_ARB,
 */
    __pyx_t_3 = PyInt_FromLong(GL_PREVIOUS_ARB); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 220; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (PyDict_SetItem(__pyx_t_9, ((PyObject *)__pyx_n_s__color_arg0), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":221
 *                               alpha_function=t1function,
 *                               color_arg0=GL_PREVIOUS_ARB,
 *                               color_arg1=GL_PREVIOUS_ARB,             # <<<<<<<<<<<<<<
 *                               alpha_arg0=GL_PREVIOUS_ARB,
 *                               alpha_arg1=GL_PREVIOUS_ARB,
 */
    __pyx_t_3 = PyInt_FromLong(GL_PREVIOUS_ARB); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (PyDict_SetItem(__pyx_t_9, ((PyObject *)__pyx_n_s__color_arg1), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":222
 *                               color_arg0=GL_PREVIOUS_ARB,
 *                               color_arg1=GL_PREVIOUS_ARB,
 *                               alpha_arg0=GL_PREVIOUS_ARB,             # <<<<<<<<<<<<<<
 *                               alpha_arg1=GL_PREVIOUS_ARB,
 *                               color_scale=t1scale,
 */
    __pyx_t_3 = PyInt_FromLong(GL_PREVIOUS_ARB); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (PyDict_SetItem(__pyx_t_9, ((PyObject *)__pyx_n_s__alpha_arg0), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":223
 *                               color_arg1=GL_PREVIOUS_ARB,
 *                               alpha_arg0=GL_PREVIOUS_ARB,
 *                               alpha_arg1=GL_PREVIOUS_ARB,             # <<<<<<<<<<<<<<
 *                               color_scale=t1scale,
 *                               alpha_scale=t1scale)
 */
    __pyx_t_3 = PyInt_FromLong(GL_PREVIOUS_ARB); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (PyDict_SetItem(__pyx_t_9, ((PyObject *)__pyx_n_s__alpha_arg1), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":224
 *                               alpha_arg0=GL_PREVIOUS_ARB,
 *                               alpha_arg1=GL_PREVIOUS_ARB,
 *                               color_scale=t1scale,             # <<<<<<<<<<<<<<
 *                               alpha_scale=t1scale)
 * 
 */
    if (PyDict_SetItem(__pyx_t_9, ((PyObject *)__pyx_n_s__color_scale), __pyx_v_t1scale) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":225
 *                               alpha_arg1=GL_PREVIOUS_ARB,
 *                               color_scale=t1scale,
 *                               alpha_scale=t1scale)             # <<<<<<<<<<<<<<
 * 
 *             # Unit 2 uses the result of unit 1 to interpolate between the
 */
    if (PyDict_SetItem(__pyx_t_9, ((PyObject *)__pyx_n_s__alpha_scale), __pyx_v_t1scale) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_3 = PyEval_CallObjectWithKeywords(__pyx_t_1, __pyx_t_8, ((PyObject *)__pyx_t_9)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":229
 *             # Unit 2 uses the result of unit 1 to interpolate between the
 *             # unit 1 and unit 2 textures.
 *             self.combine_mode(GL_TEXTURE2_ARB,             # <<<<<<<<<<<<<<
 *                               color_function=GL_INTERPOLATE_ARB,
 *                               alpha_function=GL_INTERPOLATE_ARB,
 */
    __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__combine_mode); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_9 = PyInt_FromLong(GL_TEXTURE2_ARB); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_9);
    __pyx_t_9 = 0;
    __pyx_t_9 = PyDict_New(); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_9));

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":230
 *             # unit 1 and unit 2 textures.
 *             self.combine_mode(GL_TEXTURE2_ARB,
 *                               color_function=GL_INTERPOLATE_ARB,             # <<<<<<<<<<<<<<
 *                               alpha_function=GL_INTERPOLATE_ARB,
 *                               color_arg0=GL_TEXTURE2_ARB,
 */
    __pyx_t_1 = PyInt_FromLong(GL_INTERPOLATE_ARB); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (PyDict_SetItem(__pyx_t_9, ((PyObject *)__pyx_n_s__color_function), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":231
 *             self.combine_mode(GL_TEXTURE2_ARB,
 *                               color_function=GL_INTERPOLATE_ARB,
 *                               alpha_function=GL_INTERPOLATE_ARB,             # <<<<<<<<<<<<<<
 *                               color_arg0=GL_TEXTURE2_ARB,
 *                               color_arg1=GL_TEXTURE1_ARB,
 */
    __pyx_t_1 = PyInt_FromLong(GL_INTERPOLATE_ARB); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (PyDict_SetItem(__pyx_t_9, ((PyObject *)__pyx_n_s__alpha_function), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":232
 *                               color_function=GL_INTERPOLATE_ARB,
 *                               alpha_function=GL_INTERPOLATE_ARB,
 *                               color_arg0=GL_TEXTURE2_ARB,             # <<<<<<<<<<<<<<
 *                               color_arg1=GL_TEXTURE1_ARB,
 *                               color_arg2=GL_PREVIOUS_ARB,
 */
    __pyx_t_1 = PyInt_FromLong(GL_TEXTURE2_ARB); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (PyDict_SetItem(__pyx_t_9, ((PyObject *)__pyx_n_s__color_arg0), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":233
 *                               alpha_function=GL_INTERPOLATE_ARB,
 *                               color_arg0=GL_TEXTURE2_ARB,
 *                               color_arg1=GL_TEXTURE1_ARB,             # <<<<<<<<<<<<<<
 *                               color_arg2=GL_PREVIOUS_ARB,
 *                               alpha_arg0=GL_TEXTURE2_ARB,
 */
    __pyx_t_1 = PyInt_FromLong(GL_TEXTURE1_ARB); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (PyDict_SetItem(__pyx_t_9, ((PyObject *)__pyx_n_s__color_arg1), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":234
 *                               color_arg0=GL_TEXTURE2_ARB,
 *                               color_arg1=GL_TEXTURE1_ARB,
 *                               color_arg2=GL_PREVIOUS_ARB,             # <<<<<<<<<<<<<<
 *                               alpha_arg0=GL_TEXTURE2_ARB,
 *                               alpha_arg1=GL_TEXTURE1_ARB,
 */
    __pyx_t_1 = PyInt_FromLong(GL_PREVIOUS_ARB); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (PyDict_SetItem(__pyx_t_9, ((PyObject *)__pyx_n_s__color_arg2), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":235
 *                               color_arg1=GL_TEXTURE1_ARB,
 *                               color_arg2=GL_PREVIOUS_ARB,
 *                               alpha_arg0=GL_TEXTURE2_ARB,             # <<<<<<<<<<<<<<
 *                               alpha_arg1=GL_TEXTURE1_ARB,
 *                               alpha_arg2=GL_PREVIOUS_ARB)
 */
    __pyx_t_1 = PyInt_FromLong(GL_TEXTURE2_ARB); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (PyDict_SetItem(__pyx_t_9, ((PyObject *)__pyx_n_s__alpha_arg0), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":236
 *                               color_arg2=GL_PREVIOUS_ARB,
 *                               alpha_arg0=GL_TEXTURE2_ARB,
 *                               alpha_arg1=GL_TEXTURE1_ARB,             # <<<<<<<<<<<<<<
 *                               alpha_arg2=GL_PREVIOUS_ARB)
 * 
 */
    __pyx_t_1 = PyInt_FromLong(GL_TEXTURE1_ARB); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (PyDict_SetItem(__pyx_t_9, ((PyObject *)__pyx_n_s__alpha_arg1), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":237
 *                               alpha_arg0=GL_TEXTURE2_ARB,
 *                               alpha_arg1=GL_TEXTURE1_ARB,
 *                               alpha_arg2=GL_PREVIOUS_ARB)             # <<<<<<<<<<<<<<
 * 
 *             # Finally, Unit 3 modulates the result of unit 2 with the color.
 */
    __pyx_t_1 = PyInt_FromLong(GL_PREVIOUS_ARB); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (PyDict_SetItem(__pyx_t_9, ((PyObject *)__pyx_n_s__alpha_arg2), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyEval_CallObjectWithKeywords(__pyx_t_3, __pyx_t_8, ((PyObject *)__pyx_t_9)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":240
 * 
 *             # Finally, Unit 3 modulates the result of unit 2 with the color.
 *             self.combine_mode(GL_TEXTURE3_ARB,             # <<<<<<<<<<<<<<
 *                               color_function=GL_MODULATE,
 *                               color_arg0=GL_PREVIOUS_ARB,
 */
    __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__combine_mode); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_9 = PyInt_FromLong(GL_TEXTURE3_ARB); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_9);
    __pyx_t_9 = 0;
    __pyx_t_9 = PyDict_New(); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_9));

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":241
 *             # Finally, Unit 3 modulates the result of unit 2 with the color.
 *             self.combine_mode(GL_TEXTURE3_ARB,
 *                               color_function=GL_MODULATE,             # <<<<<<<<<<<<<<
 *                               color_arg0=GL_PREVIOUS_ARB,
 *                               color_arg1=GL_PRIMARY_COLOR_ARB,
 */
    __pyx_t_3 = PyInt_FromLong(GL_MODULATE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (PyDict_SetItem(__pyx_t_9, ((PyObject *)__pyx_n_s__color_function), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":242
 *             self.combine_mode(GL_TEXTURE3_ARB,
 *                               color_function=GL_MODULATE,
 *                               color_arg0=GL_PREVIOUS_ARB,             # <<<<<<<<<<<<<<
 *                               color_arg1=GL_PRIMARY_COLOR_ARB,
 *                               alpha_function=GL_MODULATE,
 */
    __pyx_t_3 = PyInt_FromLong(GL_PREVIOUS_ARB); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (PyDict_SetItem(__pyx_t_9, ((PyObject *)__pyx_n_s__color_arg0), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":243
 *                               color_function=GL_MODULATE,
 *                               color_arg0=GL_PREVIOUS_ARB,
 *                               color_arg1=GL_PRIMARY_COLOR_ARB,             # <<<<<<<<<<<<<<
 *                               alpha_function=GL_MODULATE,
 *                               alpha_arg0=GL_PREVIOUS_ARB,
 */
    __pyx_t_3 = PyInt_FromLong(GL_PRIMARY_COLOR_ARB); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (PyDict_SetItem(__pyx_t_9, ((PyObject *)__pyx_n_s__color_arg1), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":244
 *                               color_arg0=GL_PREVIOUS_ARB,
 *                               color_arg1=GL_PRIMARY_COLOR_ARB,
 *                               alpha_function=GL_MODULATE,             # <<<<<<<<<<<<<<
 *                               alpha_arg0=GL_PREVIOUS_ARB,
 *                               alpha_arg1=GL_PRIMARY_COLOR_ARB,
 */
    __pyx_t_3 = PyInt_FromLong(GL_MODULATE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (PyDict_SetItem(__pyx_t_9, ((PyObject *)__pyx_n_s__alpha_function), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":245
 *                               color_arg1=GL_PRIMARY_COLOR_ARB,
 *                               alpha_function=GL_MODULATE,
 *                               alpha_arg0=GL_PREVIOUS_ARB,             # <<<<<<<<<<<<<<
 *                               alpha_arg1=GL_PRIMARY_COLOR_ARB,
 *                               enable=False)
 */
    __pyx_t_3 = PyInt_FromLong(GL_PREVIOUS_ARB); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (PyDict_SetItem(__pyx_t_9, ((PyObject *)__pyx_n_s__alpha_arg0), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":246
 *                               alpha_function=GL_MODULATE,
 *                               alpha_arg0=GL_PREVIOUS_ARB,
 *                               alpha_arg1=GL_PRIMARY_COLOR_ARB,             # <<<<<<<<<<<<<<
 *                               enable=False)
 * 
 */
    __pyx_t_3 = PyInt_FromLong(GL_PRIMARY_COLOR_ARB); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (PyDict_SetItem(__pyx_t_9, ((PyObject *)__pyx_n_s__alpha_arg1), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":247
 *                               alpha_arg0=GL_PREVIOUS_ARB,
 *                               alpha_arg1=GL_PRIMARY_COLOR_ARB,
 *                               enable=False)             # <<<<<<<<<<<<<<
 * 
 *             self.last = IMAGEBLEND
 */
    __pyx_t_3 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (PyDict_SetItem(__pyx_t_9, ((PyObject *)__pyx_n_s__enable), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyEval_CallObjectWithKeywords(__pyx_t_1, __pyx_t_8, ((PyObject *)__pyx_t_9)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":249
 *                               enable=False)
 * 
 *             self.last = IMAGEBLEND             # <<<<<<<<<<<<<<
 *             self.last_ramp = ramp
 *             self.last_ramplen = ramplen
 */
    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__IMAGEBLEND); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__last, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":250
 * 
 *             self.last = IMAGEBLEND
 *             self.last_ramp = ramp             # <<<<<<<<<<<<<<
 *             self.last_ramplen = ramplen
 * 
 */
    if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__last_ramp, __pyx_v_ramp) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":251
 *             self.last = IMAGEBLEND
 *             self.last_ramp = ramp
 *             self.last_ramplen = ramplen             # <<<<<<<<<<<<<<
 * 
 *         # Compute the offset to apply to the alpha.
 */
    if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__last_ramplen, __pyx_v_ramplen) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 251; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":254
 * 
 *         # Compute the offset to apply to the alpha.
 *         start = -1.0             # <<<<<<<<<<<<<<
 *         end = self.last_ramplen / 256.0
 *         offset = start + ( end - start) * fraction
 */
  __pyx_v_start = (-1.0);

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":255
 *         # Compute the offset to apply to the alpha.
 *         start = -1.0
 *         end = self.last_ramplen / 256.0             # <<<<<<<<<<<<<<
 *         offset = start + ( end - start) * fraction
 * 
 */
  __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__last_ramplen); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_9 = PyFloat_FromDouble(256.0); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_8 = __Pyx_PyNumber_Divide(__pyx_t_3, __pyx_t_9); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_v_end);
  __pyx_v_end = __pyx_t_8;
  __pyx_t_8 = 0;

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":256
 *         start = -1.0
 *         end = self.last_ramplen / 256.0
 *         offset = start + ( end - start) * fraction             # <<<<<<<<<<<<<<
 * 
 *         # Decide if we're adding or subtracting.
 */
  __pyx_t_8 = PyFloat_FromDouble(__pyx_v_start); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_9 = PyFloat_FromDouble(__pyx_v_start); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_3 = PyNumber_Subtract(__pyx_v_end, __pyx_t_9); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_9 = PyNumber_Multiply(__pyx_t_3, __pyx_v_fraction); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyNumber_Add(__pyx_t_8, __pyx_t_9); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_v_offset);
  __pyx_v_offset = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":259
 * 
 *         # Decide if we're adding or subtracting.
 *         if offset < 0:             # <<<<<<<<<<<<<<
 *             function = GL_SUBTRACT_ARB
 *             offset = -offset
 */
  __pyx_t_3 = PyObject_RichCompare(__pyx_v_offset, __pyx_int_0, Py_LT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_6) {

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":260
 *         # Decide if we're adding or subtracting.
 *         if offset < 0:
 *             function = GL_SUBTRACT_ARB             # <<<<<<<<<<<<<<
 *             offset = -offset
 *         else:
 */
    __pyx_v_function = GL_SUBTRACT_ARB;

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":261
 *         if offset < 0:
 *             function = GL_SUBTRACT_ARB
 *             offset = -offset             # <<<<<<<<<<<<<<
 *         else:
 *             function = GL_ADD
 */
    __pyx_t_3 = PyNumber_Negative(__pyx_v_offset); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_v_offset);
    __pyx_v_offset = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L10;
  }
  /*else*/ {

    /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":263
 *             offset = -offset
 *         else:
 *             function = GL_ADD             # <<<<<<<<<<<<<<
 * 
 *         # Setup unit 0 as appropriate.
 */
    __pyx_v_function = GL_ADD;
  }
  __pyx_L10:;

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":266
 * 
 *         # Setup unit 0 as appropriate.
 *         glActiveTextureARB(GL_TEXTURE0_ARB)             # <<<<<<<<<<<<<<
 *         glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, function)
 *         glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, function)
 */
  glActiveTextureARB(GL_TEXTURE0_ARB);

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":267
 *         # Setup unit 0 as appropriate.
 *         glActiveTextureARB(GL_TEXTURE0_ARB)
 *         glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, function)             # <<<<<<<<<<<<<<
 *         glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, function)
 * 
 */
  glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, __pyx_v_function);

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":268
 *         glActiveTextureARB(GL_TEXTURE0_ARB)
 *         glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, function)
 *         glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, function)             # <<<<<<<<<<<<<<
 * 
 *         cdef float *offsets = [ offset, offset, offset, offset ]
 */
  glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, __pyx_v_function);

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":270
 *         glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, function)
 * 
 *         cdef float *offsets = [ offset, offset, offset, offset ]             # <<<<<<<<<<<<<<
 * 
 *         glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, offsets)
 */
  __pyx_t_11 = __pyx_PyFloat_AsDouble(__pyx_v_offset); if (unlikely((__pyx_t_11 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_12 = __pyx_PyFloat_AsDouble(__pyx_v_offset); if (unlikely((__pyx_t_12 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_13 = __pyx_PyFloat_AsDouble(__pyx_v_offset); if (unlikely((__pyx_t_13 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_14 = __pyx_PyFloat_AsDouble(__pyx_v_offset); if (unlikely((__pyx_t_14 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_15[0] = __pyx_t_11;
  __pyx_t_15[1] = __pyx_t_12;
  __pyx_t_15[2] = __pyx_t_13;
  __pyx_t_15[3] = __pyx_t_14;
  __pyx_v_offsets = __pyx_t_15;

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":272
 *         cdef float *offsets = [ offset, offset, offset, offset ]
 * 
 *         glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, offsets)             # <<<<<<<<<<<<<<
 */
  glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, __pyx_v_offsets);

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("renpy.display.glenviron_fixed.FixedFunctionEnviron.imageblend");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_i);
  __Pyx_DECREF(__pyx_v_ramplen);
  __Pyx_DECREF(__pyx_v_t0scale);
  __Pyx_DECREF(__pyx_v_t1function);
  __Pyx_DECREF(__pyx_v_t1scale);
  __Pyx_DECREF(__pyx_v_end);
  __Pyx_DECREF(__pyx_v_offset);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/tom/ab/renpy-mainline/renpy/display/gl.pxd":1363
 * import renpy
 * 
 * cdef inline gl_check(where):             # <<<<<<<<<<<<<<
 *     cdef GLenum error
 *     error = glGetError()
 */

static CYTHON_INLINE PyObject *__pyx_f_5renpy_7display_2gl_gl_check(PyObject *__pyx_v_where) {
  GLenum __pyx_v_error;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("gl_check");

  /* "/home/tom/ab/renpy-mainline/renpy/display/gl.pxd":1365
 * cdef inline gl_check(where):
 *     cdef GLenum error
 *     error = glGetError()             # <<<<<<<<<<<<<<
 *     if error:
 *         renpy.log.info("GL error 0x%X at %s", error, where)
 */
  __pyx_v_error = glGetError();

  /* "/home/tom/ab/renpy-mainline/renpy/display/gl.pxd":1366
 *     cdef GLenum error
 *     error = glGetError()
 *     if error:             # <<<<<<<<<<<<<<
 *         renpy.log.info("GL error 0x%X at %s", error, where)
 * 
 */
  if (__pyx_v_error) {

    /* "/home/tom/ab/renpy-mainline/renpy/display/gl.pxd":1367
 *     error = glGetError()
 *     if error:
 *         renpy.log.info("GL error 0x%X at %s", error, where)             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__renpy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__log); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__info); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyInt_to_py_GLenum(__pyx_v_error); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_18));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_kp_s_18));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_18));
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v_where);
    PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_where);
    __Pyx_GIVEREF(__pyx_v_where);
    __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("renpy.display.gl.gl_check");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyMethodDef __pyx_methods[] = {
  {0, 0, 0, 0}
};

static char* __pyx_import_star_type_names[] = {
  "GLsizei",
  "GLboolean",
  "GLchar",
  "GLfloat",
  "GLubyte",
  "GLclampf",
  "GLbyte",
  "GLclampd",
  "GLushort",
  "GLsizeiptrARB",
  "GLint",
  "GLenum",
  "GLbitfield",
  "GLintptrARB",
  "GLshort",
  "GLhandleARB",
  "GLvoid",
  "GLuint",
  "GLdouble",
  "GLcharARB",
  "GLhandle",
  0
};

static int __pyx_import_star_set(PyObject *o, PyObject* py_name, char *name) {
  char** type_name = __pyx_import_star_type_names;
  while (*type_name) {
    if (__Pyx_StrEq(name, *type_name)) {
      PyErr_Format(PyExc_TypeError, "Cannot overwrite C type %s", name);
      goto bad;
    }
    type_name++;
  }
  if (0);
  else {
    if (PyObject_SetAttr(__pyx_m, py_name, o) < 0) goto bad;
  }
  return 0;
  __Pyx_AddTraceback("renpy.display.glenviron_fixed");
  bad:
  Py_DECREF(o);
  return -1;
}


/* import_all_from is an unexposed function from ceval.c */

static int
__Pyx_import_all_from(PyObject *locals, PyObject *v)
{
    PyObject *all = __Pyx_GetAttrString(v, "__all__");
    PyObject *dict, *name, *value;
    int skip_leading_underscores = 0;
    int pos, err;

    if (all == NULL) {
        if (!PyErr_ExceptionMatches(PyExc_AttributeError))
            return -1; /* Unexpected error */
        PyErr_Clear();
        dict = __Pyx_GetAttrString(v, "__dict__");
        if (dict == NULL) {
            if (!PyErr_ExceptionMatches(PyExc_AttributeError))
                return -1;
            PyErr_SetString(PyExc_ImportError,
            "from-import-* object has no __dict__ and no __all__");
            return -1;
        }
        all = PyMapping_Keys(dict);
        Py_DECREF(dict);
        if (all == NULL)
            return -1;
        skip_leading_underscores = 1;
    }

    for (pos = 0, err = 0; ; pos++) {
        name = PySequence_GetItem(all, pos);
        if (name == NULL) {
            if (!PyErr_ExceptionMatches(PyExc_IndexError))
                err = -1;
            else
                PyErr_Clear();
            break;
        }
        if (skip_leading_underscores &&
#if PY_MAJOR_VERSION < 3
            PyString_Check(name) &&
            PyString_AS_STRING(name)[0] == '_')
#else
            PyUnicode_Check(name) &&
            PyUnicode_AS_UNICODE(name)[0] == '_')
#endif
        {
            Py_DECREF(name);
            continue;
        }
        value = PyObject_GetAttr(v, name);
        if (value == NULL)
            err = -1;
        else if (PyDict_CheckExact(locals))
            err = PyDict_SetItem(locals, name, value);
        else
            err = PyObject_SetItem(locals, name, value);
        Py_DECREF(name);
        Py_XDECREF(value);
        if (err != 0)
            break;
    }
    Py_DECREF(all);
    return err;
}


static int __pyx_import_star(PyObject* m) {

    int i;
    int ret = -1;
    char* s;
    PyObject *locals = 0;
    PyObject *list = 0;
#if PY_MAJOR_VERSION >= 3
    PyObject *utf8_name = 0;
#endif
    PyObject *name;
    PyObject *item;
    
    locals = PyDict_New();              if (!locals) goto bad;
    if (__Pyx_import_all_from(locals, m) < 0) goto bad;
    list = PyDict_Items(locals);        if (!list) goto bad;
    
    for(i=0; i<PyList_GET_SIZE(list); i++) {
        name = PyTuple_GET_ITEM(PyList_GET_ITEM(list, i), 0);
        item = PyTuple_GET_ITEM(PyList_GET_ITEM(list, i), 1);
#if PY_MAJOR_VERSION >= 3
        utf8_name = PyUnicode_AsUTF8String(name);
        if (!utf8_name) goto bad;
        s = PyBytes_AS_STRING(utf8_name);
        if (__pyx_import_star_set(item, name, s) < 0) goto bad;
        Py_DECREF(utf8_name); utf8_name = 0;
#else
        s = PyString_AsString(name);
        if (!s) goto bad;
        if (__pyx_import_star_set(item, name, s) < 0) goto bad;
#endif
    }
    ret = 0;
    
bad:
    Py_XDECREF(locals);
    Py_XDECREF(list);
#if PY_MAJOR_VERSION >= 3
    Py_XDECREF(utf8_name);
#endif
    return ret;
}


#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef __pyx_moduledef = {
    PyModuleDef_HEAD_INIT,
    __Pyx_NAMESTR("glenviron_fixed"),
    0, /* m_doc */
    -1, /* m_size */
    __pyx_methods /* m_methods */,
    NULL, /* m_reload */
    NULL, /* m_traverse */
    NULL, /* m_clear */
    NULL /* m_free */
};
#endif

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_kp_s_18, __pyx_k_18, sizeof(__pyx_k_18), 0, 0, 1, 0},
  {&__pyx_n_s_19, __pyx_k_19, sizeof(__pyx_k_19), 0, 0, 1, 1},
  {&__pyx_n_s_20, __pyx_k_20, sizeof(__pyx_k_20), 0, 0, 1, 1},
  {&__pyx_kp_s_21, __pyx_k_21, sizeof(__pyx_k_21), 0, 0, 1, 0},
  {&__pyx_n_s_22, __pyx_k_22, sizeof(__pyx_k_22), 0, 0, 1, 1},
  {&__pyx_kp_u_23, __pyx_k_23, sizeof(__pyx_k_23), 0, 1, 0, 0},
  {&__pyx_kp_u_24, __pyx_k_24, sizeof(__pyx_k_24), 0, 1, 0, 0},
  {&__pyx_n_s__BLEND, __pyx_k__BLEND, sizeof(__pyx_k__BLEND), 0, 0, 1, 1},
  {&__pyx_n_s__BLIT, __pyx_k__BLIT, sizeof(__pyx_k__BLIT), 0, 0, 1, 1},
  {&__pyx_n_s__Environ, __pyx_k__Environ, sizeof(__pyx_k__Environ), 0, 0, 1, 1},
  {&__pyx_n_s__IMAGEBLEND, __pyx_k__IMAGEBLEND, sizeof(__pyx_k__IMAGEBLEND), 0, 0, 1, 1},
  {&__pyx_n_s__NONE, __pyx_k__NONE, sizeof(__pyx_k__NONE), 0, 0, 1, 1},
  {&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1},
  {&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1},
  {&__pyx_n_s__alpha_arg0, __pyx_k__alpha_arg0, sizeof(__pyx_k__alpha_arg0), 0, 0, 1, 1},
  {&__pyx_n_s__alpha_arg1, __pyx_k__alpha_arg1, sizeof(__pyx_k__alpha_arg1), 0, 0, 1, 1},
  {&__pyx_n_s__alpha_arg2, __pyx_k__alpha_arg2, sizeof(__pyx_k__alpha_arg2), 0, 0, 1, 1},
  {&__pyx_n_s__alpha_function, __pyx_k__alpha_function, sizeof(__pyx_k__alpha_function), 0, 0, 1, 1},
  {&__pyx_n_s__alpha_scale, __pyx_k__alpha_scale, sizeof(__pyx_k__alpha_scale), 0, 0, 1, 1},
  {&__pyx_n_s__alpha_source0, __pyx_k__alpha_source0, sizeof(__pyx_k__alpha_source0), 0, 0, 1, 1},
  {&__pyx_n_s__alpha_source1, __pyx_k__alpha_source1, sizeof(__pyx_k__alpha_source1), 0, 0, 1, 1},
  {&__pyx_n_s__alpha_source2, __pyx_k__alpha_source2, sizeof(__pyx_k__alpha_source2), 0, 0, 1, 1},
  {&__pyx_n_s__blend, __pyx_k__blend, sizeof(__pyx_k__blend), 0, 0, 1, 1},
  {&__pyx_n_s__blit, __pyx_k__blit, sizeof(__pyx_k__blit), 0, 0, 1, 1},
  {&__pyx_n_s__color_arg0, __pyx_k__color_arg0, sizeof(__pyx_k__color_arg0), 0, 0, 1, 1},
  {&__pyx_n_s__color_arg1, __pyx_k__color_arg1, sizeof(__pyx_k__color_arg1), 0, 0, 1, 1},
  {&__pyx_n_s__color_arg2, __pyx_k__color_arg2, sizeof(__pyx_k__color_arg2), 0, 0, 1, 1},
  {&__pyx_n_s__color_function, __pyx_k__color_function, sizeof(__pyx_k__color_function), 0, 0, 1, 1},
  {&__pyx_n_s__color_scale, __pyx_k__color_scale, sizeof(__pyx_k__color_scale), 0, 0, 1, 1},
  {&__pyx_n_s__color_source0, __pyx_k__color_source0, sizeof(__pyx_k__color_source0), 0, 0, 1, 1},
  {&__pyx_n_s__color_source1, __pyx_k__color_source1, sizeof(__pyx_k__color_source1), 0, 0, 1, 1},
  {&__pyx_n_s__color_source2, __pyx_k__color_source2, sizeof(__pyx_k__color_source2), 0, 0, 1, 1},
  {&__pyx_n_s__combine_mode, __pyx_k__combine_mode, sizeof(__pyx_k__combine_mode), 0, 0, 1, 1},
  {&__pyx_n_s__deinit, __pyx_k__deinit, sizeof(__pyx_k__deinit), 0, 0, 1, 1},
  {&__pyx_n_s__disable, __pyx_k__disable, sizeof(__pyx_k__disable), 0, 0, 1, 1},
  {&__pyx_n_s__enable, __pyx_k__enable, sizeof(__pyx_k__enable), 0, 0, 1, 1},
  {&__pyx_n_s__fraction, __pyx_k__fraction, sizeof(__pyx_k__fraction), 0, 0, 1, 1},
  {&__pyx_n_s__imageblend, __pyx_k__imageblend, sizeof(__pyx_k__imageblend), 0, 0, 1, 1},
  {&__pyx_n_s__info, __pyx_k__info, sizeof(__pyx_k__info), 0, 0, 1, 1},
  {&__pyx_n_s__init, __pyx_k__init, sizeof(__pyx_k__init), 0, 0, 1, 1},
  {&__pyx_n_s__last, __pyx_k__last, sizeof(__pyx_k__last), 0, 0, 1, 1},
  {&__pyx_n_s__last_ramp, __pyx_k__last_ramp, sizeof(__pyx_k__last_ramp), 0, 0, 1, 1},
  {&__pyx_n_s__last_ramplen, __pyx_k__last_ramplen, sizeof(__pyx_k__last_ramplen), 0, 0, 1, 1},
  {&__pyx_n_s__log, __pyx_k__log, sizeof(__pyx_k__log), 0, 0, 1, 1},
  {&__pyx_n_s__ramp, __pyx_k__ramp, sizeof(__pyx_k__ramp), 0, 0, 1, 1},
  {&__pyx_n_s__ramp_setup, __pyx_k__ramp_setup, sizeof(__pyx_k__ramp_setup), 0, 0, 1, 1},
  {&__pyx_n_s__renpy, __pyx_k__renpy, sizeof(__pyx_k__renpy), 0, 0, 1, 1},
  {&__pyx_n_s__self, __pyx_k__self, sizeof(__pyx_k__self), 0, 0, 1, 1},
  {&__pyx_n_s__unit, __pyx_k__unit, sizeof(__pyx_k__unit), 0, 0, 1, 1},
  {0, 0, 0, 0, 0, 0, 0}
};
static int __Pyx_InitCachedBuiltins(void) {
  return 0;
  return -1;
}

static int __Pyx_InitGlobals(void) {
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_8 = PyInt_FromLong(8); if (unlikely(!__pyx_int_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_16 = PyInt_FromLong(16); if (unlikely(!__pyx_int_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_32 = PyInt_FromLong(32); if (unlikely(!__pyx_int_32)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_64 = PyInt_FromLong(64); if (unlikely(!__pyx_int_64)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_128 = PyInt_FromLong(128); if (unlikely(!__pyx_int_128)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_256 = PyInt_FromLong(256); if (unlikely(!__pyx_int_256)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  return 0;
  __pyx_L1_error:;
  return -1;
}

#if PY_MAJOR_VERSION < 3
PyMODINIT_FUNC initglenviron_fixed(void); /*proto*/
PyMODINIT_FUNC initglenviron_fixed(void)
#else
PyMODINIT_FUNC PyInit_glenviron_fixed(void); /*proto*/
PyMODINIT_FUNC PyInit_glenviron_fixed(void)
#endif
{
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  #if CYTHON_REFNANNY
  void* __pyx_refnanny = NULL;
  __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
  if (!__Pyx_RefNanny) {
      PyErr_Clear();
      __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
      if (!__Pyx_RefNanny)
          Py_FatalError("failed to import 'refnanny' module");
  }
  __pyx_refnanny = __Pyx_RefNanny->SetupContext("PyMODINIT_FUNC PyInit_glenviron_fixed(void)", __LINE__, __FILE__);
  #endif
  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #ifdef __pyx_binding_PyCFunctionType_USED
  if (__pyx_binding_PyCFunctionType_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  /*--- Library function declarations ---*/
  /*--- Threads initialization code ---*/
  #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
  #ifdef WITH_THREAD /* Python build with threading support? */
  PyEval_InitThreads();
  #endif
  #endif
  /*--- Module creation code ---*/
  #if PY_MAJOR_VERSION < 3
  __pyx_m = Py_InitModule4(__Pyx_NAMESTR("glenviron_fixed"), __pyx_methods, 0, 0, PYTHON_API_VERSION);
  #else
  __pyx_m = PyModule_Create(&__pyx_moduledef);
  #endif
  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  #if PY_MAJOR_VERSION < 3
  Py_INCREF(__pyx_m);
  #endif
  __pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME));
  if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  /*--- Initialize various global constants etc. ---*/
  if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_module_is_main_renpy__display__glenviron_fixed) {
    if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_n_s____main__) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  }
  /*--- Builtin init code ---*/
  if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Global init code ---*/
  /*--- Function export code ---*/
  /*--- Type init code ---*/
  /*--- Type import code ---*/
  /*--- Function import code ---*/
  /*--- Execution code ---*/

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":24
 * 
 * from gl cimport *
 * from renpy.display.glenviron import *             # <<<<<<<<<<<<<<
 * 
 * class FixedFunctionEnviron(Environ):
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_INCREF(((PyObject *)__pyx_n_s_20));
  PyList_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s_20));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s_20));
  __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s_19), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  if (__pyx_import_star(__pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":26
 * from renpy.display.glenviron import *
 * 
 * class FixedFunctionEnviron(Environ):             # <<<<<<<<<<<<<<
 *     """
 *     This is an OpenGL environment that uses the fixed-function pipeline.
 */
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__Environ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  if (PyDict_SetItemString(((PyObject *)__pyx_t_2), "__doc__", ((PyObject *)__pyx_kp_s_21)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __Pyx_CreateClass(__pyx_t_3, ((PyObject *)__pyx_t_2), __pyx_n_s_22, "renpy.display.glenviron_fixed"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":34
 *     """
 * 
 *     def init(self):             # <<<<<<<<<<<<<<
 * 
 *         # The last blend environ used.
 */
  __pyx_t_3 = PyCFunction_New(&__pyx_mdef_5renpy_7display_15glenviron_fixed_20FixedFunctionEnviron_init, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyMethod_New(__pyx_t_3, 0, __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyObject_SetAttr(__pyx_t_1, __pyx_n_s__init, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":63
 * 
 * 
 *     def deinit(self):             # <<<<<<<<<<<<<<
 *         """
 *         Called before changing the GL context.
 */
  __pyx_t_4 = PyCFunction_New(&__pyx_mdef_5renpy_7display_15glenviron_fixed_20FixedFunctionEnviron_deinit, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyMethod_New(__pyx_t_4, 0, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyObject_SetAttr(__pyx_t_1, __pyx_n_s__deinit, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":70
 *         return
 * 
 *     def disable(self, unit):             # <<<<<<<<<<<<<<
 *         """
 *         Disables the given texture combiner.
 */
  __pyx_t_3 = PyCFunction_New(&__pyx_mdef_5renpy_7display_15glenviron_fixed_20FixedFunctionEnviron_disable, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyMethod_New(__pyx_t_3, 0, __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyObject_SetAttr(__pyx_t_1, __pyx_n_s__disable, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":79
 * 
 *     def combine_mode(self, unit,
 *                      color_function=GL_MODULATE,             # <<<<<<<<<<<<<<
 *                      color_arg0=GL_TEXTURE,
 *                      color_arg1=GL_PREVIOUS_ARB,
 */
  __pyx_t_4 = PyInt_FromLong(GL_MODULATE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_k_1 = __pyx_t_4;
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_4 = 0;

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":80
 *     def combine_mode(self, unit,
 *                      color_function=GL_MODULATE,
 *                      color_arg0=GL_TEXTURE,             # <<<<<<<<<<<<<<
 *                      color_arg1=GL_PREVIOUS_ARB,
 *                      color_arg2=GL_CONSTANT_ARB,
 */
  __pyx_t_4 = PyInt_FromLong(GL_TEXTURE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_k_2 = __pyx_t_4;
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_4 = 0;

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":81
 *                      color_function=GL_MODULATE,
 *                      color_arg0=GL_TEXTURE,
 *                      color_arg1=GL_PREVIOUS_ARB,             # <<<<<<<<<<<<<<
 *                      color_arg2=GL_CONSTANT_ARB,
 *                      color_source0=GL_SRC_COLOR,
 */
  __pyx_t_4 = PyInt_FromLong(GL_PREVIOUS_ARB); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_k_3 = __pyx_t_4;
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_4 = 0;

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":82
 *                      color_arg0=GL_TEXTURE,
 *                      color_arg1=GL_PREVIOUS_ARB,
 *                      color_arg2=GL_CONSTANT_ARB,             # <<<<<<<<<<<<<<
 *                      color_source0=GL_SRC_COLOR,
 *                      color_source1=GL_SRC_COLOR,
 */
  __pyx_t_4 = PyInt_FromLong(GL_CONSTANT_ARB); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_k_4 = __pyx_t_4;
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_4 = 0;

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":83
 *                      color_arg1=GL_PREVIOUS_ARB,
 *                      color_arg2=GL_CONSTANT_ARB,
 *                      color_source0=GL_SRC_COLOR,             # <<<<<<<<<<<<<<
 *                      color_source1=GL_SRC_COLOR,
 *                      color_source2=GL_SRC_COLOR,
 */
  __pyx_t_4 = PyInt_FromLong(GL_SRC_COLOR); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_k_5 = __pyx_t_4;
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_4 = 0;

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":84
 *                      color_arg2=GL_CONSTANT_ARB,
 *                      color_source0=GL_SRC_COLOR,
 *                      color_source1=GL_SRC_COLOR,             # <<<<<<<<<<<<<<
 *                      color_source2=GL_SRC_COLOR,
 *                      color_scale=1.0,
 */
  __pyx_t_4 = PyInt_FromLong(GL_SRC_COLOR); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_k_6 = __pyx_t_4;
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_4 = 0;

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":85
 *                      color_source0=GL_SRC_COLOR,
 *                      color_source1=GL_SRC_COLOR,
 *                      color_source2=GL_SRC_COLOR,             # <<<<<<<<<<<<<<
 *                      color_scale=1.0,
 *                      alpha_function=GL_MODULATE,
 */
  __pyx_t_4 = PyInt_FromLong(GL_SRC_COLOR); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_k_7 = __pyx_t_4;
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_4 = 0;

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":86
 *                      color_source1=GL_SRC_COLOR,
 *                      color_source2=GL_SRC_COLOR,
 *                      color_scale=1.0,             # <<<<<<<<<<<<<<
 *                      alpha_function=GL_MODULATE,
 *                      alpha_arg0=GL_TEXTURE,
 */
  __pyx_t_4 = PyFloat_FromDouble(1.0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_k_8 = __pyx_t_4;
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_4 = 0;

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":87
 *                      color_source2=GL_SRC_COLOR,
 *                      color_scale=1.0,
 *                      alpha_function=GL_MODULATE,             # <<<<<<<<<<<<<<
 *                      alpha_arg0=GL_TEXTURE,
 *                      alpha_arg1=GL_PREVIOUS_ARB,
 */
  __pyx_t_4 = PyInt_FromLong(GL_MODULATE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_k_9 = __pyx_t_4;
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_4 = 0;

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":88
 *                      color_scale=1.0,
 *                      alpha_function=GL_MODULATE,
 *                      alpha_arg0=GL_TEXTURE,             # <<<<<<<<<<<<<<
 *                      alpha_arg1=GL_PREVIOUS_ARB,
 *                      alpha_arg2=GL_CONSTANT_ARB,
 */
  __pyx_t_4 = PyInt_FromLong(GL_TEXTURE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_k_10 = __pyx_t_4;
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_4 = 0;

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":89
 *                      alpha_function=GL_MODULATE,
 *                      alpha_arg0=GL_TEXTURE,
 *                      alpha_arg1=GL_PREVIOUS_ARB,             # <<<<<<<<<<<<<<
 *                      alpha_arg2=GL_CONSTANT_ARB,
 *                      alpha_source0=GL_SRC_ALPHA,
 */
  __pyx_t_4 = PyInt_FromLong(GL_PREVIOUS_ARB); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_k_11 = __pyx_t_4;
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_4 = 0;

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":90
 *                      alpha_arg0=GL_TEXTURE,
 *                      alpha_arg1=GL_PREVIOUS_ARB,
 *                      alpha_arg2=GL_CONSTANT_ARB,             # <<<<<<<<<<<<<<
 *                      alpha_source0=GL_SRC_ALPHA,
 *                      alpha_source1=GL_SRC_ALPHA,
 */
  __pyx_t_4 = PyInt_FromLong(GL_CONSTANT_ARB); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_k_12 = __pyx_t_4;
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_4 = 0;

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":91
 *                      alpha_arg1=GL_PREVIOUS_ARB,
 *                      alpha_arg2=GL_CONSTANT_ARB,
 *                      alpha_source0=GL_SRC_ALPHA,             # <<<<<<<<<<<<<<
 *                      alpha_source1=GL_SRC_ALPHA,
 *                      alpha_source2=GL_SRC_ALPHA,
 */
  __pyx_t_4 = PyInt_FromLong(GL_SRC_ALPHA); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_k_13 = __pyx_t_4;
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_4 = 0;

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":92
 *                      alpha_arg2=GL_CONSTANT_ARB,
 *                      alpha_source0=GL_SRC_ALPHA,
 *                      alpha_source1=GL_SRC_ALPHA,             # <<<<<<<<<<<<<<
 *                      alpha_source2=GL_SRC_ALPHA,
 *                      alpha_scale=1.0,
 */
  __pyx_t_4 = PyInt_FromLong(GL_SRC_ALPHA); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_k_14 = __pyx_t_4;
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_4 = 0;

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":93
 *                      alpha_source0=GL_SRC_ALPHA,
 *                      alpha_source1=GL_SRC_ALPHA,
 *                      alpha_source2=GL_SRC_ALPHA,             # <<<<<<<<<<<<<<
 *                      alpha_scale=1.0,
 *                      enable=True):
 */
  __pyx_t_4 = PyInt_FromLong(GL_SRC_ALPHA); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_k_15 = __pyx_t_4;
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_4 = 0;

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":94
 *                      alpha_source1=GL_SRC_ALPHA,
 *                      alpha_source2=GL_SRC_ALPHA,
 *                      alpha_scale=1.0,             # <<<<<<<<<<<<<<
 *                      enable=True):
 * 
 */
  __pyx_t_4 = PyFloat_FromDouble(1.0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_k_16 = __pyx_t_4;
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_4 = 0;

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":95
 *                      alpha_source2=GL_SRC_ALPHA,
 *                      alpha_scale=1.0,
 *                      enable=True):             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_4 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_k_17 = __pyx_t_4;
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_4 = 0;

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":78
 *         glDisable(GL_TEXTURE_2D)
 * 
 *     def combine_mode(self, unit,             # <<<<<<<<<<<<<<
 *                      color_function=GL_MODULATE,
 *                      color_arg0=GL_TEXTURE,
 */
  __pyx_t_4 = PyCFunction_New(&__pyx_mdef_5renpy_7display_15glenviron_fixed_20FixedFunctionEnviron_combine_mode, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyMethod_New(__pyx_t_4, 0, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyObject_SetAttr(__pyx_t_1, __pyx_n_s__combine_mode, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":127
 * 
 * 
 *     def blit(self):             # <<<<<<<<<<<<<<
 * 
 *         if self.last != BLIT:
 */
  __pyx_t_3 = PyCFunction_New(&__pyx_mdef_5renpy_7display_15glenviron_fixed_20FixedFunctionEnviron_blit, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyMethod_New(__pyx_t_3, 0, __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyObject_SetAttr(__pyx_t_1, __pyx_n_s__blit, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":145
 *             self.last = BLIT
 * 
 *     def blend(self, fraction):             # <<<<<<<<<<<<<<
 * 
 *         if self.last != BLEND:
 */
  __pyx_t_4 = PyCFunction_New(&__pyx_mdef_5renpy_7display_15glenviron_fixed_20FixedFunctionEnviron_blend, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyMethod_New(__pyx_t_4, 0, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyObject_SetAttr(__pyx_t_1, __pyx_n_s__blend, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":187
 * 
 * 
 *     def imageblend(self, fraction, ramp):             # <<<<<<<<<<<<<<
 * 
 *         if self.last != IMAGEBLEND or self.last_ramp != ramp:
 */
  __pyx_t_3 = PyCFunction_New(&__pyx_mdef_5renpy_7display_15glenviron_fixed_20FixedFunctionEnviron_imageblend, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyMethod_New(__pyx_t_3, 0, __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyObject_SetAttr(__pyx_t_1, __pyx_n_s__imageblend, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_22, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;

  /* "/home/tom/ab/renpy-mainline/renpy/display/glenviron_fixed.pyx":1
 * #cython: profile=False             # <<<<<<<<<<<<<<
 * # Copyright 2004-2011 Tom Rothamel <pytom@bishoujo.us>
 * #
 */
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s_22); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__deinit); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_kp_u_23), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s_22); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__disable); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_kp_u_24), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_2)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;

  /* "/home/tom/ab/renpy-mainline/renpy/display/gl.pxd":1363
 * import renpy
 * 
 * cdef inline gl_check(where):             # <<<<<<<<<<<<<<
 *     cdef GLenum error
 *     error = glGetError()
 */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  if (__pyx_m) {
    __Pyx_AddTraceback("init renpy.display.glenviron_fixed");
    Py_DECREF(__pyx_m); __pyx_m = 0;
  } else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_ImportError, "init renpy.display.glenviron_fixed");
  }
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  #if PY_MAJOR_VERSION < 3
  return;
  #else
  return __pyx_m;
  #endif
}

/* Runtime support code */

static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
    PyObject *result;
    result = PyObject_GetAttr(dict, name);
    if (!result)
        PyErr_SetObject(PyExc_NameError, name);
    return result;
}

static void __Pyx_RaiseDoubleKeywordsError(
    const char* func_name,
    PyObject* kw_name)
{
    PyErr_Format(PyExc_TypeError,
        #if PY_MAJOR_VERSION >= 3
        "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
        #else
        "%s() got multiple values for keyword argument '%s'", func_name,
        PyString_AS_STRING(kw_name));
        #endif
}

static void __Pyx_RaiseArgtupleInvalid(
    const char* func_name,
    int exact,
    Py_ssize_t num_min,
    Py_ssize_t num_max,
    Py_ssize_t num_found)
{
    Py_ssize_t num_expected;
    const char *number, *more_or_less;

    if (num_found < num_min) {
        num_expected = num_min;
        more_or_less = "at least";
    } else {
        num_expected = num_max;
        more_or_less = "at most";
    }
    if (exact) {
        more_or_less = "exactly";
    }
    number = (num_expected == 1) ? "" : "s";
    PyErr_Format(PyExc_TypeError,
        #if PY_VERSION_HEX < 0x02050000
            "%s() takes %s %d positional argument%s (%d given)",
        #else
            "%s() takes %s %zd positional argument%s (%zd given)",
        #endif
        func_name, more_or_less, num_expected, number, num_found);
}

static int __Pyx_ParseOptionalKeywords(
    PyObject *kwds,
    PyObject **argnames[],
    PyObject *kwds2,
    PyObject *values[],
    Py_ssize_t num_pos_args,
    const char* function_name)
{
    PyObject *key = 0, *value = 0;
    Py_ssize_t pos = 0;
    PyObject*** name;
    PyObject*** first_kw_arg = argnames + num_pos_args;

    while (PyDict_Next(kwds, &pos, &key, &value)) {
        name = first_kw_arg;
        while (*name && (**name != key)) name++;
        if (*name) {
            values[name-argnames] = value;
        } else {
            #if PY_MAJOR_VERSION < 3
            if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key))) {
            #else
            if (unlikely(!PyUnicode_CheckExact(key)) && unlikely(!PyUnicode_Check(key))) {
            #endif
                goto invalid_keyword_type;
            } else {
                for (name = first_kw_arg; *name; name++) {
                    #if PY_MAJOR_VERSION >= 3
                    if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) &&
                        PyUnicode_Compare(**name, key) == 0) break;
                    #else
                    if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) &&
                        _PyString_Eq(**name, key)) break;
                    #endif
                }
                if (*name) {
                    values[name-argnames] = value;
                } else {
                    /* unexpected keyword found */
                    for (name=argnames; name != first_kw_arg; name++) {
                        if (**name == key) goto arg_passed_twice;
                        #if PY_MAJOR_VERSION >= 3
                        if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) &&
                            PyUnicode_Compare(**name, key) == 0) goto arg_passed_twice;
                        #else
                        if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) &&
                            _PyString_Eq(**name, key)) goto arg_passed_twice;
                        #endif
                    }
                    if (kwds2) {
                        if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
                    } else {
                        goto invalid_keyword;
                    }
                }
            }
        }
    }
    return 0;
arg_passed_twice:
    __Pyx_RaiseDoubleKeywordsError(function_name, **name);
    goto bad;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%s() keywords must be strings", function_name);
    goto bad;
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
    #if PY_MAJOR_VERSION < 3
        "%s() got an unexpected keyword argument '%s'",
        function_name, PyString_AsString(key));
    #else
        "%s() got an unexpected keyword argument '%U'",
        function_name, key);
    #endif
bad:
    return -1;
}

static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
    PyErr_Format(PyExc_ValueError,
        #if PY_VERSION_HEX < 0x02050000
                 "need more than %d value%s to unpack", (int)index,
        #else
                 "need more than %zd value%s to unpack", index,
        #endif
                 (index == 1) ? "" : "s");
}

static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
    PyErr_Format(PyExc_ValueError,
        #if PY_VERSION_HEX < 0x02050000
            "too many values to unpack (expected %d)", (int)expected);
        #else
            "too many values to unpack (expected %zd)", expected);
        #endif
}

static PyObject *__Pyx_UnpackItem(PyObject *iter, Py_ssize_t index) {
    PyObject *item;
    if (!(item = PyIter_Next(iter))) {
        if (!PyErr_Occurred()) {
            __Pyx_RaiseNeedMoreValuesError(index);
        }
    }
    return item;
}

static int __Pyx_EndUnpack(PyObject *iter, Py_ssize_t expected) {
    PyObject *item;
    if ((item = PyIter_Next(iter))) {
        Py_DECREF(item);
        __Pyx_RaiseTooManyValuesError(expected);
        return -1;
    }
    else if (!PyErr_Occurred())
        return 0;
    else
        return -1;
}

static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list) {
    PyObject *py_import = 0;
    PyObject *empty_list = 0;
    PyObject *module = 0;
    PyObject *global_dict = 0;
    PyObject *empty_dict = 0;
    PyObject *list;
    py_import = __Pyx_GetAttrString(__pyx_b, "__import__");
    if (!py_import)
        goto bad;
    if (from_list)
        list = from_list;
    else {
        empty_list = PyList_New(0);
        if (!empty_list)
            goto bad;
        list = empty_list;
    }
    global_dict = PyModule_GetDict(__pyx_m);
    if (!global_dict)
        goto bad;
    empty_dict = PyDict_New();
    if (!empty_dict)
        goto bad;
    module = PyObject_CallFunctionObjArgs(py_import,
        name, global_dict, empty_dict, list, NULL);
bad:
    Py_XDECREF(empty_list);
    Py_XDECREF(py_import);
    Py_XDECREF(empty_dict);
    return module;
}

static PyObject *__Pyx_CreateClass(
    PyObject *bases, PyObject *dict, PyObject *name, const char *modname)
{
    PyObject *py_modname;
    PyObject *result = 0;

    #if PY_MAJOR_VERSION < 3
    py_modname = PyString_FromString(modname);
    #else
    py_modname = PyUnicode_FromString(modname);
    #endif
    if (!py_modname)
        goto bad;
    if (PyDict_SetItemString(dict, "__module__", py_modname) < 0)
        goto bad;
    #if PY_MAJOR_VERSION < 3
    result = PyClass_New(bases, dict, name);
    #else
    result = PyObject_CallFunctionObjArgs((PyObject *)&PyType_Type, name, bases, dict, NULL);
    #endif
bad:
    Py_XDECREF(py_modname);
    return result;
}

static CYTHON_INLINE GLenum __Pyx_PyInt_from_py_GLenum(PyObject* x) {
    const GLenum neg_one = (GLenum)-1, const_zero = (GLenum)0;
    const int is_unsigned = const_zero < neg_one;
    if (sizeof(GLenum) == sizeof(char)) {
        if (is_unsigned)
            return (GLenum)__Pyx_PyInt_AsUnsignedChar(x);
        else
            return (GLenum)__Pyx_PyInt_AsSignedChar(x);
    } else if (sizeof(GLenum) == sizeof(short)) {
        if (is_unsigned)
            return (GLenum)__Pyx_PyInt_AsUnsignedShort(x);
        else
            return (GLenum)__Pyx_PyInt_AsSignedShort(x);
    } else if (sizeof(GLenum) == sizeof(int)) {
        if (is_unsigned)
            return (GLenum)__Pyx_PyInt_AsUnsignedInt(x);
        else
            return (GLenum)__Pyx_PyInt_AsSignedInt(x);
    } else if (sizeof(GLenum) == sizeof(long)) {
        if (is_unsigned)
            return (GLenum)__Pyx_PyInt_AsUnsignedLong(x);
        else
            return (GLenum)__Pyx_PyInt_AsSignedLong(x);
    } else if (sizeof(GLenum) == sizeof(PY_LONG_LONG)) {
        if (is_unsigned)
            return (GLenum)__Pyx_PyInt_AsUnsignedLongLong(x);
        else
            return (GLenum)__Pyx_PyInt_AsSignedLongLong(x);
    }  else {
        GLenum val;
        PyObject *v = __Pyx_PyNumber_Int(x);
        #if PY_VERSION_HEX < 0x03000000
        if (likely(v) && !PyLong_Check(v)) {
            PyObject *tmp = v;
            v = PyNumber_Long(tmp);
            Py_DECREF(tmp);
        }
        #endif
        if (likely(v)) {
            int one = 1; int is_little = (int)*(unsigned char *)&one;
            unsigned char *bytes = (unsigned char *)&val;
            int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                          bytes, sizeof(val),
                                          is_little, !is_unsigned);
            Py_DECREF(v);
            if (likely(!ret))
                return val;
        }
        return (GLenum)-1;
    }
}

static CYTHON_INLINE GLint __Pyx_PyInt_from_py_GLint(PyObject* x) {
    const GLint neg_one = (GLint)-1, const_zero = (GLint)0;
    const int is_unsigned = const_zero < neg_one;
    if (sizeof(GLint) == sizeof(char)) {
        if (is_unsigned)
            return (GLint)__Pyx_PyInt_AsUnsignedChar(x);
        else
            return (GLint)__Pyx_PyInt_AsSignedChar(x);
    } else if (sizeof(GLint) == sizeof(short)) {
        if (is_unsigned)
            return (GLint)__Pyx_PyInt_AsUnsignedShort(x);
        else
            return (GLint)__Pyx_PyInt_AsSignedShort(x);
    } else if (sizeof(GLint) == sizeof(int)) {
        if (is_unsigned)
            return (GLint)__Pyx_PyInt_AsUnsignedInt(x);
        else
            return (GLint)__Pyx_PyInt_AsSignedInt(x);
    } else if (sizeof(GLint) == sizeof(long)) {
        if (is_unsigned)
            return (GLint)__Pyx_PyInt_AsUnsignedLong(x);
        else
            return (GLint)__Pyx_PyInt_AsSignedLong(x);
    } else if (sizeof(GLint) == sizeof(PY_LONG_LONG)) {
        if (is_unsigned)
            return (GLint)__Pyx_PyInt_AsUnsignedLongLong(x);
        else
            return (GLint)__Pyx_PyInt_AsSignedLongLong(x);
    }  else {
        GLint val;
        PyObject *v = __Pyx_PyNumber_Int(x);
        #if PY_VERSION_HEX < 0x03000000
        if (likely(v) && !PyLong_Check(v)) {
            PyObject *tmp = v;
            v = PyNumber_Long(tmp);
            Py_DECREF(tmp);
        }
        #endif
        if (likely(v)) {
            int one = 1; int is_little = (int)*(unsigned char *)&one;
            unsigned char *bytes = (unsigned char *)&val;
            int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                          bytes, sizeof(val),
                                          is_little, !is_unsigned);
            Py_DECREF(v);
            if (likely(!ret))
                return val;
        }
        return (GLint)-1;
    }
}

static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_GLenum(GLenum val) {
    const GLenum neg_one = (GLenum)-1, const_zero = (GLenum)0;
    const int is_unsigned = const_zero < neg_one;
    if ((sizeof(GLenum) == sizeof(char))  ||
        (sizeof(GLenum) == sizeof(short))) {
        return PyInt_FromLong((long)val);
    } else if ((sizeof(GLenum) == sizeof(int)) ||
               (sizeof(GLenum) == sizeof(long))) {
        if (is_unsigned)
            return PyLong_FromUnsignedLong((unsigned long)val);
        else
            return PyInt_FromLong((long)val);
    } else if (sizeof(GLenum) == sizeof(PY_LONG_LONG)) {
        if (is_unsigned)
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)val);
        else
            return PyLong_FromLongLong((PY_LONG_LONG)val);
    } else {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&val;
        return _PyLong_FromByteArray(bytes, sizeof(GLenum), 
                                     little, !is_unsigned);
    }
}

static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject* x) {
    const unsigned char neg_one = (unsigned char)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(unsigned char) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(unsigned char)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to unsigned char" :
                    "value too large to convert to unsigned char");
            }
            return (unsigned char)-1;
        }
        return (unsigned char)val;
    }
    return (unsigned char)__Pyx_PyInt_AsUnsignedLong(x);
}

static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject* x) {
    const unsigned short neg_one = (unsigned short)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(unsigned short) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(unsigned short)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to unsigned short" :
                    "value too large to convert to unsigned short");
            }
            return (unsigned short)-1;
        }
        return (unsigned short)val;
    }
    return (unsigned short)__Pyx_PyInt_AsUnsignedLong(x);
}

static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject* x) {
    const unsigned int neg_one = (unsigned int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(unsigned int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(unsigned int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to unsigned int" :
                    "value too large to convert to unsigned int");
            }
            return (unsigned int)-1;
        }
        return (unsigned int)val;
    }
    return (unsigned int)__Pyx_PyInt_AsUnsignedLong(x);
}

static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject* x) {
    const char neg_one = (char)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(char) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(char)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to char" :
                    "value too large to convert to char");
            }
            return (char)-1;
        }
        return (char)val;
    }
    return (char)__Pyx_PyInt_AsLong(x);
}

static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject* x) {
    const short neg_one = (short)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(short) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(short)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to short" :
                    "value too large to convert to short");
            }
            return (short)-1;
        }
        return (short)val;
    }
    return (short)__Pyx_PyInt_AsLong(x);
}

static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject* x) {
    const int neg_one = (int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to int" :
                    "value too large to convert to int");
            }
            return (int)-1;
        }
        return (int)val;
    }
    return (int)__Pyx_PyInt_AsLong(x);
}

static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject* x) {
    const signed char neg_one = (signed char)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(signed char) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(signed char)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to signed char" :
                    "value too large to convert to signed char");
            }
            return (signed char)-1;
        }
        return (signed char)val;
    }
    return (signed char)__Pyx_PyInt_AsSignedLong(x);
}

static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject* x) {
    const signed short neg_one = (signed short)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(signed short) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(signed short)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to signed short" :
                    "value too large to convert to signed short");
            }
            return (signed short)-1;
        }
        return (signed short)val;
    }
    return (signed short)__Pyx_PyInt_AsSignedLong(x);
}

static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject* x) {
    const signed int neg_one = (signed int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(signed int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(signed int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to signed int" :
                    "value too large to convert to signed int");
            }
            return (signed int)-1;
        }
        return (signed int)val;
    }
    return (signed int)__Pyx_PyInt_AsSignedLong(x);
}

static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject* x) {
    const int neg_one = (int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to int" :
                    "value too large to convert to int");
            }
            return (int)-1;
        }
        return (int)val;
    }
    return (int)__Pyx_PyInt_AsLong(x);
}

static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject* x) {
    const unsigned long neg_one = (unsigned long)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to unsigned long");
            return (unsigned long)-1;
        }
        return (unsigned long)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to unsigned long");
                return (unsigned long)-1;
            }
            return PyLong_AsUnsignedLong(x);
        } else {
            return PyLong_AsLong(x);
        }
    } else {
        unsigned long val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (unsigned long)-1;
        val = __Pyx_PyInt_AsUnsignedLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject* x) {
    const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to unsigned PY_LONG_LONG");
            return (unsigned PY_LONG_LONG)-1;
        }
        return (unsigned PY_LONG_LONG)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to unsigned PY_LONG_LONG");
                return (unsigned PY_LONG_LONG)-1;
            }
            return PyLong_AsUnsignedLongLong(x);
        } else {
            return PyLong_AsLongLong(x);
        }
    } else {
        unsigned PY_LONG_LONG val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (unsigned PY_LONG_LONG)-1;
        val = __Pyx_PyInt_AsUnsignedLongLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject* x) {
    const long neg_one = (long)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to long");
            return (long)-1;
        }
        return (long)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to long");
                return (long)-1;
            }
            return PyLong_AsUnsignedLong(x);
        } else {
            return PyLong_AsLong(x);
        }
    } else {
        long val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (long)-1;
        val = __Pyx_PyInt_AsLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject* x) {
    const PY_LONG_LONG neg_one = (PY_LONG_LONG)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to PY_LONG_LONG");
            return (PY_LONG_LONG)-1;
        }
        return (PY_LONG_LONG)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to PY_LONG_LONG");
                return (PY_LONG_LONG)-1;
            }
            return PyLong_AsUnsignedLongLong(x);
        } else {
            return PyLong_AsLongLong(x);
        }
    } else {
        PY_LONG_LONG val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (PY_LONG_LONG)-1;
        val = __Pyx_PyInt_AsLongLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject* x) {
    const signed long neg_one = (signed long)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to signed long");
            return (signed long)-1;
        }
        return (signed long)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to signed long");
                return (signed long)-1;
            }
            return PyLong_AsUnsignedLong(x);
        } else {
            return PyLong_AsLong(x);
        }
    } else {
        signed long val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (signed long)-1;
        val = __Pyx_PyInt_AsSignedLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject* x) {
    const signed PY_LONG_LONG neg_one = (signed PY_LONG_LONG)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to signed PY_LONG_LONG");
            return (signed PY_LONG_LONG)-1;
        }
        return (signed PY_LONG_LONG)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to signed PY_LONG_LONG");
                return (signed PY_LONG_LONG)-1;
            }
            return PyLong_AsUnsignedLongLong(x);
        } else {
            return PyLong_AsLongLong(x);
        }
    } else {
        signed PY_LONG_LONG val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (signed PY_LONG_LONG)-1;
        val = __Pyx_PyInt_AsSignedLongLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE int __Pyx_StrEq(const char *s1, const char *s2) {
     while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
     return *s1 == *s2;
}

#include "compile.h"
#include "frameobject.h"
#include "traceback.h"

static void __Pyx_AddTraceback(const char *funcname) {
    PyObject *py_srcfile = 0;
    PyObject *py_funcname = 0;
    PyObject *py_globals = 0;
    PyCodeObject *py_code = 0;
    PyFrameObject *py_frame = 0;

    #if PY_MAJOR_VERSION < 3
    py_srcfile = PyString_FromString(__pyx_filename);
    #else
    py_srcfile = PyUnicode_FromString(__pyx_filename);
    #endif
    if (!py_srcfile) goto bad;
    if (__pyx_clineno) {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno);
        #else
        py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno);
        #endif
    }
    else {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromString(funcname);
        #else
        py_funcname = PyUnicode_FromString(funcname);
        #endif
    }
    if (!py_funcname) goto bad;
    py_globals = PyModule_GetDict(__pyx_m);
    if (!py_globals) goto bad;
    py_code = PyCode_New(
        0,            /*int argcount,*/
        #if PY_MAJOR_VERSION >= 3
        0,            /*int kwonlyargcount,*/
        #endif
        0,            /*int nlocals,*/
        0,            /*int stacksize,*/
        0,            /*int flags,*/
        __pyx_empty_bytes, /*PyObject *code,*/
        __pyx_empty_tuple,  /*PyObject *consts,*/
        __pyx_empty_tuple,  /*PyObject *names,*/
        __pyx_empty_tuple,  /*PyObject *varnames,*/
        __pyx_empty_tuple,  /*PyObject *freevars,*/
        __pyx_empty_tuple,  /*PyObject *cellvars,*/
        py_srcfile,   /*PyObject *filename,*/
        py_funcname,  /*PyObject *name,*/
        __pyx_lineno,   /*int firstlineno,*/
        __pyx_empty_bytes  /*PyObject *lnotab*/
    );
    if (!py_code) goto bad;
    py_frame = PyFrame_New(
        PyThreadState_GET(), /*PyThreadState *tstate,*/
        py_code,             /*PyCodeObject *code,*/
        py_globals,          /*PyObject *globals,*/
        0                    /*PyObject *locals*/
    );
    if (!py_frame) goto bad;
    py_frame->f_lineno = __pyx_lineno;
    PyTraceBack_Here(py_frame);
bad:
    Py_XDECREF(py_srcfile);
    Py_XDECREF(py_funcname);
    Py_XDECREF(py_code);
    Py_XDECREF(py_frame);
}

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
    while (t->p) {
        #if PY_MAJOR_VERSION < 3
        if (t->is_unicode) {
            *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
        } else if (t->intern) {
            *t->p = PyString_InternFromString(t->s);
        } else {
            *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
        }
        #else  /* Python 3+ has unicode identifiers */
        if (t->is_unicode | t->is_str) {
            if (t->intern) {
                *t->p = PyUnicode_InternFromString(t->s);
            } else if (t->encoding) {
                *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
            } else {
                *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
            }
        } else {
            *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
        }
        #endif
        if (!*t->p)
            return -1;
        ++t;
    }
    return 0;
}

/* Type Conversion Functions */

static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
   int is_true = x == Py_True;
   if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
   else return PyObject_IsTrue(x);
}

static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) {
  PyNumberMethods *m;
  const char *name = NULL;
  PyObject *res = NULL;
#if PY_VERSION_HEX < 0x03000000
  if (PyInt_Check(x) || PyLong_Check(x))
#else
  if (PyLong_Check(x))
#endif
    return Py_INCREF(x), x;
  m = Py_TYPE(x)->tp_as_number;
#if PY_VERSION_HEX < 0x03000000
  if (m && m->nb_int) {
    name = "int";
    res = PyNumber_Int(x);
  }
  else if (m && m->nb_long) {
    name = "long";
    res = PyNumber_Long(x);
  }
#else
  if (m && m->nb_int) {
    name = "int";
    res = PyNumber_Long(x);
  }
#endif
  if (res) {
#if PY_VERSION_HEX < 0x03000000
    if (!PyInt_Check(res) && !PyLong_Check(res)) {
#else
    if (!PyLong_Check(res)) {
#endif
      PyErr_Format(PyExc_TypeError,
                   "__%s__ returned non-%s (type %.200s)",
                   name, name, Py_TYPE(res)->tp_name);
      Py_DECREF(res);
      return NULL;
    }
  }
  else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_TypeError,
                    "an integer is required");
  }
  return res;
}

static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  Py_ssize_t ival;
  PyObject* x = PyNumber_Index(b);
  if (!x) return -1;
  ival = PyInt_AsSsize_t(x);
  Py_DECREF(x);
  return ival;
}

static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
#if PY_VERSION_HEX < 0x02050000
   if (ival <= LONG_MAX)
       return PyInt_FromLong((long)ival);
   else {
       unsigned char *bytes = (unsigned char *) &ival;
       int one = 1; int little = (int)*(unsigned char*)&one;
       return _PyLong_FromByteArray(bytes, sizeof(size_t), little, 0);
   }
#else
   return PyInt_FromSize_t(ival);
#endif
}

static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject* x) {
   unsigned PY_LONG_LONG val = __Pyx_PyInt_AsUnsignedLongLong(x);
   if (unlikely(val == (unsigned PY_LONG_LONG)-1 && PyErr_Occurred())) {
       return (size_t)-1;
   } else if (unlikely(val != (unsigned PY_LONG_LONG)(size_t)val)) {
       PyErr_SetString(PyExc_OverflowError,
                       "value too large to convert to size_t");
       return (size_t)-1;
   }
   return (size_t)val;
}


#endif /* Py_PYTHON_H */
