Fix errors in the GLUT binding.

extras/graphics/mercury_glut/glut.callback.m:
    Rename overlay_display_func/2 -> disable_overlay_display_func/2
    for consistency with every other pair of callback predicates in
    this module.

    Add a space before a determinism declaration.

    Delete doubled-up tabled_for_io attributes from foreign_procs.

    Call the correct GLUT function to disable keyboard up callbacks.

extras/graphics/mercury_glut/glut.color_map.m:
    Fix incorrect argument ordering in a documentation comment.

extras/graphics/mercury_glut/glut.font.m:
    Fix formatting.

extras/graphics/mercury_glut/glut.m:
    Fix the definition of the glut_alpha/0 function, which was returning
    the wrong value.

extras/graphics/mercury_glut/glut.overlay.m:
    Fix a documentation comment.

    Add some tabled_for_io attributes.

extras/graphics/mercury_glut/glut.window.m:
    Fix doubled-up-word.

    s/__IO/_IO etc.
This commit is contained in:
Julien Fischer
2026-02-27 16:49:38 +11:00
parent 18f1cb69ee
commit 126677a832
6 changed files with 22 additions and 21 deletions

View File

@@ -2,7 +2,7 @@
% vim: ft=mercury ts=4 sw=4 et
%-----------------------------------------------------------------------------%
% Copyright (C) 2004-2007 The University of Melbourne.
% Copyright (C) 2017-2018, 2020 The Mercury team.
% Copyright (C) 2017-2018, 2020, 2026 The Mercury team.
% This file is distributed under the terms specified in COPYING.LIB.
%-----------------------------------------------------------------------------%
%
@@ -216,7 +216,7 @@
% Unregister the overlay display callback for the current window.
%
:- pred callback.overlay_display_func(io::di, io::uo) is det.
:- pred callback.disable_overlay_display_func(io::di, io::uo) is det.
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
@@ -606,7 +606,7 @@ do_visibility_callback(VisibilityFunc, Visibility, !IO) :-
:- pragma foreign_proc("C",
disable_visibility_func(_IO0::di, _IO::uo),
[will_not_call_mercury, tabled_for_io, promise_pure, tabled_for_io],
[will_not_call_mercury, promise_pure, tabled_for_io],
"
glutVisibilityFunc(NULL);
").
@@ -624,7 +624,7 @@ do_visibility_callback(VisibilityFunc, Visibility, !IO) :-
:- pragma foreign_proc("C",
idle_func(Closure::pred(di, uo) is det, _IO0::di, _IO::uo),
[will_not_call_mercury, tabled_for_io, promise_pure, tabled_for_io],
[will_not_call_mercury, promise_pure, tabled_for_io],
"
mglut_idle_callback = Closure;
glutIdleFunc(MGLUT_idle_callback);
@@ -688,7 +688,7 @@ do_keyboard_up_callback(KeyBoardUpFunc, ScanCode, X, Y, !IO) :-
disable_keyboard_up_func(_IO0::di, _IO::uo),
[will_not_call_mercury, tabled_for_io, promise_pure],
"
glutKeyboardFunc(NULL);
glutKeyboardUpFunc(NULL);
").
%-----------------------------------------------------------------------------%
@@ -720,7 +720,7 @@ do_overlay_display_callback(OverlayDisplayFunc, !IO) :-
OverlayDisplayFunc(!IO).
:- pragma foreign_proc("C",
overlay_display_func(_IO0::di, _IO::uo),
disable_overlay_display_func(_IO0::di, _IO::uo),
[will_not_call_mercury, promise_pure],
"
glutOverlayDisplayFunc(NULL);

View File

@@ -2,7 +2,7 @@
% vim: ft=mercury ts=4 sw=4 et
%-----------------------------------------------------------------------------%
% Copyright (C) 2004-2007, 2012 The University of Melbourne.
% Copyright (C) 2017-2018, 2020 The Mercury team.
% Copyright (C) 2017-2018, 2020, 2026 The Mercury team.
% This file is distributed under the terms specified in COPYING.LIB.
%-----------------------------------------------------------------------------%
%
@@ -28,7 +28,7 @@
; blue
; green.
% color_map.set_color(Index, Red, Blue, Green, !IO).
% color_map.set_color(Index, Red, Green, Blue, !IO).
% Set the colormap entry for the given index.
%
:- pred color_map.set_color(int::in, float::in, float::in, float::in,

View File

@@ -2,7 +2,7 @@
% vim: ft=mercury ts=4 sw=4 et
%-----------------------------------------------------------------------------%
% Copyright (C) 2004-2007, 2012 The University of Melbourne.
% Copyright (C) 2017-2018, 2020 The Mercury team.
% Copyright (C) 2017-2018, 2020, 2026 The Mercury team.
% This file is distributed under the terms specified in COPYING.LIB.
%-----------------------------------------------------------------------------%
%

View File

@@ -2,7 +2,7 @@
% vim: ft=mercury ts=4 sw=4 et
%-----------------------------------------------------------------------------%
% Copyright (C) 2004-2007, 2012 The University of Melbourne.
% Copyright (C) 2017-2018 The Mercury team.
% Copyright (C) 2017-2018, 2020, 2026 The Mercury team.
% This file is distributed under the terms specified in COPYING.LIB.
%-----------------------------------------------------------------------------%
%
@@ -13,7 +13,7 @@
%
% If used with freeglut then some of the extensions available in freeglut will
% also be available. Calling the freeglut extensions when freeglut is *not*
% available will result in a software_error1/ exception being thrown.
% available will result in a software_error/1 exception being thrown.
%
% You can use the predicate glut.have_freeglut/0 to test for the presence
% of freeglut.
@@ -294,7 +294,7 @@ display_mode_to_int(luminance) = glut_luminance.
:- pragma foreign_proc("C", glut_alpha = (Value::out),
[will_not_call_mercury, promise_pure, thread_safe],
"
Value = (MR_Integer) GLUT_ACCUM;
Value = (MR_Integer) GLUT_ALPHA;
").
:- func glut_depth = int.

View File

@@ -27,7 +27,7 @@
---> normal
; overlay.
% Returns `yes' of it is possible to establish an overlay for the
% Returns `yes' if it is possible to establish an overlay for the
% current window; `no' otherwise.
%
:- pred overlay.possible(bool::out, io::di, io::uo) is det.
@@ -167,14 +167,14 @@ overlay.establish(Result, !IO) :-
:- pragma foreign_proc("C",
overlay.post_redisplay(_IO0::di, _IO::uo),
[will_not_call_mercury, promise_pure],
[will_not_call_mercury, tabled_for_io, promise_pure],
"
glutPostOverlayRedisplay();
").
:- pragma foreign_proc("C",
overlay.post_redisplay(Window::in, _IO0::di, _IO::uo),
[will_not_call_mercury, promise_pure],
[will_not_call_mercury, tabled_for_io, promise_pure],
"
glutPostWindowOverlayRedisplay((int) Window);
").

View File

@@ -2,7 +2,7 @@
% vim: ft=mercury ts=4 sw=4 et
%-----------------------------------------------------------------------------%
% Copyright (C) 2004-2007, 2012 The University of Melbourne.
% Copyright (C) 2017-2018, 2020 The Mercury team.
% Copyright (C) 2017-2018, 2020, 2026 The Mercury team.
% This file is distributed under the terms specified in COPYING.LIB.
%-----------------------------------------------------------------------------%
%
@@ -38,7 +38,7 @@
% window.
:- pred window.create(string::in, window::out, io::di, io::uo) is det.
% Create a subwindow. Implicitly the the current window is set
% Create a subwindow. Implicitly the current window is set
% to the newly created subwindow.
% XXX We need a way to handle multiple windows for this to be useful.
%
@@ -502,6 +502,7 @@ cursor_to_int(inherit) = glut_cursor_inherit.
"
V = (MR_Integer) GLUT_CURSOR_CYCLE;
").
:- func glut_cursor_wait = int.
:- pragma foreign_proc("C", glut_cursor_wait = (V::out),
[will_not_call_mercury, promise_pure, thread_safe],
@@ -711,7 +712,7 @@ window.set_cursor(Cursor, !IO) :-
]).
:- pragma foreign_proc("C",
window.get(State::in, Value::out, __IO0::di, __IO::uo),
window.get(State::in, Value::out, _IO0::di, _IO::uo),
[will_not_call_mercury, tabled_for_io, promise_pure],
"
Value = (MR_Integer) glutGet((GLenum) State);
@@ -720,7 +721,7 @@ window.set_cursor(Cursor, !IO) :-
%-----------------------------------------------------------------------------%
:- pragma foreign_proc("C",
window.has_overlay(Result::out, __IO0::di, __IO::uo),
window.has_overlay(Result::out, _IO0::di, _IO::uo),
[will_not_call_mercury, tabled_for_io, promise_pure],
"
if (glutLayerGet(GLUT_HAS_OVERLAY)) {