First, after looking through the source code our teacher provided, I figured out how the various asset builders worked. Since the MeshBuilder was explicitly stated to just copy a file to a new location I just took the TextureBuilder code and pasted into a MeshBuilder. And lo and behold, I got compiler error. Those are the best kind of errors, aren't they? The CopyFile method call complaining that it couldn't take a character array and after a lot of tinkering I found an option to change the character type for a Visual Studio project.
The next fun problem was that the MeshBuilder was taking the file with the vertex coordinates and copying it to a path that was relative to the application built in the Debug folder, so when running the code from within Visual Studio instead of just clicking on the application didn't work. To remedy this I put a dummy folder and vertex file in the same folder as the project solution. It never actually gets read, but it gets rid of some build errors.
The way I formatted my vertex input file was pretty much the laziest way possible. I had grand plans, including a triangle count and a triangle label before each set of three vertices. Upon remembering how terrible string parsing is in C++ I quickly settled on vertices delimited by new lines and every triangle spaced by an extra line. This surely change in the future, probably next week, but its a good start.
The rest of the fun problems mainly consisted of learning DirectX rules, such as winding order and finding where our teacher hard coded the draw primitive count to 1. It initially also appeared that I had to draw my triangles from the top left most vertex first, but I eventually figured out that clockwise was the only requirement and that can be reversed with a setting somewhere.
When I tried adjusting the shaders I had trouble figuring out which variations did what. I tried adjusting the fragment shader that simply passed the color to the vertex shader. I halved the color first and then set it equal to the output color, but did not see any change to the rectangle. In the vertex shader I changed the color and position based on elapsed time, similar to how the teacher did it, but I passed the time into tangent functions so the square would teleport from one corner of the screen to the other at the end of each pass. Also, I got a fun little color splash that happened twice during the slower part of the tangent curve. I tried adjusting the alpha values as a function of tangent of time as well, but found out alpha is turned off by default. You can see the values changing in the PIX debugger, but it had no effect.
Finally, we had to take a few screenshots showing us debugging in PIX, so here they are. For some reason when PIX ran my executable it only drew one of the triangles. It read the second one, but set its vertices to 0 for some reason. I never did figure out why. UPDATE: I figured out it was cause of a buffer overflow problem that I've fixed. Didn't change the screenshots though. so if you can make out those 0,0 vertices that's why.
And here's my source code.
No comments:
Post a Comment