OpenGL 3.3 core rendering on top of SDL2. Builds on sdl2.obl for the window and context; this bundle is the GL side. Compile with -lib sdl2.
Layers, thinnest first: GLWindow (window and context), GL (state), Shader, Mesh, Texture2D, Light, RenderTarget, Material, Frustum, ShadowMap, PointShadow, Overlay, Transform, and Box/Scene. All public, so nothing is capped.
Targets the 3.3 core profile, forward-compatible: the highest common denominator across the desktop platforms Objeck ships, since macOS caps at 4.1 core. GLES-only hardware is out of scope by construction.
See docs/opengl.md for setup, a minimal program, why the calls are coarse-grained, and how to add one.
ShaderSource
Assemble GLSL from lines, adding the version directive and the newlines.
Shader source was being built by appending string literals that each had to end in an explicit \n, an invariant nothing enforced. Drop one and two declarations merge into a line that still compiles; drop one after a // comment and the next statement is silently commented out. Fifty-three lines of that were spread across four programs, each restating "#version 330 core" from memory.
Example
source := ShaderSource->New();
source->Add("layout (location = 0) in vec3 in_position;");
source->Add("uniform mat4 mvp;");
source->Add("void main() { gl_Position = mvp * vec4(in_position, 1.0); }");
vertex := source->Build();Operations
Add #
Append one line, terminated.
method : public : Add(line:String) ~ ShaderSourceParameters
| Name | Type | Description |
|---|---|---|
| line | String | the line, without a trailing newline |
Return
| Type | Description |
|---|---|
| ShaderSource | this, so calls can be chained |
Build #
method : public : Build() ~ StringReturn
| Type | Description |
|---|---|
| String | the assembled source, ready for Shader->New |
New # constructor
Start a GLSL 3.30 core source. The version directive is added for you and must be first, which is the other thing that was being retyped.
New()