Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Need help with the guidiance mostly because I have the objective set up . Objective The objective will be to implement a 2 D BLIT

Need help with the guidiance mostly because I have the objective set up.
Objective
The objective will be to implement a 2D BLIT system. You will be directly manipulating the color array by inserting color values into specific spots in the array. Before we begin with the lab specifics, first create a new WIN32 CONSOLE APPLICATION. Make it an empty project and create a main.cpp. By now you should know how to define a main function, so go ahead and do so. At this time please also include the RasterSurface.h. Inside main we will use three functions that are a part of the RasterSurface class.
bool RS_Initialize( const char*_studentName, unsigned int _width, unsigned int _height );
bool RS_Update( const unsigned int*_xrgbPixels, const unsigned int _numPixels );
bool RS_Shutdown( void );
Initialize and Shutdown will only be called one time. Initialize at the start of main and Shutdown at the end of main. Update needs to be called at least one time per frame. Meaning this function needs to be called at least one time per cpu cycle. Since we do not know how many times we will be calling this function, which appropriate loop iteration keyword should we use here? As a side note, Initialize will create and open a WIN32 WINDOW. RS_Update will continue to return true until the WIN32 Window closes. Once the window is closed, RS_Update will return false. Now onto the usage of this RasterSurface class.
Lets initialize our RasterSurface to a window size of 500 by 500.
500 pixels wide by 500 pixels tall
We should also create an unsigned int array with the total number of pixels that we created our window with.
1D array and 2D array both work just fine.
RS_Update will take this array and it will need to take the total number of pixels as well.
You will also be writing a few helper functions to assist you in this process. Here are a few example functions you might need.
A function to clear the color buffer to a solid color of your choice.
A function to convert 2 dimensional coordinates to a 1 dimensional coordinate.
A function to draw a pixel (fill a certain pixel with a specific color)
A function to BLIT (Block Image Transfer)
Additionally, we give you an executable called TGA_POW2_32BIT_TO_TEXTUREARRAY.EXE that converts any 32bit uncompressed .tga file to a .h file. The usage of this executable lets us easily access the color values of each pixel of the .tga file. In order to use this executable properly, just drop it in your texture folder and double click the executable. It will convert all .tga files inside the folder to their respective .h counterpart. You should include the new header file so you can access its data members. If you do not have a .tga file, you can create one by dragging and dropping the texture into Visual Studio. Afterwards go to FILE > SAVE AS > CHANGE FILE EXTENSION TO TGA > CHOOSE A LOCATION.
Guidance
Once you setup the rendering loop, it is time to start drawing a pixel. Call your function that draws a pixel and make sure it is drawing in the correct location. Contrasting colors are best to test with.
Now that you can draw a pixel, we should now attempt to draw a tile (square set of pixels) or BLIT an image.
For the tiles height
For the tiles width
Find the location into the image array. (2D to 1D)
Draw a pixel at this location iterating through the width and the height
Once you are able to draw a BLIT / tiled image, we need to fill our color buffer with the same image. You are essentially going to repeat this BLIT horizontally and vertically as well.
For the number of evenly divisible tile heights
For the number of evenly divisible tile widths
Call your function to draw a tile.
At this point you should notice a border around the edge of your right and bottom side of the screen. This is because the remaining pixels did not constitute enough space to draw another BLIT. What needs to be done to your draw function to adjust for this?
Getting this far you should have a strong understanding on how to BLIT. Place 10 BLITs randomly placed throughout the color buffer. These can be anything of your choosing. Obvious choices would be something large enough to notice.
Now let us introduce 1cell of an animation. Be careful here because this is where you need to interpolate through color values since the animation might have alpha values lower than 255.
As soon as you can get a properly rendering BLIT with alpha transparency, solve how to iterate through the animation over time. Make sure the animation plays smoothly at 30 fps.
Grading Breakdown
These grade categories are based on your implementation of the BLIT operation described above and act as tests to verify that it can properly copy a specified section of color data to the raster surface. 25%- Get a tiled background showing on the entire color array
The color values will be strange but this is fine for this section.
25% Completion

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions