Can't get simple GLSL shaders example working

I’ve been trying all day to get a simple shaders example working. I’m now stuck on a version issue (version ‘130’ not supported), with the log and code below.

Whatever I change the version to, I get the same message, and when I leave the version out I get a message saying ‘in’ isn’t support (suggesting this is <1.3?). I’m using a Mac (MBP late '13, which apparently supports OpenGL 4.1) running Catalina.

Any help resolving this would be greatly appreciated!

Log

...
:loader: Model /usr/local/lib/python3.7/site-packages/panda3d/etc/../models/box.egg found in disk cache.
:shader: Preprocessing shader file: /Users/michael/mit/sli/scene/scene/glsl_simple.vert
:shader: Preprocessing shader file: /Users/michael/mit/sli/scene/scene/glsl_simple.frag
:display:gsg:glgsg(error): An error occurred while compiling GLSL vertex shader /Users/michael/mit/sli/scene/scene/glsl_simple.vert:
ERROR: /Users/michael/mit/sli/scene/scene/glsl_simple.vert:1: '' : version '130' is not supported
:display:gsg:glgsg(error): An error occurred while compiling GLSL fragment shader /Users/michael/mit/sli/scene/scene/glsl_simple.frag:
ERROR: /Users/michael/mit/sli/scene/scene/glsl_simple.frag:1: '' : version '130' is not supported

Vertex shader

#version 130

// Uniform inputs
uniform mat4 p3d_ModelViewProjectionMatrix;

// Vertex inputs
in vec4 p3d_Vertex;

void main() {
gl_Position = p3d_ModelViewProjectionMatrix * p3d_Vertex;
}

Fragment shader

#version 130

void main() {
  gl_FragColor = vec4(0, 0, 0, 1);
}

Script

import os
import numpy as np
from direct.showbase.ShowBase import ShowBase
from panda3d.core import FrameBufferProperties, WindowProperties
from panda3d.core import GraphicsOutput, GraphicsPipe
from panda3d.core import Texture, PerspectiveLens, Shader
from panda3d.core import ConfigVariableString, ConfigVariableBool, Filename
import matplotlib.pyplot as plt


ConfigVariableString('background-color', '1.0 1.0 1.0 0.0')  # sets background to white


class SceneSimulator(ShowBase):

  def __init__(self):
    """Create an empty scene with no cameras."""
    ShowBase.__init__(self)

    # set up texture and graphics buffer
    window_props = WindowProperties.size(1920, 1080)
    frame_buffer_props = FrameBufferProperties()
    buffer = self.graphicsEngine.make_output(self.pipe,
      f'Buffer',
      -2,
      frame_buffer_props,
      window_props,
      GraphicsPipe.BFRefuseWindow,    # don't open a window
      self.win.getGsg(),
      self.win
    )
    texture = Texture()
    buffer.add_render_texture(texture, GraphicsOutput.RTMCopyRam)
    self.buffer = buffer

    # place a box in the scene
    x, y, side_length = 0, 0, 1
    box = self.loader.loadModel("models/box")
    box.reparentTo(self.render)
    box.setScale(side_length)
    box.setPos(x - side_length / 2, y - side_length / 2, 0)

    # set up camera
    lens = PerspectiveLens()
    lens.set_film_size(1920, 1080)
    lens.set_fov(45, 30)
    pos = (0, 6, 4)
    camera = self.make_camera(buffer, lens=lens, camName=f'Camera')
    camera.reparent_to(self.render)
    camera.set_pos(*pos)
    camera.look_at(box)
    self.camera = camera

    # load shaders
    vert_path = '/Users/michael/mit/sli/scene/scene/glsl_simple.vert'
    frag_path = '/Users/michael/mit/sli/scene/scene/glsl_simple.frag'
    custom_shader = Shader.load(Shader.SL_GLSL, vertex=vert_path, fragment=frag_path)

    box.set_shader(custom_shader)

  def render_image(self) -> np.ndarray:
    self.graphics_engine.render_frame()
    texture = self.buffer.get_texture()
    data = texture.get_ram_image()
    frame = np.frombuffer(data, np.uint8)
    frame.shape = (texture.getYSize(), texture.getXSize(), texture.getNumComponents())
    frame = np.flipud(frame)
    return frame


if __name__ == '__main__':
  simulator = SceneSimulator()
  image = simulator.render_image()
  plt.imshow(image)
  plt.show()

Add this to your Config.prc file:
gl-version 3 2

I get the same error (thought it seems to also get a little further). I’ve also printed the config variable manager, which I noticed has

gl-version  not used (referenced in /usr/local/lib/python3.7/site-packages/panda3d/etc/Config.prc)

I’m not sure why that’s not being used. Do you have any idea?

Log

alpha-bits int
  current value = 0  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Config.prc)
  default value = 0

audio-library-name string
  current value = p3fmod_audio  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Config.prc)
  default value = null

basic-shaders-only bool
  current value = #f  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Config.prc)
  default value = 0

color-bits int
  current value = 1 1 1  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Config.prc)
  default value = 

cull-bin list
  current value:
    gui-popup 60 unsorted  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)

default-directnotify-level string
  current value = warning  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Config.prc)
  default value = info

default-model-extension string
  current value = .egg  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)
  default value = 

depth-bits int
  current value = 1  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Config.prc)
  default value = 0

egg-object-type-barrier  not used (referenced in /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)

egg-object-type-binary  not used (referenced in /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)

egg-object-type-bubble  not used (referenced in /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)

egg-object-type-dcs  not used (referenced in /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)

egg-object-type-direct-widget  not used (referenced in /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)

egg-object-type-dual  not used (referenced in /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)

egg-object-type-dupefloor  not used (referenced in /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)

egg-object-type-floor  not used (referenced in /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)

egg-object-type-ghost  not used (referenced in /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)

egg-object-type-glass  not used (referenced in /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)

egg-object-type-glow  not used (referenced in /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)

egg-object-type-indexed  not used (referenced in /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)

egg-object-type-invsphere  not used (referenced in /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)

egg-object-type-model  not used (referenced in /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)

egg-object-type-notouch  not used (referenced in /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)

egg-object-type-polylight  not used (referenced in /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)

egg-object-type-portal  not used (referenced in /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)

egg-object-type-seq10  not used (referenced in /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)

egg-object-type-seq12  not used (referenced in /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)

egg-object-type-seq2  not used (referenced in /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)

egg-object-type-seq24  not used (referenced in /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)

egg-object-type-seq4  not used (referenced in /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)

egg-object-type-seq6  not used (referenced in /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)

egg-object-type-seq8  not used (referenced in /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)

egg-object-type-sphere  not used (referenced in /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)

egg-object-type-trigger  not used (referenced in /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)

egg-object-type-trigger-sphere  not used (referenced in /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)

egg-object-type-tube  not used (referenced in /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)

framebuffer-hardware bool
  current value = #t  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Config.prc)
  default value = 1

framebuffer-software bool
  current value = #f  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Config.prc)
  default value = 0

fullscreen bool
  current value = #f  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Config.prc)
  default value = 0

gl-version  not used (referenced in /usr/local/lib/python3.7/site-packages/panda3d/etc/Config.prc)

hardware-animated-vertices bool
  current value = #f  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Config.prc)
  default value = 0

load-audio-type list
  current value:
    * p3ffmpeg  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)

load-display  not used (referenced in /usr/local/lib/python3.7/site-packages/panda3d/etc/Config.prc)

load-file-type list
  current value:
    egg pandaegg  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)
    p3assimp  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)
    p3ptloader  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)

load-video-type list
  current value:
    * p3ffmpeg  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)

model-cache-dir  not used (referenced in /usr/local/lib/python3.7/site-packages/panda3d/etc/Config.prc)

model-cache-textures  not used (referenced in /usr/local/lib/python3.7/site-packages/panda3d/etc/Config.prc)

model-path  not used (referenced in /usr/local/lib/python3.7/site-packages/panda3d/etc/Config.prc)

multisamples int
  current value = 0  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Config.prc)
  default value = 0

notify-level enum
  current value = info  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Config.prc)
  default value = unspecified

show-frame-rate-meter  not used (referenced in /usr/local/lib/python3.7/site-packages/panda3d/etc/Config.prc)

stencil-bits int
  current value = 0  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Config.prc)
  default value = 0

use-movietexture  not used (referenced in /usr/local/lib/python3.7/site-packages/panda3d/etc/Config.prc)

want-directtools  not used (referenced in /usr/local/lib/python3.7/site-packages/panda3d/etc/Config.prc)

want-pstats  not used (referenced in /usr/local/lib/python3.7/site-packages/panda3d/etc/Config.prc)

want-tk  not used (referenced in /usr/local/lib/python3.7/site-packages/panda3d/etc/Config.prc)

win-origin int
  current value = -2 -2  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Config.prc)
  default value = 

win-size int
  current value = 800 600  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Config.prc)
  default value = 800 600


:display: loading display module: libpandagl.dylib
Known pipe types:
  CocoaGraphicsPipe
(all display modules loaded.)
:display: Created output of type CocoaGraphicsWindow
:display: Created output of type GLGraphicsBuffer
:loader: loading file type module: p3assimp
:loader: loading file type module: p3ptloader
:gobj: Loading texture /usr/local/lib/python3.7/site-packages/panda3d/models/maps/noise.rgb
:loader: Model /usr/local/lib/python3.7/site-packages/panda3d/etc/../models/box.egg found in disk cache.
:shader: Preprocessing shader file: /Users/michael/mit/sli/scene/scene/glsl_simple.vert
:shader: Preprocessing shader file: /Users/michael/mit/sli/scene/scene/glsl_simple.frag
:display:gsg:glgsg(error): An error occurred while compiling GLSL vertex shader /Users/michael/mit/sli/scene/scene/glsl_simple.vert:
ERROR: /Users/michael/mit/sli/scene/scene/glsl_simple.vert:1: '' :  version '130' is not supported
ERROR: /Users/michael/mit/sli/scene/scene/glsl_simple.vert:2: '' :  #version required and missing.
:display:gsg:glgsg(error): An error occurred while compiling GLSL fragment shader /Users/michael/mit/sli/scene/scene/glsl_simple.frag:
ERROR: /Users/michael/mit/sli/scene/scene/glsl_simple.frag:1: '' :  version '130' is not supported
ERROR: /Users/michael/mit/sli/scene/scene/glsl_simple.frag:2: '' :  #version required and missing.
:display:gsg:glgsg(warning): Shader created-shader produced the following warnings:
WARNING: Could not find vertex shader attribute 'vertex' to match BindAttributeLocation request.
WARNING: Could not find vertex shader attribute 'p3d_Normal' to match BindAttributeLocation request.
WARNING: Could not find fragment shader output 'p3d_FragData' to match FragDataBinding request.

:display: Closing CocoaGraphicsWindow

gl-version needs to be set before the window is opened. Adding it to your code after starting ShowBase or after importing DirectStart would not work.

Are you sure you have it set correctly? It needs to be set “gl-version 3 2” with spaces exactly as shown. The message you showed seems not to include the value, which is odd and suggests it failed to parse.

Which version of Panda3D?

Right, I got this after closing the window, editing Config.prc and then running the script (which opens a new window). I was printing the config variable manager before I created a ShowBase, if I print it after I get the value for gl-version (see log).

My version is

panda3d                       1.10.4.1

Log

alpha-bits int
  current value = 0  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Config.prc)
  default value = 0

audio-library-name string
  current value = p3fmod_audio  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Config.prc)
  default value = null

basic-shaders-only bool
  current value = #f  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Config.prc)
  default value = 0

color-bits int
  current value = 1 1 1  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Config.prc)
  default value = 

cull-bin list
  current value:
    gui-popup 60 unsorted  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)

default-directnotify-level string
  current value = warning  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Config.prc)
  default value = info

default-model-extension string
  current value = .egg  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)
  default value = 

depth-bits int
  current value = 1  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Config.prc)
  default value = 0

egg-object-type-barrier string
  current value = <Collide> { Polyset descend }  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)
  default value = 

egg-object-type-binary string
  current value = <Scalar> alpha { binary }  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)
  default value = 

egg-object-type-bubble string
  current value = <Collide> { Sphere keep descend }  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)
  default value = 

egg-object-type-dcs string
  current value = <DCS> { 1 }  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)
  default value = 

egg-object-type-direct-widget string
  current value = <Scalar> collide-mask { 0x80000000 } <Collide> { Polyset descend }  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)
  default value = 

egg-object-type-dual string
  current value = <Scalar> alpha { dual }  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)
  default value = 

egg-object-type-dupefloor string
  current value = <Collide> { Polyset keep descend level }  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)
  default value = 

egg-object-type-floor string
  current value = <Collide> { Polyset descend level }  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)
  default value = 

egg-object-type-ghost string
  current value = <Scalar> collide-mask { 0 }  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)
  default value = 

egg-object-type-glass string
  current value = <Scalar> alpha { blend_no_occlude }  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)
  default value = 

egg-object-type-glow string
  current value = <Scalar> blend { add }  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)
  default value = 

egg-object-type-indexed string
  current value = <Scalar> indexed { 1 }  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)
  default value = 

egg-object-type-invsphere string
  current value = <Collide> { InvSphere descend }  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)
  default value = 

egg-object-type-model string
  current value = <Model> { 1 }  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)
  default value = 

egg-object-type-notouch string
  current value = <DCS> { no_touch }  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)
  default value = 

egg-object-type-polylight string
  current value = <Scalar> polylight { 1 }  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)
  default value = 

egg-object-type-portal string
  current value = <Scalar> portal { 1 }  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)
  default value = 

egg-object-type-seq10 string
  current value = <Switch> { 1 } <Scalar> fps { 10 }  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)
  default value = 

egg-object-type-seq12 string
  current value = <Switch> { 1 } <Scalar> fps { 12 }  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)
  default value = 

egg-object-type-seq2 string
  current value = <Switch> { 1 } <Scalar>  fps { 2 }  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)
  default value = 

egg-object-type-seq24 string
  current value = <Switch> { 1 } <Scalar> fps { 24 }  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)
  default value = 

egg-object-type-seq4 string
  current value = <Switch> { 1 } <Scalar>  fps { 4 }  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)
  default value = 

egg-object-type-seq6 string
  current value = <Switch> { 1 } <Scalar>  fps { 6 }  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)
  default value = 

egg-object-type-seq8 string
  current value = <Switch> { 1 } <Scalar> fps { 8 }  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)
  default value = 

egg-object-type-sphere string
  current value = <Collide> { Sphere descend }  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)
  default value = 

egg-object-type-trigger string
  current value = <Collide> { Polyset descend intangible }  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)
  default value = 

egg-object-type-trigger-sphere string
  current value = <Collide> { Sphere descend intangible }  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)
  default value = 

egg-object-type-tube string
  current value = <Collide> { Tube descend }  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)
  default value = 

framebuffer-hardware bool
  current value = #t  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Config.prc)
  default value = 1

framebuffer-software bool
  current value = #f  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Config.prc)
  default value = 0

fullscreen bool
  current value = #f  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Config.prc)
  default value = 0

gl-version int
  current value = 3 2  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Config.prc)
  default value = 

hardware-animated-vertices bool
  current value = #f  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Config.prc)
  default value = 0

load-audio-type list
  current value:
    * p3ffmpeg  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)

load-display string
  current value = pandagl  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Config.prc)
  default value = *

load-file-type list
  current value:
    egg pandaegg  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)
    p3assimp  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)
    p3ptloader  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)

load-video-type list
  current value:
    * p3ffmpeg  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Confauto.prc)

model-cache-dir filename
  current value = $HOME/Library/Caches/Panda3D-1.10  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Config.prc)
  default value = 

model-cache-textures bool
  current value = #f  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Config.prc)
  default value = 1

model-path search-path
  current value:
    $MAIN_DIR  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Config.prc)
    $THIS_PRC_DIR/..  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Config.prc)
    $THIS_PRC_DIR/../models  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Config.prc)

multisamples int
  current value = 0  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Config.prc)
  default value = 0

notify-level enum
  current value = info  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Config.prc)
  default value = unspecified

show-frame-rate-meter bool
  current value = #f  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Config.prc)
  default value = 0

stencil-bits int
  current value = 0  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Config.prc)
  default value = 0

use-movietexture  not used (referenced in /usr/local/lib/python3.7/site-packages/panda3d/etc/Config.prc)

want-directtools bool
  current value = #f  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Config.prc)
  default value = 0

want-pstats bool
  current value = #f  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Config.prc)
  default value = 0

want-tk bool
  current value = #f  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Config.prc)
  default value = 0

win-origin int
  current value = -2 -2  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Config.prc)
  default value = 

win-size int
  current value = 800 600  (from /usr/local/lib/python3.7/site-packages/panda3d/etc/Config.prc)
  default value = 800 600


:display:gsg:glgsg(error): An error occurred while compiling GLSL vertex shader /Users/michael/mit/sli/scene/scene/glsl_simple.vert:
ERROR: /Users/michael/mit/sli/scene/scene/glsl_simple.vert:1: '' :  version '130' is not supported
ERROR: /Users/michael/mit/sli/scene/scene/glsl_simple.vert:2: '' :  #version required and missing.
:display:gsg:glgsg(error): An error occurred while compiling GLSL fragment shader /Users/michael/mit/sli/scene/scene/glsl_simple.frag:
ERROR: /Users/michael/mit/sli/scene/scene/glsl_simple.frag:1: '' :  version '130' is not supported
ERROR: /Users/michael/mit/sli/scene/scene/glsl_simple.frag:2: '' :  #version required and missing.
:display:gsg:glgsg(warning): Shader created-shader produced the following warnings:
WARNING: Could not find vertex shader attribute 'vertex' to match BindAttributeLocation request.
WARNING: Could not find vertex shader attribute 'p3d_Normal' to match BindAttributeLocation request.
WARNING: Could not find fragment shader output 'p3d_FragData' to match FragDataBinding request.

I’ve also included my full Config.prc (GL version is the last line).

Config.prc

/u/l/l/p/s/p/etc ❯❯❯ cat Config.prc
###########################################################
###                                                     ###
### Panda3D Configuration File -  User-Editable Portion ###
###                                                     ###
###########################################################

# Uncomment one of the following lines to choose whether you should
# run using OpenGL, DirectX or TinyPanda (software) rendering.
# There can only be one load-display line, but you can use
# multiple aux-display lines to specify fallback modules.
# When the module indicated by load-display fails, it will fall
# back to the next display module indicated by aux-display,
# when that fails, the next aux-display line, and so on.

load-display pandagl
#load-display pandadx9
#load-display pandagles
#load-display p3tinydisplay

# These control the placement and size of the default rendering window.
# A value of -2 for the origin means to center it on the screen,
# while -1 lets the window manager choose the position.

win-origin -2 -2
win-size 800 600

# Uncomment this line if you want to run Panda fullscreen instead of
# in a window.

fullscreen #f

# The framebuffer-hardware flag forces it to use an accelerated driver.
# The framebuffer-software flag forces it to use a software renderer.
# If you set both to false, it will use whatever's available.

framebuffer-hardware #t
framebuffer-software #f

# These set the minimum requirements for the framebuffer.
# A value of 1 means: get as many bits as possible,
# consistent with the other framebuffer requirements.

depth-bits 1
color-bits 1 1 1
alpha-bits 0
stencil-bits 0
multisamples 0

# These control the amount of output Panda gives for some various
# categories.  The severity levels, in order, are "spam", "debug",
# "info", "warning", and "error"; the default is "info".  Uncomment
# one (or define a new one for the particular category you wish to
# change) to control this output.

notify-level info
default-directnotify-level warning

# These specify where model files may be loaded from.  You probably
# want to set this to a sensible path for yourself.  $THIS_PRC_DIR is
# a special variable that indicates the same directory as this
# particular Config.prc file.

model-path    $MAIN_DIR
model-path    $THIS_PRC_DIR/..
model-path    $THIS_PRC_DIR/../models

# This enable the automatic creation of a TK window when running
# Direct.

want-directtools  #f
want-tk           #f

# Enable/disable performance profiling tool and frame-rate meter

want-pstats            #f
show-frame-rate-meter  #f

# Enable audio using the OpenAL audio library by default:

audio-library-name p3fmod_audio

# Enable the use of the new movietexture class.

use-movietexture #t

# The new version of panda supports hardware vertex animation, but it's not quite ready

hardware-animated-vertices #f

# Enable the model-cache, but only for models, not textures.

model-cache-dir $HOME/Library/Caches/Panda3D-1.10
model-cache-textures #f

# This option specifies the default profiles for Cg shaders.
# Setting it to #t makes them arbvp1 and arbfp1, since these
# seem to be most reliable. Setting it to #f makes Panda use
# the latest profile available.

basic-shaders-only #f

gl-version 3 2

So, I’ve confirmed that before the call to ShowBase.__init__(self) (in the constructor of my SceneSimulator, GL version is not set, and then afterwards it is.

A window is opened as a part of the call to ShowBase.__init__(self), is it possible that the GL version is not set by then?

Forcing GL Version before I call ShowBase.__init__(self) (by running ConfigVariableString('gl-version', '3 2')) does not fix the problem.

It’s not a string variable; your declaring it anew as a string might just confuse Panda.

Use:

loadPrcFileData("", "gl-version 3 2")

Before constructing ShowBase.

This really is the right fix, so it ought to work.

I also remembered, suddenly, that Apple’s drivers do not support GLSL 130, even in 3.2 mode. You need at least 150.

I remembered reading that Macs freak out about 130, so I tried 150 (combined with the Config.prc addition).

I also had to change the fragment shader to be

#version 150

out vec4 fragColor;

void main() {
  fragColor = vec4(0, 0, 0, 1);
}

since gl_FragColor was deprecated.

It’s now working (see the black box in the attached image).

In summary, the solution was

  1. Add gl-version 3 2 to Config.prc
  2. Use version 150 instead of 130
  3. Update fragment shader to no longer use gl_FragColor

Thanks @rdb for the help!

Just saw this after I posted. Yep – this was the solution. Thank you very much.