An demo of how use opengl with juce, anyone want to do it together?

I want to port the tutorial on to juce framework.
Current I have done eight tutorial as follows .

pull Request is welcome!

Tutorial triangle And Shader

Tutorial multiTexture

Tutorial Coordinate-Systems







Hi @bzhkl,
Very nice idea :smiley:
Unfortunately I can not contribute now, but I will keep my fingers crossed for this project to grow.

Thank you for sharing.

Awesome idea, too bad I’m on a Mac :laughing:

I’ve update the code, so now we can open openglWithJuce.xcodeproj, compile and run !
But unfortunately , there is some bug with the code or with my graphic card,
when i call glBindVertexArray, it throws GL_INVALID_OPERATION with error code 1282.
I assume it‘s my graphic card bug.
Anyone want help to test, thanks!

I have some OpenGL examples on my GitHub. Maybe they help. The basic one is using the juce::OpenGLContext. The other two are using glew

Thank you for the code , and I can make it running after add the code openGLContext.setOpenGLVersionRequired(juce::OpenGLContext::openGL3_2);
but behave differently from win version as follow image, I’ll look into it.

Hi @bzhkl,

First of all I want to say that you inspired me to learn OpenGL :slight_smile: Thanks.

I found some issue with tutorial 3 and 4 on my macOs.

I digged a bit and I found that this is a problem with translating shaders from version 2 to version 3.
I will create pull request and there describe what I found in more details.

On my windows machine everything works OK.

@ mateusz
Thank you very much , looking forward it , and I will look into it too!

I think it’s tricky.
because shader is compiled successfully and without any error .
And the output info shows that Current glsl version is 4.10 and should support in and out keyword.
I also checked the glversion in initialise function by
AlertWindow::showMessageBox(AlertWindow::AlertIconType::InfoIcon, "glversion", (char*)glGetString(GL_VERSION));
also is 4.10.
I also tried modify juce code
#define JUCE_GLSL_VERSION "#version 150"
#define JUCE_GLSL_VERSION "#version 410"
then shader can compile and link without any error , but the demo cube still can’t show .
Anyway your pull request works . I’ll merge and Now I can move forward on my mac .

I finally figure out what’s the fundamental problem. It’s basically how @ mateusz does.
Let’s say tutorial 3. we just change the vertex shader from

attribute vec3  aPos;
attribute vec3  aColor;
attribute vec2  aTexCoord;


layout (location=0) in vec3  aPos;
layout (location=1) in vec3  aColor;
layout (location=2) in vec2  aTexCoord;

Which is how original tutorial write. It’s my bad.(originally I want to support old graphic card, but it seems not work! so I want to use glsl version 330 instead)

then We need to specify the glsl version we want to use in shader .
like #version 330 core

I think juce team should give us a chance to specify what’s
GLSL version we want to use , then problem solved!



#define JUCE_GLSL_VERSION "#version 300 es"


#define JUCE_GLSL_VERSION "#version 150"





we want to customise
#define JUCE_GLSL_VERSION "#version 150" this line to
#define JUCE_GLSL_VERSION "#version 330 core" as we need.

Sorry, I did not described what I have changed in translateVertexShaderToV3 and translateFragmentShaderToV3 methods.

I am glad I helped. :slight_smile:

I made a JUCE OpenGL setup tutorial for rendering basic interactive 3D objects including a triangle, pyramid, and cube. It’s a code-along tutorial video with available source code and some utility classes.

You can access the tutorial for free or pay what you want via Gumroad:

I thought this might be helpful to those in this thread.