### Initialize and Link Shaders in OpenGLAda Source: https://flyx.github.io/OpenGLAda/gl-objects-shaders.html Demonstrates the complete workflow for creating shader objects, loading source files, compiling, and linking them into a program. ```ada declare Vertex_Shader : GL.Objects.Shaders.Shader (Kind => GL.Objects.Shaders.Vertex_Shader); Fragment_Shader : GL.Objects.Shaders.Shader (Kind => GL.Objects.Shaders.Fragment_Shader); Program : GL.Objects.Programs.Program; begin -- initialize objects Vertex_Shader.Initialize_Id; Fragment_Shader.Initialize_Id; Program.Initialize_Id; -- load and compile shaders GL.Files.Load_Shader_Source_From_File (Vertex_Shader, "vertex.glsl"); GL.Files.Load_Shader_Source_From_File (Fragment_Shader, "fragment.glsl"); Vertex_Shader.Compile; Fragment_Shader.Compile; if not Vertex_Shader.Compile_Status then Ada.Text_IO.Put_Line ("Compilation of vertex shader failed. log:"); Ada.Text_IO.Put_Line (Vertex_Shader.Info_Log); end if; if not Fragment_Shader.Compile_Status then Ada.Text_IO.Put_Line ("Compilation of fragment shader failed. log:"); Ada.Text_IO.Put_Line (Fragment_Shader.Info_Log); end if; -- set up program Program.Attach (Vertex_Shader); Program.Attach (Fragment_Shader); Program.Link; if not Program.Link_Status then Ada.Text_IO.Put_Line ("Program linking failed. Log:"); Ada.Text_IO.Put_Line (Program.Info_Log); return; end if; Program.Use_Program; -- do something useful here end; ``` -------------------------------- ### Initialize and Bind OpenGL Objects Source: https://flyx.github.io/OpenGLAda/gl-objects.html Demonstrates initializing texture object references and binding them to a target for configuration. ```ada declare use GL.Objects.Textures; My_Texture, My_Other_Texture : Texture; begin -- Create IDs for the textures My_Texture.Initialize_Id; My_Other_Texture.Initialize_Id; -- Bind the texture to a target -- (Note that the texture's type is determined by the target it get -- bound to. You should not bind the texture to another target afterwards) Targets.Texture_2D.Bind (My_Texture); Targets.Texture_2D.Set_Minifying_Filter (Linear_Mipmap_Nearest); -- do something useful here -- ... Targets.Texture_2D.Bind (My_Other_Texture); -- if you did not copy the value of My_Texture, the OpenGL texture -- that is referenced by My_Texture gets destroyed at this point. -- The object referenced by My_Other_Texture lives on, as it is -- the currently bound texture to the target Texture_2D. end; ``` -------------------------------- ### Build OpenGLAda test projects Source: https://flyx.github.io/OpenGLAda/setup/macos.html Commands to compile the test projects using gprbuild with the quartz windowing system. ```bash $ gprbuild -p -P opengl-test.gpr -XWindowing_System=quartz $ gprbuild -p -P opengl-text-test.gpr -XWindowing_System=quartz $ gprbuild -p -P opengl-images-test.gpr -XWindowing_System=quartz ``` -------------------------------- ### Build OpenGLAda projects with gnatmake Source: https://flyx.github.io/OpenGLAda/setup/windows.html Commands to compile the OpenGLAda test projects using gnatmake on Windows. ```bash $ gnatmake -p -P opengl-test.gpr -XWindowing_System=windows $ gnatmake -p -P opengl-text-test.gpr -XWindowing_System=quartz ``` -------------------------------- ### Define and Initialize a Custom Window Source: https://flyx.github.io/OpenGLAda/glfw-v3.html Derive from Glfw.Windows.Window to handle events like key presses. Ensure the callback is enabled after initialization. ```ada type My_Window is new Glfw.Windows.Window with null record; overriding procedure Init (Object : not null access My_Window; Width, Height : Glfw.Size; Title : String; Monitor : Glfw.Monitors.Monitor := Glfw.Monitors.No_Monitor; Share : access Glfw.Windows.Window'Class := null); overriding procedure Key_Changed (Object : not null access My_Window; Key : Glfw.Input.Keys.Key; Scancode : Glfw.Input.Keys.Scancode; Action : Glfw.Input.Keys.Action; Mods : Glfw.Input.Keys.Modifiers); procedure Init (Object : not null access My_Window; Width, Height : Glfw.Size; Title : String; Monitor : Glfw.Monitors.Monitor := Glfw.Monitors.No_Monitor; Share : access Glfw.Windows.Window'Class := null) is Upcast : Glfw.Windows.Window_Reference := Glfw.Windows.Window (Object.all)'Access; begin Upcast.Init (Width, Height, Title, Monitor, Share); Object.Enable_Callback (Glfw.Windows.Callbacks.Key); end Init; procedure Key_Changed (Object : not null access My_Window; Key : Glfw.Input.Keys.Key; Scancode : Glfw.Input.Keys.Scancode; Action : Glfw.Input.Keys.Action; Mods : Glfw.Input.Keys.Modifiers) is use type Glfw.Input.Keys.Key; begin If Key = Glfw.Input.Keys.Escape then Object.Set_Should_Close (True); end if; end Key_Changed; ``` -------------------------------- ### Querying Texture Parameters with Proxies Source: https://flyx.github.io/OpenGLAda/gl-objects-textures.html Use a texture proxy to query potential parameters without allocating memory, then use the actual texture target to create the texture. ```Ada GL.Objects.Textures.Targets.Texture_2D_Proxy.Load_Empty_Texture ``` ```Ada GL.Objects.Textures.Targets.Texture_2D.Load_Empty_Texture ``` -------------------------------- ### Rendering primitives with Input_Token Source: https://flyx.github.io/OpenGLAda/gl-immediate.html Demonstrates the lifecycle of an Input_Token to define and push vertices to the OpenGL pipeline. The token is automatically finalized when it goes out of scope. ```ada declare Token : Input_Token := Start (Line_Strip); begin Token.Add_Vertex (Vector'(-0.5, 0.5, 0.5, 1.0)); Token.Add_Vertex (Vector'(0.5, 0.5, 0.5, 1.0)); Token.Add_Vertex (Vector'(0.5, -0.5, 0.5, 1.0)); Token.Add_Vertex (Vector'(-0.5, -0.5, 0.5, 1.0)); Token.Add_Vertex (Vector'(-0.5, 0.5, 0.5, 1.0)); end; -- at this point, the token gets destroyed. ``` -------------------------------- ### Enabling 2D Textures Source: https://flyx.github.io/OpenGLAda/gl-objects-textures.html Required when using the deprecated fixed pixel pipeline to enable 2D texture functionality. ```Ada GL.Toggles.Enable (GL.Toggles.Texture_2D) ``` -------------------------------- ### Configure Alpha Blending Source: https://flyx.github.io/OpenGLAda/gl-buffers.html Enables blending and sets the blend function for the color buffer. ```ada GL.Toggles.Enable (GL.Toggles.Blend); GL.Blending.Set_Blend_Func (GL.Blending.Src_Alpha, GL.Blending.One_Minus_Src_Alpha); ``` -------------------------------- ### Cube Map Target Source: https://flyx.github.io/OpenGLAda/gl-objects-textures.html The primary target for binding cube map textures. ```Ada GL.Objects.Textures.Targets.Texture_Cube_Map ``` -------------------------------- ### Cube Map Texture Targets Source: https://flyx.github.io/OpenGLAda/gl-objects-textures.html Specific targets for cube map faces used to define parts of a texture bound to the main cube map target. ```Ada GL.Objects.Textures.Targets.Texture_Cube_Map_Positive_X GL.Objects.Textures.Targets.Texture_Cube_Map_Negative_X GL.Objects.Textures.Targets.Texture_Cube_Map_Positive_Y GL.Objects.Textures.Targets.Texture_Cube_Map_Negative_Y GL.Objects.Textures.Targets.Texture_Cube_Map_Positive_Z GL.Objects.Textures.Targets.Texture_Cube_Map_Negative_Z ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.