For the magnet’s homework, my thought process was as follows:
1. Magnet Struct: I am used to writing pure C++ classes, but I decided to use a struct to model my magnet. I had some issues with construction and pointers and not modifying values. I overcame this by doing some further review of structs and debugging their values when needed.
2. OnDraw(): Initially, I was very confused about how the shader program will render more than one object (and with different colors) . I thought I could use more than one shader program and link that to the method, but knowing that I had to use one vertex array object, it made it difficult. I overcame this issue, but asking questions and “drawing” out how one rectangle can be simply modified for the whole program via matrices, uniforms, and attributes. I now appreciate the power of saving/reusing geometry to populate the world.
3. World Coordinates: The final challenge was understanding how to map the pixel coordinates and the default world coordinates together. This caused me to go way off track and get bogged down by converting between the two. But with a orthographic projection matrix, the world coordinates and magnet implementation made more sense as a whole.
4. Vector3: The Vector3 Class that I had designed earlier this semester was giving me issues with any sort of operator (+,-,*,/). I’m not sure why, but the same methods in a Vector4 seemed to work just fine. I will have to look into this to ensure that Vector3 works as expected for its functions. So for some situations, I had to do the arithmetic operations in a longer /alternative way.