void display()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glLoadIdentity(); // camera functionality must be in display method
	cam.Update();//MUST UPDATE CAMERA BEFORE DRAWING OBJECTS
	//obj.Draw();
	if (worldTwoCount == -1)
		world.Draw(); //VERY IMPORTANT
	else
		world2.Draw();
	glutSwapBuffers();
}
Esempio n. 2
0
//Main display function
void display(void)
{

	glClearColor(0.2f, 0.3f, 1.0f, 0.9f);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glColor3f(0.0f, 0.0f, 0.0f);

	glPushMatrix();
	glMatrixMode(GL_MODELVIEW);
	glViewport(0, (WINDOW_HEIGHT / 3) * 2, WINDOW_WIDTH, WINDOW_HEIGHT - (WINDOW_HEIGHT / 3) * 2);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glOrtho(0.0, (GLdouble)WINDOW_WIDTH, (WINDOW_HEIGHT / 3) * 2, (GLdouble)WINDOW_HEIGHT, -1.0, 1.0);

	//draw the user interface **NOT THE MINI MAP**
	drawUI();

	glPopMatrix();
	glPushMatrix();
	glEnable(GL_LIGHTING);
	glEnable(GL_LIGHT0);

	//draw the actual world, with lighting
	theWorld.Draw(continuousRendering);
	glDisable(GL_LIGHTING);
	glPopMatrix();

	//draw the mini map interface 
	drawMap();
	glutSwapBuffers();
}
Esempio n. 3
0
int main(int argc, char*argv[])
{
	EventManager::Initialize();
	Renderer::Initialize();

	World world;

	if (argc > 1)
	{
		world.LoadScene(argv[1]);
	}
	else
	{
		// TODO - You can alternate between different scenes for testing different things
		// Static Scene contains no animation
		// Animated Scene does
#if defined(PLATFORM_OSX)		//Bad OS!
//		world.LoadScene("Scenes/AnimatedScene.scene");
//		world.LoadScene("Scenes/StaticScene.scene");
//		world.LoadScene("Scenes/CoordinateSystem.scene");
#else
	//	world.LoadScene("../Assets/Scenes/AnimatedSceneWithParticles.scene");
		world.LoadScene("../Assets/Scenes/NOISE.scene");
	//	world.LoadScene("../Assets/Scenes/AnimatedScene.scene");
	//	world.LoadScene("../Assets/Scenes/StaticScene.scene");
	//	world.LoadScene("../Assets/Scenes/CoordinateSystem.scene");
#endif
	}

	// Main Loop
	do
	{
		// Update Event Manager - Frame time / input / events processing / sound
		EventManager::Update();

		// Update World
		float dt = EventManager::GetFrameTime();
		float currentVolume = EventManager::GetCurrentVolume();
		float* currentSpec = EventManager::GetCurrentSpec();
		world.Update(dt, currentVolume, currentSpec);

		// Draw World
		world.Draw();
	}
	while(EventManager::ExitRequested() == false);

	Renderer::Shutdown();
	EventManager::Shutdown();

	return 0;
}
Esempio n. 4
0
void onDrawCb()
{
    // Keep track of time
    theFpsTracker.timestamp();

    // Draw Scene and overlay
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    theCamera.draw();
    //drawAxes();

    vec3 cpos = theCamera.getPosition();
    float pos[4] = {cpos[0], cpos[1]+2.0, cpos[2],0.0};
    glLightfv(GL_LIGHT0, GL_POSITION, pos);

    theWorld.Draw();
    theJello.Draw(cpos);
    //drawOverlay();
    glutSwapBuffers();

	
}
Esempio n. 5
0
int main(int argc, char** argv){
	//ShowWindow(GetForegroundWindow(), SW_HIDE);
	Display display(WIDTH, HEIGHT, "OpenGL");
	if (Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 2048) < 0){ std::cout << "ERROR: MixOpenAudio: " << Mix_GetError() << std::endl; }

	World world; Shader* shader = world.GetShader();
	Brush br(24, 6, 24, &world, "./res/tex/pxl_cuboid.jpg"); br.Move(-2, 0, -2);

	Brush c1(1, 0.5, 3, &world, "./res/tex/pxl_cuboid.jpg"); c1.Move(2, 0, 2);
	Brush c2(1, 1.0, 3, &world, "./res/tex/pxl_cuboid.jpg"); c2.Move(3, 0, 2);
	Brush c3(1, 0.2, 1.5, &world, "./res/tex/pxl_cuboid.jpg"); c3.Move(6, 0.9, 2);
	Brush c4(1, 0.2, 1.5, &world, "./res/tex/pxl_cuboid.jpg"); c4.Move(6, 1.1, 3.5);

	Brush box(1, 1, 1, &world, "./res/tex/pxl_cuboid.jpg"); box.Move(6, 0.5, 6);

	Player player(shader); display.SetPlayer(player);
	Camera cammy; cammy.Init(glm::vec3(0, 0, 0), 70.0f, 1600 / 900, 0.01f, 1000.0f);
	Ambient amb1; shader->AddAmbient(&amb1); amb1.m_range = 3; amb1.m_intensity = 0.2;
	Ambient amb2; shader->AddAmbient(&amb2); amb2.SetPosition(1, 1, 1);
	Ambient amb3; shader->AddAmbient(&amb3); amb3.SetPosition(15, 1, 10); amb3.SetColor(0.2, 0.5, 0.7);

	Prop prop(world.GetMesh("./res/models/cucco.obj"), world.GetTexture("./res/models/cucco.jpg"), shader); world.AddProp(&prop);
	Prop stone(world.GetMesh("./res/models/salesman.obj"), world.GetTexture("./res/models/salesman.jpg"), shader); world.AddProp(&stone); stone.Scale(0.01); stone.Teleport(0, -10, 0);
	Sound laugh; laugh.Init("./res/sounds/sale_laugh.wav", 0.7); laugh.Load();
	
	player.SetListener(Player_OnClick, OnClick);

	float count = 0.0f;
	while (!display.IsClosed()){
		display.Clear(0.1f, 0.3f, 0.8f, 1.0f);
		world.Draw(&player.GetCamera());
		player.DrawHUD();
		display.Update();

		laugh.Update(player.GetCamera().GetPos());

		if (count >= 2 * PI){ count = 0; }
		count += 0.05f;
		c4.Rotate(0, 1, 0);

		if (glm::distance(prop.position, player.GetCamera().GetPos()) >= 2){
			prop.velocity = (player.GetCamera().GetPos() - prop.position) / 64.0f;
			prop.velocity.y = 0;
			prop.SetRotate(0, PI / 2 - GetAngleRad(glm::vec2(0, 0), GetXZ(prop.velocity)), 0);
		}
		else{
			prop.velocity *= 0;
		}
		prop.Rotate(0, sin(count) * PI / 360, 0);
		amb1.m_position = player.GetCamera().GetPos();

		if (player.mouse_buttons[0]){//Left Clicking
			player.mouse_buttons[0] = false;
			stone.Teleport(world.GetAimPoint(&player));
			stone.SetRotate(0, PI / 2 - GetAngleRad(glm::vec2(0, 0), GetXZ(player.GetCamera().GetPos() - stone.position)), 0);
			laugh.pos = stone.position;
			laugh.Emit(player.GetCamera().GetPos());
		}

		world.Update();
		player.Update();
		world.IsCollide(&player);
		player.CommenceVelocity();
	}
	Mix_CloseAudio();
	Mix_Quit();
	return 0;
}
Esempio n. 6
0
int main(int argc, char*argv[])
{
	EventManager::Initialize();
	Renderer::Initialize();

	World world;

	// If Running on Windows Then Play Background Music
	// PlaySound(TEXT("../Assets/Sounds/Danger-Zone.wav"), NULL, SND_FILENAME | SND_ASYNC | SND_LOOP);

	/*loading screen block*/ {

		LoadingScreen loadingScreen;
		loadingScreen.Draw();

		//	world.LoadScene("../Assets/Scenes/AnimatedSceneWithParticles.scene");
		//	world.LoadScene("../Assets/Scenes/AnimatedScene.scene");
		//	world.LoadScene("../Assets/Scenes/Spline.scene");
		//	world.LoadScene("../Assets/Scenes/StaticScene.scene");
		//	world.LoadScene("../Assets/Scenes/CoordinateSystem.scene");
		//	world.LoadScene("../Assets/Scenes/CollisionDemo.scene");
		//	world.LoadScene("../Assets/Scenes/Animal.scene");
		//	world.LoadScene("../Assets/Scenes/StaticScene.scene");
		//	world.LoadScene("../Assets/Scenes/CoordinateSystem.scene");
		//	world.LoadScene("../Assets/Scenes/Discoball.scene");
		//	world.LoadScene("../Assets/Scenes/Player.scene");
			world.LoadScene();
	}

	double fps = 1.0f / FPS;
	double dtStep = 1.0f / PHYSICS_FPS;
	
	double dtAcc = 0;

#ifdef DEBUG_FRAME_RATE
	long seconds = 0;
	double currentTime = 0.0;
	long remainingMsAcc = 0;
	long sleepCtr = 0;
#endif

	// Reset the polled values in the EventManager because scene loading is long.
	EventManager::Update();

	do
	{
		double start = glfwGetTime();

		// Update Event Manager - Frame time / input / events processing 
		EventManager::Update();

		float dt = EventManager::GetFrameTime();

		// Apply fixed delta time steps to each world update,
		// and drawing can be done if at least 1 world update was done.
		dtAcc += dt;
		bool draw = false;
		while (dtAcc >= dtStep) {
			dtAcc -= dtStep;
			world.Update(dtStep);
			draw = true;
		}

		if (draw) {
			world.Draw();
		}

#ifndef DEBUG_FRAME_RATE
		// Each frame should be "fps" seconds long.
		// If updating and rendering took less than fps seconds long then sleep for the remainder.
		int remainingMs = (start + fps - glfwGetTime()) * 1000;
		if (remainingMs > 0) {
			SLEEP_FUNC(remainingMs);
		}
#else
		long remainingMs = (start + fps - glfwGetTime()) * 1000;
		remainingMsAcc += remainingMs;

		currentTime += dt;
		if (currentTime - seconds >= 1) {
			seconds++;

			double avgRemaingMs = remainingMsAcc / (double)sleepCtr;
			cout << "avg remaining ms " << avgRemaingMs << endl;

			remainingMsAcc = 0;
			sleepCtr = 0;
		}

		if (remainingMs < 0) {
			cout << "OVER FRAME TIME BY " << abs(remainingMs) << " ms" << endl;
		}

		if (remainingMs > 0) {
			sleepCtr++;
			SLEEP_FUNC(remainingMs);
		}
#endif
	}
	while(EventManager::ExitRequested() == false);

	Renderer::Shutdown();
	EventManager::Shutdown();

	return 0;
}
Esempio n. 7
0
int main(int argc, char*argv[])
{
	EventManager::Initialize();
	Renderer::Initialize();

	World world;    
    
	world.LoadScene();

	// If Running on Windows Then Play Background Music
	// PlaySound(TEXT("../Assets/Sounds/RainbowRoad.wav"), NULL, SND_FILENAME | SND_ASYNC | SND_LOOP);

//	if (argc > 1)
//	{
//		world.LoadScene(argv[1]);
//	}
//	else
//	{
//		// TODO - You can alternate between different scenes for testing different things
//		// Static Scene contains no animation
//		// Animated Scene does
//		world.LoadScene("../Assets/Scenes/AnimatedSceneWithParticles.scene");
//		world.LoadScene("../Assets/Scenes/AnimatedScene.scene");
	if (argc > 1)
	{
		world.LoadScene(argv[1]);
	}
	else
	{
		// TODO - You can alternate between different scenes for testing different things
		// Static Scene contains no animation
		// Animated Scene does

//		world.LoadScene("../Assets/Scenes/AnimatedSceneWithParticles.scene");
//		world.LoadScene("../Assets/Scenes/AnimatedScene.scene");
//		world.LoadScene("../Assets/Scenes/Spline.scene");

//		world.LoadScene("../Assets/Scenes/StaticScene.scene");
//		world.LoadScene("../Assets/Scenes/CoordinateSystem.scene");
//		world.LoadScene("../Assets/Scenes/CollisionDemo.scene");
//		world.LoadScene("../Assets/Scenes/Animal.scene");
//		world.LoadScene("../Assets/Scenes/StaticScene.scene");
//		world.LoadScene("../Assets/Scenes/CoordinateSystem.scene");
//		world.LoadScene("../Assets/Scenes/Discoball.scene");
//		world.LoadScene("../Assets/Scenes/Player.scene");
	}
//#endif
//	}

	double fps = 1.0f / FPS;
	double dtStep = fps;
	
	double dtAcc = 0;

	// Main Loop
	do
	{
		double start = glfwGetTime();

		// Update Event Manager - Frame time / input / events processing 
		EventManager::Update();

		// Update World
		float dt = EventManager::GetFrameTime();

		bool draw = false;

		// Apply fixed delta time steps to each world update,
		// and drawing can be done if at least 1 world update was done.
		dtAcc += dt;
		while (dtAcc >= dtStep) {
			dtAcc -= dtStep;
			world.Update(dtStep);
			draw = true;
		}

		// Draw World
		if (draw) {
			world.Draw();
		}

		// Each frame should be "fps" seconds long.
		// If updating and rendering took less than fps seconds long then sleep for the remainder.
		int remainingMs = (start + fps - glfwGetTime()) * 1000;
		if (remainingMs > 0) {
			SLEEP_FUNC(remainingMs);
		}
		world.Draw();    
	}
	while(EventManager::ExitRequested() == false);

	Renderer::Shutdown();
	EventManager::Shutdown();

	return 0;
}