Skip to content

Commit

Permalink
d3d_light_get_enabled, buffer_get_lights
Browse files Browse the repository at this point in the history
  • Loading branch information
omicronrex committed Aug 22, 2024
1 parent b505c5a commit aaa3ac0
Show file tree
Hide file tree
Showing 3 changed files with 128 additions and 58 deletions.
149 changes: 91 additions & 58 deletions gm82dx9.gej
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"folder": "gm82",
"version": "1.0",
"author": "Floogle && renex",
"date": "21/08/2024",
"date": "22/08/2024",
"license": "Free to use, also for commercial games.",
"description": "Requires Game Maker 8.2 Network. Part of the standard Game Maker 8.2 distribution. This extension package upgrades Game Maker to DirectX version 9.0, providing extended render state control and HLSL9 shaders.",
"helpfile": "",
Expand Down Expand Up @@ -84,6 +84,17 @@
"argtypes": [],
"returntype": 2
},
{
"name": "d3d_light_get_enabled",
"extname": "",
"calltype": 12,
"helpline": "d3d_light_get_enabled(index)",
"hidden": false,
"argtypes": [
2
],
"returntype": 2
},
{
"name": "d3d_get_viewport_h",
"extname": "__gm82dx9_getviewporth",
Expand Down Expand Up @@ -257,6 +268,24 @@
],
"returntype": 2
},
{
"name": "d3d_transform_add_stack_top",
"extname": "",
"calltype": 12,
"helpline": "d3d_transform_add_stack_top()",
"hidden": false,
"argtypes": [],
"returntype": 2
},
{
"name": "d3d_transform_get_determinant",
"extname": "",
"calltype": 12,
"helpline": "d3d_transform_get_determinant()",
"hidden": false,
"argtypes": [],
"returntype": 2
},
{
"name": "d3d_transform_set_matrix",
"extname": "",
Expand All @@ -283,24 +312,6 @@
],
"returntype": 2
},
{
"name": "d3d_transform_add_stack_top",
"extname": "",
"calltype": 12,
"helpline": "d3d_transform_add_stack_top()",
"hidden": false,
"argtypes": [],
"returntype": 2
},
{
"name": "d3d_transform_get_determinant",
"extname": "",
"calltype": 12,
"helpline": "d3d_transform_get_determinant()",
"hidden": false,
"argtypes": [],
"returntype": 2
},
{
"name": "d3d_transform_xst",
"extname": "",
Expand Down Expand Up @@ -1076,24 +1087,23 @@
"returntype": 2
},
{
"name": "__gm82dx9_resize_backbuffer",
"name": "__gm82dx9_abort",
"extname": "",
"calltype": 12,
"helpline": "",
"hidden": true,
"argtypes": [
2,
2
],
"argtypes": [],
"returntype": 2
},
{
"name": "__gm82dx9_abort",
"name": "__gm82dx9_buffer_get_lights",
"extname": "",
"calltype": 12,
"helpline": "",
"hidden": true,
"argtypes": [],
"argtypes": [
2
],
"returntype": 2
},
{
Expand Down Expand Up @@ -1192,6 +1202,31 @@
],
"returntype": 2
},
{
"name": "__gm82dx9_projectvertex",
"extname": "",
"calltype": 12,
"helpline": "",
"hidden": true,
"argtypes": [
2,
2,
2
],
"returntype": 2
},
{
"name": "__gm82dx9_resize_backbuffer",
"extname": "",
"calltype": 12,
"helpline": "",
"hidden": true,
"argtypes": [
2,
2
],
"returntype": 2
},
{
"name": "__gm82dx9_setalphabuffer",
"extname": "",
Expand Down Expand Up @@ -1311,12 +1346,13 @@
"returntype": 2
},
{
"name": "__gm82dx9_shader_pixel_uniform_matrix",
"name": "__gm82dx9_shader_pixel_uniform_b_buffer",
"extname": "",
"calltype": 12,
"helpline": "",
"hidden": true,
"argtypes": [
2,
2,
2
],
Expand Down Expand Up @@ -1349,13 +1385,12 @@
"returntype": 2
},
{
"name": "__gm82dx9_shader_pixel_uniform_b_buffer",
"name": "__gm82dx9_shader_pixel_uniform_matrix",
"extname": "",
"calltype": 12,
"helpline": "",
"hidden": true,
"argtypes": [
2,
2,
2
],
Expand Down Expand Up @@ -1431,12 +1466,13 @@
"returntype": 2
},
{
"name": "__gm82dx9_shader_vertex_uniform_matrix",
"name": "__gm82dx9_shader_vertex_uniform_b_buffer",
"extname": "",
"calltype": 12,
"helpline": "",
"hidden": true,
"argtypes": [
2,
2,
2
],
Expand Down Expand Up @@ -1469,13 +1505,12 @@
"returntype": 2
},
{
"name": "__gm82dx9_shader_vertex_uniform_b_buffer",
"name": "__gm82dx9_shader_vertex_uniform_matrix",
"extname": "",
"calltype": 12,
"helpline": "",
"hidden": true,
"argtypes": [
2,
2,
2
],
Expand Down Expand Up @@ -1667,19 +1702,6 @@
2
],
"returntype": 2
},
{
"name": "__gm82dx9_projectvertex",
"extname": "",
"calltype": 12,
"helpline": "",
"hidden": true,
"argtypes": [
2,
2,
2
],
"returntype": 2
}
],
"constants": [
Expand Down Expand Up @@ -2007,6 +2029,17 @@
"init": "__gm82dx9_init",
"final": "__gm82dx9_quit",
"functions": [
{
"name": "buffer_get_lights",
"extname": "",
"calltype": 2,
"helpline": "buffer_get_lights(buffer)",
"hidden": false,
"argtypes": [
2
],
"returntype": 2
},
{
"name": "d3d_fog_trick",
"extname": "",
Expand Down Expand Up @@ -2062,6 +2095,19 @@
],
"returntype": 2
},
{
"name": "d3d_project_vertex",
"extname": "",
"calltype": 2,
"helpline": "d3d_project_vertex(x,y,z)",
"hidden": false,
"argtypes": [
2,
2,
2
],
"returntype": 2
},
{
"name": "d3d_set_alphablend",
"extname": "",
Expand Down Expand Up @@ -2189,19 +2235,6 @@
"hidden": true,
"argtypes": null,
"returntype": 2
},
{
"name": "d3d_project_vertex",
"extname": "",
"calltype": 2,
"helpline": "d3d_project_vertex(x,y,z)",
"hidden": false,
"argtypes": [
2,
2,
2
],
"returntype": 2
}
],
"constants": []
Expand Down
19 changes: 19 additions & 0 deletions source/gm82dx9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,25 @@ GMREAL __gm82dx9_set_alphatest(double enable,double value,double cmpfunc) {
Device->SetRenderState(D3DRS_ALPHAFUNC,(DWORD)(int)cmpfunc);
return 0;
}
GMREAL d3d_light_get_enabled(double index) {
///d3d_light_get_enabled(index)
//Returns: whether the light with index is enabled.

BOOL enabled;
vibe_check(Device->GetLightEnable((int)index,&enabled));
return enabled?1:0;
}
GMREAL __gm82dx9_buffer_get_lights(double buffer) {
D3DLIGHT9 light;
char* dest=(char*)(int)buffer;

for (int i=0;i<8;i++) {
vibe_check(Device->GetLight(i,&light));
memcpy(dest+i*104,&light,104);
}

return 0;
}
GMREAL __gm82dx9_set_light(
double index, double type,
double x, double y, double z,
Expand Down
18 changes: 18 additions & 0 deletions source/gm82dx9.gml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

if (__gm82dx9_checkstart()) exit

var __i; __i=0 repeat (8) {d3d_light_define_direction(__i,0,0,1,0) __i+=1}

//set target to appsurf at end step, to catch view setup and all draw events
object_event_add(__gm82dx9_controller,ev_step,ev_step_end,"__gm82dx9_prepare()")
//finally after all draw events, compose the window
Expand Down Expand Up @@ -154,6 +156,22 @@
} else d3d_set_fog(0,0,0,0)


#define buffer_get_lights
///buffer_get_lights(buffer)
var __buf;

__buf=argument0

if (!buffer_exists(__buf)) {
show_error("Trying to get lights data into a nonexisting buffer("+string(__buf)+").",0)
return 0
}

buffer_set_size(__buf,104*8)
buffer_set_pos(__buf,0)
__gm82dx9_buffer_get_lights(buffer_get_address(__buf,0))


#define draw_set_blend_alphamode
///draw_set_blend_alphamode(enable,[mode or [src,dest]])
if (argument_count<2) {
Expand Down

0 comments on commit aaa3ac0

Please sign in to comment.