Beispiel #1
0
void	draw_flat_map(t_map *map, t_img *img)
{
	float	s;
	t_pix	i;
	t_pix	os;

	s = FT_MIN(img->width / (float)map->width,
	img->height / (float)map->height) * 0.9;
	os.x = img->width / 2 - map->width * s / 2;
	os.y = img->height / 2 - map->height * s / 2;
	i.x = -1;
	while (++i.x < map->width)
	{
		i.y = -1;
		while (++i.y < map->height)
		  {
		    draw_tex(img, tile_at_index(map, i.x, i.y), (t_pix){i.x + os.x / s, i.y + os.y / s}, s);
		  }
	}
	set_color(0xFF0000);
	i = (t_pix){map->eye->pos.x * s + os.x, map->eye->pos.y * s + os.y};
	draw_circle(img, i, s / 2);
	set_color(0xFFFF00);
	draw_line(img, i, (t_pix){i.x + map->eye->dir.x * s,
				i.y + map->eye->dir.y * s});
	set_color(0x00FF00);
	draw_line(img, i, (t_pix){i.x + (map->eye->dir.x + map->eye->plane.x) * s,
				i.y + (map->eye->dir.y + map->eye->plane.y) * s});
	draw_line(img, i, (t_pix){i.x + (map->eye->dir.x - map->eye->plane.x) * s,
				i.y + (map->eye->dir.y - map->eye->plane.y) * s});
}
Beispiel #2
0
void	draw(t_display *d, int x, int color)
{
	if (d->map->map[d->ray->map_y][d->ray->map_x] == '1')
		draw_color(d, x, color);
	else
		draw_tex(d, x);
}
Beispiel #3
0
enum piglit_result
piglit_display(void)
{
	bool pass = true;
	GLuint tex;

	tex = create_texture();

	clear_texture(tex);

	draw_tex(tex);

	glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, 0);

	glDeleteTextures(1, &tex);

	pass &= piglit_probe_rect_rgb(VALUE_CLEAR_X * 2,
				      VALUE_CLEAR_Y * 2,
				      VALUE_CLEAR_WIDTH * 2,
				      VALUE_CLEAR_HEIGHT * 2,
				      green);

	pass &= piglit_probe_rect_rgb(ZERO_CLEAR_X * 2,
				      ZERO_CLEAR_Y * 2,
				      ZERO_CLEAR_WIDTH * 2,
				      ZERO_CLEAR_HEIGHT * 2,
				      black);

	/* Everything else should be red */

	pass &= probe_tex(0, 0,
			  TEX_WIDTH, ZERO_CLEAR_Y);
	pass &= probe_tex(0, ZERO_CLEAR_Y,
			  ZERO_CLEAR_X, ZERO_CLEAR_HEIGHT);
	pass &= probe_tex(ZERO_CLEAR_X + ZERO_CLEAR_WIDTH, ZERO_CLEAR_Y,
			  TEX_WIDTH - ZERO_CLEAR_X - ZERO_CLEAR_WIDTH,
			  ZERO_CLEAR_HEIGHT);
	pass &= probe_tex(0, VALUE_CLEAR_Y,
			  VALUE_CLEAR_X, VALUE_CLEAR_HEIGHT);
	pass &= probe_tex(VALUE_CLEAR_X + VALUE_CLEAR_WIDTH, VALUE_CLEAR_Y,
			  TEX_WIDTH - VALUE_CLEAR_X - VALUE_CLEAR_WIDTH,
			  VALUE_CLEAR_HEIGHT);
	pass &= probe_tex(0, VALUE_CLEAR_Y + VALUE_CLEAR_HEIGHT,
			  TEX_WIDTH,
			  TEX_HEIGHT - VALUE_CLEAR_Y - VALUE_CLEAR_HEIGHT);

	piglit_present_results();

	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
Beispiel #4
0
void cmd_viewtex(){
    // Views a texture (made up of patches).
    WAD_TEX *temp_tex;

    // Try to load up and then display the texture.
    temp_tex=wad_loadpatch(parse_words[1]);
    if(temp_tex!=NULL){
        // Display texture statistics.
        sprintf(saybuf,"width %d, height %d",temp_tex->w,temp_tex->h);
        con_printf(saybuf);

        // Dump the texture to the screen.
        clear_to_color(vgabuf,0);
        draw_tex(temp_tex);
        vsync();
        blit(vgabuf,screen,0,0,0,0,screen_width,screen_height);
        readkey();
        wad_killpatch(temp_tex);
    }
    else{
        con_printf("viewtex failed");
    }
}
Beispiel #5
0
static bool gl1_gfx_frame(void *data, const void *frame,
      unsigned frame_width, unsigned frame_height, uint64_t frame_count,
      unsigned pitch, const char *msg, video_frame_info_t *video_info)
{
   gfx_ctx_mode_t mode;
   const void *frame_to_copy = NULL;
   unsigned width            = 0;
   unsigned height           = 0;
   unsigned bits             = gl1_video_bits;
   bool draw                 = true;
   gl1_t *gl1                = (gl1_t*)data;
   unsigned pot_width        = 0;
   unsigned pot_height       = 0;

   gl1_context_bind_hw_render(gl1, false);

   /* FIXME: Force these settings off as they interfere with the rendering */
   video_info->xmb_shadows_enable   = false;
   video_info->menu_shader_pipeline = 0;

   if (!frame || !frame_width || !frame_height)
      return true;

   if (gl1->should_resize)
   {
      gfx_ctx_mode_t mode;

      gl1->should_resize = false;

      mode.width        = width;
      mode.height       = height;

      video_info->cb_set_resize(video_info->context_data,
            mode.width, mode.height);

      gl1_gfx_set_viewport(gl1, video_info, video_info->width, video_info->height, false, true);
   }

   glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
   glClear(GL_COLOR_BUFFER_BIT);

   glEnable(GL_BLEND);
   glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

   if (  gl1_video_width  != frame_width  ||
         gl1_video_height != frame_height ||
         gl1_video_pitch  != pitch)
   {
      if (frame_width > 4 && frame_height > 4)
      {
         gl1_video_width  = frame_width;
         gl1_video_height = frame_height;
         gl1_video_pitch  = pitch;

         pot_width = get_pot(frame_width);
         pot_height = get_pot(frame_height);

         if (gl1_video_buf)
            free(gl1_video_buf);

         gl1_video_buf = (unsigned char*)malloc(pot_width * pot_height * 4);
      }
   }

   width         = gl1_video_width;
   height        = gl1_video_height;
   pitch         = gl1_video_pitch;

   pot_width = get_pot(width);
   pot_height = get_pot(height);

   if (  frame_width  == 4 &&
         frame_height == 4 &&
         (frame_width < width && frame_height < height)
      )
      draw = false;

   if (draw && gl1_video_buf)
   {
      if (bits == 32)
      {
         unsigned y;
         /* copy lines into top-left portion of larger (power-of-two) buffer */
         for (y = 0; y < height; y++)
            memcpy(gl1_video_buf + ((pot_width * (bits / 8)) * y), (const unsigned char*)frame + (pitch * y), width * (bits / 8));
      }
      else if (bits == 16)
         conv_rgb565_argb8888(gl1_video_buf, frame, width, height, pot_width * sizeof(unsigned), pitch);

      frame_to_copy = gl1_video_buf;
   }

   if (gl1->video_width != width || gl1->video_height != height)
   {
      gl1->video_width  = width;
      gl1->video_height = height;
   }

   video_context_driver_get_video_size(&mode);

   gl1->screen_width           = mode.width;
   gl1->screen_height          = mode.height;

   if (draw)
   {
      if (frame_to_copy)
      {
         draw_tex(gl1, pot_width, pot_height, width, height, gl1->tex, frame_to_copy);
      }
   }

   if (gl1_menu_frame && video_info->menu_is_alive)
   {
      frame_to_copy = NULL;
      width         = gl1_menu_width;
      height        = gl1_menu_height;
      pitch         = gl1_menu_pitch;
      bits          = gl1_menu_bits;

      pot_width = get_pot(width);
      pot_height = get_pot(height);

      if (gl1_menu_size_changed)
      {
         gl1_menu_size_changed = false;

         if (gl1_menu_video_buf)
         {
            free(gl1_menu_video_buf);
            gl1_menu_video_buf = NULL;
         }
      }

      if (!gl1_menu_video_buf)
         gl1_menu_video_buf = (unsigned char*)malloc(pot_width * pot_height * 4);

      if (bits == 16 && gl1_menu_video_buf)
      {
         conv_rgba4444_argb8888(gl1_menu_video_buf, gl1_menu_frame, width, height, pot_width * sizeof(unsigned), pitch);

         frame_to_copy = gl1_menu_video_buf;

         if (gl1->menu_texture_full_screen)
         {
            glViewport(0, 0, video_info->width, video_info->height);
            draw_tex(gl1, pot_width, pot_height, width, height, gl1->menu_tex, frame_to_copy);
            glViewport(gl1->vp.x, gl1->vp.y, gl1->vp.width, gl1->vp.height);
         }
         else
            draw_tex(gl1, pot_width, pot_height, width, height, gl1->menu_tex, frame_to_copy);
      }
   }

#ifdef HAVE_MENU
   if (gl1->menu_texture_enable)
      menu_driver_frame(video_info);
   else if (video_info->statistics_show)
   {
      struct font_params *osd_params = (struct font_params*)
         &video_info->osd_stat_params;

      if (osd_params)
      {
         font_driver_render_msg(video_info, NULL, video_info->stat_text,
               (const struct font_params*)&video_info->osd_stat_params);
#if 0
         osd_params->y               = 0.350f;
         osd_params->scale           = 0.75f;
         font_driver_render_msg(video_info, NULL, video_info->chat_text,
               (const struct font_params*)&video_info->osd_stat_params);
#endif
      }
   }

#ifdef HAVE_MENU_WIDGETS
   menu_widgets_frame(video_info);
#endif
#endif

#ifdef HAVE_OVERLAY
   if (gl1->overlay_enable)
      gl1_render_overlay(gl1, video_info);
#endif

   if (msg)
      font_driver_render_msg(video_info, NULL, msg, NULL);

   video_info->cb_update_window_title(
         video_info->context_data, video_info);

   /* Screenshots. */
   if (gl1->readback_buffer_screenshot)
      gl1_readback(gl1,
            4, GL_RGBA, GL_UNSIGNED_BYTE,
            gl1->readback_buffer_screenshot);

   /* emscripten has to do black frame insertion in its main loop */
#ifndef EMSCRIPTEN
   /* Disable BFI during fast forward, slow-motion,
    * and pause to prevent flicker. */
   if (
         video_info->black_frame_insertion
         && !video_info->input_driver_nonblock_state
         && !video_info->runloop_is_slowmotion
         && !video_info->runloop_is_paused)
   {
      video_info->cb_swap_buffers(video_info->context_data, video_info);
      glClear(GL_COLOR_BUFFER_BIT);
   }
#endif

   video_info->cb_swap_buffers(video_info->context_data, video_info);

   /* check if we are fast forwarding or in menu, if we are ignore hard sync */
   if (video_info->hard_sync
         && !video_info->input_driver_nonblock_state
         && !gl1->menu_texture_enable)
   {
      glClear(GL_COLOR_BUFFER_BIT);
      glFinish();
   }

   gl1_context_bind_hw_render(gl1, true);

   return true;
}