Game Development Reference
In-Depth Information
the Alt + Enter key stroke back in Chapter 1 , Getting Started , when we created the
GameWindow base class.
Note that the resolution we are rendering at does not change when you do this.
When we resize the window, the image we drew simply gets stretched to fit the new
size of the window. You can have your swap chain and viewport resized by adding
an event handler and subscribing it to the Resize event of our form (remember that
our RenderForm object is stored in our FormObject property that is defined by the
GameWindow base class). In this event handler, you would dispose of the Render-
TargetView object using its Dispose() method and recreate it with the new win-
dow size. You would then reset the viewport as well.
Before you run the program, remember to edit the Dispose(bool) method, and
make sure it disposes of all of our objects. See the downloadable code for this
chapter to see the new code for this method. Once that's done, we're ready to run
the program. The following is a screenshot of this program in action, showing our in-
verted triangle:
Our inverted triangle being rendered in our game window
You may be wondering why the triangle is blue. We never set a color for it, so how
didthathappen?Well,ifyoulookinour Effects.fx fileattheshadercode,youwill
see that the pixel shader is hardcoded to shade every pixel it draws blue. The pixel
shader has only a single line of code that returns the color blue in RGBA format. The
Search WWH ::




Custom Search