Binsk
Member
SOLVED?: I'm not sure why, but if I switch from matrix_build_projection_perspective to matrix_build_projection_perspective_fov it renders as expected. That is what I normally use anyway so I'm going to call that the solution.
Howdy! I am no newbie to the 3D scene with GameMaker and elsewhere which is why I am baffled here. I'm just trying to set up a simple scene for testing purposes that renders a 3D plane as a floor.
As far as I can tell I'm not missing anything but I'm just getting a black screen (minus my debugging 2D circle which renders fine). Can someone just glance at my code and tell me if I'm missing something obvious?
CREATE CODE:
(create vbuffer for plane)
DRAW CODE:
My shader code is the default shader minus texture handling. I've ruled out the shader as I've forced it to just display white and I still get nothing.
I'm sure that I'm just missing something really stupid so if someone with fresh eyes can take a gander it would be appreciated. I've been programming a lot and my brain is a bit pooped so I think I'm glazing over something.
Thanks in advance.
Howdy! I am no newbie to the 3D scene with GameMaker and elsewhere which is why I am baffled here. I'm just trying to set up a simple scene for testing purposes that renders a 3D plane as a floor.
As far as I can tell I'm not missing anything but I'm just getting a black screen (minus my debugging 2D circle which renders fine). Can someone just glance at my code and tell me if I'm missing something obvious?
CREATE CODE:
(create vbuffer for plane)
Code:
vertex_format_begin();
vertex_format_add_position_3d();
vertex_format_add_color();
vbFormat = vertex_format_end();
vbFloor = vertex_create_buffer();
vertex_begin(vbFloor, vbFormat);
// Defined as a strip
vertex_position_3d(vbFloor, -.5, -5, 0);
vertex_color(vbFloor, c_white, 1.);
vertex_position_3d(vbFloor, .5, -5, 0);
vertex_color(vbFloor, c_white, 1.);
vertex_position_3d(vbFloor, -.5, 5, 0);
vertex_color(vbFloor, c_white, 1.);
vertex_position_3d(vbFloor, .5, 5, 0);
vertex_color(vbFloor, c_white, 1.);
vertex_end(vbFloor);
vertex_freeze(vbFloor);
gpu_set_cullmode(cull_noculling);
Code:
///@desc Render Scene
draw_set_color(c_white);
draw_set_alpha(1.);
// Save old matrices for reset
var _proj_old = matrix_get(matrix_projection),
_view_old = matrix_get(matrix_view),
_world_old = matrix_get(matrix_world);
// Build new matrices
var _proj_new = matrix_build_projection_perspective(room_width, room_height, 0.01, 1024);
var _view_new = matrix_build_lookat(-128, -128, 128, 0, 0, 0, 0, 0, 1);
matrix_set(matrix_projection, _proj_new);
matrix_set(matrix_view, _view_new);
// Render a floor:
matrix_set(matrix_world, matrix_build(0, 0, 0, 0, 0, 0, 50, 50, 50));
shader_set(dummyShd);
vertex_submit(vbFloor, pr_trianglestrip, -1);
shader_reset();
matrix_set(matrix_projection, _proj_old);
matrix_set(matrix_view, _view_old);
matrix_set(matrix_world, _world_old);
draw_circle(100, 100, 50, false);
I'm sure that I'm just missing something really stupid so if someone with fresh eyes can take a gander it would be appreciated. I've been programming a lot and my brain is a bit pooped so I think I'm glazing over something.
Thanks in advance.
Last edited: