예제 #1
0
void render() {
	for (int i = 0; i < 2; i++) {
		cameras[i].projection_matrix = glm::perspective(cameras[i].fovy, cameras[i].aspect_ratio, 1.0f, 30.0f);
	}	
			
	fbo->bind();
	glFrontFace(GL_CW);
	glViewport(0, 0, viewport.x, viewport.y);
	glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	diffuse_shader.bind();
	diffuse_shader.set_uniform_value("light_direction", light_direction);
	render_model(teapot, cameras[1], diffuse_shader);
	diffuse_shader.release();
	fbo->release();

	glFrontFace(GL_CCW);
	glViewport(0, 0, viewport.x, viewport.y);
	glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);	
	
	diffuse_shader.bind();
	render_model(teapot, cameras[0], diffuse_shader);
	diffuse_shader.release();

	glActiveTexture(texture_unit_0.unit_id);
	glBindTexture(texture_unit_0.texture->target, texture_unit_0.texture->handle);
	glActiveTexture(texture_unit_1.unit_id);
	glBindTexture(texture_unit_1.texture->target, texture_unit_1.texture->handle);
	reflection_shader.bind();
	reflection_shader.set_uniform_value("R0", 0.08f);
	reflection_shader.set_uniform_value("viewport", viewport);
	reflection_shader.set_uniform_value("texture0", texture_unit_0.index);
	reflection_shader.set_uniform_value("texture1", texture_unit_1.index);
	render_model(board, cameras[0], reflection_shader);
	reflection_shader.release();
	glBindTexture(texture_unit_0.texture->target, 0);
	glActiveTexture(0);

	// debug_draw_texture(color_texture.handle);

}
void Outlined_object_renderer::construct_model( const std::shared_ptr<Visible_object>& object )
{
    Open_gl_attributes attribs( Open_gl_attributes::ENABLE_BIT, false );
    {
        Call_list_handle handle = m_context_store->create_call_list( 1 );
        unsigned int gl_handle = m_context_store->get_call_list( handle );
        Open_gl_commands::new_list( gl_handle, GL_COMPILE );
        attribs.disable( Open_gl_attributes::TEXTURE_2D );
        render_model( *object->model(), false );
        Open_gl_commands::end_list();
        m_object_data_map[object] = handle;
    }
    {
        Call_list_handle handle = m_context_store->create_call_list( 1 );
        unsigned int gl_handle = m_context_store->get_call_list( handle );
        Open_gl_commands::new_list( gl_handle, GL_COMPILE );
        attribs.disable( Open_gl_attributes::TEXTURE_2D );
        Open_gl_commands::material( GL_AMBIENT, Color::BLACK );
        Open_gl_commands::material( GL_DIFFUSE, Color::BLACK );
        render_model( *object->model(), true );
        Open_gl_commands::end_list();
        m_flat_model_map[object] = handle;
    }
}
예제 #3
0
파일: graphics.c 프로젝트: derkyjadex/alice
static void render_widget(AlWidget *widget, Vec2 translate, Box2 scissor)
{
	widget->valid = true;

	if (!widget->visible)
		return;

	Vec2 location = vec2_add(widget->location, translate);
	Box2 bounds = box2_add_vec2(widget->bounds, location);
	scissor = box2_round(box2_intersect(scissor, bounds));

	if (!box2_is_valid(scissor))
		return;

	if (!widget->passThrough) {
		set_scissor(scissor);

		render_widget_main(widget, bounds);

		if (widget->border.width > 0) {
			scissor = box2_expand(scissor, -widget->border.width);
			set_scissor(scissor);
		}

		if (widget->model.model) {
			render_model(widget->model.model, vec2_add(widget->model.location, location), widget->model.scale);
		}

		if (widget->text.value) {
			render_text(widget->text.value, widget->text.colour, vec2_add(widget->text.location, location), widget->text.size);
		}
	}

	FOR_EACH_WIDGET(child, widget) {
		render_widget(child, location, scissor);
	}
예제 #4
0
int main() {
	int i = 0;
	int j = 1;
	int musicCounter = 0;
	UINT8 *base = Physbase();
	UINT8 *base2 = buffer;
	
	UINT8 ch;
	UINT8 has_moved = 1;
	UINT8 switchBase = 0;
	
	UINT32 timeNow, timeThen, prevCall;

	struct Model game;
	struct Model *gamePtr = &game;
	
	base2 += 256 - ((long)base2 & (long)0xFF);

	init_model(gamePtr);
	
	disable_cursor();
	Setscreen(-1, base2, -1);
	disable_cursor();
	Setscreen(-1, base, -1);
	
	timeNow = get_time();
	timeThen = timeNow + DELAY;
	
	start_sound();
	prevCall = timeNow;
	srand(time(0));
	
	while(!game_over(gamePtr)) {
	
		if(update_music(get_time() - prevCall)){
			prevCall = get_time();		
		}
			
		/* Check if there is kbd input */
		if(kbd_is_waiting()) {
			ch = kbd_read_char();	
			request_player_move(gamePtr, 0, ch);
		}

		/* If clock ticked */
		if(timeNow != get_time()) {

			
			/* Check if a second has passed */
			if(timeNow >= timeThen) {
				update_score(gamePtr, 1);
				timeThen = timeNow + DELAY;
			}
			
			/* Move player ship */
			has_moved = move_player_ship(gamePtr, 0);
			if(has_moved){
				thruster();
			}

			/* Move enemy ships and check collisions with player ship */
			for(i = 0; i < NUM_ENEMIES; i++) {
				move_enemy_ship(gamePtr, i);
				collision(gamePtr,i,0);
			}	
			

			/* Render the model with double buffering */
			if(switchBase) {
				render_model(gamePtr, base, has_moved);
				Setscreen(-1, base, -1);
			}
			else {
				render_model(gamePtr, base2, has_moved);
				Setscreen(-1, base2, -1);
			}

			Vsync();
			switchBase = !switchBase;
			
		}
		
		stop_thruster();		
		timeNow = get_time();
	
	}
	
	stop_sound();
	explosion();
	
	render_model(gamePtr, base, has_moved);
	Setscreen(-1, base, -1);
	Vsync();
	
	return 0;
}