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.


TheLearner

Member Since 30 Jan 2011
Offline Last Active Feb 09 2012 01:53 PM

Topics I've Started

How do i increase the radius once per second

09 February 2012 - 01:53 PM

Hi,

I started learning OpenGL not too long ago from this website:
http://www.swiftless...opengltuts.html


I got only to point 5: OpenGL Color.

What I want to do is:
· Draw a sphere: done
· Increase its radius once a second: NOT done

I don’t want to use the keyboard to increase the radius. I already know how to do that.

Here is what my code looks like:
#include "TimeUtils.hpp"
//More code
int main(int argc, char *argv[])
{
//More code
/*
		Increment Sphere radius once a second
	*/
	long time01, time02;
	time01 = time_now();// Returns the time now
  
	long timeDifference = 0;
	long lastDifference = 0;
	long count  = 0;
  
	while(1)
	{
		time02 = time_now();  // Returns the time now	
		count  = (time02-time01)/1000; // Number of seconds since “time01”
		timeDifference = count;
		if(timeDifference != lastDifference)
		{
			lastDifference = timeDifference;
			Sphere::itsRadius = Sphere::itsRadius + 0.002; //Does not work: Supposed to increase radius once per second
		}
  
		glutReshapeFunc(resize);
		glutDisplayFunc(display);
		glutIdleFunc(idle);
//More code
glutMainLoop();
if( ((time02-time01)/1000) >= MAX) break;// Stop after MAX seconds
	  }//End while loop
return EXIT_SUCCESS;
}//End main()
//More code
static void display(void)
{
	const double t = glutGet(GLUT_ELAPSED_TIME) / 1000.0;
	const double a = t*90.0;
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glColor3d(1,0,0);
	glPushMatrix();
	glTranslated(0,0,-6);
	glutSolidSphere(Sphere::itsRadius,Sphere::itsSlices,Sphere::itsStacks);
	glPopMatrix();
	glutSwapBuffers();
}
//More code


The time trick I used above work on its own but, not when I draw my sphere.

Thank you for your help.

Regards,

Herve

need help to get started

30 January 2011 - 08:39 AM

Hello,

I have never written codes for games. I am a very good (i think) C, C++, MATLAB and python programmer.
I want to start writing codes for games. Apparently i have to learn C# and use Visual studio.
I don't really like Windows tough (i use Linux: Ubuntu). However, if i have to use Windows to develop
game, so be it.

My questions are:
What language should is use?
What compiler should i use?
Do i really have to learn a new language?
Is there a game that every beginner starts with? (a "Hello World!" type of game) :D

Thank you very much in advance

PARTNERS