How to make a window using the WinAPI? #3070
Answered
by
DreepyYunky
DreepyYunky
asked this question in
Q&A
-
Any code example out there on the WinAPI for Odin? |
Beta Was this translation helpful? Give feedback.
Answered by
DreepyYunky
Jan 21, 2024
Replies: 1 comment 5 replies
-
Oh I just recently picked up Odin but my understanding is that there's nothing new here. package main
import "core:sys/windows"
import "core:unicode/utf16"
// A Windows specific window
WindowsWindow :: struct {
hwnd: windows.HWND,
}
main :: proc() {
// zero initialized memory on stack
tmp: [64]u16
// convert to utf-16
utf16.encode_string(tmp[:], "MyWindowClass")
cls: windows.WNDCLASSW
cls.lpszClassName = raw_data(tmp[:]) // raw_data returns the underlying data of a built-in data type
windows.RegisterClassW(&cls)
} Odin just let's us call directly into the Win32 API which I think is nice. Nothing new to learn. You could also use glfw or raylib if you wanted to. |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
After some errors, checking
sys/windows
's source, and consulting code examples written in C, I did get a window to work.Maybe I'll create a gist or something like that so others can easily get started