packages/pyglGA/scripts/basicTriangle.py
def init():
    """ 
    Initialises an SDL2 window with an OpenGL state context

    Parameters:
    None

    Returns:
        gWindow: the SDL2 window
        gContext: the OpenGL context of the gWindow
        gVersionLabel: the OpeGL Version and context info
    """

    if SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) != 0:
        print("SDL could not initialize! SDL Error: ", SDL_GetError())
        raise RuntimeError('SDL could not initialize!')
        exit(1)

    print("\nYay! Initialized SDL successfully in basicTriangle!")
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG)
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE)
    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1)
    SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24)
    SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8)
    SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1)
    SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1)
    SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 16)
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4) # OpenGL 4.1 version
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1)
    
    SDL_SetHint(SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK, b"1")
    SDL_SetHint(SDL_HINT_VIDEO_HIGHDPI_DISABLED, b"1")

    # CREATE WINDOW
    window_title = 'BasicTriangle'
    windowWidth = 1024
    windowHeight = 768
    gWindow = SDL_CreateWindow(window_title.encode(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,windowWidth, windowHeight, SDL_WINDOW_OPENGL)

    if gWindow is None:
        print("Window could not be created! SDL Error: ", SDL_GetError())
        raise RuntimeError('Failed to create SDL window')
        #exit(1)

    print("Yay! Created window successfully in basicTriangle!")
    gContext = SDL_GL_CreateContext(gWindow)
    print("Yay! Created OpenGL context successfully in basicTriangle!\n\n")
    
    if gContext is None:
        print("OpenGL context could not be created! SDL Error: ", SDL_GetError())
        raise RuntimeError('OpenGL context could not be created!')

    SDL_GL_MakeCurrent(gWindow, gContext)

    if SDL_GL_SetSwapInterval(1) < 0:
        print("Warning: Unable to set VSync! SDL Error: " + SDL_GetError())
        raise RuntimeError('Unable to set VSync! SDL Error:!')

    gVersionLabel = 'OpenGL +', glGetString(GL_VERSION).decode() + ', GLSL', glGetString(GL_SHADING_LANGUAGE_VERSION).decode() + ', Renderer', glGetString(GL_RENDERER).decode()
    print(gVersionLabel)

    return gWindow, gContext, str(gVersionLabel)
 
    Initialises an SDL2 window with an OpenGL state context

    Parameters:
    None

    Returns:
        gWindow: the SDL2 window
        gContext: the OpenGL context of the gWindow
        gVersionLabel: the OpeGL Version and context info
    
Initialises an SDL2 window with an OpenGL state context
Parameters:
None

the SDL2 window
gContext: the OpenGL context of the gWindow
gVersionLabel: the OpeGL Version and context info
Initialises an SDL2 window with an OpenGL state context Parameters : None the SDL2 window gContext : the OpenGL context of the gWindow gVersionLabel : the OpeGL Version and context info
def init():
    if SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) != 0:
        print("SDL could not initialize! SDL Error: ", SDL_GetError())
        raise RuntimeError('SDL could not initialize!')
        exit(1)
    print("\nYay! Initialized SDL successfully in basicTriangle!")
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG)
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE)
    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1)
    SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24)
    SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8)
    SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1)
    SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1)
    SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 16)
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4) 
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1)
    SDL_SetHint(SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK, b"1")
    SDL_SetHint(SDL_HINT_VIDEO_HIGHDPI_DISABLED, b"1")
    window_title = 'BasicTriangle'
    windowWidth = 1024
    windowHeight = 768
    gWindow = SDL_CreateWindow(window_title.encode(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,windowWidth, windowHeight, SDL_WINDOW_OPENGL)
    if gWindow is None:
        print("Window could not be created! SDL Error: ", SDL_GetError())
        raise RuntimeError('Failed to create SDL window')
    print("Yay! Created window successfully in basicTriangle!")
    gContext = SDL_GL_CreateContext(gWindow)
    print("Yay! Created OpenGL context successfully in basicTriangle!\n\n")
    if gContext is None:
        print("OpenGL context could not be created! SDL Error: ", SDL_GetError())
        raise RuntimeError('OpenGL context could not be created!')
    SDL_GL_MakeCurrent(gWindow, gContext)
    if SDL_GL_SetSwapInterval(1) < 0:
        print("Warning: Unable to set VSync! SDL Error: " + SDL_GetError())
        raise RuntimeError('Unable to set VSync! SDL Error:!')
    gVersionLabel = 'OpenGL +', glGetString(GL_VERSION).decode() + ', GLSL', glGetString(GL_SHADING_LANGUAGE_VERSION).decode() + ', Renderer', glGetString(GL_RENDERER).decode()
    print(gVersionLabel)
    return gWindow, gContext, str(gVersionLabel)
def init ( ) : if SDL_Init ( SDL_INIT_VIDEO | SDL_INIT_TIMER ) != 0 : print ( "SDL could not initialize! SDL Error: " , SDL_GetError ( ) ) raise RuntimeError ( 'SDL could not initialize!' ) exit ( 1 ) print ( "\nYay! Initialized SDL successfully in basicTriangle!" ) SDL_GL_SetAttribute ( SDL_GL_CONTEXT_FLAGS , SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG ) SDL_GL_SetAttribute ( SDL_GL_CONTEXT_PROFILE_MASK , SDL_GL_CONTEXT_PROFILE_CORE ) SDL_GL_SetAttribute ( SDL_GL_DOUBLEBUFFER , 1 ) SDL_GL_SetAttribute ( SDL_GL_DEPTH_SIZE , 24 ) SDL_GL_SetAttribute ( SDL_GL_STENCIL_SIZE , 8 ) SDL_GL_SetAttribute ( SDL_GL_ACCELERATED_VISUAL , 1 ) SDL_GL_SetAttribute ( SDL_GL_MULTISAMPLEBUFFERS , 1 ) SDL_GL_SetAttribute ( SDL_GL_MULTISAMPLESAMPLES , 16 ) SDL_GL_SetAttribute ( SDL_GL_CONTEXT_MAJOR_VERSION , 4 ) SDL_GL_SetAttribute ( SDL_GL_CONTEXT_MINOR_VERSION , 1 ) SDL_SetHint ( SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK , b"1" ) SDL_SetHint ( SDL_HINT_VIDEO_HIGHDPI_DISABLED , b"1" ) window_title = 'BasicTriangle' windowWidth = 1024 windowHeight = 768 gWindow = SDL_CreateWindow ( window_title . encode ( ) , SDL_WINDOWPOS_CENTERED , SDL_WINDOWPOS_CENTERED , windowWidth , windowHeight , SDL_WINDOW_OPENGL ) if gWindow is None : print ( "Window could not be created! SDL Error: " , SDL_GetError ( ) ) raise RuntimeError ( 'Failed to create SDL window' ) print ( "Yay! Created window successfully in basicTriangle!" ) gContext = SDL_GL_CreateContext ( gWindow ) print ( "Yay! Created OpenGL context successfully in basicTriangle!\n\n" ) if gContext is None : print ( "OpenGL context could not be created! SDL Error: " , SDL_GetError ( ) ) raise RuntimeError ( 'OpenGL context could not be created!' ) SDL_GL_MakeCurrent ( gWindow , gContext ) if SDL_GL_SetSwapInterval ( 1 ) < 0 : print ( "Warning: Unable to set VSync! SDL Error: " + SDL_GetError ( ) ) raise RuntimeError ( 'Unable to set VSync! SDL Error:!' ) gVersionLabel = 'OpenGL +' , glGetString ( GL_VERSION ) . decode ( ) + ', GLSL' , glGetString ( GL_SHADING_LANGUAGE_VERSION ) . decode ( ) + ', Renderer' , glGetString ( GL_RENDERER ) . decode ( ) print ( gVersionLabel ) return gWindow , gContext , str ( gVersionLabel )
Initialises an SDL2 window with an OpenGL state context
Parameters:
None
Initialises an SDL2 window with an OpenGL state context Parameters : None
""" 
    Initialises an SDL2 window with an OpenGL state context

    Parameters:
    None

    Returns:
        gWindow: the SDL2 window
        gContext: the OpenGL context of the gWindow
        gVersionLabel: the OpeGL Version and context info
    """ # OpenGL 4.1 version # CREATE WINDOW #exit(1)