Sunday, January 30, 2011

Coding and Recoding

For the past week, I have been struggling to get a grip on this project. Honestly, my biggest challenge right now is figuring out what exactly I need to do, and if I am doing it right. The past few days, I kept finding myself going back and forth, writing some code and realizing that it was not the structure that I wanted. It's really frustrating, putting in so much work and hours of energy every day, only to realize that I need to re write that code in some way to better suit my newfound purposes. I suppose that all is not lost though. On the bright side of this nerve-wrecking week, I am learning about what I need a lot more as my code evolves and my diagrams keep changing.


I've never worked on a project independently. I mean, I've done independent studies before, where all of the curriculum was spelled out for me with specific deadlines and precise instructions, and I've worked on projects by myself on a much smaller scale. I'm not used to this much freedom-- it scares me. I always wonder if I'm on the right track, if my ideas are stupid, if I should keep going with what I'm doing or stop and change track, or if I do change, I wonder if I shouldn't have done that. I keep doubting myself, and hounding myself, eating myself alive with worry. I really need to get over this and just get confident but I'm so stressed out thinking about the fact that it's already midterms and I'm not even halfway done. I know I can do this. I know that I'm more than capable. The biggest thing in my way is my own uncertainty. 


So, here's an update on what I've actually been doing for the past week:


I initially took a piece of Sample code from the 4th edition of the OpenGL Superbible titled "ccube.cpp", which draws a color mapped cube, and created a function called createCube() which encapsulated the OpenGL calls to create a cube into one space. In order to set the cube's vertices, rather than declaring 24 separate floats, I ported in my own Math library and set the vertices as vectors. Getting the setup to work took a full day alone. There were so many errors and linker problems, and I finally figured it out and could work on creating that cube function. 


I then realized that I would probably want to allow for various parameters beyond a default cube, such as vertices of a cube, and/or colors, so I added several more variations of the createCube() function. After doing this, I got stuck. I didn't know where to go from here. I decided that it might be smart to create the same sort of structure for triangles and spheres. However, there was a problem yet again. Creating a triangle and sphere required using the GLBatch class, which is not how I had implemented the createCube functions. Looking at the book's examples, I learned that calls on the batch object were necessary at various points in the code, not something that could be neatly enclosed in one function like I had done for the cube. This is when I came to the realization that I needed to adopt a different approach, and it has led me to the point where I am now.


On the train today, I mapped out a high level overview of what my code structure should look like. I left a lot of room for alterations, but I feel like this is a much better approach. Now, I am off to implement it. More to come soon.

No comments:

Post a Comment