-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgl2.heightmap.m
More file actions
47 lines (36 loc) · 1.4 KB
/
gl2.heightmap.m
File metadata and controls
47 lines (36 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
:- module gl2.heightmap.
%==============================================================================%
:- interface.
%==============================================================================%
:- use_module render.
:- import_module list.
:- use_module opengl.
%------------------------------------------------------------------------------%
:- type panel.
:- type heightmap ---> heightmap(list(panel)).
:- func init = panel.
:- instance model.loadable(panel).
:- instance render.heightmap(gl2, heightmap, opengl.texture).
%==============================================================================%
:- implementation.
%==============================================================================%
:- use_module model.
:- use_module mglow.
:- type panel ---> panel(list(model.vertex)).
init = panel([]).
:- instance model.loadable(panel) where [
next(Vertex, panel(Vertices),
panel(list.append(Vertices, [Vertex|[]])))
].
:- pred draw(panel::in, mglow.window::di, mglow.window::uo) is det.
draw(panel(Vertices), !Window) :-
begin(opengl.triangle_fan, !Window),
color(1.0, 1.0, 1.0, 1.0, !Window),
list.foldl(gl2.draw_vertex, Vertices, !Window),
end(!Window).
:- instance render.heightmap(gl2, heightmap, opengl.texture) where [
(draw_heightmap(_, heightmap(Faces), Tex, !Window) :-
opengl.bind_texture(Tex, !Window),
list.foldl(draw, Faces, !Window)
)
].