goku
goku game engine_en
goku game engine_en
  • Chapter 1: Introduction to SDL2, Rust, and goku
  • Chapter2: The Base Structure: SpriteSheet
  • Chapter 3: Animated Textures
  • Chapter 4: Handling Textures: TextureManager
  • Chapter 5: Bringing Textures to Life: GameObject
  • Chapter 6: The Foundation: Tile System
  • Chapter 7: Moving the View: Camera
  • Chapter 8: Particle System
  • Chapter 9: The User Interface Layer
  • Chapter 10: The Button Element
  • Chapter 11: The Text Box Element
  • Chapter 12: The Checkbox Element
  • Chapter 13: The Slider Element
  • Chapter 14: The Audio System
  • Chapter 15: The AI System
  • Chapter 16: The Window System
  • Chapter 17: User Input Handling
  • Chapter 18: Rendering a Parallax Background
  • Chapter 19: Timing and Frame Rate Management
  • Chapter 20: Conclusion
Powered by GitBook
On this page

Chapter 16: The Window System

The Window struct represents a window on the screen in which the game will be displayed. This system uses the sdl2::video module from the SDL2 library in Rust.

The Window struct contains three fields: sdl_context, video_subsystem, and canvas. The sdl_context is the main context of the SDL library. The video_subsystem is a subsystem that handles the video functionalities. The canvas is a structure that represents the area where we can draw things.

A Window is created with a specific title, width, and height. The new function initializes SDL2, creates a window with the specified title, width, and height, and returns a Result which contains either a new instance of Window or an error message.

The window is created in the center of the screen and it's using the OpenGL context. The canvas is created in software mode, which means it uses the CPU for rendering. This is typically slower than using the GPU but is more widely supported.

PreviousChapter 15: The AI SystemNextChapter 17: User Input Handling

Last updated 1 year ago