Jump to content
  • Advertisement
Sign in to follow this  
Stabhead

OpenGL Urgent help needed! Array display and text output

This topic is 3789 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi guys, I have two questions that i could really do with some urgent help with. 1. Im having trouble with displaying the results of an array ive created. The array is filled with six random numbers between 1-60 (for a lottery type program). My problem is when i display these numbers through text in opengl the results keep reiterating through different random numbers, looping through them on screen. I just want the six random numbers to display as six static numbers on screen. Here is the code for displaying the array:
int array[] = {-1,-1,-1,-1,-1,-1};
int size = 6;

void showLottery(int ball[], int size)
{

(runLotto == true);
qsort( array, size, sizeof(int), compare_ints );         
ostringstream text;

	for( int i = 0; i < size; i++ ) {
		if (size = 6)
			text << "\nYour Ball " << i + 1 << " number is : " <<  ball;
	}
	
	string str = text.str();
	

		glPushMatrix();
		glColor3f(0.0f, 0.0f, 0.0f);
		glTranslatef(0.0f, 0.9f, -5.0f);
		glScalef(0.2f, 0.3f, 0.2f);
		t3dDraw2D(str, 0, 0);
		glPopMatrix();

}

And in display():
	glPushMatrix();
	fillLottery(array, size);
	showLottery(array, size);					//Displays selected Balls
	glPopMatrix();

2. My other question was how i would go about producing an output via notepad to show a thousand results of both the users pick of numbers and the lottery numbers? I want to see how many times the same number picks are chosen. Ive looked at :
 ofstream *myfile = new ofstream("output.txt");
 *myfile ...output

Is this the best way of producing an output text file? Any help would be greatfully appreciated. Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement

Swift,

I was having problems creating the text but found an example off videotutorialsrock.com that was very useful.

From there I found the appropriate text class and code to display text that worked on my program. Not sure what library is used?

Thanks for the quick reply btw! [smile]

Share this post


Link to post
Share on other sites
Quote:
Original post by Stabhead
I was having problems creating the text but found an example off videotutorialsrock.com that was very useful.

OK, I found the tutorial, and despite being a really, seriously weird way to render text, it looks like it works.

It looks like your problem is that you call fillLottery() every frame, and I am presuming that function generates a new set of random numbers. Try calling fillLottery() just once, before you start your rendering loop.

Share this post


Link to post
Share on other sites

Ok well that works like a treat, thanks alot swiftcoder....very much appreciated!

[smile]

I just need abit of guidance on how best to go about displaying the results of more than one group of lottery numbers on a text file.

Any ideas?



Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!