# Saffron

• R/O
• HTTP
• SSH
• HTTPS

## コミット

#### よく使われているワード(クリックで追加)

Graphics library for Mercury, including OpenGL bindings, TGA image reading, and X11, Win32, and SDL2 windowing and input.

### 差分

--- a/saffron.geometry.m
+++ b/saffron.geometry.m
 @@ -36,6 +36,15 @@ 36 36 :- mode vertex(muo, muo, muo, muo) = (mdi) is det. 37 37 :- mode vertex(in, in, in, in) = (in) is semidet. % Implied. 38 38 39 +:- pred vertex(float, float, float, float, vertex2d). 40 +:- mode vertex(in, in, in, in, out) is det. 41 +:- mode vertex(di, di, di, di, uo) is det. 42 +:- mode vertex(mdi, mdi, mdi, mdi, muo) is det. 43 +:- mode vertex(out, out, out, out, in) is det. 44 +:- mode vertex(uo, uo, uo, uo, di) is det. 45 +:- mode vertex(muo, muo, muo, muo, mdi) is det. 46 +:- mode vertex(in, in, in, in, in) is semidet. % Implied. 47 + 39 48 %-----------------------------------------------------------------------------% 40 49 % This is intended to be used as if it was a functor for vertex, to construct 41 50 % or destructure the vector so that the vector's fields appear directly in the
 @@ -49,6 +58,15 @@ 49 58 :- mode vertex(muo, muo, muo, muo, muo) = (mdi) is det. 50 59 :- mode vertex(in, in, in, in, in) = (in) is semidet. % Implied. 51 60 61 +:- pred vertex(float, float, float, float, float, vertex3d). 62 +:- mode vertex(in, in, in, in, in, out) is det. 63 +:- mode vertex(di, di, di, di, di, uo) is det. 64 +:- mode vertex(mdi, mdi, mdi, mdi, mdi, muo) is det. 65 +:- mode vertex(out, out, out, out, out, in) is det. 66 +:- mode vertex(uo, uo, uo, uo, uo, di) is det. 67 +:- mode vertex(muo, muo, muo, muo, muo, mdi) is det. 68 +:- mode vertex(in, in, in, in, in, in) is semidet. % Implied. 69 + 52 70 %-----------------------------------------------------------------------------% 53 71 54 72 :- type primitive_type --->
 @@ -174,11 +192,37 @@ 174 192 175 193 %-----------------------------------------------------------------------------% 176 194 195 +:- pragma foreign_export("C", 196 + vertex(in, in, in, in) = (out), 197 + "SaffronGeometry_CreateVertex2D"). 198 + 199 +%-----------------------------------------------------------------------------% 200 + 201 +:- pragma foreign_export("C", 202 + vertex(out, out, out, out, in), 203 + "SaffronGeometry_GetVertex2D"). 204 + 205 +%-----------------------------------------------------------------------------% 206 + 207 +:- pragma foreign_export("C", 208 + vertex(in, in, in, in, in) = (out), 209 + "SaffronGeometry_CreateVertex3D"). 210 + 211 +%-----------------------------------------------------------------------------% 212 + 213 +:- pragma foreign_export("C", 214 + vertex(out, out, out, out, out, in), 215 + "SaffronGeometry_GetVertex3D"). 216 + 217 +%-----------------------------------------------------------------------------% 218 + 177 219 vertex(X, Y, U, V) = vertex(vector.vector2.vector(X, Y), U, V). 220 +vertex(X, Y, U, V, vertex(vector.vector2.vector(X, Y), U, V)). 178 221 179 222 %-----------------------------------------------------------------------------% 180 223 181 224 vertex(X, Y, Z, U, V) = vertex(vector.vector3.vector(X, Y, Z), U, V). 225 +vertex(X, Y, Z, U, V, vertex(vector.vector3.vector(X, Y, Z), U, V)). 182 226 183 227 %-----------------------------------------------------------------------------% 184 228
--- a/saffron.gl.buffer.m
+++ b/saffron.gl.buffer.m
 @@ -19,6 +19,11 @@ 19 19 :- interface. 20 20 %=============================================================================% 21 21 22 +:- use_module array. 23 +:- use_module list. 24 + 25 +:- use_module saffron.geometry. 26 + 22 27 %-----------------------------------------------------------------------------% 23 28 % The function pointers to let us create buffers. 24 29 :- type buffer_ctx.
 @@ -39,11 +44,68 @@ 39 44 <= saffron.gl.context(Ctx). 40 45 :- mode create_buffer_ctx(in, out, di, uo) is det. 41 46 47 +%-----------------------------------------------------------------------------% 48 + 49 +:- pred destroy_buffer(buffer_ctx::in, buffer::in, io.io::di, io.io::uo) is det. 50 + 51 +%-----------------------------------------------------------------------------% 52 + 53 +:- pred create_buffer(buffer_ctx::in, buffer::uo, io.io::di, io.io::uo) is det. 54 + 55 +%-----------------------------------------------------------------------------% 56 + 57 +:- instance saffron.destroy(buffer_ctx, buffer). 58 + 59 +%-----------------------------------------------------------------------------% 60 + 61 +:- pred bind_buffer(buffer_ctx, buffer, buffer_type, io.io, io.io). 62 +:- mode bind_buffer(in, in, in, di, uo) is det. 63 + 64 +%-----------------------------------------------------------------------------% 65 + 66 +:- type buffer_data(T) == (pred(buffer_ctx, buffer_type, T, io.io, io.io)). 67 +:- inst buffer_data == (pred(in, in, in, di, uo) is det). 68 + 69 +:- pred buffer_data_float_array 70 + `with_type` buffer_data(array.array(float)) 71 + `with_inst` buffer_data. 72 + 73 +:- pred buffer_data_float_list 74 + `with_type` buffer_data(list.list(float)) 75 + `with_inst` buffer_data. 76 + 77 +:- pred buffer_data_int_array 78 + `with_type` buffer_data(array.array(int)) 79 + `with_inst` buffer_data. 80 + 81 +:- pred buffer_data_int_list 82 + `with_type` buffer_data(list.list(int)) 83 + `with_inst` buffer_data. 84 + 85 +:- pred buffer_data_vertex2d_array 86 + `with_type` buffer_data(array.array(saffron.geometry.vertex2d)) 87 + `with_inst` buffer_data. 88 + 89 +:- pred buffer_data_vertex2d_list 90 + `with_type` buffer_data(list.list(saffron.geometry.vertex2d)) 91 + `with_inst` buffer_data. 92 + 93 +:- pred buffer_data_vertex3d_array 94 + `with_type` buffer_data(array.array(saffron.geometry.vertex3d)) 95 + `with_inst` buffer_data. 96 + 97 +:- pred buffer_data_vertex3d_list 98 + `with_type` buffer_data(list.list(saffron.geometry.vertex3d)) 99 + `with_inst` buffer_data. 100 + 42 101 %=============================================================================% 43 102 :- implementation. 44 103 %=============================================================================% 45 104 46 -:- use_module array. 105 +:- use_module vector. 106 +:- use_module vector.vector2. 107 +:- use_module vector.vector3. 108 + 47 109 :- pragma foreign_import_module("C", saffron.gl). 48 110 49 111 % Define the native prototypes to handle buffers.
 @@ -256,7 +318,6 @@ saffron_gl_create_buffer_ctx_internal: 256 318 IOo = IOi; 257 319 "). 258 320 259 - 260 321 %-----------------------------------------------------------------------------% 261 322 262 323 create_buffer_ctx(Ctx, MaybeBufferCtx, !IO) :-