Drago3D
A downloadable project
If you've used 3D in GameMaker in the past before migrating to GMS2, you've probably been warned against using the compatibility scripts that GameMaker provides for you when you import an older project. There are many reasons for this:
- They're slow
- They're very barebones
- They were created to use the DirectX 8 API, which at this point in time, is older than a significant number of GameMaker's actual users
- They're actually even slower than you think, since the compatibility functions don't even make an API call but instead emulate them within GML
Vertex buffers are the preferred substitute in whatever the current year is, which are orders of magnitude faster and more capable. However, there remains something to be said for having a set of immediate-mode functions for drawing 3D geometry, so here you go.
This requires a relatively modern version of GameMaker to work. There's a version for LTS (2022.0), which won't work with the original version due to some changes to the way statics are initialized.
Performance
In all cases performance with Drago3D will be noticeably better than with using the compatibility functions.
Some shapes, particularly spheres, will get a much, much larger boost. This is due to the potentially large number of vertices that can be involved, as the compatibility functions build the geometry from scratch (and then delete it) every single time they're called.
Documentation
can be found here.
Other Stuff
I "fixed" the texture mapping on the tops and bottoms of cylinders and cones.
Yes I realize the name is probably going to make the search results weird.
Should You Use This In A Finished Game?
Ideally you only use this thing for blocking out levels and replace everything with proper 3D meshes when you're finished, but if you really want to use this in production I can't stop you. It's better than the original d3d, at least.
Using this with shaders
These should work with the default GameMaker shader. If you want to use your own, the vertex format is position
, normal
, color
, texture
, which is what 95% of you are probably using anyway.
Price
This is going to be free, like most of my other stuff. I'd appreciate an involuntary payment via either Itch or Patreon.
Other Relevant Projects
I've made a bunch of other things for 3D in Gamemaker that you might be interested in:
Download
Click download now to get access to the following files:
Development log
- Added functions for drawing capsules and lines34 days ago
- Added a 2022.0 LTS versionMar 28, 2024
Comments
Log in with itch.io to leave a comment.
Really nice. Thank you for making this.
When i create the d3d_draw_block()
My texture is clipping. Disappear at the some point.
I dont know why, or something in my projection is wrong, idk.
Edit :
My bad, i forgot to create gpu_set_ztestenable(true) and gpu_set_zwriteenable(true)
Thanks for your Script. Really Love It
I had the same issue thanks for comment
Seems like mine always crashes from the static vertex = Drago3D_Internals.Vertex;
in the d3d_draw_block.
Can’t replicate it. What version of GameMaker are you using?
Slightly old: 2022.0.30
Hmm, something probably changed in the way statics are initialized since LTS came out. I’ll look at it in a little while
Thanks for taking a look. One day I'll update to the current version.
Okay sorry for the delay, try replacing the Drago3D_Internals file with this: https://gist.github.com/DragoniteSpam/2839c0d97596f3d36066aa6635a9e609
I’ll make a “proper” LTS release after dinner.
Does this include functions for rotating models? Attempting to rewrite an old game I built in 3D that uses a lot of transformations. :]
Btw, thanks for doing this- I hope it helps quite a few people.
Edit: I realize you can probably just set the matrix to rotate it. I'm not sure what I was expecting. D3D was really weird.