Page 5 of 20
Re: C++ GUI Frameworks
Posted: Mon Jul 05, 2010 6:30 pm
by Matthew
I think it's best to learn what you are supposed to use however.
Arosenivai wrote:Well I must admit when it comes to knowledge of rendering. I'm a little course to say the least, but I can talk to one of my team members, who is very good at it if you'd like.
What team is this and what do you refer to?
Re: C++ GUI Frameworks
Posted: Tue Jul 06, 2010 12:28 am
by Arosenivai
I'm designing a physics engine with a couple of comp sci and comp. engineering majors. We all want to go into game development, as an independent. (it's a long story)
Re: C++ GUI Frameworks
Posted: Tue Jul 06, 2010 11:57 am
by Matthew
Interesting. All my luck for that. I hope it goes well.
What type of physics will it be for?
Re: C++ GUI Frameworks
Posted: Tue Jul 06, 2010 1:58 pm
by Arosenivai
well it is a all-purpose physics engine, so technically it could be used for anything, but we have some ideas for a couple of games. Right now it's only capable of solid collisions, but I'm working on cloths and soft bodies now.
Re: C++ GUI Frameworks
Posted: Fri Jul 09, 2010 3:00 am
by Scott
Don't want to break up any conversation but do either of you know why this doesn't work?
Code: Select all
#include <iostream>
int main()
{
using namespace std;
int i, j = 100, k = 1;
int realNum, input;
cout << "Think of a number. I am going to try to guess that number.\n";
cout << "You type 1 if the number I guess is too high type 2 if it\nis too low.When I get it right type 3\n\nPress ENTER when you are ready\n";
cin.get();
while (input != 3)
{
srand( (unsigned)time(0) );
realNum = (rand() % j + k);
cout << "k:\t" << k << "\nj:\t" << j << "\n";
cout << "Is it " << realNum << "?\n> ";
cin >> input;
if (input == 1)
j = --realNum;
else if (input == 2)
k = ++realNum;
}
cout << "So you were thinking of " << realNum << "? I knew it.";
cin.get();
cin.get();
return 0;
}
As you can probably tell I am trying to make it close the gap between the numbers it is guessing. I have two lines displaying what the values of k and j are and they seem to be correct yet it often guessing higher than desired. I don't understand rand() that well so I could very well just not be using it properly.
Re: C++ GUI Frameworks
Posted: Fri Jul 09, 2010 12:18 pm
by Matthew
j and k isn't the bounds in this case. j is the range - 1 and k is the starting number. Eg. When j is 31 and k is 5, you will get a random number between 5 and 35.
When the computer guesses wrong, the range will always decrease and the starting point will change when the computer was too low.
Try it again with this information.
Re: C++ GUI Frameworks
Posted: Fri Jul 09, 2010 1:02 pm
by Arosenivai
exactly instead of:
if (input == 1)
j = --realNum;
else if (input == 2)
k = ++realNum;
try:
if ( input == 1){//too high case
j = realNum-k; // decreases the range if realNum is too high
} else if( input ==2){//too low case
j -= ( realNum +1 - k); //decreases the range by all numbers j through realNum
k = realNum + 1; // sets the minimum to the increment of realNum
}
For a note in coding: try to avoid naming integers a, b, c, i, j, k, et cetera. and try and give them a name based on their purpose. in this case j can be modulusControl, modControl, et cetera. and k can be minimum, min, minNum, et cetera. It makes tends to make it easier to read.
EDIT: note the reason I called j = modControl instead of range, is because the range is actually 1 less than j.
Re: C++ GUI Frameworks
Posted: Fri Jul 09, 2010 7:33 pm
by Scott
Thanks for the help. I didn't really understand the reference to rand() so I just took a shot in the dark.
I almost always name my variables something meaningful but I simply named them like this because they were just counters. I guess I could have named them rangeHigh and rangeLow. Anyway, thanks for the help.
Re: C++ GUI Frameworks
Posted: Fri Jul 09, 2010 7:40 pm
by Matthew
For counters, anything, name your variables by something you want get confused with.
You can get away with using variables like x for loops.
Re: C++ GUI Frameworks
Posted: Fri Jul 09, 2010 8:06 pm
by Arosenivai
loop constraints are fine to keep vague as long as they have no real purpose besides controlling index locations and what not.
I can't think of a counter example off the top of my head, but coding is usually done on a case by case basis anyway. Happy coding.
Re: C++ GUI Frameworks
Posted: Fri Jul 09, 2010 9:35 pm
by Scott
I'm not going to admit to being anything I'm not, I am fairly new to programming. I've done SOME Ruby and have been learning C++ for several months now. I appreciate all the tips. I'm probably not going to name all of my variables at any giving time but I will try to name as many as I can when I post questions anywhere because I do realize how code can be confusing when you have no idea what everything does. Thanks again.
I don't want to become overbearing but do either of you know of a good online tutorial for OpenGL and/or GLUT? The ones I have found have lots of errors and I'm fairly sure I have Code::Blocks setup right.
Re: C++ GUI Frameworks
Posted: Sat Jul 10, 2010 3:35 am
by Arosenivai
This is a openGL tutorial that may help. I don't know if it talks too much about GLUT, but you can check. ( I keep getting urged to learn openGL by my friend and fellow team member, Bruno, as you can tell I haven't been able to get around to it yet. )
http://www.glprogramming.com/red/about.html
Re: C++ GUI Frameworks
Posted: Sat Jul 10, 2010 3:40 am
by Scott
Thanks for the tutorial I'll be sure to look through it. Is OpenGL mainly used for 3D imagery or is it also used for 2D? I am interested in using it for game programming although am unsure if it's capabilities would accommodate doing this.
Re: C++ GUI Frameworks
Posted: Sat Jul 10, 2010 4:06 am
by Arosenivai
It's for both, I'm working on a physics engine( 2d and 3d, but I'm currently working on the 3d ), and openGL, or at least the code I manage to scrape together works just fine for testing demos. One of my friends who is a CS major has used openGL multiple times for some of the 2d flash like games he makes. He would suggest using something easier like SDL, but, if you really are interested in video game programming in the long term or even as a career, you should probably pursue learning the ins and outs of both openGL and dare I say *coughing and choking sounds* DirectX.
Re: C++ GUI Frameworks
Posted: Sat Jul 10, 2010 8:46 am
by Matthew
Make sure you look at VBOs and/or display lists. VBOs are the most preferable I believe.