Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.






The second day, yesterdays work removed.

Posted by TMKCodes, 19 July 2012 · 794 views

OpenGL C++ Programming glfw
The second day, yesterdays work removed. 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<T> structure and called the class Screw::Vertices<T>. 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.




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.
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.

December 2014 »

S M T W T F S
 123456
78910111213
14151617 18 1920
21222324252627
28293031   

Recent Comments

PARTNERS