[m-rev.] diff: implement mogl.bitmap/9 for opengl binding
Julien Fischer
juliensf at csse.unimelb.edu.au
Wed Feb 14 15:37:16 AEDT 2007
Estimated hours taken: 1
Branches: main
Since bitmaps can now be used as binary contains use them to implement
bitmaps in the OpenGL binding.
TODO: do the same for texture and pixel data.
extras/graphics/mercury_opengl/mogl.m:
Implement a binding to mogl.bitmap/9.
Julien.
Index: mogl.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/extras/graphics/mercury_opengl/mogl.m,v
retrieving revision 1.24
diff -u -r1.24 mogl.m
--- mogl.m 6 Dec 2006 04:14:11 -0000 1.24
+++ mogl.m 14 Feb 2007 04:27:06 -0000
@@ -22,7 +22,6 @@
% - various state queries
% - stuff from later versions of OpenGL
% - break this module up into submodules
-% - bitmaps
% - after the next release the foreign code
% attributes will need to be updated (terminates/does_not_terminate)
% - document all this ;)
@@ -34,6 +33,7 @@
:- include_module mogl.type_tables.
+:- import_module bitmap.
:- import_module bool.
:- import_module float.
:- import_module int.
@@ -393,11 +393,8 @@
% Bitmaps
%
-/*
-:- pred bitmap(int, int, float, float, float, float, list(int),
- io.state, io.state).
-:- mode bitmap(in, in, in, in, in, in, in, di, uo) is det.
-*/
+:- pred mogl.bitmap(int::in, int::in, float::in, float::in,
+ float::in, float::in, bitmap::bitmap_ui, io::di, io::uo) is det.
%------------------------------------------------------------------------------%
%
@@ -2606,11 +2603,27 @@
% Bitmaps
%
-/*
-:- pred bitmap(int, int, float, float, float, float, list(int),
- io.state, io.state).
-:- mode bitmap(in, in, in, in, in, in, in, di, uo) is det.
-*/
+mogl.bitmap(Width, Height, XOrig, YOrig, XMove, YMove, Bitmap, !IO) :-
+ ( num_bits(Bitmap) < Width * Height ->
+ throw(software_error("mogl.bitmap/9: bitmap is to small."))
+ ;
+ bitmap_2(Width, Height, XOrig, YOrig, XMove, YMove, Bitmap, !IO)
+ ).
+
+:- pred bitmap_2(int::in, int::in, float::in, float::in, float::in, float::in,
+ bitmap::bitmap_ui, io::di, io::uo) is det.
+
+:- pragma foreign_proc("C",
+ bitmap_2(Width::in, Height::in, XOrig::in, YOrig::in,
+ XMove::in, YMove::in, Bitmap::bitmap_ui, IO0::di, IO::uo),
+ [will_not_call_mercury, promise_pure],
+"
+
+ glBitmap((GLsizei) Width, (GLsizei) Height, (GLfloat) XOrig,
+ (GLfloat) YOrig, (GLfloat) XMove, (GLfloat) YMove,
+ (GLubyte *) Bitmap->elements);
+ IO = IO0;
+").
%------------------------------------------------------------------------------%
%
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list