Difference between revisions of "Chili Framework"

From Chilipedia
Jump to: navigation, search
(Graphics)
(Core Classes)
Line 4: Line 4:
  
 
=== Game ===
 
=== Game ===
 +
:''Main article: [[Game (Chili Framework)]]''<br />
 +
 
The <code>Game</code> class is where you put the code to make the game do the things. The predefined member functions <code>UpdateModel()</code> and <code>ComposeFrame()</code> are where you put your game logic and your rendering code, respectively. <code>Game</code> is composed of the <code>Graphics</code> object used for drawing and keeps a reference to the <code>MainWindow</code> object to interface with the Windows system (which includes the keyboard and mouse inputs).
 
The <code>Game</code> class is where you put the code to make the game do the things. The predefined member functions <code>UpdateModel()</code> and <code>ComposeFrame()</code> are where you put your game logic and your rendering code, respectively. <code>Game</code> is composed of the <code>Graphics</code> object used for drawing and keeps a reference to the <code>MainWindow</code> object to interface with the Windows system (which includes the keyboard and mouse inputs).
  

Revision as of 12:56, 13 July 2016

The Chili Framework is designed as a vehicle to make it fun and easy to learn C++ in a graphical context. It wraps a bunch of pain-in-the-ass WinAPI and Direct3D bullshit giving us direct access to the framebuffer for manipulating screen pixels. This allows us to explore basic graphical concepts at the same time that we are learning the fundamentals of the C++ language. Our research shows that this results in a 69% lower incidence of learners shitting themselves to death out of sheer boredom.

Core Classes

Game

Main article: Game (Chili Framework)

The Game class is where you put the code to make the game do the things. The predefined member functions UpdateModel() and ComposeFrame() are where you put your game logic and your rendering code, respectively. Game is composed of the Graphics object used for drawing and keeps a reference to the MainWindow object to interface with the Windows system (which includes the keyboard and mouse inputs).

Graphics

Main article: Graphics (Chili Framework)

This class takes care of all the Direct3D setup bullshit and provides an interface to the graphical output of the application. Use Graphics to draw on the screen, anything you like, even dicks (especially dicks). PutPixel() is generally how this is gone about, although later on more sophisticated dick-drawing routines are created based on PutPixel(). You can also use Graphics::ScreenWidth etc. to make sure you keep your dicks inside the screen boundaries.


MainWindow

Takes care of creating the window and handling the window messages. The message handling involves piping the mouse and keyboard messages to their respective objects. In fact, MainWindow has eaten Keyboard and Mouse alive, and now they live in its belly. So you need to through MainWindow to get your input done, à la wnd.mouse.Read(). You can also use this class to figure out whether the main window is minimized or if it's out of focus, and you can kill the fat bastard with wnd.Kill().

Keyboard

With Keyboard, you can get the current state of depressed keys, and you can pop key press and release events out of an Event queue contained in Keyboard. You can also turn autorepeat on/off. Whopee. (Note: the kbd object lives in MainWindow's belly.)

Mouse

With Mouse, you can get the current state of the mouse keys and the pointer position, and you can pop mouse events out of an Event queue contained in Mouse. You can also check whether the mouse is in the window client region. Whopee. (Note: lives in MainWindow's belly.)

Color

Color represents a 32-bit RGBA color value (or a single pixel if you like), and gives you member functions to access the (fudge) packed channels. There is also a Colors namespace with predefined colors, like Colors::Aqua (not to be confused with Aqua, the majestic Danish eurodance group).

Other Bullshit Components

Main

The Main.cpp file contains the function wWinMain(), which is the entry point for the program (where the whole shebang starts). It creates the MainWindow object, creates the Game object, and repeatedly performs the steps a) process all pending windows messages and b) process a game frame, until it is time for the big sleep. There is also a bunch of exception catching code to catch any stray exceptions and display their error information via a message box.

ChiliException

The class ChiliException forms the basis for all exceptions that will be generated by the framework or the game code. GraphicsException and WindowsException are specific types that inherit from ChiliException. If you want to throw your own exceptions, you should inherit from ChiliException, but that's kind of an advanced topic, so don't sweat it Broseph.

ChiliWin

This file should be included in lieu of <Windows.h>. It includes <Windows.h>, but before doing so it defines some preprocessor switches which set the target minimum version of Windows (Vista) and cut some unused bullshit from the included Windows code, saving on compilation time. If you somehow end up using weird WinAPI bullshit, you might need to modify this file to re-enable that code.

Framebuffer Shaders

Since D3D11 is a little bitch and won't let us touch its goodies (i.e. the backbuffer), we have to copy our composed frame over to a texture and then draw that texture to the backbuffer. Therefore, we need pixel and vertex shaders. Note that the solution is set up to first compile the shader sources to C++ header files (extension *.shh, which I just pulled out of my ass by the way) and then compile the C++ source files. Graphics.cpp includes the *.shh files, so when browsing the code of a fresh/cleaned solution you may notice errors in Graphics.cpp, but that's probably just because the *.shh files don't exist yet. Build once and those errors should disappear.

Resource

The ChiliFramework.res contains the custom application icons and Resource.h contains the codes used to identify the icon bitmaps in the *.res file. These allow the icons to be build right into the executable.

DXErr

Some code written by a guy at Microsoft that translates DirectX error codes into something with a little more je ne sais quoi. Used to be part of the SDK, but whatever I guess. Licensing status not really clear.

Miscellaneous

Criticisms

Some people resent a custom framework being used in the tutorials. Fuck em.