Exemple #1
0
void init()
{
    allegro_init();
    set_color_depth(32);

    if(set_gfx_mode(GFX_AUTODETECT_WINDOWED, 320, 240, 0, 0))
    {
        allegro_message("%s.", allegro_error);
        exit(1);
    }

    init_engine(SCREEN_W, SCREEN_H);
    point_at_color_buffer(&buffer);
    setup_projection(90.0, -1.333, 1.333, -1.0, 1.0, 0.0, 200.0);
    set_znear(1.0);
    set_clipping_rect(10, 10, buffer->w - 11, buffer->h - 11);
    init_clipper();
    set_rasterizer_function(flat_zbuff_sides);
    set_world_clip_func(2, wclip_to_rend_int, 0, 0, 0, 0);
    set_scr_clip_func(4, rend_int_to_tri, 0, 0, 0, 0);

    install_keyboard();
    install_mouse();
    srand(time(NULL));
}
Exemple #2
0
// Render the actual scene
void terrain::render()
{
	// Enable depth testing
	glEnable(GL_DEPTH_TEST);

	// Enable automatic normalization of normals
	glEnable(GL_NORMALIZE);

	// Clear the screen
	glClearColor(1,1,1,0);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	// Nothing to do if we are not properly initialized
	if (!initialized)
		return;

	// Setup perspective and modelview matrix
	setup_projection();
	// Setup light
	setup_light();


	// Render the solid terrain with lighting and texture mapping
	if (show_solid)
		render_solid_terrain();

	// Render the outline of the terrain
	if (show_wireframe)
		render_wireframe_terrain();

	// Eventually render level lines
	if (show_levels)
		render_level_lines();
}
void init()
{
 allegro_init();

 set_color_depth(32);
 if(set_gfx_mode(GFX_AUTODETECT_WINDOWED, GFX_W, GFX_H, 0, 0))
  {
   allegro_message("Error: %s.", allegro_error);
   exit(1);
  }

 install_keyboard();
 install_mouse();

 buffer = create_bitmap(SCREEN_W, SCREEN_H);
 zbuffer = create_bitmap_ex(32, SCREEN_W, SCREEN_H);
 texture = load_bitmap("data/wall.bmp", NULL);
 skin = load_bitmap("data/babe_skin.bmp", NULL);
 texture2 = load_bitmap("data/color.bmp", NULL);

 setup_projection(90.0, -1.333, 1.333, -1.0, 1.0, -1.0, 200.0);
 init_renderer(GFX_H);
 bind_color_buffer(buffer);
 bind_zbuffer(zbuffer);
 bind_texture(texture);
}
Exemple #4
0
 void Slice::draw_plane (int axis, Displayable::Shader& shader_program, Projection& with_projection)
 {
   ASSERT_GL_MRVIEW_CONTEXT_IS_CURRENT;
   setup_projection (axis, with_projection);
   draw_plane_primitive (axis, shader_program, with_projection);
   draw_crosshairs (with_projection);
   draw_orientation_labels (with_projection);
   ASSERT_GL_MRVIEW_CONTEXT_IS_CURRENT;
 }
Exemple #5
0
void example_3d_primitives::render()
{
	glEnable(GL_DEPTH_TEST);

	// Clear the screen
	glClearColor(1,1,1,0);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	// Setup a perspective projection and lighting
	setup_projection();
	setup_light();

	glScaled(0.4, 0.4, 0.4);

	// Move 5 units to the left, save the current transformation
	// and show a rotated tetrahedron
	glTranslated(-5, 0, 0);
	glPushMatrix();
	glRotated(angle, 0, 1, 0);
	glColor3d(1, 1, 0);
	render_tetrahedron();
	glPopMatrix();

	// Move 3 units to the right, save the current transformation
	// and show a rotated cylinder
	glTranslated(3, 0, 0);
	glPushMatrix();
	glRotated(angle, 1, 0, 0);
	glColor3d(0, 1, 0);
	render_cylinder();
	glPopMatrix();

	// Move 3 units to the right, save the current transformation
	// and show a rotated cube
	glTranslated(3, 0, 0);
	glPushMatrix();
	glRotated(angle, 0, 1, 1);
	glColor3d(1, 0, 0);
	render_cube();
	glPopMatrix();

	// Move 3 units to the right, save the current transformation
	// and show a rotated sphere
	glTranslated(3, 0, 0);
	glPushMatrix();
	glRotated(angle, 0, 1, 0);
	glColor3d(0, 0, 1);
	render_sphere();
	glPopMatrix();
}
MapDrawingArea::MapDrawingArea(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>&):
    Gtk::DrawingArea(cobject),
    pressed(false),
    zoom(1),
    tran_x(0),
    tran_y(0),
    topleft(-1, -1),
    bottomright(1, 1),
    lat(0),
    lon(0)
{
    add_events(Gdk::SCROLL_MASK | Gdk::ENTER_NOTIFY_MASK | Gdk::LEAVE_NOTIFY_MASK | Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK | Gdk::POINTER_MOTION_MASK);
    setup_projection();
    setup_surfaces();
    setup_bounds();
}
Exemple #7
0
// Setup the scene and render cube system
void cube_system::render()
{
	// Enable depth testing
	glEnable(GL_DEPTH_TEST);
	// Disable lighting
	glDisable(GL_LIGHTING);

	// Clear the screen and depth buffer
	glClearColor(1,1,1,0);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	// Set the projection and view
	setup_projection();

	// Render the system
	render_system();
}
	void primary_timer_func() override
	{
		//
		// UPDATE
		//

		for (unsigned i=0; i<entities.size(); i++)
		{
			entities[i]->place.position += entities[i]->velocity.position;
			entities[i]->place.rotation += entities[i]->velocity.rotation;
		}



		//
		// DRAW
		//

		// the functionality of this line might eventually be embedded in the framework
		setup_projection();

		// draw the entities in our scene
		vec3d camera_position = camera.get_real_position();
		vec3d light_position = light.position;

		// draw the skybox (and clear the depth buffer)
		skybox->place.position = camera_position;
		skybox->draw(0, 0);
		al_clear_depth_buffer(1);

		for (unsigned i=0; i<entities.size(); i++)
		{
			entities[i]->draw(camera_position, light_position);
		}



		// draw the Construct (the environment box)
/*
		glEnable(GL_CULL_FACE); // requiring opengl should eventually be fazed out
		construct.draw();
		glDisable(GL_CULL_FACE);
*/

	}
void MapDrawingArea::after_change()
{
    setup_projection();
    setup_db();
    redraw_from_db();
}