#include #include #include #include #include #include "viewport.h" typedef struct game_object_t { char name[128]; char* uuid; } game_object; const char* gl_versions[7] = { "UNKNOWN", "1.1", "2.1", "3.3", "4.3", "ES 2.0", "ES 3.0" }; Camera camera; char* gen_uuid() { char v[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; //3fb17ebc-bc38-4939-bc8b-74f2443281d4 //8 dash 4 dash 4 dash 4 dash 12 static char buf[37] = {0}; //gen random for all spaces because lazy for(int i = 0; i < 36; ++i) { buf[i] = v[rand()%16]; } //put dashes in place buf[8] = '-'; buf[13] = '-'; buf[18] = '-'; buf[23] = '-'; //needs end byte buf[36] = '\0'; return buf; } int main() { SetConfigFlags(FLAG_WINDOW_RESIZABLE); InitWindow(800, 600, "gear"); InitViewport(); rligSetup(true); ImGuiIO *ioptr = igGetIO(); ioptr->ConfigFlags |= ImGuiConfigFlags_DockingEnable; camera = (Camera){ 0 }; camera.position = (Vector3) { 10.0f, 10.0f, 10.0f }; camera.target = (Vector3) { 0.0f, 0.0f, 0.0f }; camera.up = (Vector3) { 0.0f, 1.0f, 0.0f }; camera.fovy = 70.0f; camera.projection = CAMERA_PERSPECTIVE; //SetTargetFPS(60); ImGuiStyle* style = igGetStyle(); ImVec4* colors = style->Colors; colors[ImGuiCol_Text] = (ImVec4){1.00f, 1.00f, 1.00f, 1.00f}; colors[ImGuiCol_TextDisabled] = (ImVec4){0.50f, 0.50f, 0.50f, 1.00f}; colors[ImGuiCol_WindowBg] = (ImVec4){0.29f, 0.34f, 0.26f, 1.00f}; colors[ImGuiCol_ChildBg] = (ImVec4){0.29f, 0.34f, 0.26f, 1.00f}; colors[ImGuiCol_PopupBg] = (ImVec4){0.24f, 0.27f, 0.20f, 1.00f}; colors[ImGuiCol_Border] = (ImVec4){0.54f, 0.57f, 0.51f, 0.50f}; colors[ImGuiCol_BorderShadow] = (ImVec4){0.14f, 0.16f, 0.11f, 0.52f}; colors[ImGuiCol_FrameBg] = (ImVec4){0.24f, 0.27f, 0.20f, 1.00f}; colors[ImGuiCol_FrameBgHovered] = (ImVec4){0.27f, 0.30f, 0.23f, 1.00f}; colors[ImGuiCol_FrameBgActive] = (ImVec4){0.30f, 0.34f, 0.26f, 1.00f}; colors[ImGuiCol_TitleBg] = (ImVec4){0.24f, 0.27f, 0.20f, 1.00f}; colors[ImGuiCol_TitleBgActive] = (ImVec4){0.29f, 0.34f, 0.26f, 1.00f}; colors[ImGuiCol_TitleBgCollapsed] = (ImVec4){0.00f, 0.00f, 0.00f, 0.51f}; colors[ImGuiCol_MenuBarBg] = (ImVec4){0.24f, 0.27f, 0.20f, 1.00f}; colors[ImGuiCol_ScrollbarBg] = (ImVec4){0.35f, 0.42f, 0.31f, 1.00f}; colors[ImGuiCol_ScrollbarGrab] = (ImVec4){0.28f, 0.32f, 0.24f, 1.00f}; colors[ImGuiCol_ScrollbarGrabHovered] = (ImVec4){0.25f, 0.30f, 0.22f, 1.00f}; colors[ImGuiCol_ScrollbarGrabActive] = (ImVec4){0.23f, 0.27f, 0.21f, 1.00f}; colors[ImGuiCol_CheckMark] = (ImVec4){0.59f, 0.54f, 0.18f, 1.00f}; colors[ImGuiCol_SliderGrab] = (ImVec4){0.35f, 0.42f, 0.31f, 1.00f}; colors[ImGuiCol_SliderGrabActive] = (ImVec4){0.54f, 0.57f, 0.51f, 0.50f}; colors[ImGuiCol_Button] = (ImVec4){0.29f, 0.34f, 0.26f, 0.40f}; colors[ImGuiCol_ButtonHovered] = (ImVec4){0.35f, 0.42f, 0.31f, 1.00f}; colors[ImGuiCol_ButtonActive] = (ImVec4){0.54f, 0.57f, 0.51f, 0.50f}; colors[ImGuiCol_Header] = (ImVec4){0.35f, 0.42f, 0.31f, 1.00f}; colors[ImGuiCol_HeaderHovered] = (ImVec4){0.35f, 0.42f, 0.31f, 0.6f}; colors[ImGuiCol_HeaderActive] = (ImVec4){0.54f, 0.57f, 0.51f, 0.50f}; colors[ImGuiCol_Separator] = (ImVec4){0.14f, 0.16f, 0.11f, 1.00f}; colors[ImGuiCol_SeparatorHovered] = (ImVec4){0.54f, 0.57f, 0.51f, 1.00f}; colors[ImGuiCol_SeparatorActive] = (ImVec4){0.59f, 0.54f, 0.18f, 1.00f}; colors[ImGuiCol_ResizeGrip] = (ImVec4){0.19f, 0.23f, 0.18f, 0.00f}; // grip invis colors[ImGuiCol_ResizeGripHovered] = (ImVec4){0.54f, 0.57f, 0.51f, 1.00f}; colors[ImGuiCol_ResizeGripActive] = (ImVec4){0.59f, 0.54f, 0.18f, 1.00f}; colors[ImGuiCol_Tab] = (ImVec4){0.35f, 0.42f, 0.31f, 1.00f}; colors[ImGuiCol_TabHovered] = (ImVec4){0.54f, 0.57f, 0.51f, 0.78f}; colors[ImGuiCol_TabActive] = (ImVec4){0.59f, 0.54f, 0.18f, 1.00f}; colors[ImGuiCol_TabUnfocused] = (ImVec4){0.24f, 0.27f, 0.20f, 1.00f}; colors[ImGuiCol_TabUnfocusedActive] = (ImVec4){0.35f, 0.42f, 0.31f, 1.00f}; colors[ImGuiCol_DockingPreview] = (ImVec4){0.59f, 0.54f, 0.18f, 1.00f}; colors[ImGuiCol_DockingEmptyBg] = (ImVec4){0.20f, 0.20f, 0.20f, 1.00f}; colors[ImGuiCol_PlotLines] = (ImVec4){0.61f, 0.61f, 0.61f, 1.00f}; colors[ImGuiCol_PlotLinesHovered] = (ImVec4){0.59f, 0.54f, 0.18f, 1.00f}; colors[ImGuiCol_PlotHistogram] = (ImVec4){1.00f, 0.78f, 0.28f, 1.00f}; colors[ImGuiCol_PlotHistogramHovered] = (ImVec4){1.00f, 0.60f, 0.00f, 1.00f}; colors[ImGuiCol_TextSelectedBg] = (ImVec4){0.59f, 0.54f, 0.18f, 1.00f}; colors[ImGuiCol_DragDropTarget] = (ImVec4){0.73f, 0.67f, 0.24f, 1.00f}; colors[ImGuiCol_NavHighlight] = (ImVec4){0.59f, 0.54f, 0.18f, 1.00f}; colors[ImGuiCol_NavWindowingHighlight] = (ImVec4){1.00f, 1.00f, 1.00f, 0.70f}; colors[ImGuiCol_NavWindowingDimBg] = (ImVec4){0.80f, 0.80f, 0.80f, 0.20f}; colors[ImGuiCol_ModalWindowDimBg] = (ImVec4){0.80f, 0.80f, 0.80f, 0.35f}; style->FrameBorderSize = 1.0f; style->WindowRounding = 0.0f; style->ChildRounding = 0.0f; style->FrameRounding = 0.0f; style->PopupRounding = 0.0f; style->ScrollbarRounding = 0.0f; style->GrabRounding = 0.0f; style->TabRounding = 0.0f; bool show_demo = false; bool show_debug = true; sl_vec(game_object*) game_objects = { 0 }; for(int i = 0; i < 10000; i++) { game_object* obj = calloc(sizeof(game_object), 1); snprintf(obj->name, 128, "bob %d", i); obj->uuid = gen_uuid(); sl_vec_push(game_objects, obj); } //sl_vec_push(game_objects, (game_object){"john"}); game_object* selected = NULL; while(!WindowShouldClose()) { UpdateViewport(); BeginDrawing(); { ClearBackground(BLACK); BeginViewport(); { ClearBackground(BLACK); BeginMode3D(camera); { DrawCube((Vector3){0.0f, 0.0f, 0.0f}, 5.0f, 5.0f, 5.0f, RED); DrawGrid(10, 10); } EndMode3D(); DrawFPS(10, 10); //DrawText(TextFormat( /*int y = 50; for(sl_vec_it(obj, game_objects)) { DrawText(obj->name, 10, y, 20, WHITE); y += 20; }*/ } EndViewport(); rligBegin(); { if(igBeginMainMenuBar()) { if(igBeginMenu("File", true)) { if(igMenuItem_Bool("Quit", "ESC", false, true)) { CloseWindow(); } igEndMenu(); } if(igBeginMenu("Debug", true)) { igCheckbox("Show demo window", &show_demo); igEndMenu(); } igEndMainMenuBar(); } igDockSpaceOverViewport(NULL, 0, NULL); if(show_demo) igShowDemoWindow(&show_demo); RenderViewport(); igBegin("Game Objects", NULL, 0); { for(sl_vec_it(obj_ptr, game_objects)) { game_object* obj = *obj_ptr; igPushID_Str(obj->uuid); if(igSelectable_Bool(obj->name, selected == obj, 0, (ImVec2){0, 0})) selected = obj; igPopID(); } } igEnd(); igBegin("Properties", NULL, 0); { if(selected != NULL) { igInputText("##name", selected->name, 128, 0, NULL, NULL); } } igEnd(); if(show_debug) { igBegin("Debug", &show_debug, 0); { igText("raylib %s", RAYLIB_VERSION); igText("OpenGL %s", gl_versions[rlGetVersion()]); igText("FPS: %d", GetFPS()); igText("Frame time: %f", GetFrameTime()); igText("Cursor hidden: %d", IsCursorHidden()); igText("\nResolutions"); igText("Window: %dx%d", GetScreenWidth(), GetScreenHeight()); for(int i = 0; i < GetMonitorCount(); i++) { igText("%s: %dx%d@%d", GetMonitorName(i), GetMonitorWidth(i), GetMonitorHeight(i), GetMonitorRefreshRate(i)); } } igEnd(); } } rligEnd(); } EndDrawing(); } rligShutdown(); CloseWindow(); }