Exemplo n.º 1
0
//=======================================
void draw()
{
	glActiveTexture(GL_TEXTURE0);
	glPushMatrix();
		myTerrain.drawTerrain();
	glPopMatrix();

	glPushMatrix();
		wall.draw(SLOWDOWN);
	glPopMatrix();

	//draw tank
	glPushMatrix();
		myTank.draw(g_ViewMod);
	glPopMatrix();

	glActiveTexture(GL_TEXTURE1);
}
Exemplo n.º 2
0
void renderScene() {
    // clear whatever was drawn to the screen last time - 
    // set the clear color to black and then signal to clear the RGB buffer.
    glClearColor( 0, 0, 0, 1 );
    glClear( GL_COLOR_BUFFER_BIT );

    // switch to GL_MODELVIEW, for when we start using glTranslatef(), glScalef(), etc..
    glMatrixMode( GL_MODELVIEW );
    glLoadIdentity();

    //draw background
	drawBackground();
	//draw tank
	glTranslatef(myTank.location[0],myTank.location[1],0);
	myTank.draw();
	glTranslatef(-myTank.location[0],-myTank.location[1],0);
	//drawObjects
	drawObjects();
	spawnMissiles();
	glutSwapBuffers();
    //glFlush();
}
Exemplo n.º 3
0
int main(void) {
	GLFWwindow* window;

	glfwSetErrorCallback(error_callback);

	if (!glfwInit())
		exit(EXIT_FAILURE);

	window = glfwCreateWindow(800, 600, "Simple example", NULL, NULL);
	if (!window) {
		glfwTerminate();
		exit(EXIT_FAILURE);
	}

	glfwMakeContextCurrent(window);

	glfwSetKeyCallback(window, key_callback);

	std::cout << "Drawing a window." << std::endl;

	Tank tan = Tank();
	tan.state.x = 50;
	tan.state.y = 50;

	long curTicks = 0;
	float tps = 25.0f;
	while (!glfwWindowShouldClose(window)) {
		float ratio;
		int width, height;

		for (; curTicks < (float) glfwGetTime() * tps; curTicks++) {
			gameTick(tan);
		}

		glfwGetFramebufferSize(window, &width, &height);
		ratio = width / (float) height;

		glViewport(0, 0, width, height);
		glClear(GL_COLOR_BUFFER_BIT);

		glMatrixMode(GL_PROJECTION);
		glLoadIdentity();
		//glOrtho(-ratio, ratio, -1.f, 1.f, -10, 10);
		glOrtho(0, width/2, 0, height/2, -10, 10);
		glMatrixMode(GL_MODELVIEW);

		glLoadIdentity();
		//glRotatef((float) glfwGetTime() * 10.f, 0.f, 0.f, 1.f);
		//glTranslatef((float) glfwGetTime() * 20.f, 0.f, 0.f);
		//tan.state.h = (float) glfwGetTime() * -10.f;
		//tan.state.turretH = (float) glfwGetTime() * 10.f;

		//drawCube(0, 0, 0);
		//drawTri();
		//glLineWidth(2.f);
		tan.draw();

		glfwSwapBuffers(window);
		glfwPollEvents();
	}

	glfwDestroyWindow(window);

	glfwTerminate();
	std::cout << "Byebye" << std::endl;
	exit(EXIT_SUCCESS);
}