Exemplo n.º 1
0
void draw(void)
{
    GLenum err;
    GLdouble secs;

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    draw_room();
    draw_cone();

    /* draw the front and then the back faces (essentially sorts the
       polygons). */
    secs = get_secs();
    glEnable(GL_BLEND);
    glEnable(GL_CULL_FACE);
    glCullFace(GL_FRONT);
    draw_sphere(secs * 360. / 10.);
    glCullFace(GL_BACK);
    draw_sphere(secs * 360. / 10.);
    glDisable(GL_CULL_FACE);
    glDisable(GL_BLEND);

    err = glGetError();
    if (err != GL_NO_ERROR) printf("Error:  %s\n", gluErrorString(err));

    glutSwapBuffers();
}
Exemplo n.º 2
0
void
update_cache (enum em em, enum vm vm)
{
  int x, y;

  int room_view_bkp = room_view;

  clear_bitmap (cache, TRANSPARENT_COLOR);

  con_caching = true;

  for (y = mr.h - 1; y >= 0; y--)
    for (x = 0; x < mr.w; x++) {
      if (mr.cell[x][y].room) {
        room_view = mr.cell[x][y].room;
        mr.dx = x;
        mr.dy = y;
        draw_room (mr.cell[x][y].cache, room_view, em, vm);
      } else draw_bitmap (room0, mr.cell[x][y].cache, 0, 0, 0);
    }

  con_caching = false;

  room_view = room_view_bkp;
}
Exemplo n.º 3
0
void draw(roomGrid *room_grid, progress *puzzle, char *instructions_list[NUM_INSTRUCTIONS], Chicken *hen)
{
    SDL_Surface *background, *sprite, *chicken;
    SDL_Texture *backtex, *spritetex, *chickentex;

    load_image(room_grid, &background, &backtex, "lab1sheet.png");
    load_image(room_grid, &sprite, &spritetex, "prof2.png");
    load_image(room_grid, &chicken, &chickentex, "chicken.png");

    initialise_roomgrid_components(room_grid, puzzle);
    position_sprite(room_grid);
    Mix_PlayChannel(-1, room_grid -> mus, -1);

    while (room_grid -> gamerunning)
    {
        
        movement(room_grid, puzzle, instructions_list, hen);     
        collision_detection(room_grid);
        SDL_RenderClear(room_grid -> renderer);
        draw_room(background, backtex, room_grid);

        /*RenderClear to wipe framebuffer, RenderCopy to compose final framebuffer, RenderPresent puts on screen*/
        SDL_RenderCopy(room_grid -> renderer, spritetex, &room_grid -> rcObj, &room_grid -> rcSprite);
        SDL_RenderPresent(room_grid -> renderer);
    }

    // SDL_Delay(5000);
    SDL_DestroyTexture(backtex);
    SDL_DestroyTexture(spritetex);
    SDL_DestroyTexture(chickentex);
    SDL_DestroyRenderer(room_grid -> renderer);
    SDL_DestroyWindow(room_grid -> window);
}
Exemplo n.º 4
0
void draw(void)
{
    GLenum err;
    GLdouble secs, degrees;

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    /* one revolution every 10 seconds... */
    secs = get_secs();
    secs = secs - 10.*trunc(secs / 10.);
    degrees = (secs/10.) * (360.);

    draw_room();

    glEnable(GL_BLEND);
    glEnable(GL_CULL_FACE);
    glCullFace(GL_FRONT);
    draw_cone();
    draw_sphere(degrees);
    glCullFace(GL_BACK);
    draw_cone();
    draw_sphere(degrees);
    glDisable(GL_CULL_FACE);
    glDisable(GL_BLEND);

    err = glGetError();
    if (err != GL_NO_ERROR) printf("Error:  %s\n", gluErrorString(err));

    glutSwapBuffers();
}
Exemplo n.º 5
0
// Draw everything
void draw_all_objects(
	int* room_display_lists,
	float lid_degrees,
	float* dancer_angles, float dancer_angle,float dancer_y,
	float door_angle
) {
	// int* room_display_lists = all_display_lists[0];

	// Room walls and door
	draw_room(room_display_lists, door_angle);

	// Box and dancer
	glPushMatrix();
		// glTranslatef(0,2.6001,1.7);
		glTranslatef(-2,2.1+.001,-1);
		draw_box(room_display_lists ,lid_degrees);
	glPopMatrix();
	glPushMatrix();
		glTranslatef(-2,dancer_y,-2.7);
		draw_dancer(room_display_lists, dancer_angles, dancer_angle);
	glPopMatrix();

	// Furniture
	glPushMatrix();
		glTranslatef(-2,-1,-2.7);
		draw_table(room_display_lists);
	glPopMatrix();
	glPushMatrix();
		glTranslatef(5,-2.05,0);
		draw_one_legged_table(room_display_lists);
	glPopMatrix();
	glPushMatrix();
		glTranslatef(4.5,-2,-2.5);
		glRotatef(-90,0,1,0);
		draw_chair(room_display_lists);
	glPopMatrix();
	glPushMatrix();
		glTranslatef(0,-2,0);
		draw_stool(room_display_lists);
	glPopMatrix();

	// Lights
	// lamp
	glPushMatrix();
		glTranslatef(-3,-1.5,0);
		draw_lamp(room_display_lists);
	glPopMatrix();
	// wall light
	glPushMatrix();
		glTranslatef(4,2,-5);
		glRotatef(-90,0,1,0);
		draw_wall_light(room_display_lists);
	glPopMatrix();
}
Exemplo n.º 6
0
void 
draw_scene(GLdouble degrees, GLint bits)
{
    glEnable(GL_CULL_FACE);
    draw_room();

    if (bits & TORUS_BIT)
	draw_torus(degrees);
    if (bits & SPHERE_BIT)
	draw_sphere(degrees);
}
Exemplo n.º 7
0
static void draw_stuff( HWND hwnd )
{
    HDC                 win_dc;
    PAINTSTRUCT         paint;
    RECT                intersect;

    win_dc = BeginPaint( hwnd, &paint );
    if( IntersectRect( &intersect, &paint.rcPaint, &Draw_area ) ) {
        hThree_d = three_d_begin( win_dc, &Draw_area );
        draw_room();
        three_d_draw( hThree_d );
        three_d_end( hThree_d );
    }
    EndPaint( hwnd, &paint );
}
Exemplo n.º 8
0
void
update_room0_cache (enum em em, enum vm vm)
{
  int room_view_bkp = room_view;

  con_caching = true;

  if (room0) clear_bitmap (room0, TRANSPARENT_COLOR);
  else room0 = create_bitmap (ORIGINAL_WIDTH, ORIGINAL_HEIGHT);

  room_view = 0;
  mr.dx = 0;
  mr.dy = 0;
  draw_room (room0, room_view, em, vm);

  con_caching = false;

  room_view = room_view_bkp;
}
Exemplo n.º 9
0
void
update_room0_cache (enum em em, enum vm vm)
{
  room_view = 0;
  struct pos mouse_pos_bkp = mouse_pos;
  invalid_pos (&mouse_pos);
  con_caching = true;

  if (! room0) room0 = create_bitmap (ORIGINAL_WIDTH, ORIGINAL_HEIGHT);

  clear_bitmap (room0, TRANSPARENT_COLOR);

  mr.dx = 0;
  mr.dy = 0;
  draw_room (room0, 0, em, vm);

  con_caching = false;
  mouse_pos = mouse_pos_bkp;
}
Exemplo n.º 10
0
void draw(void)
{
    GLenum err;
    GLdouble secs;

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    draw_room();
    draw_cone();

    glEnable(GL_BLEND);
    secs = get_secs();
    draw_sphere(secs * 360. / 10.);
    glDisable(GL_BLEND);

    err = glGetError();
    if (err != GL_NO_ERROR) printf("Error:  %s\n", gluErrorString(err));

    glutSwapBuffers();
}
Exemplo n.º 11
0
/*
 * do_post:
 *	Put a trading post room and stuff on the screen
 */
void do_post()
{
  struct coord tp;
  int i;
  struct room *rp;
  struct object *op;
  struct linked_list *ll;

  free_list(lvl_obj); /* throw old items away */

  for (rp = rooms; rp < &rooms[MAXROOMS]; rp++) {
    rp->r_goldval = 0;    /* no gold */
    rp->r_nexits = 0;     /* no exits */
    rp->r_flags = ISGONE; /* kill all rooms */
  }
  rp = &rooms[0];  /* point to only room */
  rp->r_flags = 0; /* this room NOT gone */
  rp->r_max.x = 40;
  rp->r_max.y = 10;                       /* 10 * 40 room */
  rp->r_pos.x = (COLS - rp->r_max.x) / 2; /* center horizontal */
  rp->r_pos.y = 1;                        /* 2nd line */
  draw_room(rp);                          /* draw the only room */
  i = roll(4, 10);                        /* 10 to 40 items */
  for (; i > 0; i--) {                    /* place all the items */
    ll = new_thing(FALSE, ANYTHING);      /* get something */
    attach(lvl_obj, ll);
    op = OBJPTR(ll);
    setoflg(op, ISPOST); /* object in trading post */
    tp = *rnd_pos(rp);
    op->o_pos = tp;
    mvaddch(tp.y, tp.x, op->o_type);
  }
  trader = 0;
  wmove(cw, 12, 0);
  waddstr(cw, "Welcome to Friendly Fiend's Flea Market\n\r");
  waddstr(cw, "=======================================\n\r");
  waddstr(cw, "$: Prices object that you stand upon.\n\r");
  waddstr(cw, "#: Buys the object that you stand upon.\n\r");
  waddstr(cw, "%: Trades in something in your pack for gold.\n\r");
  trans_line();
}
Exemplo n.º 12
0
void draw(void)
{
    GLenum err;
    GLdouble secs;

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    draw_room();
    draw_cone();
    secs = get_secs();

    /* draw the transparent object... */
    glEnable(GL_POLYGON_STIPPLE);
    draw_sphere(secs * 360. / 10.);
    glDisable(GL_POLYGON_STIPPLE);

    err = glGetError();
    if (err != GL_NO_ERROR) printf("Error:  %s\n", gluErrorString(err));

    glutSwapBuffers();
}
Exemplo n.º 13
0
void draw(void)
{
    GLenum err;
    GLdouble secs, degrees;

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    /* one revolution every 10 seconds... */
    secs = get_secs();
    secs = secs - 10.*trunc(secs / 10.);
    degrees = (secs/10.) * (360.);

#if 0
    draw_room();
#endif
    draw_torus(degrees);

    err = glGetError();
    if (err != GL_NO_ERROR) printf("Error:  %s\n", gluErrorString(err));

    glutSwapBuffers();
}
Exemplo n.º 14
0
/*
 * do_rooms:
 *	Create rooms and corridors with a connectivity graph
 */
do_rooms()
{
    register int i;
    register struct room *rp;
    register THING *tp;
    register int left_out;
    coord top;
    coord bsze;
    coord mp;

    /*
     * bsze is the maximum room size
     */
    bsze.x = COLS/3;
    bsze.y = LINES/3;
    /*
     * Clear things for a new level
     */
    for (rp = rooms; rp < &rooms[MAXROOMS]; rp++)
	rp->r_goldval = rp->r_nexits = rp->r_flags = 0;
    /*
     * Put the gone rooms, if any, on the level
     */
    left_out = rnd(4);
    for (i = 0; i < left_out; i++)
	rooms[rnd_room()].r_flags |= ISGONE;
    /*
     * dig and populate all the rooms on the level
     */
    for (i = 0, rp = rooms; i < MAXROOMS; rp++, i++)
    {
	/*
	 * Find upper left corner of box that this room goes in
	 */
	top.x = (i%3)*bsze.x + 1;
	top.y = i/3*bsze.y;
	if (rp->r_flags & ISGONE)
	{
	    /*
	     * Place a gone room.  Make certain that there is a blank line
	     * for passage drawing.
	     */
	    do
	    {
		rp->r_pos.x = top.x + rnd(bsze.x-2) + 1;
		rp->r_pos.y = top.y + rnd(bsze.y-2) + 1;
		rp->r_max.x = -COLS;
		rp->r_max.x = -LINES;
	    } until (rp->r_pos.y > 0 && rp->r_pos.y < LINES-1);
	    continue;
	}
    if (rnd(10) < level - 1)
	    rp->r_flags |= ISDARK;
	/*
	 * Find a place and size for a random room
	 */
	do
	{
	    rp->r_max.x = rnd(bsze.x - 4) + 4;
	    rp->r_max.y = rnd(bsze.y - 4) + 4;
	    rp->r_pos.x = top.x + rnd(bsze.x - rp->r_max.x);
	    rp->r_pos.y = top.y + rnd(bsze.y - rp->r_max.y);
	} until (rp->r_pos.y != 0);
	/*
	 * Put the gold in
	 */
	if (rnd(2) == 0 && (!amulet || level >= max_level))
	{
	    register THING *gold;

	    gold = new_item();
	    gold->o_goldval = rp->r_goldval = GOLDCALC;
	    rnd_pos(rp, &rp->r_gold);
	    gold->o_pos = rp->r_gold;
	    gold->o_flags = ISMANY;
	    gold->o_group = GOLDGRP;
	    gold->o_type = GOLD;
	    attach(lvl_obj, gold);
	}
	draw_room(rp);
	/*
	 * Put the monster in
	 */
	if (rnd(100) < (rp->r_goldval > 0 ? 80 : 25))
	{
	    tp = new_item();
	    do
	    {
		rnd_pos(rp, &mp);
	    } until (winat(mp.y, mp.x) == FLOOR);
	    new_monster(tp, randmonster(FALSE), &mp);
	    give_pack(tp);
	}
    }
Exemplo n.º 15
0
do_rooms()
{
    int i;
    struct room *rp;
    struct linked_list  *item;
    struct thing    *tp;
    int left_out;
    coord   top;
    coord   bsze;
    coord   mp;

    /*
     * bsze is the maximum room size
     */
    bsze.x = COLS / 3;
    bsze.y = (LINES - 2) / 3;

    /*
     * Clear things for a new level
     */
    for (rp = rooms; rp < &rooms[MAXROOMS]; rp++)
	rp->r_nexits = rp->r_flags = rp->r_fires = 0;

    /*
     * Put the gone rooms, if any, on the level
     */
    left_out = rnd(4);
    for (i = 0; i < left_out; i++)
	rooms[rnd_room()].r_flags |= ISGONE;

    /*
     * dig and populate all the rooms on the level
     */
    for (i = 0, rp = rooms; i < MAXROOMS; rp++, i++) {
	bool    has_gold = FALSE;

	/*
	 * Find upper left corner of box that this room goes in
	 */
	top.x = (i % 3) * bsze.x;
	top.y = i / 3 * bsze.y + 1;
	if (rp->r_flags & ISGONE) {

	    /*
	     * Place a gone room.  Make certain that there is a
	     * blank line for passage drawing.
	     */
	    do {
		rp->r_pos.x = top.x + rnd(bsze.x - 2) + 1;
		rp->r_pos.y = top.y + rnd(bsze.y - 2) + 1;
		rp->r_max.x = -COLS;
		rp->r_max.x = -LINES;
	    } while (rp->r_pos.y < 1 || rp->r_pos.y > LINES - 3);
	    continue;
	}
	if (rnd(80) < level - 15)
	    rp->r_flags |= ISDARK;

	/*
	 * Find a place and size for a random room
	 */
	do {
	    rp->r_max.x = rnd(bsze.x - 4) + 4;
	    rp->r_max.y = rnd(bsze.y - 4) + 4;
	    rp->r_pos.x = top.x + rnd(bsze.x - rp->r_max.x);
	    rp->r_pos.y = top.y + rnd(bsze.y - rp->r_max.y);
	} while (rp->r_pos.y == 0);

	/* Draw the room */
	draw_room(rp);

	/*
	 * Put the gold in
	 */
	if (rnd(100) < 50 && (!has_artifact || level >= max_level)) {
	    struct linked_list  *item;
	    struct object   *cur;
	    coord   tp;

	    has_gold = TRUE;    /* This room has gold in it */

	    item = spec_item(GOLD, NULL, NULL, NULL);
	    cur = OBJPTR(item);

	    /* Put it somewhere */
	    rnd_pos(rp, &tp);
	    cur->o_pos = tp;
	    /* Put the gold into the level list of items */
	    add_obj(item, tp.y, tp.x);

	    if (roomin(&tp) != rp) {
		endwin();
		abort();
	    }
	}

	/*
	 * Put the monster in
	 */
	if (rnd(100) < (has_gold ? 80 : 40)) {
	    short   which;
	    int i, count;

	    item = new_item(sizeof *tp);
	    tp = THINGPTR(item);
	    do {
		rnd_pos(rp, &mp);
	    } while (mvwinch(stdscr, mp.y, mp.x) != FLOOR);

	    which = randmonster(NOWANDER, NOGRAB);
	    new_monster(item, which, &mp, NOMAXSTATS);

	    /*
	     * See if we want to give it a treasure to carry
	     * around.
	     */
	    if (rnd(100) < monsters[tp->t_index].m_carry)
		attach(tp->t_pack, new_thing());

	    /*
	     * If it has a fire, mark it
	     */
	    if (on(*tp, HASFIRE)) {
		rp->r_flags |= HASFIRE;
		rp->r_fires++;
	    }

	    /*
	     * If it carries gold, give it some
	     */
	    if (on(*tp, CARRYGOLD)) {
		struct object   *cur;

		item = spec_item(GOLD, NULL, NULL, NULL);
		cur = OBJPTR(item);
		cur->o_count = GOLDCALC + GOLDCALC + GOLDCALC;
		cur->o_pos = tp->t_pos;
		attach(tp->t_pack, item);
	    }

	    i = rnd(7);
	    if (on(*tp, ISSWARM) && i < 5)
		count = roll(2, 4);
	    else if (on(*tp, ISFLOCK) && i < 5)
		count = roll(1, 4);
	    else
		count = 0;

	    for (i = 1; i <= count; i++) {
		coord   *mpos;

		if ((mpos = place_mons(mp.y, mp.x)) != NULL) {
		    struct linked_list  *nitem;

		    nitem = new_item(sizeof(struct thing));
		    new_monster(nitem, which, mpos,
			NOMAXSTATS);

		    /*
		     * If the monster is on a trap, trap
		     * it
		     */
		    if (isatrap(mvinch(mpos->y, mpos->x)))
			be_trapped(THINGPTR(nitem), mp);
		    if (on(*tp, ISFRIENDLY))
			turn_on(*(THINGPTR(nitem)),
			    ISFRIENDLY);
		    else
			turn_off(*(THINGPTR(nitem)),
			    ISFRIENDLY);
		}
	    }
	    if (count > 0) {
		int boost = rnd(3) + 1;

		if (on(*tp, LOWCAST) || on(*tp, MEDCAST) ||
		    on(*tp, HIGHCAST))
		    turn_on(*tp, CANCAST);
		tp->t_stats.s_hpt += 3 * boost;
		tp->t_stats.s_arm -= 2 * boost;
		tp->t_stats.s_lvl += 2 * boost;
		tp->t_stats.s_str += 2 * boost;
		tp->t_stats.s_intel += 2 * boost;
		tp->t_stats.s_exp += 4 * boost *
		    monsters[which].m_add_exp;
	    }
	}
    }
}
Exemplo n.º 16
0
int main(void)
{

	uint move_index = 0;
	uint frame_index = 0;
	uint last_ant_id = 0;
	uint arrived_count = 0;
	t_map *map = create_map();
	Scaler scaler(map);
	std::vector<std::vector<Move> > moves;
	create_moves(moves);
	sf::RenderWindow window(sf::VideoMode(WIN_SZ, WIN_SZ), "lem_in Visualizer");
	sf::Font font;

	if (!font.loadFromFile("font.otf"))
		std::cout << "failed to load font!" << std::endl;

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        window.clear(sf::Color::Black);
        draw_tubes(map, window, scaler);
        for (uint i = 0; i < map->rooms->size; i++)
        	draw_room((t_room*)array_get(map->rooms, i), window, font, map, arrived_count, last_ant_id, scaler);
        draw_move_list(moves[move_index], frame_index, map, window, last_ant_id, font, scaler);
        if (frame_index < FRAME_COUNT)
        	frame_index++;
        else
        {
        	arrived_count += apply_move_list(moves[move_index], map, last_ant_id);
        	move_index++;
        	frame_index = 0;
        	if (move_index >= moves.size())
        	{
        		window.clear(sf::Color::Black);
        		draw_tubes(map, window, scaler);
		        for (uint i = 0; i < map->rooms->size; i++)
		        	draw_room((t_room*)array_get(map->rooms, i), window, font, map, arrived_count, last_ant_id, scaler);
		        window.display();
        		sf::sleep(sf::milliseconds(2000));
        		//
        		arrived_count = 0;
        		last_ant_id = 0;
        		reset_map(map);
        		move_index = 0;
        		//
        		window.clear(sf::Color::Black);
        		draw_tubes(map, window, scaler);
		        for (uint i = 0; i < map->rooms->size; i++)
		        	draw_room((t_room*)array_get(map->rooms, i), window, font, map, arrived_count, last_ant_id, scaler);
		        window.display();
        		sf::sleep(sf::milliseconds(2000));
        	}
        }
        window.display();
        sf::sleep(sf::milliseconds(10));
    }
	return (0);
}
Exemplo n.º 17
0
do_rooms()
{
    register int i;
    register struct room *rp;
    register struct linked_list *item;
    register struct thing *tp;
    register int left_out;
    coord top;
    coord bsze;
    coord mp;

    /*
     * bsze is the maximum room size
     */
    bsze.x = cols()/3;
    bsze.y = lines()/3;
    /*
     * Clear things for a new level
     */
    for (rp = rooms; rp < &rooms[MAXROOMS]; rp++)
	rp->r_goldval = rp->r_nexits = rp->r_flags = 0;
    /*
     * Put the gone rooms, if any, on the level
     */
    left_out = rnd(4);
    for (i = 0; i < left_out; i++)
	rooms[rnd_room()].r_flags |= ISGONE;
    /*
     * dig and populate all the rooms on the level
     */
    for (i = 0, rp = rooms; i < MAXROOMS; rp++, i++)
    {
	/*
	 * Find upper left corner of box that this room goes in
	 */
	top.x = (i%3)*bsze.x + 1;
	top.y = i/3*bsze.y;
	if (rp->r_flags & ISGONE)
	{
	    /*
	     * Place a gone room.  Make certain that there is a blank line
	     * for passage drawing.
	     */
	    do
	    {
		rp->r_pos.x = top.x + rnd(bsze.x-2) + 1;
		rp->r_pos.y = top.y + rnd(bsze.y-2) + 1;
		rp->r_max.x = -cols();
		rp->r_max.x = -lines();
	    } until(rp->r_pos.y > 0 && rp->r_pos.y < lines()-1);
	    continue;
	}
	if (rnd(10) < level-1)
	    rp->r_flags |= ISDARK;
	/*
	 * Find a place and size for a random room
	 */
	do
	{
	    rp->r_max.x = rnd(bsze.x - 4) + 4;
	    rp->r_max.y = rnd(bsze.y - 4) + 4;
	    rp->r_pos.x = top.x + rnd(bsze.x - rp->r_max.x);
	    rp->r_pos.y = top.y + rnd(bsze.y - rp->r_max.y);
	} until (rp->r_pos.y != 0);
	/*
	 * Put the gold in
	 */
	if (rnd(100) < 50 && (!amulet || level >= max_level))
	{
	    rp->r_goldval = GOLDCALC;
	    rnd_pos(rp, &rp->r_gold);
	    if (roomin(&rp->r_gold) != rp)
		endwin(), abort();
	}
	draw_room(rp);
	/*
	 * Put the monster in
	 */
	if (rnd(100) < (rp->r_goldval > 0 ? 80 : 25))
	{
	    item = new_item(sizeof *tp);
	    tp = (struct thing *) ldata(item);
	    do
	    {
		rnd_pos(rp, &mp);
	    } until(mvwinch(stdscr, mp.y, mp.x) == FLOOR);
	    new_monster(item, randmonster(FALSE), &mp);
	    /*
	     * See if we want to give it a treasure to carry around.
	     */
	    if (rnd(100) < monsters[tp->t_type-'A'].m_carry)
		attach(tp->t_pack, new_thing());
	}
    }
Exemplo n.º 18
0
static void draw_stuff( HWND hwnd )
{
    HPS                 win_dc;
    RECTL               paint;
    RECTL               intersect;
#ifdef DRAW_ALL_AT_ONCE
    int                 old_top;
    int                 width, height;
    SIZEL               sizl = { 0, 0 };
    BITMAPINFOHEADER2   bmih;
    LONG                formats[24];
    POINTL              pts[3];
    LONG                old_cursor;
    LONG                hour_glass_cur;
    RECTL               interior;
    DEVOPENSTRUC        dop = { 0L, "DISPLAY", NULL, 0L,
                                0L, 0L, 0L, 0L, 0L };
#endif


    win_dc = WinBeginPaint( hwnd, 0, &paint );
    GpiCreateLogColorTable( win_dc, 0L, LCOLF_RGB, 0L, 0L, NULL );
#ifdef DRAW_ALL_AT_ONCE
    old_top = paint.yBottom;
    paint.yBottom = Draw_area.yTop;
#endif
    WinFillRect( win_dc, &paint, SYSCLR_WINDOW );
#ifdef DRAW_ALL_AT_ONCE
    paint.yBottom = old_top;
#endif
    if( WinIntersectRect( Main_hab, &intersect, &paint, &Draw_area ) ) {

#ifdef DRAW_ALL_AT_ONCE
        width = Draw_area.xRight - Draw_area.xLeft;
        height = Draw_area.yTop - Draw_area.yBottom;
        interior.xLeft = 0;
        interior.yBottom = 0;
        interior.xRight = width;
        interior.yTop = height;
        if( Draw_bitmap == NULLHANDLE ) {
            Hdc = DevOpenDC( Main_hab, OD_MEMORY, "*", 5L,
                                            (PDEVOPENDATA)&dop, NULLHANDLE );
            Mem_dc = GpiCreatePS( Main_hab, Hdc, &sizl, PU_PELS | GPIA_ASSOC );
            memset( &bmih, 0, sizeof( BITMAPINFOHEADER2 ) );
            GpiQueryDeviceBitmapFormats( Mem_dc, 24L, formats );
            bmih.cbFix = sizeof( BITMAPINFOHEADER2 );
            bmih.cx = width;
            bmih.cy = height;
            bmih.cPlanes = (USHORT) formats[0];
            bmih.cBitCount = (USHORT) formats[1];
            Draw_bitmap = GpiCreateBitmap( Mem_dc, &bmih, 0L, NULL, NULL );
            Old_bitmap = GpiSetBitmap( Mem_dc, Draw_bitmap );
            GpiCreateLogColorTable( Mem_dc, 0, LCOLF_RGB, 0, 0, NULL );
            WinFillRect( Mem_dc, &interior, SYSCLR_WINDOW );

            hour_glass_cur = WinQuerySysPointer( HWND_DESKTOP, SPTR_WAIT, FALSE );
            old_cursor = WinQueryPointer( HWND_DESKTOP );
            WinSetPointer( HWND_DESKTOP, hour_glass_cur );

            hThree_d = three_d_begin( Mem_dc, &interior );
            draw_room();
            three_d_draw( hThree_d );
            three_d_end( hThree_d );

            WinSetPointer( HWND_DESKTOP, old_cursor );
        }

        pts[0].x = Draw_area.xLeft;
        pts[0].y = Draw_area.yBottom;
        pts[1].x = Draw_area.xLeft + width;
        pts[1].y = Draw_area.yBottom + height;
        pts[2].x = 0;
        pts[2].y = 0;
        GpiBitBlt( win_dc, Mem_dc, 3, pts, ROP_SRCCOPY, BBO_IGNORE );
#else
        hThree_d = three_d_begin( win_dc, &Draw_area );
        draw_room();
        three_d_draw( hThree_d );
        three_d_end( hThree_d );
#endif

    }
    WinEndPaint( win_dc );
}
Exemplo n.º 19
0
void draw_scene(GLdouble secs, int passes, GLenum cullFace, 
		GLuint stencilVal, GLuint mirror)
{
  GLenum newCullFace;
  int passesPerMirror, passesPerMirrorRem;
  unsigned int curMirror, drawMirrors;
  int i;

  /* one pass to draw the real scene */
  passes--;

  /* only draw in my designated locations */
  glStencilFunc(GL_EQUAL, stencilVal, 0xffffffff);

  /* draw things which may obscure the mirrors first */
  draw_sphere(secs);
  draw_cone();

  /* now draw the appropriate number of mirror reflections.  for
   * best results, we perform a depth-first traversal by allocating
   * a number of passes for each of the mirrors. */
  if (mirror != 0xffffffff) {
    passesPerMirror = passes / (nMirrors - 1);
    passesPerMirrorRem = passes % (nMirrors - 1);
    if (passes > nMirrors - 1) drawMirrors = nMirrors - 1;
    else drawMirrors = passes;
  } else {
    /* mirror == -1 means that this is the initial scene (there was no 
     * mirror) */
    passesPerMirror = passes / nMirrors;
    passesPerMirrorRem = passes % nMirrors;
    if (passes > nMirrors) drawMirrors = nMirrors;
    else drawMirrors = passes;
  }
  for (i = 0; drawMirrors > 0; i++) {
    curMirror = i % nMirrors;
    if (curMirror == mirror) continue;
    drawMirrors--;

    /* draw mirror into stencil buffer but not color or depth buffers */
    glColorMask(0, 0, 0, 0);
    glDepthMask(0);
    glStencilOp(GL_KEEP, GL_KEEP, GL_INCR); 
    draw_mirror(&mirrors[curMirror]);
    glColorMask(1, 1, 1, 1);
    glDepthMask(1);
    glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);

    /* draw reflected scene */
    newCullFace = reflect_through_mirror(&mirrors[curMirror], cullFace);
    if (passesPerMirrorRem) {
      draw_scene(secs, passesPerMirror + 1, newCullFace, stencilVal + 1, 
		 curMirror);      
      passesPerMirrorRem--;
    } else {
      draw_scene(secs, passesPerMirror, newCullFace, stencilVal + 1, 
		 curMirror);
    }
    undo_reflect_through_mirror(&mirrors[curMirror], cullFace);

    /* back to our stencil value */
    glStencilFunc(GL_EQUAL, stencilVal, 0xffffffff);    
  }

  draw_room(); 
}