コード例 #1
0
ファイル: GameMap.cpp プロジェクト: ze0nni/SeaSage
void GameMap::renderMap(float rx, float ry, float angle, int rsize) {
    int cx = (int)(rx/MAP_CELL_SIZE);
    int cy = (int)(ry/MAP_CELL_SIZE);
    int sx = cx-rsize; //if (sx<0) {sx=0;}
    int sy = cy-rsize; //if (sy<0) {sy=0;}
    int ex = cx+rsize; //if (ex>width-1) ex=width-1;
    int ey = cy+rsize; //if (ey>height-1) ey=height-1;
    glPushMatrix();

    //сместим на центр
    float ox;
    float oy;
    ox=-(rsize) * MAP_CELL_SIZE;
    oy=ox;
    ox-=rx-cx*MAP_CELL_SIZE;
    oy-=ry-cy*MAP_CELL_SIZE;
    glRotated(angle*180.0d/M_PI, 0, 1, 0);
    glTranslatef(ox, 0.0f, oy);
    //Рисуем блоки
    enumCells(sx, ex, sy, ey, &drawBlocksproc);

    //рисуем воду
    glEnable(GL_ALPHA_TEST);
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    //enumCells(sx, ex, sy, ey, &drawWaterproc);
    renderWater();


    glDisable(GL_ALPHA_TEST);
    glDisable(GL_BLEND);

    glPopMatrix();
}
コード例 #2
0
void UINodeBackgroundScene::renderFailedWaterHeight (int x, int y) const
{
	renderCave(x, y);
	renderGround(x, y);
	renderFailedCenter(x, y, MapFailedReasons::FAILED_WATER_HEIGHT);
	renderWater(x, y);
}
コード例 #3
0
ファイル: ex15.c プロジェクト: spetz911/vog
GLUSboolean update(GLUSfloat time)
{
    static GLfloat passedTime = 0.0f;

    static GLUSfloat angle = 0.0f;

    GLfloat inverseViewMatrix[16];

    glusLookAtf(g_viewMatrix, 0.0f, 1.0f, 0.0f, (GLfloat) 0.5f * sinf(angle), 1.0f, -(GLfloat) 0.5f * cosf(angle), 0.0f, 1.0f, 0.0f);

    glusMatrix4x4Copyf(inverseViewMatrix, g_viewMatrix, GLUS_TRUE);
    glusMatrix4x4InverseRigidBodyf(inverseViewMatrix);
    glusMatrix4x4ExtractMatrix3x3f(g_inverseViewNormalMatrix, inverseViewMatrix);

    // Render the background
    renderBackground(g_viewMatrix);

    // Render the water texture
    renderWaterTexture(passedTime);

    // Render the water scene
    renderWater(passedTime);

    passedTime += time;

    angle += 2.0f * PIf / 120.0f * time;

    return GLUS_TRUE;
}
コード例 #4
0
/**
 * Function to render and display content.
 */
GLUSboolean update(GLUSfloat time)
{
	static GLfloat passedTime = 0.0f;

	static GLUSfloat angle = 0.0f;

	// http://www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/clear.html
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	// http://www.opengl.org/sdk/docs/man/xhtml/glUseProgram.xml
	glUseProgram(g_programBackground.program);

	// http://www.opengl.org/sdk/docs/man/xhtml/glUniform.xml
	glUniformMatrix4fv(g_modelViewLocationBackground, 1, GL_FALSE, g_modelView);

	// ToDo:
	glBindVertexArray(g_vaoBackground);

	// ToDo:
	glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);

	//http://www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/enable.html
	glEnable( GL_CULL_FACE);

	// http://www.opengl.org/sdk/docs/man/xhtml/glDrawElements.xml
	glDrawElements(GL_TRIANGLES, g_numberIndicesBackground, GL_UNSIGNED_INT, 0);
	
	// Update the texture
	updateTexture(passedTime);

	// Render the water scene
	renderWater(passedTime, angle);

	passedTime += time;

	angle += 2.0f * PIf / 120.0f * time;

	return GLUS_TRUE;
}
コード例 #5
0
void UINodeBackgroundScene::renderFailedNpcFish (int x, int y) const
{
	renderFailedCenter(x, y, MapFailedReasons::FAILED_NPC_FISH);
	renderWater(x, y);
}
コード例 #6
0
	void Battle::renderWorld()
	{
		gfx->SetDefState();
		glClearColor(FogColor[0],FogColor[1],FogColor[2],FogColor[3]);
		gfx->clearDepth();		// Clear screen

		cam.setView();

		pSun.Set(cam);
		pSun.Enable();

		cam.setView();

		cam.zfar *= 100.0f;
		cam.setView();
		glDisable(GL_FOG);
		glColor4ub(0xFF, 0xFF, 0xFF, 0xFF);
		glEnable(GL_TEXTURE_2D);
		glDisable(GL_BLEND);
		if (lp_CONFIG->render_sky)
		{
			glDisable(GL_LIGHTING);
			glDepthMask(GL_FALSE);
			glTranslatef(cam.rpos.x, cam.rpos.y + cam.shakeVector.y, cam.rpos.z);
			glRotatef(sky_angle, 0.0f, 1.0f, 0.0f);
			if (lp_CONFIG->ortho_camera)
			{
				const float scale = cam.zoomFactor / 800.0f * std::sqrt(float(SCREEN_H * SCREEN_H + SCREEN_W * SCREEN_W));
				glScalef( scale, scale, scale );
			}
			sky.draw();
		}
		else
			gfx->clearScreen();

		glDepthMask(GL_TRUE);
		glEnable(GL_CULL_FACE);
		glEnable(GL_LIGHTING);
		glEnable(GL_FOG);
		updateZFAR();

		if (lp_CONFIG->wireframe)
			glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);

		map->draw(&cam, byte(1 << players.local_human_id), false, 0.0f, t, dt * units.apparent_timefactor);

		if (lp_CONFIG->wireframe)
			glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);

		cam.setView(lp_CONFIG->shadow_quality < 2);

		features.draw(render_time);		// Dessine les éléments "2D"

		/*----------------------------------------------------------------------------------------------*/

		// Dessine les unités sous l'eau / Draw units which are under water
		cam.setView(lp_CONFIG->shadow_quality < 2);
		if (cam.rpos.y <= gfx->low_def_limit)
		{
			if (lp_CONFIG->shadow_quality >= 2)
				glFogi (GL_FOG_COORD_SRC, GL_FOG_COORD);
			units.draw(true, false, true, lp_CONFIG->height_line);
			glFogi (GL_FOG_COORD_SRC, GL_FRAGMENT_DEPTH);
		}

		// Dessine les objets produits par les armes sous l'eau / Draw weapons which are under water
		weapons.draw(true);

		if (lp_CONFIG->particle)
			particle_engine.drawUW();

		renderWater();

		// Render map object icons (if in tactical mode)
		if (cam.rpos.y > gfx->low_def_limit)
		{
			cam.setView(true);
			features.draw_icons();
		}

		cam.setView(lp_CONFIG->shadow_quality < 2);
		if (lp_CONFIG->shadow_quality >= 2)
			glFogi (GL_FOG_COORD_SRC, GL_FOG_COORD);
		// Dessine les unités non encore dessinées / Draw units which have not been drawn
		units.draw(false, false, true, lp_CONFIG->height_line);
		glFogi (GL_FOG_COORD_SRC, GL_FRAGMENT_DEPTH);

		// Dessine les objets produits par les armes n'ayant pas été dessinés / Draw weapons which have not been drawn
		weapons.draw(false);
	}