protected override void InitializeWindowRenderer() { // Ensure to not share this context with other contexts before this point. SetupOpenGLAttributes(false, _glLogLevel); IntPtr context = SDL_GL_CreateContext(WindowHandle); SDL_GL_SetSwapInterval(1); if (context == IntPtr.Zero) { string errorMessage = $"SDL_GL_CreateContext failed with error \"{SDL_GetError()}\""; Logger.Error?.Print(LogClass.Application, errorMessage); throw new Exception(errorMessage); } // NOTE: The window handle needs to be disposed by the thread that created it and is handled separately. _openGLContext = new SDL2OpenGLContext(context, WindowHandle, false); // First take exclusivity on the OpenGL context. ((Renderer)Renderer).InitializeBackgroundContext(SDL2OpenGLContext.CreateBackgroundContext(_openGLContext)); _openGLContext.MakeCurrent(); GL.ClearColor(0, 0, 0, 1.0f); GL.Clear(ClearBufferMask.ColorBufferBit); SwapBuffers(); Renderer?.Window.SetSize(DefaultWidth, DefaultHeight); MouseDriver.SetClientSize(DefaultWidth, DefaultHeight); }
protected override void BeforeRun() { //This function is called before COSMOS starts //Console.WriteLine("Cosmos booted sucessfully, now starting Kernel"); display = new BufferedDisplayDriver(); PrintDebug("After display create"); display.init(); PrintDebug("After display init"); mouse = new MouseDriver(display.getHeight(), display.getWidth()); mr = new MouseRenderer(mouse, display, 2); }
public static void handleMouse(MouseDriver mouse) { if (isVisible) { if (mouse.LeftClickState()) { if (held) { if (mouse.X() + width < 320) { x = mouse.X(); } else { x = 320 - width; } if (mouse.Y() + height < 200) { y = mouse.Y(); } else { y = 200 - height; } } else { if (mouse.X() > (x + width - 20) && mouse.X() < (x + width) && mouse.Y() > y && mouse.Y() < y + 20) { isVisible = false; } else { if (mouse.X() > x && mouse.X() < (x + width - 60) && mouse.Y() > y && mouse.Y() < y + 20) { held = true; } } } } else { held = false; } } }
public void handleMouse(MouseDriver mouse) { if (mouse.LeftClickState()) { if (held) { x = mouse.X(); y = mouse.Y(); } else { if (mouse.X() > x && mouse.X() < (x + width - 60) && mouse.Y() > y && mouse.Y() < y + 20) { held = true; } } } else { held = false; } }
/* protected override void Run() * { * Font f = new BasicFont(); * FontRenderer fr = new FontRenderer(display, f, 63); * FontRenderer dfr = new FontRenderer(display, f, 0); * * IconPack ip = new BasicIconPack(); * IconRenderer ir = new IconRenderer(display, ip); * * startMenu = false; * held = false; * * second = time.Second(); * while (true) * { * WindowManager.handleMouse(mouse); * handleMouse(mouse); * draw(fr, dfr, startMenu, ir); * WindowManager.drawWindows(display, ir, dfr); * mr.renderMouse(); * display.step(); * } */ public void handleMouse(MouseDriver mouse) { if (mouse.LeftClickState()) { if (held == false) { if (mouse.X() > 0 && mouse.X() < 120 && mouse.Y() > 0 && mouse.Y() < 15) { startMenu = !startMenu; } else if (startMenu && mouse.X() > 0 && mouse.X() < 120 && mouse.Y() > 15 && mouse.Y() < 155) { if (mouse.X() > 25 && mouse.X() < 110 && mouse.Y() > 80 && mouse.Y() < 95) { Sys.Power.Reboot(); } } else { if (mouse.X() > 85 && mouse.X() < 105 && mouse.Y() > 15 && mouse.Y() < 25) { NotepadWindow.reset(); } if (startMenu == true) { startMenu = false; } } held = true; } } else { held = false; } }
public static void handleMouse(MouseDriver mouse) { NotepadWindow.handleMouse(mouse); }
protected override void InitializeRenderer() { Renderer?.Window.SetSize(DefaultWidth, DefaultHeight); MouseDriver.SetClientSize(DefaultWidth, DefaultHeight); }
public MouseRenderer(MouseDriver m, DisplayDriver d, int c) { mouse = m; display = d; color = c; }
public MouseRenderer(MouseDriver m, DisplayDriver d, int c = 2) { mouse = m; display = d; color = c; }