-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVBO.gml
141 lines (135 loc) · 5.04 KB
/
VBO.gml
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/*********************************************************************************************
* __ __________________ ________________________________ __________ ________ *
* /\ \ /\ __ \ ___\__ _\ /\ __ \ ___\__ _\ == \ __ \ "-.\ \ __ \ \/\ \__ _\ (tm) *
* \ \ \_\_\ \/\ \___ \/\ \/ \ \ __ \___ \/\ \/\ __<\ \/\ \ \-. \ __ \ \_\ \/\ \/ *
* \ \_____\_____\_____\ \_\ \ \_\ \_\_____\ \_\ \_\ \_\_____\_\\"\_\_\ \_\_____\ \_\ *
* \/_____/_____/_____/\/_/ \/_/\/_/_____/\/_/\/_/\/_/_____/_/ \/_/_/\/_/_____/\/_/ *
* -------------------------------------------------------------------------------- *
* Lost Astronaut Game Development Framework (c) 2007-2020 H. Elwood Gilliland III *
*********************************************************************************************
* This software is copyrighted software. Use of this code is given only with permission to *
* parties who have been granted such permission by its author, Herbert Elwood Gilliland III *
* *
* CubeMappedSphereGML was based on: *
* https://github.com/LAGameStudio/apolune/blob/trunk/Apolune/CubeMappedSphere.h *
* https://github.com/LAGameStudio/apolune/blob/trunk/Apolune/VBOFlavors.h *
* ...and other files in the Lost Astronaut Game Creation Framework *
* *
* CubeMappedSphereGML is licensed BSD "New" "Revised" and requires adherence to the license.*
* *
* Thanks to Dragonite for his 3D tutorials that helped jog my memory. *
* Find them on reddit.com/r/GML and YouTube *
*********************************************************************************************/
/*
Purpose:
To wrangle VBO creation and common operations.
*/
#macro VBOs global.vbo
function Init_VBO(){
global.vbo = {
list: [],
V: function () {
vertex_format_begin();
vertex_format_add_position_3d();
var vf=vertex_format_end();
var bo=vertex_create_buffer();
return {
kind: pr_trianglelist,
format: "V",
vbo: bo,
v_format: vf
};
},
VC: function () {
vertex_format_begin();
vertex_format_add_position_3d();
vertex_format_add_color();
var vf=vertex_format_end();
var bo=vertex_create_buffer();
return {
kind: pr_trianglelist,
format: "VC",
vbo: bo,
v_format: vf
};
},
VCLines: function () {
vertex_format_begin();
vertex_format_add_position_3d();
vertex_format_add_color();
var vf=vertex_format_end();
var bo=vertex_create_buffer();
return {
kind: pr_linelist,
format: "VCLines",
vbo: bo,
v_format: vf
};
},
VNT: function () {
vertex_format_begin();
vertex_format_add_position_3d();
vertex_format_add_normal();
vertex_format_add_texcoord();
var vf=vertex_format_end();
var bo=vertex_create_buffer();
return {
kind: pr_trianglelist,
format: "VNT",
vbo: bo,
v_format: vf
};
},
VNTC: function () {
vertex_format_begin();
vertex_format_add_position_3d();
vertex_format_add_normal();
vertex_format_add_texcoord();
vertex_format_add_color();
var vf=vertex_format_end();
var bo=vertex_create_buffer();
return {
kind: pr_trianglelist,
format: "VNTC",
vbo: bo,
v_format: vf
};
},
Add: {
V: function ( vboo, vx,vy,vz ) {
vertex_position_3d(vboo.vbo,vx,vy,vz);
},
VC: function ( vboo, vx,vy,vz, cr,cg,cb,ca ) {
vertex_position_3d(vboo.vbo,vx,vy,vz);
vertex_color(vboo.vbo, make_color_rgb(cr*255.0,cg*255.0,cb*255.0), ca );
},
VC_c: function ( vboo, vx,vy,vz, c,a ) {
vertex_position_3d(vboo.vbo,vx,vy,vz);
vertex_color(vboo.vbo, c,a );
},
VNT: function ( vboo, vx,vy,vz, nx,ny,nz, tx,ty ) {
vertex_position_3d(vboo.vbo,vx,vy,vz);
vertex_normal(vboo.vbo,vx,vy,vz);
vertex_texcoord(vboo.vbo,tx,ty);
},
VNTC: function ( vboo, vx,vy,vz, nx,ny,nz, tx,ty, cr,cg,cb,ca ) {
vertex_position_3d(vboo.vbo,vx,vy,vz);
vertex_normal(vboo.vbo,vx,vy,vz);
vertex_texcoord(vboo.vbo,tx,ty);
vertex_color(vboo.vbo, make_color_rgb(cr*255.0,cg*255.0,cb*255.0), ca );
},
VNTC_c: function ( vboo, vx,vy,vz, nx,ny,nz, tx,ty, c,a ) {
vertex_position_3d(vboo.vbo,vx,vy,vz);
vertex_normal(vboo.vbo,vx,vy,vz);
vertex_texcoord(vboo.vbo,tx,ty);
vertex_color(vboo.vbo, c,a);
},
},
Begin: function ( vbo_object ) { vertex_begin(vbo_object.vbo,vbo_object.v_format); },
End: function ( vbo_object ) { vertex_end(vbo_object.vbo); },
Freeze: function ( vbo_object ) { vertex_freeze(vbo_object.vbo); },
Draw: function ( vbo_object, texture ) {
vertex_submit(vbo_object.vbo, vbo_object.kind, texture);
}
};
}