/* * * Copyright (C) 2026 andromeda * * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along with this program. If not, see . * */ module main; import std::io; import std::os; import rgfw; import rsgl; import rfont; import libc::termios; faultdef FAIL_OPENPTY, FAIL_FORK; char[*] font_data = $embed("Miracode.ttf"); fn Window* init() { GlHints* hints = rgfw::getGlobalHints(); hints.major = 3; hints.minor = 3; hints.profile = GlProfile.COMPATIBILITY; rgfw::setGlobalHints(hints); return rgfw::createWindow("window title", 0, 0, 800, 400, WindowFlags.CENTER | WindowFlags.NO_RESIZE | WindowFlags.OPENGL); } fn int? init_tty() { int master; int slave; if (openpty(&master, &slave, null, null, null) < 0) return FAIL_OPENPTY~; Pid_t f = fork(); switch (f) { case -1: return FAIL_FORK~; case 0: // child dup2(slave, 0); dup2(slave, 1); dup2(slave, 2); os::exit(execvp(getenv("SHELL"), {null})); default: // parent return master; } } fn int main(String[] args) { init_tty()!!; Window* window = init(); rsgl::Renderer* renderer = rsgl::renderer_init(rsgl::gl::rendererProc(), &rgfw::getProcAddress); rsgl::renderer_viewport(renderer, rsgl::@rect(0,0,500,500)); rsgl::renderer_updateSize(renderer, 500, 500); rfont::Renderer* renderer_rfont = rsgl::rfont::renderer_init(renderer); Font* font = rfont::font_init_data(renderer_rfont, &font_data, 60, 500, 500); int w; int h; while (!rgfw::window_shouldClose(window)) { rgfw::pollEvents(); rgfw::window_getSize(window, &w, &h); rsgl::renderer_clear(renderer, rsgl::@rgb(125,25,75)); rsgl::renderer_viewport(renderer, rsgl::@rect(0,0,w,h)); rfont::renderer_set_framebuffer(renderer_rfont, w, h); rfont::renderer_set_color(renderer_rfont, 1, 1, 1, 1); rfont::draw_text(renderer_rfont, font, "smth hedgehog C3 idk", 0, 10, 60); rsgl::renderer_render(renderer); rgfw::window_swapBuffers(window); } rgfw::window_close(window); return(0); } struct Winsize { ushort ws_row; ushort ws_column; ushort ws_xpixel; ushort ws_ypixel; } extern fn CInt dup2(CInt, CInt); extern fn CInt execvp(ZString, ZString[]); extern fn Pid_t fork(); extern fn ZString getenv(ZString); extern fn CInt openpty(CInt*, CInt*, ZString, Termios*, Winsize*);