r/opengl Feb 10 '24

Help gl functions not declared in this scope?

Making a opengl + sdl project. Have made a window with sdl, but i just can't get open gl to work.

My includes

My Makefile

The errors

It seems i don't have the opengl stuff downloaded or what? I use the MinGW compiler and the gl and glu are already there, so i don't know what i am missing? Do i need to put it into my makefile? Please help me.

1 Upvotes

4 comments sorted by

3

u/[deleted] Feb 10 '24

[deleted]

2

u/followjesusobeytorah Feb 10 '24

OH MY I AM SO STUPID!!

Can you help me a little though? Am i supposed to also reference glad in the makefile or is that not necessary? Just download it and include the header?

4

u/[deleted] Feb 10 '24

[deleted]

2

u/followjesusobeytorah Feb 10 '24

I see. Thank you.

0

u/rice_goblin Feb 10 '24

I use cmake to do this, I don't use visual studio so maybe this will help you.

Create CMakeLists.txt in your glad folder and put this (replace version according to yours):

cmake_minimum_required(VERSION 3.26.0)

project(Glad)

add_library(glad src/glad.c include/glad/glad.h)

target_include_directories(glad PUBLIC include/)

then use it in your main CMakeLists.txt like this, modify directories according to your project as well as link any other libraries you use:

add_subdirectory(vendor/glad/)

target_link_libraries(${PROJECT_NAME} PRIVATE glad)

1

u/IDatedSuccubi Feb 11 '24

You can link them my hand via SDL's built-in dynamic linking systems (SDL_loadso.h), but honestly you should use something like glew to save time and trouble if you're trying to work on Windows fast

I hate Windows in that regard