
r/odinlang

Showcase: A HTTP/1.1 server library for Odin
Hey, I'd like to share Tina HTTP — A HTTP/1.1 server framework/library built on Tina concurrency framework. It passes 33/33 spec compliance check using uNetworking/h1spec for compliance check. There is some API reference guide in the README but there are a few examples to show how to use it.
Datastar example using the experimental/alpha SDK
See the [README](https://github.com/pmbanugo/tina/tree/main/examples) for running the examples or for using the HTTP library API. Here's info if you want to verify the compliance check.
I'll write and share a blog post about the architecture and how it's built on Tina Isolates. But the example and rough doc should have good enough detail for anyone who wants to try it and leave feedback.
Looking forward to you trying it and sharing your thoughts/feedback.
Showcase video of the top 10 games from the Karl2D Jam
youtube.comAnd if so, is there any sort of roadmap/timeline for it? I know that nbio was released a couple months ago so it seems like the groundwork for a net/http package is being laid.
Affinity Engine is a custom 3D game engine and editor built from scratch in the Odin programming language, using Raylib for rendering and Dear ImGui for the editor UI.
Every system is hand-written. I have designed it for full control over how data flows, how scenes are structured, and how things render while using Raylib to handle the "hard part" of 3D.
This is a preview of the editor so far and the 3d rendering. The editor currently includes gizmo, entity creation, entity editing, entity removal, entity duplication, entity management (id's, names, transforms etc..) file management, .json scene save/load, and a "play/stop" game feature. This is very early and just meant to be used as a preview of what's to come.
The project will be focused towards people wanting to create games or 3D scenes using the Odin language. I have plans on adding Lua as a scripting language later on.
The engine is maintaining a steady performance with no noticeable spikes. A public Alpha release date is to be determined.
compilation time conditional imports... somehow?
Context: currently I'm working on a game that uses dear imgui for all of the debug UI. I'm looking for an easy way to make these procedures only available at DEBUG builds.
I know that I can go through each procedure that uses imgui and define them conditionally with when ODIN_DEBUG, and do the same for the places that call them. That is actually what I'm doing already. However, it's hard to find the places that I need to do this. What if I miss a spot?
You know what would be easier? Being able to wrap the import statements themselves in these when blocks. This way I can easily grep my codebase for imports of this specific module, wrap them all with a when ODIN_DEBUG statement, and then have my compiler scream in case i use them anywhere inside a production build.
Any easy way to achieve this?
package main
import "fmt"
type Game interface {
Init()
Update(dt float64)
Draw(dt float64)
}
func RunGame(g Game) {
g.Init()
for range 10 {
dt := 1.0 //calculate dt
g.Update(dt)
g.Draw(dt)
}
}
type MyGame struct {
Data int
}
func (g *MyGame) Init() {
g.Data = 0
}
func (g *MyGame) Update(dt float64) {
g.Data += 1
}
func (g *MyGame) Draw(dt float64) {
fmt.Println(g.Data)
}
func main() {
var myGame MyGame
RunGame(&myGame)
}
how to simulate this go code in odin: i want to create a game interface where users can override update and draw function while being able to access game variables (Data in this example).
you can run the above code in go playground
Could context.io solve function coloring without signature changes?
It might be worth considering an approach in Odin similar to Zig's std.Io — particularly because Odin already has `context`. With something like `context.io`, this could potentially be done without requiring any signature changes in libraries.
I don't have deep experience with nbio, but it seems to me that unless you adopt a model like Go's goroutines or Zig's std.Io, the function coloring problem is essentially unavoidable. Given that Odin already has `context`, I'd argue it's actually in a better position than Zig to adopt and apply this kind of approach.
The first, mostly introductory part of a new series in which we'll build a physics engine on top of a 3D software renderer we've built from scratch in the previous series.
In this opening part, we'll set up the project, implement a few minor preparatory changes, take a highl-level look at the architecture of a physics engine, and outline the plan for how we're going to build our own across the upcoming eight parts.
In
I made a very minimalist Odin formatter for myself. I have tried odinfmt in the past. I have nothing against it, but I prefer something that leaves the code more as it is. I like it when the formatter lets me add newlines to anything, and doesn't ever introduce newlines. That's a big one for me.
So, lucyfmt's killer features are:
- It leaves your code alone! Plus, it does the following:
- Indents lines with 1 tab per scope level, except for
whenblocks. - Adds one indent level to parameters if they were broken up into multiple lines.
- There's no way to configure this formatter. This is a great feature, actually. I'll tell you why:
- Keeps it simple.
- There's no way for you to screw it up.
- Every file formatted with lucyfmt is formatted exactly the same.
Showcase
// Adds indentation, **only** if you break up a function call in multiple lines.
ct.window = sdl.CreateWindow(
"lucydx12",
sdl.WINDOWPOS_UNDEFINED,
sdl.WINDOWPOS_UNDEFINED,
WINDOW_WIDTH,
WINDOW_HEIGHT,
{.ALLOW_HIGHDPI, .SHOWN, .RESIZABLE},
)
// This will _not_ get broken up into multiple lines! lucyfmt respects the programmer.
ct.window = sdl.CreateWindow("lucydx12", sdl.WINDOWPOS_UNDEFINED, sdl.WINDOWPOS_UNDEFINED, WINDOW_WIDTH, WINDOW_HEIGHT, {.ALLOW_HIGHDPI, .SHOWN, .RESIZABLE})
// Same to struct initializers
to_render_target_barrier := dx.RESOURCE_BARRIER {
Type = .TRANSITION,
Flags = {},
Transition = {
pResource = g_dx_context.targets[g_dx_context.frame_index],
StateBefore = dx.RESOURCE_STATE_PRESENT,
StateAfter = {.RENDER_TARGET},
Subresource = dx.RESOURCE_BARRIER_ALL_SUBRESOURCES,
},
}
// `case` lines don't get indented.
for &s in g_scenes {
st := scene_status_load(&s.status)
#partial switch st {
case .Ready:
scene_status_store(&s.status, .QueuedForDeletion)
case .Free:
if !found_free {
scene_schedule_load(&s, new_scene)
}
found_free = true
}
}
// It doesn't over-indent if you open more than 1 bracket or paren in the same line.
scene_walk(scene, nil, proc(node: Node, scene: Scene, data: rawptr) {
ct := &g_dx_context
if node.mesh == -1 {
return
}
mesh_to_render := scene.meshes[node.mesh]
for prim in mesh_to_render.primitives {
dc := DrawConstants {
mesh_index = u32(g_mesh_drawn_count),
material_index = u32(prim.material_index),
}
ct.cmdlist->SetGraphicsRoot32BitConstants(0, 2, &dc, 0)
ct.cmdlist->DrawIndexedInstanced(prim.index_count, 1, prim.index_offset, 0, 0)
}
})
LucyDX12 is formatted with lucyfmt. Why did you think the code looks so pretty?
Feedback
I want other people to use this. I'm sure it's not only me that I want something like this. So please, let me know if you are interested in using this, but it's not exactly to your liking. Maybe we can make it work.
OdinUP is a version manager.
link: https://github.com/prathmesh-barot/odinup
you should try it and tell what i forgot to add