The second day, yesterdays work removed.

Published July 19, 2012
Advertisement
Triangle is where the second day is finished.

Today after I wrote my yesterdays report I continued programming and I created View class which constructor opens glfw window and I tried to pass the three templates I created yesterday as parameters in to the View class, but I found it pretty hard, because I had to reinterpret_cast the template class pointers to some valid pointer type. Well I almost got killed at stackoverflow for asking help solving problem I had before i realized I can just cast them to another type.

After I got it working I went for a cigarette and realized that I had taken control of the main loop which was something I did not want to do, but cowboy programming on the fly is somewhat dangerous. So I removed all of the code. Wrote new template structure vertex with the coordinates as members and two vertex structure pointers as members.

Then I wrote template class to manage this Screw::Vertex structure and called the class Screw::Vertices. Now I can push as many vertices to the class as I want and my computer can handle. I can also get the vertices back as array for GL_ARRAY_BUFFERS.

I copied the Vertices\Vertex templates to another file used search and replace and I had Colors template class and Color template structure.

So I started writing the View class again, but this time I left the main loop to main(). Somehow I started writing c++ wrapper for the OpenGL functions I used. You can see me drawing triangle on the image and that is as far as I currently am. C++ code lines currently at 475 if you are interested how it took me more than a 15 minutes to draw that damn triangle. :P

Second day and two problems.

I got a problem passing template class as regular class method parameter and using the template class as vector type. I went into stackoverflow and ask help, but their solutions were not what I wanted, but I realized myself what I wanted and posted it as solution to my post. Soon I got almost killed for casting class pointer to char pointer. Well after I redid basically everything I had problems getting openGL to actually draw on the window I created. I had every damn function call correctly, but I was not drawing on the visible screen, which took some time to notice.

What tomorrow?

Tomorrow I am going to create Github repository for ScrewGui and start writing some 2D element classes which use the Vertices and Colors templates.
0 likes 2 comments

Comments

Aardvajk
Why are you actually trying to store different types of data in the same storage? Do you understand why the reinterpret_cast stuff is such a bad idea? They were quick to shout out on StackOverflow but nobody seemed to actually explain the potential problems.
July 20, 2012 12:38 PM
ToniKorpela
Yeah none of them actually explained the problem of reinterpret_casting, but I kinda realized one problem myself which is why I decided to scratch everything and do it so that I don't need to cast it to another type.
July 20, 2012 12:47 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement
Advertisement