opengl.errors: Use new 'Debugging' function to optimise out error checks when not building in 'debug' mode.
This commit is contained in:
@@ -3,6 +3,7 @@ with
|
|||||||
GL.Binding,
|
GL.Binding,
|
||||||
ada.Text_IO;
|
ada.Text_IO;
|
||||||
|
|
||||||
|
|
||||||
package body openGL.Errors
|
package body openGL.Errors
|
||||||
is
|
is
|
||||||
use GL;
|
use GL;
|
||||||
@@ -10,62 +11,83 @@ is
|
|||||||
|
|
||||||
function Current return String
|
function Current return String
|
||||||
is
|
is
|
||||||
use GL.Binding;
|
|
||||||
check_is_OK : constant Boolean := openGL.Tasks.Check; pragma Unreferenced (check_is_OK);
|
|
||||||
the_Error : constant GL.GLenum := glGetError;
|
|
||||||
begin
|
begin
|
||||||
case the_Error is
|
if Debugging
|
||||||
when GL.GL_NO_ERROR => return "no error";
|
then
|
||||||
when GL_INVALID_ENUM => return "invalid Enum";
|
declare
|
||||||
when GL_INVALID_VALUE => return "invalid Value";
|
use GL.Binding;
|
||||||
when GL_INVALID_OPERATION => return "invalid Operation";
|
check_is_OK : constant Boolean := openGL.Tasks.Check; pragma Unreferenced (check_is_OK);
|
||||||
when GL_OUT_OF_MEMORY => return "out of Memory";
|
the_Error : constant GL.GLenum := glGetError;
|
||||||
when others => return "unknown openGL error detected (Code:" & the_Error'Image & ")";
|
begin
|
||||||
end case;
|
case the_Error
|
||||||
|
is
|
||||||
|
when GL.GL_NO_ERROR => return "no error";
|
||||||
|
when GL_INVALID_ENUM => return "invalid Enum";
|
||||||
|
when GL_INVALID_VALUE => return "invalid Value";
|
||||||
|
when GL_INVALID_OPERATION => return "invalid Operation";
|
||||||
|
when GL_OUT_OF_MEMORY => return "out of Memory";
|
||||||
|
when others => return "unknown openGL error detected (Code:" & the_Error'Image & ")";
|
||||||
|
end case;
|
||||||
|
end;
|
||||||
|
end if;
|
||||||
|
|
||||||
|
return "";
|
||||||
end Current;
|
end Current;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
procedure log (Prefix : in String := "")
|
procedure log (Prefix : in String := "")
|
||||||
is
|
is
|
||||||
current_Error : constant String := Current;
|
|
||||||
|
|
||||||
function Error_Message return String
|
|
||||||
is
|
|
||||||
begin
|
|
||||||
if Prefix = ""
|
|
||||||
then return "openGL error: '" & current_Error & "'";
|
|
||||||
else return Prefix & ": '" & current_Error & "'";
|
|
||||||
end if;
|
|
||||||
end Error_Message;
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if current_Error = "no error"
|
if Debugging
|
||||||
then
|
then
|
||||||
return;
|
declare
|
||||||
end if;
|
current_Error : constant String := Current;
|
||||||
|
|
||||||
raise openGL.Error with Error_Message;
|
function Error_Message return String
|
||||||
|
is
|
||||||
|
begin
|
||||||
|
if Prefix = ""
|
||||||
|
then return "openGL error: '" & current_Error & "'";
|
||||||
|
else return Prefix & ": '" & current_Error & "'";
|
||||||
|
end if;
|
||||||
|
end Error_Message;
|
||||||
|
|
||||||
|
begin
|
||||||
|
if current_Error = "no error"
|
||||||
|
then
|
||||||
|
return;
|
||||||
|
end if;
|
||||||
|
|
||||||
|
raise openGL.Error with Error_Message;
|
||||||
|
end;
|
||||||
|
end if;
|
||||||
end log;
|
end log;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
procedure log (Prefix : in String := ""; Error_occurred : out Boolean)
|
procedure log (Prefix : in String := ""; Error_occurred : out Boolean)
|
||||||
is
|
is
|
||||||
use ada.Text_IO;
|
|
||||||
current_Error : constant String := Current;
|
|
||||||
begin
|
begin
|
||||||
if current_Error = "no error"
|
if Debugging
|
||||||
then
|
then
|
||||||
error_Occurred := False;
|
declare
|
||||||
return;
|
use ada.Text_IO;
|
||||||
end if;
|
current_Error : constant String := Current;
|
||||||
|
begin
|
||||||
|
if current_Error = "no error"
|
||||||
|
then
|
||||||
|
error_Occurred := False;
|
||||||
|
return;
|
||||||
|
end if;
|
||||||
|
|
||||||
error_Occurred := True;
|
error_Occurred := True;
|
||||||
|
|
||||||
if Prefix = ""
|
if Prefix = ""
|
||||||
then put_Line ("openGL error: '" & current_Error & "'");
|
then put_Line ("openGL error: '" & current_Error & "'");
|
||||||
else put_Line (Prefix & ": '" & current_Error & "'");
|
else put_Line (Prefix & ": '" & current_Error & "'");
|
||||||
|
end if;
|
||||||
|
end;
|
||||||
end if;
|
end if;
|
||||||
end log;
|
end log;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user