OpenGL functions like glBegin / glVertex3f are not recognized in JUCE/Visual Studio project

Hi everyone,

I’ve been stuck for days trying to get basic OpenGL rendering (using classic glBegin /glVertex3f style) to work inside a JUCE project on Windows using Visual Studio. No matter what I try, ( i am trying with chat, i donw kknow C++, actuallly i dont know any other language ) I’m constantly getting errors like:

‘glLineWidth’: identifier not found

‘glBegin’: identifier not found

‘glVertex3f’: identifier not found

‘GL_LINES’: undeclared identifier

‘glColor3f’: identifier not found

‘glEnd’: identifier not found

Setup:

  • Windows 10 (x64)
  • Visual Studio 2022 (Community Edition, latest update)
  • JUCE 7 (cloned directly from GitHub)
  • Windows SDK 10.0.19041.0 installed
  • "opengl32.lib" is properly linked
  • I’ve added <Windows.h> and <GL/gl.h> with #pragma comment(lib, "opengl32.lib")
  • Everything compiles in a basic Console Application (so OpenGL headers and libs are available)

In JUCE project, here’s what I’ve tried:

#include <JuceHeader.h>

#define WIN32_LEAN_AND_MEAN

#define NOMINMAX

#include <windows.h>

#include <GL/gl.h>

#pragma comment(lib, “opengl32.lib”)

Made sure Projuicer paths are correct:

  • Global paths point to valid JUCE and modules directories
  • juce_opengl module is added

opengl32.lib is correctly linked:

  • Tried adding it via #pragma comment(lib, ...)
  • Also added manually in Visual Studio’s project properties under Linker > Input > Additional Dependencies

SDKs:

  • Tried installing/uninstalling multiple versions of Windows SDK
  • Removed Windows 11 SDKs and only kept 10.0.19041.0
  • Validated that <gl.h> and opengl32.lib exist in C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um\GL and Lib\x64

Reinstalled Visual Studio from scratch
Re-downloaded JUCE from GitHub
Rebuilt the Projucer project from zero
Tried building with VS2019 Toolset
Tried changing platform target (x86, x64)
Tried building only a minimal OpenGL test inside JUCE — same result.

What’s still happening:

  • #include <GL/gl.h> gives no compile error itself
  • But none of the GL functions are recognized (symbols undefined or undeclared)
  • JUCE builds fine otherwise; it’s only OpenGL functions that fail

I’m seriously out of ideas at this point. I donw know C++ chat helps me so. Has anyone managed to get legacy-style OpenGL (non-shader) rendering working inside a JUCE component?

Are there any specific compiler/linker settings that I’m missing? Or something in JUCE that prevents those raw OpenGL calls?

Any help is greatly appreciated :folded_hands:

Thanks in advance!

You are linking two different open gl libraries, your own one and the juce one, they will probably be conflicting. You want to include <juce_opengl/juce_opengl.h>, attach an opengl renderer to your class and use the name space ::juce::gl. Also some of those functions are deprecated on mac os(if you’re worried about cross platform builds). Other than that I suggest not relying on chat gpt and reading the juce documentation - save yourself some time

1 Like

Yeah everything joeloftus said, plus (and I’m sure you’ve heard this a thousand times already) you really shouldn’t be writing a new project with legacy OpenGL these days. If this is just for education or fun then it’s fine, but do be aware that immediate mode OpenGL has pretty much nothing in common with modern graphics APIs

1 Like

also cool profile picture

1 Like