Skip to content

Commit 2e58423

Browse files
committed
update to use ulra-violet.
1 parent b13b975 commit 2e58423

File tree

10 files changed

+85
-240
lines changed

10 files changed

+85
-240
lines changed

Cargo.lock

Lines changed: 48 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ publish = false
1212
[dependencies]
1313
bytemuck = "1"
1414
ogl33 = { version = "0.2", features = ["debug_error_checks"]}
15+
ultraviolet = "0.7"
1516

1617
# these should be dev dependencies, but i use the bin directory
1718
# during dev so they live here, except during a crates.io release

examples/010-transforms-intro.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ use learn::{
1515
null_str, Buffer, BufferType, Shader, ShaderProgram, ShaderType, VertexArray,
1616
};
1717
use learn_opengl as learn;
18-
use learn_opengl::math::*;
1918
use ogl33::*;
19+
use ultraviolet::*;
2020

2121
type Vertex = [f32; 3 + 2];
2222
type TriIndexes = [u32; 3];
@@ -219,7 +219,7 @@ fn main() {
219219

220220
// update the "world state".
221221
let time = sdl.get_ticks() as f32 / 1000.0_f32;
222-
let transform = Mat4::rotate_z(time);
222+
let transform = Mat4::from_rotation_z(time);
223223

224224
// and then draw!
225225
unsafe {

examples/011-coordinate-basics.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ use learn::{
1717
null_str, Buffer, BufferType, Shader, ShaderProgram, ShaderType, VertexArray,
1818
};
1919
use learn_opengl as learn;
20-
use learn_opengl::math::*;
2120
use ogl33::*;
21+
use ultraviolet::*;
2222

2323
type Vertex = [f32; 3 + 2];
2424
type TriIndexes = [u32; 3];
@@ -224,10 +224,10 @@ fn main() {
224224
glGetUniformLocation(shader_program.0, name)
225225
};
226226

227-
let view = Mat4::translate(vec3(0.0, 0.0, -1.0));
227+
let view = Mat4::from_translation(Vec3::new(0.0, 0.0, -1.0));
228228
unsafe { glUniformMatrix4fv(view_loc, 1, GL_FALSE, view.as_ptr()) };
229229

230-
let projection = perspective_view(
230+
let projection = ultraviolet::projection::lh_yup::perspective_gl(
231231
45.0_f32.to_radians(),
232232
(WINDOW_WIDTH as f32) / (WINDOW_HEIGHT as f32),
233233
0.1,
@@ -249,7 +249,7 @@ fn main() {
249249

250250
// update the "world state".
251251
let time = sdl.get_ticks() as f32 / 1000.0_f32;
252-
let model = Mat4::rotate_x(1.3) * Mat4::rotate_z(time);
252+
let model = Mat4::from_rotation_x(1.3) * Mat4::from_rotation_z(time);
253253

254254
// and then draw!
255255
unsafe {

examples/012-depth-buffer-cube.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ use learn::{
1717
null_str, Buffer, BufferType, Shader, ShaderProgram, ShaderType, VertexArray,
1818
};
1919
use learn_opengl as learn;
20-
use learn_opengl::math::*;
2120
use ogl33::*;
21+
use ultraviolet::*;
2222

2323
type Vertex = [f32; 3 + 2];
2424
/// Draw this with glDrawArrays(GL_TRIANGLES, 0, 36)
@@ -249,10 +249,10 @@ fn main() {
249249
glGetUniformLocation(shader_program.0, name)
250250
};
251251

252-
let view = Mat4::translate(vec3(0.0, 0.0, -2.0));
252+
let view = Mat4::from_translation(Vec3::new(0.0, 0.0, -2.0));
253253
unsafe { glUniformMatrix4fv(view_loc, 1, GL_FALSE, view.as_ptr()) };
254254

255-
let projection = perspective_view(
255+
let projection = ultraviolet::projection::lh_yup::perspective_gl(
256256
45.0_f32.to_radians(),
257257
(WINDOW_WIDTH as f32) / (WINDOW_HEIGHT as f32),
258258
0.1,
@@ -274,8 +274,9 @@ fn main() {
274274

275275
// update the "world state".
276276
let time = sdl.get_ticks() as f32 / 1000.0_f32;
277-
let model =
278-
Mat4::rotate_y(1.0) * Mat4::rotate_x(0.5) * Mat4::rotate_z(time);
277+
let model = Mat4::from_rotation_y(1.0)
278+
* Mat4::from_rotation_x(0.5)
279+
* Mat4::from_rotation_z(time);
279280

280281
// and then draw!
281282
unsafe {

examples/013-multi-cube.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ use learn::{
1717
null_str, Buffer, BufferType, Shader, ShaderProgram, ShaderType, VertexArray,
1818
};
1919
use learn_opengl as learn;
20-
use learn_opengl::math::*;
2120
use ogl33::*;
21+
use ultraviolet::*;
2222

2323
type Vertex = [f32; 3 + 2];
2424
/// Draw this with glDrawArrays(GL_TRIANGLES, 0, 36)
@@ -262,10 +262,10 @@ fn main() {
262262
glGetUniformLocation(shader_program.0, name)
263263
};
264264

265-
let view = Mat4::translate(vec3(0.0, 0.0, -3.0));
265+
let view = Mat4::from_translation(Vec3::new(0.0, 0.0, -3.0));
266266
unsafe { glUniformMatrix4fv(view_loc, 1, GL_FALSE, view.as_ptr()) };
267267

268-
let projection = perspective_view(
268+
let projection = ultraviolet::projection::lh_yup::perspective_gl(
269269
45.0_f32.to_radians(),
270270
(WINDOW_WIDTH as f32) / (WINDOW_HEIGHT as f32),
271271
0.1,
@@ -293,10 +293,10 @@ fn main() {
293293
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
294294

295295
for (i, position) in CUBE_POSITIONS.iter().copied().enumerate() {
296-
let model = Mat4::translate(position)
297-
* Mat4::rotate_x(3.0)
298-
* Mat4::rotate_y((1.0 + i as f32) * 0.8)
299-
* Mat4::rotate_z(time * (1.0 + i as f32));
296+
let model = Mat4::from_translation(position)
297+
* Mat4::from_rotation_x(3.0)
298+
* Mat4::from_rotation_y((1.0 + i as f32) * 0.8)
299+
* Mat4::from_rotation_z(time * (1.0 + i as f32));
300300

301301
glUniformMatrix4fv(model_loc, 1, GL_FALSE, model.as_ptr());
302302

examples/014-mouse-look.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ use learn::{
1717
null_str, Buffer, BufferType, Shader, ShaderProgram, ShaderType, VertexArray,
1818
};
1919
use learn_opengl as learn;
20-
use learn_opengl::math::*;
2120
use ogl33::*;
21+
use ultraviolet::*;
2222

2323
type Vertex = [f32; 3 + 2];
2424
/// Draw this with glDrawArrays(GL_TRIANGLES, 0, 36)
@@ -262,7 +262,7 @@ fn main() {
262262
glGetUniformLocation(shader_program.0, name)
263263
};
264264

265-
let projection = perspective_view(
265+
let projection = ultraviolet::projection::lh_yup::perspective_gl(
266266
45.0_f32.to_radians(),
267267
(WINDOW_WIDTH as f32) / (WINDOW_HEIGHT as f32),
268268
0.1,
@@ -296,9 +296,11 @@ fn main() {
296296

297297
// update the "world state".
298298
let time = sdl.get_ticks() as f32 / 10_000.0_f32;
299-
let view =
300-
Mat4::euler_angles(0.0, view_pitch.to_radians(), view_yaw.to_radians())
301-
* Mat4::translate(vec3(0.0, 0.0, -3.0));
299+
let view = Mat4::from_euler_angles(
300+
0.0,
301+
view_pitch.to_radians(),
302+
view_yaw.to_radians(),
303+
) * Mat4::from_translation(Vec3::new(0.0, 0.0, -3.0));
302304

303305
// and then draw!
304306
unsafe {
@@ -307,10 +309,10 @@ fn main() {
307309
glUniformMatrix4fv(view_loc, 1, GL_FALSE, view.as_ptr());
308310

309311
for (i, position) in CUBE_POSITIONS.iter().copied().enumerate() {
310-
let model = Mat4::translate(position)
311-
* Mat4::rotate_x(3.0)
312-
* Mat4::rotate_y((1.0 + i as f32) * 0.8)
313-
* Mat4::rotate_z(time * (1.0 + i as f32));
312+
let model = Mat4::from_translation(position)
313+
* Mat4::from_rotation_x(3.0)
314+
* Mat4::from_rotation_y((1.0 + i as f32) * 0.8)
315+
* Mat4::from_rotation_z(time * (1.0 + i as f32));
314316

315317
glUniformMatrix4fv(model_loc, 1, GL_FALSE, model.as_ptr());
316318

examples/015-fps-movement.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ use learn::{
1717
null_str, Buffer, BufferType, Shader, ShaderProgram, ShaderType, VertexArray,
1818
};
1919
use learn_opengl as learn;
20-
use learn_opengl::math::*;
2120
use ogl33::*;
2221
use std::collections::HashSet;
22+
use ultraviolet::*;
2323

2424
type Vertex = [f32; 3 + 2];
2525
/// Draw this with glDrawArrays(GL_TRIANGLES, 0, 36)
@@ -263,7 +263,7 @@ fn main() {
263263
glGetUniformLocation(shader_program.0, name)
264264
};
265265

266-
let projection = perspective_view(
266+
let projection = ultraviolet::projection::lh_yup::perspective_gl(
267267
45.0_f32.to_radians(),
268268
(WINDOW_WIDTH as f32) / (WINDOW_HEIGHT as f32),
269269
0.1,
@@ -322,10 +322,10 @@ fn main() {
322322
glUniformMatrix4fv(view_loc, 1, GL_FALSE, view.as_ptr());
323323

324324
for (i, position) in CUBE_POSITIONS.iter().copied().enumerate() {
325-
let model = Mat4::translate(position)
326-
* Mat4::rotate_y(3.0)
327-
* Mat4::rotate_x((1.0 + i as f32) * 0.8)
328-
* Mat4::rotate_z(time * (1.0 + i as f32));
325+
let model = Mat4::from_translation(position)
326+
* Mat4::from_rotation_y(3.0)
327+
* Mat4::from_rotation_x((1.0 + i as f32) * 0.8)
328+
* Mat4::from_rotation_z(time * (1.0 + i as f32));
329329

330330
glUniformMatrix4fv(model_loc, 1, GL_FALSE, model.as_ptr());
331331

src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ TODO:
3333
use core::convert::{TryFrom, TryInto};
3434
use ogl33::*;
3535

36-
pub mod math;
37-
3836
/// Takes a string literal and concatenates a null byte onto the end.
3937
#[macro_export]
4038
macro_rules! null_str {

0 commit comments

Comments
 (0)