ze1
Member
Hi, I have a simple dungeon crawler project in GMS1 that used a bunch of d3d functions. When I imported that project into GMS2.3, the project conversion created new functions to replace the deprecated ones in GMS2.3, but it doesn't work when I run the game in GMS2.3. I've attached the pictures of the game both in GMS1 and GMS2.3.
Here are the converted functions below. They have the same names as their respective GMS D3D functions
__init_global
d3d_start
d3d_vertex_normal_texture
d3d_set_projection
d3d_set_fog
d3d_primitive_begin_texture
d3d_primitive_end
d3d_draw_floor
d3d_draw_block
Here are the converted functions below. They have the same names as their respective GMS D3D functions
__init_global
GML:
function __init_global() {
gml_pragma( "global", "__init_global();");
// set any global defaults
layer_force_draw_depth(true,0); // force all layers to draw at depth 0
draw_set_colour( c_black );
}
d3d_start
GML:
/// @description d3d - enable 3d
function d3d_start() {
var ret = global.__d3d;
global.__d3d = true;
//camera_apply(global.__d3dCamera);
gpu_set_ztestenable(true);
gpu_set_zwriteenable(true);
return ret;
}
GML:
/// @description d3d - Defines a vertex for a textured primitive in 3D along with its corresponding normal.
/// @param x the x position
/// @param y the y position
/// @param z the z position
/// @param nx the normal x
/// @param ny the normal y
/// @param nz the normal z
/// @param u the normal u
/// @param v the normal v
function d3d_vertex_normal_texture(argument0, argument1, argument2, argument3, argument4, argument5, argument6, argument7) {
vertex_position_3d( global.__d3dPrimBuffer, argument0, argument1, argument2 );
vertex_normal( global.__d3dPrimBuffer, argument3, argument4, argument5 );
vertex_colour( global.__d3dPrimBuffer, draw_get_colour(), draw_get_alpha() );
vertex_texcoord( global.__d3dPrimBuffer, (argument6 * global.__d3dPrimTexW) + global.__d3dPrimTexX, (argument7 * global.__d3dPrimTexH) + global.__d3dPrimTexY );
}
GML:
/// @description @description d3d - set projection
/// @param xFrom x of from position
/// @param yFrom y of from position
/// @param zFrom z of from position
/// @param xTo x of to position
/// @param yTo y of to position
/// @param zTo z of to position
/// @param xUp x of up vector
/// @param yUp y of up vector
/// @param zUp z of up vector
function d3d_set_projection(argument0, argument1, argument2, argument3, argument4, argument5, argument6, argument7, argument8) {
var m = matrix_build_lookat( argument0, argument1, argument2,
argument3, argument4, argument5,
argument6, argument7, argument8 );
var cam = camera_get_active();
camera_set_view_mat( cam, m );
if( !global.__d3d ) {
//apply default ortho projection
var mproj = matrix_build_projection_ortho(camera_get_view_width(cam),camera_get_view_height(cam),1,32000);
camera_set_proj_mat( cam, mproj);
}
camera_apply(cam);
}
d3d_set_fog
GML:
/// @description d3d - set fog enable/disable and colour
/// @param enable true if enabled, false if disabled
/// @param colour colour of the fog
/// @param near distance to when fog starts
/// @param far distance to when fog becomes absolute
function d3d_set_fog(argument0, argument1, argument2, argument3) {
gpu_set_fog(argument0, argument1, argument2, argument3 );
}
d3d_primitive_begin_texture
GML:
/// @description d3d - begin making a primitive stream
/// @param kind Primitive kind
/// @param tex Texture Index
function d3d_primitive_begin_texture(argument0, argument1) {
if (global.__d3dPrimKind != -1) {
show_debug_message( "ERROR : cannot begin a primitive before end called on previous")
}
global.__d3dPrimKind = argument0;
global.__d3dPrimTex = argument1;
var __uvs = texture_get_uvs(global.__d3dPrimTex);
global.__d3dPrimTexX = __uvs[0];
global.__d3dPrimTexY = __uvs[1];
global.__d3dPrimTexW = __uvs[2] - __uvs[0];
global.__d3dPrimTexH = __uvs[3] - __uvs[1];
vertex_begin( global.__d3dPrimBuffer, global.__d3dPrimVF );
}
d3d_primitive_end
GML:
/// @description d3d - end the primitive stream
function d3d_primitive_end() {
if (global.__d3dPrimKind != -1) {
vertex_end( global.__d3dPrimBuffer );
vertex_submit( global.__d3dPrimBuffer, global.__d3dPrimKind, global.__d3dPrimTex );
// mark this as finished
global.__d3dPrimKind = -1;
} else {
show_debug_message( "d3d_primitive_end :: with no d3d_primitive_begin ");
}
}
d3d_draw_floor
GML:
/// @description Draws a simple 3D floor.
/// @param x1 The initial x coordinate of the floor.
/// @param y1 The initial y coordinate of the floor.
/// @param z1 The initial z coordinate of the floor.
/// @param x2 The opposite x coordinate of the floor.
/// @param y2 The opposite y coordinate of the floor.
/// @param z2 The opposite z coordinate of the floor.
/// @param tex The id of the texture to use (-1 for no texture)
/// @param hrepeat Amount of horizontal repetitions for the texture.
/// @param vrepeat Amount of vertical repetitions for the texture.
/// @returns
function d3d_draw_floor(argument0, argument1, argument2, argument3, argument4, argument5, argument6, argument7, argument8) {
var __x1 = argument0;
var __y1 = argument1;
var __z1 = argument2;
var __x2 = argument3;
var __y2 = argument4;
var __z2 = argument5;
var __tex = argument6;
var __hrepeat = argument7;
var __vrepeat = argument8;
var __xdiff = __x2 - __x1;
var __zdiff = __z2 - __z1;
var __lsquared = (__xdiff * __xdiff) + (__zdiff * __zdiff);
if (__lsquared == 0)
return 0;
var __l = sqrt(__lsquared);
var __nx = -__zdiff / __l;
var __nz = __xdiff / __l;
var __oldrep = gpu_get_texrepeat();
gpu_set_texrepeat(true)
d3d_primitive_begin_texture(pr_trianglefan, __tex);
d3d_vertex_normal_texture(__x1, __y1, __z1, __nx, 0, __nz, 0, 0);
d3d_vertex_normal_texture(__x1, __y2, __z1, __nx, 0, __nz, 0, __vrepeat);
d3d_vertex_normal_texture(__x2, __y2, __z2, __nx, 0, __nz, __hrepeat, __vrepeat);
d3d_vertex_normal_texture(__x2, __y1, __z2, __nx, 0, __nz, __hrepeat, 0);
d3d_primitive_end();
gpu_set_texrepeat(__oldrep);
}
GML:
/// @description Draws a simple 3D block.
/// @param x1 The initial x coordinate of the block.
/// @param y1 The initial y coordinate of the block.
/// @param z1 The initial z coordinate of the block.
/// @param x2 The opposite x coordinate of the block.
/// @param y2 The opposite y coordinate of the block.
/// @param z2 The opposite z coordinate of the block.
/// @param tex The id of the texture to use (-1 for no texture)
/// @param hrepeat Amount of horizontal repetitions for the texture.
/// @param vrepeat Amount of vertical repetitions for the texture.
/// @returns
function d3d_draw_block(argument0, argument1, argument2, argument3, argument4, argument5, argument6, argument7, argument8) {
var __x1 = argument0;
var __y1 = argument1;
var __z1 = argument2;
var __x2 = argument3;
var __y2 = argument4;
var __z2 = argument5;
var __tex = argument6;
var __hrepeat = argument7;
var __vrepeat = argument8;
var __oldrep = gpu_get_texrepeat();
gpu_set_texrepeat(true)
d3d_primitive_begin_texture(pr_trianglelist, __tex);
d3d_vertex_normal_texture(__x1, __y1, __z1, 0, 0, -1, 0, 0);
d3d_vertex_normal_texture(__x1, __y2, __z1, 0, 0, -1, 0, __vrepeat);
d3d_vertex_normal_texture(__x2, __y2, __z1, 0, 0, -1, __hrepeat, __vrepeat);
d3d_vertex_normal_texture(__x2, __y2, __z1, 0, 0, -1, __hrepeat, __vrepeat);
d3d_vertex_normal_texture(__x2, __y1, __z1, 0, 0, -1, __hrepeat, 0);
d3d_vertex_normal_texture(__x1, __y1, __z1, 0, 0, -1, 0, 0);
d3d_vertex_normal_texture(__x1, __y1, __z2, 0, 0, 1, 0, 0);
d3d_vertex_normal_texture(__x2, __y1, __z2, 0, 0, 1, __hrepeat, 0);
d3d_vertex_normal_texture(__x2, __y2, __z2, 0, 0, 1, __hrepeat, __vrepeat);
d3d_vertex_normal_texture(__x2, __y2, __z2, 0, 0, 1, __hrepeat, __vrepeat);
d3d_vertex_normal_texture(__x1, __y2, __z2, 0, 0, 1, 0, __vrepeat);
d3d_vertex_normal_texture(__x1, __y1, __z2, 0, 0, 1, 0, 0);
d3d_vertex_normal_texture(__x1, __y2, __z1, 0, 1, 0, 0, 0);
d3d_vertex_normal_texture(__x1, __y2, __z2, 0, 1, 0, 0, __vrepeat);
d3d_vertex_normal_texture(__x2, __y2, __z2, 0, 1, 0, __hrepeat, __vrepeat);
d3d_vertex_normal_texture(__x2, __y2, __z2, 0, 1, 0, __hrepeat, __vrepeat);
d3d_vertex_normal_texture(__x2, __y2, __z1, 0, 1, 0, __hrepeat, 0);
d3d_vertex_normal_texture(__x1, __y2, __z1, 0, 1, 0, 0, 0);
d3d_vertex_normal_texture(__x2, __y2, __z1, 1, 0, 0, 0, 0);
d3d_vertex_normal_texture(__x2, __y2, __z2, 1, 0, 0, 0, __vrepeat);
d3d_vertex_normal_texture(__x2, __y1, __z2, 1, 0, 0, __hrepeat, __vrepeat);
d3d_vertex_normal_texture(__x2, __y1, __z2, 1, 0, 0, __hrepeat, __vrepeat);
d3d_vertex_normal_texture(__x2, __y1, __z1, 1, 0, 0, __hrepeat, 0);
d3d_vertex_normal_texture(__x2, __y2, __z1, 1, 0, 0, 0, 0);
d3d_vertex_normal_texture(__x2, __y1, __z1, 0, -1, 0, 0, 0);
d3d_vertex_normal_texture(__x2, __y1, __z2, 0, -1, 0, 0, __vrepeat);
d3d_vertex_normal_texture(__x1, __y1, __z2, 0, -1, 0, __hrepeat, __vrepeat);
d3d_vertex_normal_texture(__x1, __y1, __z2, 0, -1, 0, __hrepeat, __vrepeat);
d3d_vertex_normal_texture(__x1, __y1, __z1, 0, -1, 0, __hrepeat, 0);
d3d_vertex_normal_texture(__x2, __y1, __z1, 0, -1, 0, 0, 0);
d3d_vertex_normal_texture(__x1, __y1, __z1, -1, 0, 0, 0, 0);
d3d_vertex_normal_texture(__x1, __y1, __z2, -1, 0, 0, 0, __vrepeat);
d3d_vertex_normal_texture(__x1, __y2, __z2, -1, 0, 0, __hrepeat, __vrepeat);
d3d_vertex_normal_texture(__x1, __y2, __z2, -1, 0, 0, __hrepeat, __vrepeat);
d3d_vertex_normal_texture(__x1, __y2, __z1, -1, 0, 0, __hrepeat, 0);
d3d_vertex_normal_texture(__x1, __y1, __z1, -1, 0, 0, 0, 0);
d3d_primitive_end();
gpu_set_texrepeat(__oldrep);
}
Attachments
-
261.7 KB Views: 5
-
7.4 KB Views: 4