"""
Centralized OpenGL imports for pyPhotoAlbum.

Provides a single point of import for all OpenGL functions used throughout
the application. This centralizes GL dependency management and provides
graceful handling when OpenGL is not available (e.g., during testing).

Usage:
    from pyPhotoAlbum.gl_imports import glBegin, glEnd, GL_QUADS, GL_AVAILABLE

    if GL_AVAILABLE:
        # Safe to use GL functions
        glBegin(GL_QUADS)
        ...
"""

try:
    from OpenGL.GL import (
        # Drawing primitives
        glBegin,
        glEnd,
        glVertex2f,
        GL_QUADS,
        GL_LINE_LOOP,
        GL_LINE_STRIP,
        GL_LINES,
        GL_TRIANGLE_FAN,
        # Colors
        glColor3f,
        glColor4f,
        # Line state
        glLineWidth,
        glLineStipple,
        GL_LINE_STIPPLE,
        # General state
        glEnable,
        glDisable,
        GL_DEPTH_TEST,
        GL_BLEND,
        GL_SRC_ALPHA,
        GL_ONE_MINUS_SRC_ALPHA,
        glBlendFunc,
        # Textures
        glGenTextures,
        glBindTexture,
        glTexImage2D,
        glTexParameteri,
        glDeleteTextures,
        GL_TEXTURE_2D,
        GL_RGBA,
        GL_UNSIGNED_BYTE,
        GL_TEXTURE_MIN_FILTER,
        GL_TEXTURE_MAG_FILTER,
        GL_LINEAR,
        glTexCoord2f,
        # Matrix operations
        glPushMatrix,
        glPopMatrix,
        glScalef,
        glTranslatef,
        glLoadIdentity,
        glRotatef,
        # Clear operations
        glClear,
        glClearColor,
        glFlush,
        GL_COLOR_BUFFER_BIT,
        GL_DEPTH_BUFFER_BIT,
        # Viewport
        glViewport,
        glMatrixMode,
        glOrtho,
        GL_PROJECTION,
        GL_MODELVIEW,
        # Info/debug
        glGetString,
        GL_VERSION,
    )

    GL_AVAILABLE = True

except ImportError:
    GL_AVAILABLE = False

    # Define dummy functions/constants for when OpenGL is not available
    # This allows the code to be imported without OpenGL for testing
    def _gl_stub(*args, **kwargs):
        pass

    glBegin = glEnd = glVertex2f = _gl_stub
    glColor3f = glColor4f = _gl_stub
    glLineWidth = glLineStipple = _gl_stub
    glEnable = glDisable = glBlendFunc = _gl_stub
    glGenTextures = glBindTexture = glTexImage2D = _gl_stub
    glTexParameteri = glDeleteTextures = glTexCoord2f = _gl_stub
    glPushMatrix = glPopMatrix = glScalef = glTranslatef = _gl_stub
    glLoadIdentity = glRotatef = _gl_stub
    glClear = glClearColor = glFlush = _gl_stub
    glViewport = glMatrixMode = glOrtho = _gl_stub
    glGetString = _gl_stub

    # Constants
    GL_QUADS = GL_LINE_LOOP = GL_LINE_STRIP = GL_LINES = GL_TRIANGLE_FAN = 0
    GL_LINE_STIPPLE = GL_DEPTH_TEST = GL_BLEND = 0
    GL_SRC_ALPHA = GL_ONE_MINUS_SRC_ALPHA = 0
    GL_TEXTURE_2D = GL_RGBA = GL_UNSIGNED_BYTE = 0
    GL_TEXTURE_MIN_FILTER = GL_TEXTURE_MAG_FILTER = GL_LINEAR = 0
    GL_COLOR_BUFFER_BIT = GL_DEPTH_BUFFER_BIT = 0
    GL_PROJECTION = GL_MODELVIEW = 0
    GL_VERSION = 0
