r/odinlang

▲ 33 r/odinlang+1 crossposts

Direct3D 12 Renderer in Odin - Devlog #1

I'm making a 3D Renderer in Odin! I hope this is interesting to someone.

lucypero.com
u/lucypero — 21 hours ago

My attempt at wrapping llama.cpp for Odin

Hi fellow Odin aficionados,

I am trying to build a wrapper for llama.cpp that would allow direct calls from Odin (inspired by an older work by Yevhen K). So far, only a portion of the API is covered; it allows for making a simple chat application with multiple prompt-response exchanges. It is not ready for common use but I plan, if time allows, to gradually make it so. I will be glad for all critique; there are many points in the API I'm not sure whether I am calling it properly, and many others where I'm not sure it is the proper way how an Odin API should look or behave.

https://github.com/CzechBlueBear/odin_llama_ng

u/CzechBlueBear — 18 hours ago

Why passing context as parameters is required for anonymous procedures?

I created a procedure that loops through a dynamic array of projectiles, and accepts a anonymous procedure that has every instance of the looping projectiles as reference for context.

The compiler yells at me because &obstacles and &enemies doesn't exists in the anonymous proc context, although they do exists from the context i'm calling the update_and_mutate_projectiles proc.

I come from java, rust and javascript, and passing context to lambdas can be done without having to pass them down as parameters, so i'm wondering if this is a behavior related to low level stuff or preventing bad practices

u/GreatDaneQ — 1 day ago

Question about structuring project configuration for bigger Odin projects

Hey,

I've been generally enjoying Odin for small projects, but there's a struggle I've been having as soon as the project hits the point where structure is needed.

This problem is usually solved in other languages via conventional project structures implemented by standard centralized build systems, which Odin avoids.

Example: If I have a project with multiple entrypoints that also have common logic they need to be able to import, something like this project structure:

├── bin
│  ├── entrypoint1
│  │  └── main.odin  # import "local:common"
│  └── entrypoint2
│     └── main.odin  # import "local:common"
├── local
│  └── common
│     └── common.odin

For this structure to work, however, I need to always call odin like odin run bin/entrypoint1 -collection:local=./local as a CLI option.

In order for it to persist as project configuration, I need to create a Makefile duplicating every odin sub-command that takes that option.

This is also required if I need any other non-default compiler option passed in.

For it to also work with OLS, I need to create a ols.json file and repeat configuration mirroring the same compiler options there as well, so there's no longer a single source of truth describing the project's flags, and if this ever changes or I need to add more collections (like vendored dependencies), there are now two places to update.

How are you dealing with this issue in your projects?

reddit.com
u/Imaginos_In_Disguise — 3 days ago

Built a terminal blackjack game in Odin as my first project with the language

Hey! I decided to try to learn Odin by building something concrete. Over a few evenings I put together terminal21, a blackjack game that runs in the terminal.

Features:

- 312 cards deck with reshuffle at 25% remaining

- Split, double down (9/10/11 only)

- Betting system with save/load (JSON)

- Dealer AI (hits until 17+)

- Ace as 1 or 11

I'm sure there are plenty of non-idiomatic things in there. Feedbacks are very welcome! It was a great way to learn something about the language. I'm sure it's not idiomatic in any way, but it was fun and I had a blast.

github.com
u/BayslakJourney — 3 days ago
▲ 122 r/odinlang+2 crossposts

Part 2! - "No Graphics API" Vulkan Implementation

About 6 months ago I posted here about a prototype implementation I had made of the famous blog post by Sebastian Aaltonen. Back then the project was more of a proof of concept than anything else, and did not even support textures. The custom shading language compiler could only build very basic shaders.

Now the project is much more developed and mature, supporting nice features such as compute shaders, raytracing and indirect rendering. There are even quite a few examples that show that you can make substantial things with relatively few lines of code (without giving up control).

Have a look if you're interested:
https://github.com/leotmp/no_gfx_api

u/No_Grapefruit1933 — 8 days ago

I just made my first project with odin and the language is amazing

Hi, I just wanted to share my opinion about odin.

I have made a cli that records desktop audio (music in my case) using miniaudio and then streams that audio by tcp. Also uses dbus, first, to control the music player, and second, to publish a service in avahi.

It is amazing that odin has the vendor packages :D I also love how simple is to use c bindings, for example the dbus binding I have used, but also the miniaudio vendor package.

For me was impressive the binary size 1.1Mb, it is crazy that the program fits in that. Another point for Odin was memory allocation, it felt simple but powerful, and very lightweight. (Allocating 3 MB and seeing that consumes that and not more is mind blowing)

This project is the first time I code in odin and it will not be the last, I really enjoyed the language.

What are your favorite features or differences comparing to other languages? I am very curious to hear about

(If anyone is interested in the project I leave here a link: https://github.com/PiterWeb/audio-be)

u/PiterzKun — 8 days ago
▲ 177 r/odinlang+1 crossposts

Quilt, developed with Odin & Raylib

u/POiNTx — 10 days ago

Best alternatives to VS Code for Odin development?

I was wondering what text editor or IDE the community uses/likes the most for Odin development besides VS Code?
Nothing against VS Code, I just personally just don't like using it.
Thanks in advance!

reddit.com
u/EdSterling — 10 days ago
▲ 6 r/odinlang+1 crossposts

Would love some feedback on super simple game written in Odin

Hi there, I'm not much of a game dev but would love some feedback on a project I spent a few days on. It's basically just a space-invaders like game written in Odin using raylib. I'm aware that it looks quite bare bones but I wanted to get some feedback early so I don't run in a completely wrong direction.

https://github.com/MaximeBonnin/land-invader (download under releases)

Things I am aware off:

- Game play lacks depth, needs more bullet types etc

- Assets. Currently it's just boxes and silence.

- Preventing cheating

Things I think are decent:

- Scoreboard works

- The game is hard and getting a high score feels good

u/Mori-Spumae — 9 days ago

json marshaling struct fails

Apparently when writing to a json file you get an error if you try to marshal a pointer to a struct, so i searched for the error and found you can put this at the end of your line

`attack_target: ^Entity \`json:"-"\`,` 

`aggro_target: ^Entity \`json:"-"\`,` 

This works on another project just fine, but on my current project it is still throwing the Unsupported_Type error. It has worked before as well, which is whats confusing me. I'm only saving the list of entities to the file:

`if level_data, err := json.marshal(&entities, options, allocator = context.temp_allocator); err == nil{`

	`_ = os.write_entire_file("level.json", level_data)`

	`log.info("level.json")`

`}else{`

	`log.info(err)`

`}`

The only two pointers in the entity struct are the two posted above, is there another type that doesn't work for writing to the file? I also looked into debugging to get a little more information that just a "Unsupported Type" error but the docs are kinda trash. Anyone dealt with this before?

reddit.com
u/Alternative-Title-87 — 11 days ago

Is there a measurable difference in making procedures contextless?

I've been writing a serialization layer for my game's networking and I figured that my read/write operations do not need the context pointer. Would adding contextless make any difference performance-wise, besides the obvious lack of needing to pass another parameter to the functions?

reddit.com
u/AnnoyingMemer — 12 days ago

Physics Engine in Odin from Scratch, Part III

In the third part of a series of tutorials on building a physics engine in Odin from scratch, we'll start implementing the cornerstone of our engine based on the theoretical foundation from the previous part, and by the end, our cubes will fall under the influence of gravity.

marianpekar.com
u/marianpekar — 14 days ago