Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!

1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Member Since 17 Jun 2011
Offline Last Active Aug 26 2012 06:31 AM

Topics I've Started

Leaking memory.

20 August 2012 - 02:31 AM

How do you deal with your bad memory?

Personally I have so bad memory that I need to daily check same stuff from wiki or some other documentation. I keep forgetting words and if I remember the word I might not remember how to spell it. I do not remember peoples names unless I see the name daily, Facebook helps with this. I barely remember anyone's face without actually seeing their face and sometimes even then the person might feel like total stranger. I barely remember events from the past correctly.

For example I forgot that Finland president changed until I remembered to check who won the selection. I forgot that Finland won MM ice hockey gold last year and I still need to ask my friend was it last year or when. When I am drinking in the city pretty much every time someone comes to me and say hello to me and I do not have any idea who they are even though they seem to know me. It is absolutely fucking annoying when you try to say something and in the middle of the sentence I go, "What the fuck was the word?"

This becomes really time consuming with programming when I have to keep checking function names and parameters from documentation or earlier code.

Calculating if mouse position is inside plane figure

21 July 2012 - 09:03 AM

Hello. I have small problem with OpenGL coordinates. It's been a while since I used OpenGL and back then I used OpenGL 2.1 not 3.3.

So I basically have triangle vertices:
GLfloat Vertices[] = {
0.75f, 0.75f, 0.0f, 1.0f,
0.75f, -0.75f, 0.0f, 1.0f,
-0.75f, -0.75f, 0.0f, 1.0f };

Now I have mouse coordinates for example 512, 384 which is the center at 1024, 768 window.
When I translate this normalized 1.0f equals 1024 and -1.0f equals 0 for X and for Y 1.0f equals 768 and -1.0f 0.
Now I have these coordinates:
896, 672, 0
896, 288, 0
384, 288, 0
I do not care about Z because I need to calculate only the GUI elements, which are on Z = 0;

Now I can calculate if the mouse coordinates are on top of the triangle, but for some reason glfw gives mouse coordinates with top-left coordinate as the 0.0 and OpenGL uses the bottom-left corner as 0.0, this means that I need to turn the mouse yPosition around, but at the center it still would be 384, but any other value would be different. MyPosition = 768 - oldMyPosition;
if((((896 >= MxPosition) == true && (672 >= MyPosition) == true) && 
((896 >= MxPosition) == true && (288 <= MyPosition) == true) &&
((384 <= MxPosition) == true && (288 <= MyPosition) == true)) == true) {
     return true;
} else {
     return false;
Of course this if statement is not the finished one, but should I calculate it this way or should I use some other method?

Thinking of Rolling My own GUI toolkit.

13 July 2012 - 12:22 AM

So I am probably going to do the same mistake as many other programmers have done and maybe failed.

You know the feeling when you want to reinvent the wheel and everyone tries to say that don't do that, but you just want to roll your own even though you really don't have any specific reason.

Well I am currently only thinking of programming my own game graphical user interface toolkit to run on top of OpenGL 3.3 with C++. I'm writing here because I want to know if I am missing something.

Basically first I need to write button, which is actually quite easy to draw with opengl and the mouse clicks on the button are quite easy to track with existing window framework, like with glfw. The button requires data like width, height, xyz position, bgcolor/bgimage and child text. Before I can create the text child I need to write code to load fonts and draw text on the screen. That's 3 classes, button, text, font.

Now I have the required classes to create window. First the window requires whole window width, height, bg. Header of the window needs width, height, bg and window text child for title. Three buttons as windows child for minimize, close and resize. Though implementing resizing feature I will most likely leave for later. The header actually itself needs to be a button, so that the window can be moved. After the window has been written I can write different widgets to fill the window. :) Next are the little bit more complex ones like text input, radio boxes, etc.

Basically my only problem is font loading, but well if I start doing this it's not going to be big problem. What I think I can bring to the table is easy way to build GUI widgets to your games with .xml templates and afterwards registering event calls on the code. Qt, GTK and MFC does something like this, but those are not good for game development in my mind.

So the only question remains should I roll my own or just use CEGUI?