# My Project: Formine

**URL:** <https://fortran-lang.discourse.group/t/my-project-formine/8779>\
**Category:** Announcements\
**Created:** [October 31, 2024, 2:15pm UTC](https://fortran-lang.discourse.group/t/my-project-formine/8779 "2024-10-31T14:15:22Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![jordan4ibanez](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/jordan4ibanez/32/5314_2.png) [@jordan4ibanez](https://fortran-lang.discourse.group/u/jordan4ibanez)\
**Post date:** [October 31, 2024, 2:15pm UTC](https://fortran-lang.discourse.group/t/my-project-formine/8779/1 "2024-10-31T14:15:22Z")

</div>

I suppose I will announce this as you can actually fly around this thing and look at the existing map at the moment.

Formine is a voxel game written in Fortran 03+, LuaJIT, and C.

Here is a video: [https://youtu.be/Sn-0dpEhpT4](https://youtu.be/Sn-0dpEhpT4)

Here is the github: [GitHub - jordan4ibanez/formine: A voxel game, written in Fortran, LuaJIT, and C.](https://github.com/jordan4ibanez/formine)

Extremely early stages. I am working on the Vulkan backend at the moment.

---

<div class="post-metadata">

**Author:** ![vmagnin](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/vmagnin/32/28_2.png) [@vmagnin](https://fortran-lang.discourse.group/u/vmagnin)\
**Post date:** [October 31, 2024, 3:41pm UTC](https://fortran-lang.discourse.group/t/my-project-formine/8779/2 "2024-10-31T15:41:39Z")

</div>

> [@jordan4ibanez](#):
>
> Formine is a voxel game written in Fortran 03+, LuaJIT, and C.

Can you explain the roles of each of the three languages?

---

<div class="post-metadata">

**Author:** ![jordan4ibanez](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/jordan4ibanez/32/5314_2.png) [@jordan4ibanez](https://fortran-lang.discourse.group/u/jordan4ibanez)\
**Post date:** [October 31, 2024, 3:49pm UTC](https://fortran-lang.discourse.group/t/my-project-formine/8779/3 "2024-10-31T15:49:07Z")

</div>

Fortran: The main driver, basically 95% of the program is written in this.  
LuaJIT: The scripting language. Allows extremely easy modding and JIT compilation of mods. (only blocks and biomes at the moment)  
C: For when I need to get deeper to the hardware.

A specific example in C would be this, which is the Vulkan driver I am writing for it:

```C
#include <stdlib.h>
#include <assert.h>
#include <vulkan/vulkan_core.h>

VkInstance *vk_grab_instance_pointer()
{
  void *data = malloc(sizeof(VkInstance));

  assert(data);

  return (VkInstance *)data;
}

```

I cannot get the size of `VkInstance` to create the base data. It’s a pointer, I have access to it. Just pass that to Fortran. 🙂

And in `forvk.f90`:

```fortran
module forvk
  interface
    function vk_grab_instance_pointer() result(ptr) bind(c, name = "vk_grab_instance_pointer")
      use, intrinsic :: iso_c_binding
      implicit none

      type(c_ptr) :: ptr
    end function vk_grab_instance_pointer
  end interface
end module forvk

```

If you look at hashmap\_f90 and fortran\_vector, you’ll see how I use C to get more performance out of Fortran without making it a nightmare to work with.

Additionally, some things I quite literally need C to work with. In Forthread I must use pthreads. This allows me to create a high performance thread pool to do tasks as fast as the hardware will allow me to without restricting the way it it used.

Also you’ll notice that it says it’s like 20% C++ for some reason, this is probably github getting confused as I ship STB\_IMAGE and there’s a whole bunch of comments and ifdefs. 😃

---

<div class="post-metadata">

**Author:** ![vmagnin](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/vmagnin/32/28_2.png) [@vmagnin](https://fortran-lang.discourse.group/u/vmagnin)\
**Post date:** [October 31, 2024, 4:00pm UTC](https://fortran-lang.discourse.group/t/my-project-formine/8779/4 "2024-10-31T16:00:08Z")

</div>

> [@jordan4ibanez](#):
>
> Also you’ll notice that it says it’s like 20% C++ for some reason, this is probably github getting confused as I ship STB\_IMAGE and there’s a whole bunch of comments and ifdefs. 😃

Maybe this recent post about a `.gitattributes` file could be helpful:

> [@Guidelines for GitHub Fortran repos](https://fortran-lang.discourse.group/t/guidelines-for-github-fortran-repos/8440/14):
>
> Just a little tip for the GitHub users. I just faced a strange situation where my repos where flagged as mainly Javascript or Pascal repos. Because some of my repos contain: the documentation site (lots of .js and .html files) or include files (I use .inc which is recognized as Pascal) the ‘Languages’ statistics on GitHub are often wrong. If you end up in the same situation you can add a .gitattributes file to the root of your Github repository with the following: \*.inc linguist-language=F…

---

<div class="post-metadata">

**Author:** ![fedebenelli](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/fedebenelli/32/1823_2.png) [@fedebenelli](https://fortran-lang.discourse.group/u/fedebenelli)\
**Post date:** [October 31, 2024, 5:06pm UTC](https://fortran-lang.discourse.group/t/my-project-formine/8779/5 "2024-10-31T17:06:00Z")

</div>

Incredible work! This is a good example of how Fortran is able to work as a general use language besides just number crunching

---

<div class="post-metadata">

**Author:** ![jordan4ibanez](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/jordan4ibanez/32/5314_2.png) [@jordan4ibanez](https://fortran-lang.discourse.group/u/jordan4ibanez)\
**Post date:** [November 1, 2024, 1:51am UTC](https://fortran-lang.discourse.group/t/my-project-formine/8779/6 "2024-11-01T01:51:30Z")

</div>

I’m not sure this will actually have any affect sadly because it’s a pure C file that’s just huge. STB libs have a lot of comments, which I can probably solve relatively easily. But I like complaining about it first lol.

---

<div class="post-metadata">

**Author:** ![jordan4ibanez](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/jordan4ibanez/32/5314_2.png) [@jordan4ibanez](https://fortran-lang.discourse.group/u/jordan4ibanez)\
**Post date:** [November 1, 2024, 1:51am UTC](https://fortran-lang.discourse.group/t/my-project-formine/8779/7 "2024-11-01T01:51:52Z")

</div>

Thank you, thank you. I will certainly keep it up. 8)

---

<div class="post-metadata">

**Author:** ![jordan4ibanez](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/jordan4ibanez/32/5314_2.png) [@jordan4ibanez](https://fortran-lang.discourse.group/u/jordan4ibanez)\
**Post date:** [November 20, 2024, 5:24am UTC](https://fortran-lang.discourse.group/t/my-project-formine/8779/8 "2024-11-20T05:24:58Z")

</div>

Well, I kept it up. And now we have our first Vulkan triangle.

 ![vulkan_triangle](https://global.discourse-cdn.com/free1/uploads/fortran_lang/original/2X/9/9cc4b69715e07ac7be2a52ced85770c71d341390.jpeg)

---

<div class="post-metadata">

**Author:** ![Carltoffel](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/carltoffel/32/1680_2.png) [@Carltoffel](https://fortran-lang.discourse.group/u/Carltoffel)\
**Post date:** [November 20, 2024, 12:29pm UTC](https://fortran-lang.discourse.group/t/my-project-formine/8779/9 "2024-11-20T12:29:12Z")

</div>

I’m impressed by the smoothness of the build process. Clone, fpm run, done. Nothing else had to be done.
