Skip to content

Failed to create GL context on mac when attempting to initalize #239

@maxall41

Description

@maxall41

Hello,
Im trying to use SDL2_gpu to draw a few primitive shapes but I'm running into some issues. Mainly that I just get a blank screen with the draw color and none of the shapes. I turned on debugging with GPU_SetDebugLevel(GPU_DEBUG_LEVEL_MAX); and I get:

GPU_CreateTargetFromWindow: BACKEND ERROR - Failed to create GL context.
GPU_InitRendererByID: BACKEND ERROR - Renderer OpenGL 4 failed to initialize properly

I think this has something todo with me needing to add:

find_package(OpenGL REQUIRED)
include_directories( ${OPENGL_INCLUDE_DIRS}  ${GLUT_INCLUDE_DIRS} )
target_link_libraries(flame_engine ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} )

to my cmake file to avoid getting a bunch of symbol errors about OpenGL not being found. Does anybody know what might be causing this?
Full CMake:

cmake_minimum_required(VERSION 3.22)
project(flame_engine)

set(CMAKE_CXX_STANDARD 14)

link_directories(/opt/homebrew/Cellar/sdl2/2.0.22/lib/)

add_executable(flame_engine main.cpp)

find_package(OpenGL REQUIRED)
include_directories( ${OPENGL_INCLUDE_DIRS}  ${GLUT_INCLUDE_DIRS} )
target_link_libraries(flame_engine ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} )

target_link_libraries(flame_engine SDL2)
target_link_libraries(flame_engine SDL2_gpu)

target_include_directories(flame_engine
        PRIVATE
        /opt/homebrew/Cellar/sdl2/2.0.22/include/)

System:
macOS Monterey
MacBook Pro 14 inch (M1 Max)
With 32GB of memory

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions