Jump to content

April 2017 »

2324 25 26272829

Recent Comments

- - - - -

Yesterday was the first day of ScrewGUI

User interface Programming C++
4: Adsense

So what is this?

I am going to start writing daily reports about what I do with ScrewGUI my new C++ project. I forgot yesterday to write the first report, but I will write it now before continuing programming. You will get today's report later today.

What I programmed yesterday?

I Wrote three templates which were Screw::Vertex, Screw::Line and Screw::Triangle.

First I wrote Screw::Vertex templates constructor to take 4 parameters x,y,z,w which are the 3 dimensional coordinates for vertex. Then I wrote constructor which does not take the parameters, but sets the coordinates to zero.

I also wrote functions to get and set the vertex data called:
  • T * GetVertexData()
  • void SetVertexData(T x, T y, T z, T w)
The GetVertexData function returns array which contains the four coordinates and the SetVertexData takes them as parameters and sets the values to the templates private members.

Then I programmed the Screw::Line template constructor which took two Screw::Vertex objects as parameter and another constructor which did not take these Screw::Vertex objects as parameter, but created two new empty Screw::Vertex objects. I wrote the destructor to delete the created Screw::Vertex objects, but not the ones which were passed to the Screw::Line object.

I also wrote the get and set public member functions:
  • T * GetVertexData()
  • void SetVertexData(T xOne, T yOne, T zOne, T wOne, T xTwo, T yTwo, T zTwo, T wTwo)
The inner functionality was little bit different from Screw::Vertex implementation, because I did not use private coordinate members in Screw::Line, but used two Screw::Vertex objects as the private members. So I wrote the implementation so that Screw::Line get and set called Screw::Vertex Get and Set functions.

Screw::Triangle was pretty much the same as Screw::Line, but as Triangle has three points I needed three Screw::Vertex objects. I programmed the constructor which took three Screw::Vertex objects as parameter and one which created three new empty Screw::Vertex objects and the destructor which deleted these created objects.

As with the previous templates I wrote the get and set functions:
  • T * GetVertexData()
  • void SetVertexData(T VertexID, T x, T y, T z, T w)
I opted to use T VertexID because having twelve parameters was kind of long and I did not want to pass array into the function, because that would require the library user to create the array when using Screw::Triangle template.

What problems I ran into.

When I was programming Screw::Triangles Set function I realized that twelve parameters was bit too much and opted to use VertexID and force the user of the library to call the SetVertexData function three times to set every vertex coordinates. Now I am thinking if I should apply the same functionality in Screw::Line and most likely I will.

What I am going to do today.

I am going to write template View which will construct glfw window and draw the given objects on screen.

Note: GameDev.net moderates comments.