示例#1
0
	lighting_example(
		const example_params& params,
		const example_state_view& state,
		eagine::memory::buffer& temp_buffer
	): erase_prog(params)
	 , light_prog(params)
	 , background(
		temp_buffer,
		(shapes::vertex_attrib_kind::position  |0),
		36, 72
	), shape(
		temp_buffer,
		(shapes::vertex_attrib_kind::position  |0)+
		(shapes::vertex_attrib_kind::normal    |1)+
		(shapes::vertex_attrib_kind::wrap_coord|2),
		96, 144
	), shp_turns(0.0f)
	 , cam_orbit(0.0f)
	 , cam_turns(0.0f)
	 , cam_pitch(0.5f)
	 , cam_dist_dir(-1)
	 , cam_turn_dir(1)
	 , cam_elev_dir(1)
	{
		gl.clear_depth(1);
		gl.disable(GL.cull_face);

		set_projection(state);
	}
示例#2
0
int main(int argc, char* argv[]) {
  win_set_width(WIN_WIDTH);
  win_set_height(WIN_HEIGHT);
  win_new();
  glfwSetWindowTitle(APP_TITLE);
  glClearColor(BG_COLOR[0], BG_COLOR[1], BG_COLOR[2], BG_COLOR[3]);
  font_set_color(FONT_COLOR[0], FONT_COLOR[1], FONT_COLOR[2], FONT_COLOR[3]);

  // main loop
  while(1) {
    glClear(GL_COLOR_BUFFER_BIT);
    
    set_projection();

    draw_font_set();

    report_fps();

    glfwSwapBuffers();
    if(!glfwGetWindowParam(GLFW_OPENED))
      break;

    fps_inc_frames_drawn();
  }

  glfwTerminate();
  return 0;
}
示例#3
0
		bc_orthographic_camera::bc_orthographic_camera(bcUINT16 p_back_buffer_width,
			bcUINT16 p_back_buffer_height,
			bcFLOAT p_near_clip,
			bcFLOAT p_far_clip)
			: bc_icamera(p_back_buffer_width, p_back_buffer_height, p_far_clip, p_near_clip)
		{
			set_projection(p_back_buffer_width, p_back_buffer_height, p_near_clip, p_far_clip);
		}
示例#4
0
void
ChartProjection::Set(const PixelRect &rc, const OrderedTask &task,
                     const GeoPoint &fallback_loc)
{
  const GeoPoint center = task.GetTaskCenter(fallback_loc);
  const fixed radius = max(fixed(10000), task.GetTaskRadius(fallback_loc));
  set_projection(rc, center, radius);
}
示例#5
0
文件: director.cpp 项目: yujiang/mos
void director::create_director()
{
	glEnable(GL_TEXTURE_2D);
	set_alpha_blending(true);
	set_projection();

	//glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
}
static void
champlain_map_source_desc_set_property (GObject *object,
    guint prop_id,
    const GValue *value,
    GParamSpec *pspec)
{
  ChamplainMapSourceDesc *desc = CHAMPLAIN_MAP_SOURCE_DESC (object);

  switch (prop_id)
    {
    case PROP_ID:
      set_id (desc, g_value_get_string (value));

    case PROP_NAME:
      set_name (desc, g_value_get_string (value));
      break;

    case PROP_LICENSE:
      set_license (desc, g_value_get_string (value));
      break;

    case PROP_LICENSE_URI:
      set_license_uri (desc, g_value_get_string (value));
      break;

    case PROP_URI_FORMAT:
      set_uri_format (desc, g_value_get_string (value));
      break;

    case PROP_MIN_ZOOM_LEVEL:
      set_min_zoom_level (desc, g_value_get_uint (value));
      break;

    case PROP_MAX_ZOOM_LEVEL:
      set_max_zoom_level (desc, g_value_get_uint (value));
      break;

    case PROP_TILE_SIZE:
      set_tile_size (desc, g_value_get_uint (value));
      break;

    case PROP_PROJECTION:
      set_projection (desc, g_value_get_enum (value));
      break;

    case PROP_CONSTRUCTOR:
      set_constructor (desc, g_value_get_pointer (value));
      break;

    case PROP_DATA:
      set_data (desc, g_value_get_pointer (value));
      break;

    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
    }
}
示例#7
0
		bc_perspective_camera::bc_perspective_camera(bcUINT16 p_back_buffer_width, 
			bcUINT16 p_back_buffer_height, 
			bcFLOAT p_height_fov, 
			bcFLOAT p_near_clip, 
			bcFLOAT p_far_clip)
			: bc_icamera(p_back_buffer_width, p_back_buffer_height, p_near_clip, p_far_clip)
		{
			set_projection(p_back_buffer_width, p_back_buffer_height, p_height_fov, p_near_clip, p_far_clip);
		}
示例#8
0
文件: gl.c 项目: magicseb/RetroArch
static void gl_render_msg(gl_t *gl, const char *msg)
{
   if (!gl->font)
      return;

   GLfloat font_vertex[8]; 
   GLfloat font_vertex_dark[8]; 
   GLfloat font_tex_coords[8];

   // Deactivate custom shaders. Enable the font texture.
   gl_shader_use(0);
   set_viewport(gl, gl->win_width, gl->win_height, false, false);
   glBindTexture(GL_TEXTURE_2D, gl->font_tex);
   glTexCoordPointer(2, GL_FLOAT, 0, font_tex_coords);

   // Need blending. 
   // Using fixed function pipeline here since we cannot guarantee presence of shaders (would be kinda overkill anyways).
   glEnable(GL_BLEND);

   struct font_output_list out;

   // If we get the same message, there's obviously no need to render fonts again ...
   if (strcmp(gl->font_last_msg, msg) != 0)
   {
      font_renderer_msg(gl->font, msg, &out);
      struct font_output *head = out.head;

      struct font_rect geom;
      calculate_msg_geometry(head, &geom);
      adjust_power_of_two(gl, &geom);
      blit_fonts(gl, head, &geom);

      font_renderer_free_output(&out);
      strlcpy(gl->font_last_msg, msg, sizeof(gl->font_last_msg));

      gl->font_last_width = geom.width;
      gl->font_last_height = geom.height;
   }
   calculate_font_coords(gl, font_vertex, font_vertex_dark, font_tex_coords);
   
   glVertexPointer(2, GL_FLOAT, 0, font_vertex_dark);
   glColorPointer(4, GL_FLOAT, 0, gl->font_color_dark);
   glDrawArrays(GL_QUADS, 0, 4);
   glVertexPointer(2, GL_FLOAT, 0, font_vertex);
   glColorPointer(4, GL_FLOAT, 0, gl->font_color);
   glDrawArrays(GL_QUADS, 0, 4);

   // Go back to old rendering path.
   glTexCoordPointer(2, GL_FLOAT, 0, gl->tex_coords);
   glVertexPointer(2, GL_FLOAT, 0, vertexes_flipped);
   glColorPointer(4, GL_FLOAT, 0, white_color);
   glBindTexture(GL_TEXTURE_2D, gl->texture[gl->tex_index]);

   glDisable(GL_BLEND);
   set_projection(gl, true);
}
示例#9
0
	void pointer_motion(const example_state_view& state)
	override
	{
		if(state.pointer_dragging())
		{
			mod_cam_turns(-state.norm_delta_pointer_x()*0.5f);
			mod_cam_pitch(-state.norm_delta_pointer_y()*1.0f);
			set_projection(state);
		}
	}
示例#10
0
void
ChartProjection::Set(const PixelRect &rc,
                     const TaskProjection &task_projection,
                     fixed radius_factor)
{
  const GeoPoint center = task_projection.get_center();
  const fixed radius = max(fixed(10000),
                           task_projection.ApproxRadius() * radius_factor);
  set_projection(rc, center, radius);
}
示例#11
0
void special( int key, int x, int y )
{
	switch( key )
	{
	// camera controls
	case GLUT_KEY_LEFT:			cam_azim -= 5.0; break;
	case GLUT_KEY_RIGHT:		cam_azim += 5.0; break;
	case GLUT_KEY_UP:			cam_elev += 5.0; break;
	case GLUT_KEY_DOWN:			cam_elev -= 5.0; break;
	case GLUT_KEY_PAGE_UP:		cam_zoom(-5.0); break;
	case GLUT_KEY_PAGE_DOWN:	cam_zoom( 5.0); break;
	
	case GLUT_KEY_F1:
		ortho = false;
		gridon = false;
		cam_elev = 6;		// 6' tall
		cam_azim = 0;
		cam_dist = 550;
		cam_panx = 0;
		cam_pany = 15;
		set_projection();
		start();
		break;

	case GLUT_KEY_F2:
		ortho = true;
		cam_elev = 25;		// 6' tall
		cam_azim = 40;
		cam_dist = 950;
		cam_panx = 0;
		cam_pany = -44;
		set_projection();
		break;

	default:
		print_help();
		break;
	}

	// refresh after a command
	glutPostRedisplay();
}
示例#12
0
	void user_idle(const example_state_view& state)
	override
	{
		if(state.user_idle_time() > seconds_(1))
		{
			const float s = state.frame_duration().value()/5;

			mod_cam_orbit(s*cam_dist_dir);
			mod_cam_turns(s*cam_turn_dir);
			mod_cam_pitch(s*cam_elev_dir);

			set_projection(state);
		}
	}
示例#13
0
        Window::Window(const int id, const YAML::Node c) : BaseElement(c), window_id(id) {
            set_projection(
                c["near"].as<float>(1.0),
                c["far"].as<float>(80.0),
                c["right"].as<float>(0.5),
                c["left"].as<float>(-0.5),
                c["top"].as<float>(0.5),
                c["bottom"].as<float>(-0.5)
            );

            glClearColor(0.2,0.2,0.5,0);
            glEnable(GL_DEPTH_TEST);
            glEnable(GL_TEXTURE_2D);
        }
   void draw_scene()
   {
      // setup the render settings
      al_set_render_state(ALLEGRO_DEPTH_TEST, 1);
      al_set_render_state(ALLEGRO_WRITE_MASK, ALLEGRO_MASK_DEPTH | ALLEGRO_MASK_RGBA);
      al_clear_depth_buffer(1);

      ALLEGRO_TRANSFORM t;
      Entity3D *camera = static_cast<Entity3D *>(scene_root.find_first("name", "camera"));
      if (camera) camera->place.build_reverse_transform(&t);
      else al_identity_transform(&t);
      set_projection(backbuffer_sub_bitmap, &t);

      // draw our scene
      scene_root._draw();
   }
示例#15
0
int main(int argc, char * argv[])
{
    glutInit(&argc, argv);
    glutCreateWindow("BlockBuster");
    glutReshapeWindow(glutGet(GLUT_SCREEN_WIDTH)/1.5, glutGet(GLUT_SCREEN_HEIGHT)/1.5);
    
    //init game state
    initGame();
    
    printf("running");
    
    glutDisplayFunc(display);
    glutIdleFunc(idle);
    glutPassiveMotionFunc(passive_motion);
    glutKeyboardFunc(keyboard);
    
    set_projection();
    glutMainLoop();
}
示例#16
0
文件: gl.c 项目: magicseb/RetroArch
static void set_viewport(gl_t *gl, unsigned width, unsigned height, bool force_full, bool allow_rotate)
{
   if (gl->keep_aspect && !force_full)
   {
      float desired_aspect = g_settings.video.aspect_ratio;
      float device_aspect = (float)width / height;

      // If the aspect ratios of screen and desired aspect ratio are sufficiently equal (floating point stuff), 
      // assume they are actually equal.
      if (fabs(device_aspect - desired_aspect) < 0.0001)
         glViewport(0, 0, width, height);
      else if (device_aspect > desired_aspect)
      {
         float delta = (desired_aspect / device_aspect - 1.0) / 2.0 + 0.5;
         glViewport(width * (0.5 - delta), 0, 2.0 * width * delta, height);
         width = 2.0 * width * delta;
      }
      else
      {
         float delta = (device_aspect / desired_aspect - 1.0) / 2.0 + 0.5;
         glViewport(0, height * (0.5 - delta), width, 2.0 * height * delta);
         height = 2.0 * height * delta;
      }
   }
   else
      glViewport(0, 0, width, height);

   set_projection(gl, allow_rotate);

   gl->vp_width = width;
   gl->vp_height = height;

   // Set last backbuffer viewport.
   if (!force_full)
   {
      gl->vp_out_width = width;
      gl->vp_out_height = height;
   }

   //RARCH_LOG("Setting viewport @ %ux%u\n", width, height);
}
示例#17
0
int main(int argc, char* argv[]) {
    //glut initialization
	glutInit(&argc, argv);
    
	glutInitWindowSize(init_win_width, init_win_height);
	win_id = glutCreateWindow(win_title);
	if(win_id <= 0) {
		fprintf(stderr, "Error: glutCreateWindow() returned %d\n", win_id);
		exit(1);
	}
    
    //scene initialization
    init();
    
	glutDisplayFunc(display);
	glutKeyboardFunc(keyboard);
	glutIdleFunc(idle);
    glutMouseFunc(mouse);
    glutMotionFunc(motion);
    
	set_projection();
	set_lighting();
    
    init_textures();
	glEnable(GL_TEXTURE_2D);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    
    numOfVerts = NULL;
    
    glBindTexture(GL_TEXTURE_2D, 0);
	
	glutMainLoop();
    
	return 0;
}
示例#18
0
    cube_example(
        const example_state_view& state,
        eagine::memory::buffer& temp_buffer
    ): prog()
        , cube(
            temp_buffer,
            shapes::vertex_attrib_kind::position+
            shapes::vertex_attrib_kind::normal+
            shapes::vertex_attrib_kind::box_coord+
            shapes::vertex_attrib_kind::face_coord
        ), cam_orbit(0.5)
        , cam_turns(0.12f)
        , cam_pitch(0.72f)
        , cam_dist_dir(-1)
        , cam_turn_dir(1)
        , cam_elev_dir(1)
    {
        gl.clear_color(0.6f, 0.6f, 0.5f, 0);
        gl.clear_depth(1);
        gl.enable(GL.depth_test);

        set_projection(state);
    }
示例#19
0
文件: gl.c 项目: magicseb/RetroArch
static void gl_set_rotation(void *data, unsigned rotation)
{
   gl_t *gl = (gl_t*)data;
   gl->rotation = 90 * rotation;
   set_projection(gl, true);
}
示例#20
0
void keyboard( unsigned char key, int x, int y )
{
	if( isupper(key) )
		key = tolower(key);

	switch( key )
	{
	case 'a':
		if( anim )
			stop();
		else
			start();
		break;

	case 'c': reset_camera(); break;
	case 'f': fps_status = !fps_status; break;
	case 'g': gridon = !gridon; break;
	case 'p': planeon = !planeon; break;
	case 'h': half = !half; break;
	
	case 'l':
		lights = !lights;
		if( lights )
			glEnable(GL_LIGHTING);
		else
			glDisable(GL_LIGHTING);
		break;

	case 'b':
		cull = !cull;
		if( cull )
			glEnable(GL_CULL_FACE);
		else
			glDisable(GL_CULL_FACE);
		break;

	case 'o':
		ortho = !ortho;
		set_projection();
		break;

	case 's':
		smooth = !smooth;
		glShadeModel(smooth ? GL_SMOOTH : GL_FLAT);
		break;

	case 'w':
		wire = !wire;
		glPolygonMode(GL_FRONT_AND_BACK, wire ? GL_LINE : GL_FILL);
		break;

	case ' ':
		fullscreen = !fullscreen;
		set_fullscreen();
		break;

	case '\t':
		printf("\ncamera:\n"
				"-------------------\n"
				"%3.3f elev\n"
				"%3.3f azim\n"
				"%3.3f dist\n"
				"%3.3f x\n"
				"%3.3f y\n",
				cam_elev,
				cam_azim,
				cam_dist,
				cam_panx,
				cam_pany );
		break;

	case 'q': exit(0); break;
	default:
		print_help();
		break;
	}

	// refresh after a command
	glutPostRedisplay();
}
示例#21
0
	void pointer_scrolling(const example_state_view& state)
	override
	{
		mod_cam_orbit(-state.norm_delta_pointer_z());
		set_projection(state);
	}
示例#22
0
		void bc_icamera::set_projection(bcUINT16 p_back_buffer_width, bcUINT16 p_back_buffer_height) noexcept
		{
			set_projection(p_back_buffer_width, p_back_buffer_height, m_near, m_far);
		}
示例#23
0
		void bc_perspective_camera::set_projection(bcUINT16 p_back_buffer_width, bcUINT16 p_back_buffer_height, bcFLOAT p_height_fov, bcFLOAT p_near_clip, bcFLOAT p_far_clip) noexcept
		{
			m_field_of_view = p_height_fov;
			set_projection(p_back_buffer_width, p_back_buffer_height, p_near_clip, p_far_clip);
		}
示例#24
0
	void resize(const example_state_view& state)
	override
	{
		gl.viewport(state.width(), state.height());
		set_projection(state);
	}
示例#25
0
//-----------------------------------------------------------------------------
// name: main_draw()
// desc: ...
//-----------------------------------------------------------------------------
void AudicleWindow::main_draw( )
{
    assert( this == AudicleWindow::main() );
    m_frame_stamp++;

    AudicleWindow::main()->get_current_time( TRUE );
    
    // clear buffers
    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );

    if( m_antialiased )
    {
        glHint( GL_POINT_SMOOTH_HINT, GL_NICEST );
        glHint( GL_LINE_SMOOTH_HINT, GL_NICEST );
        glEnable( GL_POINT_SMOOTH );
        glEnable( GL_LINE_SMOOTH );
    }
    else
    {
        glDisable( GL_POINT_SMOOTH );
        glDisable( GL_LINE_SMOOTH );
    }

    // set projection ( may be picking )
    set_projection();

    AudicleFace * face = Audicle::instance()->face();

    // push state
    face->render_pre();

    // set view matrices 
    face->render_view();     

    // do yer buzinezz;
    face->render( NULL );
/*
    glEnable(GL_TEXTURE_2D);
    glColor4d ( 0,0,0,1.0);
    glPushMatrix();
    scaleFont( 1.0, 1.0 );

    kernedFont->Render( "hi!" );
    monospacedFont->Render( "hello!" );

    glPopMatrix();    
    glDisable(GL_TEXTURE_2D);
*/
    // restore state
    face->render_post();

    // rendering for constant overlay...
    // we may place a windowmanager here?
    // move messages to a non-static setup....
    // for now put a console at least in here..



    // ui_render_console ();
    
    // flush
    glFlush();
    // swap
    if( m_render_mode == GL_RENDER )
        glutSwapBuffers();
}
示例#26
0
static void display() {

	totalVerts = 0;
    
	glLoadIdentity();
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    
    glPushMatrix();
    glRotatef(angle, 0, 0, 1);
    glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, specLight);	// Make sphere glow (emissive)
    glLightfv(GL_LIGHT0, GL_POSITION, dirI );
    glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, Noemit);
    glPopMatrix();
    
	// set camera viewpoint
	camera_lookat();
    
    center[0] = sphereCenter[0];
    center[1] = sphereCenter[1];
    center[2] = sphereCenter[2];
    
    glColor3f(1.0, 1.0, 1.0);
    
    draw_verts(center, 0, false, 0);//draw sphere
    
    center[0] = 0;
    center[1] = 0;
    center[2] = 10.0;
    draw_verts(center, 1, true, 3);//draw arena
    
    center[0] = -18.5;
    center[1] = 0;
    center[2] = 0;
    
    for(int i = 0; i < numOfBars; i++){//draw bars
        barHeight = get_bar_height(center);
        glColor3f(0.5, 0.1, barHeight/5);
        draw_cube(center, 30/barHeight, 3, false);
        center[0] += 4;
    }
    
    center[0] = actionCenter[0];
    center[1] = actionCenter[1];
    center[2] = actionCenter[2];
    
    glColor3f(1.0, 1.0, 1.0);
    draw_cube(center, .7, .7, true);//draw action block
    
    center[0] = 18.5;
    center[1] = 0.1;
    center[2] = 3.0;
    glColor3f(1.0, 1.0, 1.0);
    draw_verts(center, 2, false, 0);//draw end 1
    center[0] = -18.5;
    draw_verts(center, 3, false, 0);//draw end 2
    
    center[0] = 0;
    center[1] = sphereCenter[1];
    draw_verts(center, 5, false, 0);//draw bar
    
    
    grid_terrain_draw(num_adj_levels);//draw terrain
    
    glColor3f(0.5, 0.5, 0.5);
    center[0] = -40;
    glRotatef(rotation, 0, 1, 0);
    draw_verts(center, 4, false, 0);//draw stands
    glRotatef(90, 0, 1, 0);
    draw_verts(center, 4, false, 0);//draw stands
    glRotatef(90, 0, 1, 0);
    draw_verts(center, 4, false, 0);
    glRotatef(90, 0, 1, 0);
    draw_verts(center, 4, false, 0);
    
    center[1] = 15;
    glColor3f(.4, .4, 1.0);
    glutSolidSphere(50, 20, 10);
    
    draw_diagnostics(fps_vertices);//draw text
    
    if(display_help){    
		set_ortho_projection();
		glparams_draw();
		set_projection();
    }
    
	glFlush();
    
	// increment frame count for framerate code
	++frame_count;
}