initial commit
This commit is contained in:
commit
6f73f2d443
35 changed files with 4673 additions and 0 deletions
63
test/lettuce.c3
Normal file
63
test/lettuce.c3
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
import std::io;
|
||||
import sdl3::sdl;
|
||||
|
||||
fn int main() {
|
||||
sdl::init(sdl::INIT_VIDEO);
|
||||
|
||||
Window* win = sdl::create_window("SDL3 Image", 640, 480, 0);
|
||||
if (win == null) {
|
||||
io::eprintfn("SDL_CreateWindow Error: %s", sdl::get_error());
|
||||
sdl::quit();
|
||||
return 1;
|
||||
}
|
||||
|
||||
Renderer* ren = sdl::create_renderer(win, null);
|
||||
if (ren == null) {
|
||||
io::eprintfn("SDL_CreateRenderer Error: %s", sdl::get_error());
|
||||
sdl::destroy_window(win);
|
||||
sdl::quit();
|
||||
return 1;
|
||||
}
|
||||
|
||||
Surface* bmp = sdl::load_bmp("lettuce.bmp");
|
||||
if (bmp == null) {
|
||||
io::eprintfn("SDL_LoadBMP Error: %s", sdl::get_error());
|
||||
sdl::destroy_renderer(ren);
|
||||
sdl::destroy_window(win);
|
||||
sdl::quit();
|
||||
return 1;
|
||||
}
|
||||
|
||||
Texture* tex = sdl::create_texture_from_surface(ren, bmp);
|
||||
sdl::destroy_surface(bmp);
|
||||
|
||||
if (tex == null) {
|
||||
io::eprintfn("SDL_CreateTextureFromSurface Error: %s", sdl::get_error());
|
||||
sdl::destroy_renderer(ren);
|
||||
sdl::destroy_window(win);
|
||||
sdl::quit();
|
||||
return 1;
|
||||
}
|
||||
|
||||
Event e;
|
||||
bool quit = false;
|
||||
|
||||
while (!quit) {
|
||||
while (sdl::poll_event(&e)) {
|
||||
if (e.type == sdl::EVENT_QUIT) {
|
||||
quit = true;
|
||||
}
|
||||
}
|
||||
|
||||
sdl::render_clear(ren);
|
||||
sdl::render_texture(ren, tex, null, null);
|
||||
sdl::render_present(ren);
|
||||
}
|
||||
|
||||
sdl::destroy_texture(tex);
|
||||
sdl::destroy_renderer(ren);
|
||||
sdl::destroy_window(win);
|
||||
sdl::quit();
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue