Exemplo n.º 1
0
Overlay::Overlay(renderer* parent) : parent(parent)
{
	{
		CoreSuspender suspend;
		//parent->zoom(df::zoom_commands::zoom_reset);
		good_viewscreen = false;
		ReadTileLocations();
		copy_from_inner(); 
	}

	front_mutex = al_create_mutex();

	int32_t flags = al_get_new_bitmap_flags();
	if(al_get_current_display() != NULL){
		al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP | ALLEGRO_ALPHA_TEST);
	}
	front = al_create_bitmap(0,0);
	if(al_get_current_display() != NULL){
		al_set_new_bitmap_flags(al_get_bitmap_flags(al_get_backbuffer(al_get_current_display())));
	}
	back = al_create_bitmap(0,0);
	al_set_new_bitmap_flags(flags);

	Flip();
};
Exemplo n.º 2
0
przycisk_img::przycisk_img(int wsp_x, int wsp_y, std::string kadres_obrazka):przycisk(wsp_x,wsp_y),adres_obrazka(kadres_obrazka){
	al_init_image_addon();
	obrazek = al_load_bitmap(adres_obrazka.data());

	if (!obrazek) {
		al_show_native_message_box(NULL, "Blad", "Cos nie tak",
			"Nie moge wczytac bitmapy kwadrat!", NULL, ALLEGRO_MESSAGEBOX_ERROR);
	}
	szer_ekranu = al_get_display_width(al_get_current_display());
	wys_ekranu = al_get_display_height(al_get_current_display());
	rozmiar_y=al_get_bitmap_height(obrazek);
	rozmiar_x=al_get_bitmap_width(obrazek);
	al_shutdown_image_addon();
}
Exemplo n.º 3
0
void KinectPlayer::Render()
{
//   if (!mPlayerPresent) {
//      return;
//   }

   std::vector<UserData> users;
   mUserTracking.GetUsers(users);

   if (users.empty()) {
      return;
   }

   al_set_target_bitmap(mBitmap);
   al_clear_to_color(al_map_rgb(0x00, 0x00, 0x00));
   al_convert_mask_to_alpha(mBitmap, al_map_rgb(0x00, 0x00, 0x00));

   xn::SceneMetaData scene_meta;
   mUserTracking.GetUserPixels(users[0], scene_meta);

   const XnRGB24Pixel* pRgbBuf = mKinect.GetImageData();
   const XnLabel* pLabelBuf = scene_meta.Data();

   ALLEGRO_LOCKED_REGION* lock = al_lock_bitmap(mBitmap,
                                                al_get_bitmap_format(mBitmap),
                                                ALLEGRO_LOCK_WRITEONLY);

   al_set_target_bitmap(mBitmap);
   for (int y = 0; y < mBitmapHeight; y++)
   {
      for (int x = 0; x < mBitmapWidth; x++, pLabelBuf++, pRgbBuf++)
      {
         if (*pLabelBuf == users[0].GetId())
         {
            al_put_pixel(x, y, al_map_rgb(pRgbBuf->nRed,
                                          pRgbBuf->nGreen,
                                          pRgbBuf->nBlue));
         }
      }
   }
   al_unlock_bitmap(mBitmap);

   const int screen_x_res = al_get_display_width(al_get_current_display());
   const int screen_y_res = al_get_display_height(al_get_current_display());

   al_set_target_bitmap(al_get_backbuffer(al_get_current_display()));
   al_draw_scaled_bitmap(mBitmap, 0, 0, mBitmapWidth, mBitmapHeight,
      GetXPos(), GetYPos(), GetWidth(), GetHeight(), 0);
}
Exemplo n.º 4
0
void Image::print()
{
	ALLEGRO_DISPLAY *display = al_get_current_display();

	switch (mode)
	{
            case IMAGE_MODE_DEFAULT:
	        al_draw_bitmap(image, x, y, flag);
	        break;

	    case IMAGE_MODE_FULLSCREEN:
	    	al_draw_scaled_bitmap(
   			   image,
	    	   0, 0, al_get_bitmap_width(image), al_get_bitmap_height(image),
	    	   0, 0, al_get_display_width(display), al_get_display_height(display), flag);
		    break;

	    case IMAGE_MODE_REGION:
	    	//al_convert_mask_to_alpha(image, al_map_rgb(255,0,255));
	    	al_draw_bitmap_region(
	    	   image,
	    	   region_x, region_y, region_w, region_h,
	    	   x, y, flag);
		    break;
	}
}
Exemplo n.º 5
0
void error(const char *err)
{
    ALLEGRO_DISPLAY *dialogErr;
    dialogErr=al_is_system_installed()?al_get_current_display():NULL;
    al_show_native_message_box(dialogErr,"ERREUR", "Erreur", err,NULL,0);
    exit(EXIT_FAILURE);
}
Exemplo n.º 6
0
Arquivo: map.cpp Projeto: faod/ld33
void Map::drawTile(const Tile &t, std::shared_ptr<ALLEGRO_BITMAP> ptr)
{
    std::shared_ptr<ALLEGRO_BITMAP> bm;
    Tileset* ts = nullptr;

    switch(t.getBiome())
    {
        case GRASS: ts = &grass_; break;
        case SWAMP: ts = &swamp_; break;
        case ROCK:  ts = &rock_;  break;
        default: break;
    };

    al_set_target_bitmap(bm_);

    bm = *ts << t.topleft();
    al_draw_bitmap(bm.get(), t.getx() * 32, t.gety() * 32, 0);
    bm = *ts << t.topright();
    al_draw_bitmap(bm.get(), t.getx() * 32 + 16, t.gety() * 32, 0);
    bm = *ts << t.botleft();
    al_draw_bitmap(bm.get(), t.getx() * 32, t.gety() * 32 + 16, 0);
    bm = *ts << t.botright();
    al_draw_bitmap(bm.get(), t.getx() * 32 + 16, t.gety() * 32 + 16, 0);

    if(ptr != nullptr)
    {
        al_draw_bitmap(ptr.get(), t.getx() * 32, t.gety() * 32, 0);
    }

#ifdef _DEBUG
    t.asObject().drawHull(glm::vec2(0., 0.));
#endif //_DEBUG

    al_set_target_backbuffer(al_get_current_display());
}
Exemplo n.º 7
0
Arquivo: map.cpp Projeto: faod/ld33
Tileset::Tileset(ALLEGRO_COLOR cl)
{
    spritesheet_ = al_create_bitmap(64, 64);
    al_set_target_bitmap(spritesheet_);
    al_clear_to_color(cl);
    al_set_target_backbuffer(al_get_current_display());
}
Exemplo n.º 8
0
  inline bool				initRender() throw()
  {
    ALLEGRO_DISPLAY			*d;
    glm::vec3				pos;

    d = al_get_current_display();
    if (!d)
      return false;
    this->size_ = glm::vec3(al_get_display_width(d), al_get_display_height(d), 0.0f);
    this->center_ = glm::vec3(this->size_.x / 2.0f, this->size_.y / 2.0f, 0.0f);
    this->max_ = this->min_;
    this->max_ += this->size_;

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glViewport(0, 0, this->size_.x * this->zoom_, this->size_.y * this->zoom_);
    glOrtho(0 * this->zoom_,
	    this->size_.x,
	    0 *this->zoom_,
	    this->size_.y,
	    -10000,
	    10000);
    glMatrixMode(GL_MODELVIEW);
    return true;
  }
Exemplo n.º 9
0
 VisualBullet(float x_in, float y_in, float dir[2], float acc[2]) : Bullet(x_in, y_in, dir, acc) {
   ALLEGRO_DISPLAY *old = al_get_current_display();
   bmp_p = al_create_bitmap(10, 10);
   al_set_target_bitmap(bmp_p);
   al_clear_to_color(al_map_rgb(255, 0, 255)); //viola
   al_set_target_backbuffer(old);
 }
Exemplo n.º 10
0
void Object::getDisplayData()
{
    ALLEGRO_DISPLAY *display = al_get_current_display();

    displayW = al_get_display_width(display);
    displayH = al_get_display_height(display);
}
Exemplo n.º 11
0
void Object::generate_error_bitmap()
{
	if(testBit(ISMEM_BITMAP))
	{
		bitmap = create_memory_bitmap();
	} else {
		bitmap = al_create_bitmap(w, h);
	}

    ALLEGRO_COLOR background = al_color_html("#3f51b5");
    ALLEGRO_COLOR shadow = al_color_html("#1a237e");
    ALLEGRO_COLOR sign = al_color_html("#ffeb3b");
	
	al_set_target_bitmap(bitmap);
    al_clear_to_color(background);

    // Shadow (3 triangles)
    al_draw_filled_triangle(w / 2.0f, h / 4.0f, w, (h * 3.0f) / 4.0f, w / 2.0f, h, shadow);
    al_draw_filled_triangle(w, (h * 3.0f) / 4.0f, w, h, w / 2.0f, h, shadow);
    al_draw_filled_triangle(w / 2.0f, h / 4.0f, w / 2.0f, h, w / 4.0f, (h * 3.0f) / 4.0f, shadow);
	
    // Alert sign triangle
	al_draw_filled_triangle(w / 2.0f, h / 4.0f, ((w * 3.0f) / 4), ((h * 3.0f) / 4.0f), w / 4.0f, ((h * 3.0f) / 4.0f), sign);
		
    // Exclamation point
	al_draw_filled_rectangle((w * 15.0f) / 32.0f, ((h * 14.0f) / 32.0f), ((w * 17.0f) / 32.0f), ((h * 19.0f) / 32.0f), background);
    al_draw_filled_rectangle((w * 15.0f) / 32.0f, (h * 5.0f) / 8.0f, (w * 17.0f) / 32.0f, (h * 11.0f) / 16.0f, background);
		
	al_set_target_backbuffer(al_get_current_display());
}
Exemplo n.º 12
0
/* Creates a memory bitmap.
 */
static ALLEGRO_BITMAP *_al_create_memory_bitmap(int w, int h)
{
   ALLEGRO_BITMAP *bitmap;
   int pitch;
   int format = al_get_new_bitmap_format();

   format = _al_get_real_pixel_format(al_get_current_display(), format);

   bitmap = al_calloc(1, sizeof *bitmap);
   bitmap->size = sizeof(*bitmap);

   pitch = w * al_get_pixel_size(format);

   bitmap->vt = NULL;
   bitmap->format = format;
   bitmap->flags = (al_get_new_bitmap_flags() | ALLEGRO_MEMORY_BITMAP) &
      ~ALLEGRO_VIDEO_BITMAP;
   bitmap->w = w;
   bitmap->h = h;
   bitmap->pitch = pitch;
   bitmap->display = NULL;
   bitmap->locked = false;
   bitmap->cl = bitmap->ct = 0;
   bitmap->cr_excl = w;
   bitmap->cb_excl = h;
   al_identity_transform(&bitmap->transform);
   bitmap->parent = NULL;
   bitmap->xofs = bitmap->yofs = 0;
   bitmap->memory = al_malloc(pitch * h);
   bitmap->preserve_texture = !(al_get_new_bitmap_flags() & ALLEGRO_NO_PRESERVE_TEXTURE);
   return bitmap;
}
Exemplo n.º 13
0
bool InputField::Bitmap()
{

   // al_set_target_bitmap(bmp);
    al_set_target_bitmap(as_bitmap);
    al_clear_to_color(bckground_color);

    //float tx = (text_width <= width ? 0 : width - text_width);
    float tx = (text_width <= width ? (center == true ? (width - text_width)/2 : 0) : width - text_width);

    al_draw_text(font, text_color, tx, (height - text_height) / 2.0f, 0, text.c_str());

    if(detectingbutton->is_button_clicked() == true)
    {
        if(bling > 30)
        {
            al_draw_line(tx + text_width -2, (height - text_height) / 2.0f, tx + text_width -2, (height + text_height) / 2.0f, text_color, 2);
            if(bling > 60)
            {
                bling = 0;
            }
        }
        bling++;
    }

    /*al_set_target_bitmap(as_bitmap);
    al_clear_to_color(al_map_rgba(0,0,0,0));
    al_draw_bitmap(bmp, 0, 0, 0);*/
    al_draw_rounded_rectangle(0, 0, width, height, 5, 5, outline_color, 2);
    al_set_target_backbuffer(al_get_current_display());
    return true;
}
Exemplo n.º 14
0
/* Function: al_destroy_display
 */
void al_destroy_display(ALLEGRO_DISPLAY *display)
{
   if (display) {
      /* This causes warnings and potential errors on Android because
       * it clears the context and Android needs this thread to have
       * the context bound in its destroy function and to destroy the
       * shader. Just skip this part on Android.
       */
#ifndef ALLEGRO_ANDROID
      ALLEGRO_BITMAP *bmp;

      bmp = al_get_target_bitmap();
      if (bmp && _al_get_bitmap_display(bmp) == display)
         al_set_target_bitmap(NULL);

      /* This can happen if we have a current display, but the target bitmap
       * was a memory bitmap.
       */
      if (display == al_get_current_display())
         _al_set_current_display_only(NULL);
#endif

      al_destroy_shader(display->default_shader);
      display->default_shader = NULL;

      ASSERT(display->vt);
      display->vt->destroy_display(display);
   }
}
Exemplo n.º 15
0
static void wgl_destroy_display(ALLEGRO_DISPLAY *disp)
{
   ALLEGRO_SYSTEM_WIN *system = (ALLEGRO_SYSTEM_WIN *)al_get_system_driver();
   ALLEGRO_DISPLAY_WGL *wgl_disp = (ALLEGRO_DISPLAY_WGL *)disp;
   ALLEGRO_DISPLAY *old_disp = al_get_current_display();

   if (old_disp != disp)
      _al_set_current_display_only(disp);

   if (system->mouse_grab_display == disp)
      system->mouse_grab_display = NULL;

   destroy_display_internals(wgl_disp);
   _al_event_source_free(&disp->es);
   _al_vector_find_and_delete(&system->system.displays, &disp);

   _al_vector_free(&disp->bitmaps);
   al_free(disp->ogl_extras);

   if (old_disp != disp)
      _al_set_current_display_only(old_disp);

   al_free(disp->vertex_cache);
   al_free(wgl_disp);
}
Exemplo n.º 16
0
static bool ogl_lock_region_nonbb_readwrite(
   ALLEGRO_BITMAP *bitmap, ALLEGRO_BITMAP_EXTRA_OPENGL *ogl_bitmap,
   int x, int gl_y, int w, int h, int format, bool* restore_fbo)
{
   bool ok;

   ASSERT(bitmap->parent == NULL);
   ASSERT(bitmap->locked == false);
   ASSERT(_al_get_bitmap_display(bitmap) == al_get_current_display());

   /* Try to create an FBO if there isn't one. */
   *restore_fbo =
      _al_ogl_setup_fbo_non_backbuffer(_al_get_bitmap_display(bitmap), bitmap);

   if (ogl_bitmap->fbo_info) {
      ALLEGRO_DEBUG("Locking non-backbuffer READWRITE with fbo\n");
      ok = ogl_lock_region_nonbb_readwrite_fbo(bitmap, ogl_bitmap,
         x, gl_y, w, h, format);
   }
   else {
      ALLEGRO_DEBUG("Locking non-backbuffer READWRITE no fbo\n");
      ok = ogl_lock_region_nonbb_readwrite_nonfbo(bitmap, ogl_bitmap,
         x, gl_y, w, h, format);
   }

   return ok;
}
Exemplo n.º 17
0
/* Function: al_hold_bitmap_drawing
 */
void al_hold_bitmap_drawing(bool hold)
{
   ALLEGRO_DISPLAY *current_display = al_get_current_display();

   if (current_display) {
      if (hold && !current_display->cache_enabled) {
         /*
          * Set the hardware transformation to identity, but keep the bitmap
          * transform the same as it was. Relies on the fact that when bitmap
          * holding is turned on, al_use_transform does not update the hardware
          * transformation.
          */
         ALLEGRO_TRANSFORM old, ident;
         al_copy_transform(&old, al_get_current_transform());
         al_identity_transform(&ident);

         al_use_transform(&ident);
         current_display->cache_enabled = hold;
         al_use_transform(&old);
      }
      else {
         current_display->cache_enabled = hold;
      }

      if (!hold) {
         current_display->vt->flush_vertex_cache(current_display);
         /*
          * Reset the hardware transform to match the stored transform.
          */
         al_use_transform(al_get_current_transform());
      }
   }
}
Exemplo n.º 18
0
/* Function: al_hold_bitmap_drawing
 */
void al_hold_bitmap_drawing(bool hold)
{
   ALLEGRO_DISPLAY *current_display = al_get_current_display();
   current_display->cache_enabled = hold;
   if(!hold)
      current_display->vt->flush_vertex_cache(current_display);
}
/* joydx_get_joystick: [primary thread]
 *
 *  Returns the address of a ALLEGRO_JOYSTICK structure for the device
 *  number NUM.
 */
static ALLEGRO_JOYSTICK *joydx_get_joystick(int num)
{
   ALLEGRO_JOYSTICK *ret = NULL;
   unsigned i;
   ASSERT(num >= 0);

   EnterCriticalSection(&joydx_thread_cs);

   for (i = 0; i < MAX_JOYSTICKS; i++) {
      ALLEGRO_JOYSTICK_DIRECTX *joy = &joydx_joystick[i];

      if (ACTIVE_STATE(joy->config_state)) {
         if (num == 0) {
            ret = (ALLEGRO_JOYSTICK *)joy;
            break;
         }
         num--;
      }
   }

   LeaveCriticalSection(&joydx_thread_cs);

#if 0
   /* is this needed? */
   if (ret) {
      ALLEGRO_DISPLAY *display = al_get_current_display();
      if (display)
         _al_win_joystick_dinput_grab(display);
   }
#endif

   return ret;
}
Exemplo n.º 20
0
/* Function: al_get_display_flags
 */
int al_get_display_flags(void)
{
   ALLEGRO_DISPLAY *display = al_get_current_display();
   ASSERT(display);

   return display->flags;
}
Exemplo n.º 21
0
/* Function: al_set_window_title
 */
void al_set_window_title(const char *title)
{
   ALLEGRO_DISPLAY *current_display = al_get_current_display();

   if (current_display && current_display->vt && current_display->vt->set_window_title)
      current_display->vt->set_window_title(current_display, title);
}
Exemplo n.º 22
0
/* Function: al_get_display_format
 */
int al_get_display_format(void)
{
   ALLEGRO_DISPLAY *display = al_get_current_display();
   ASSERT(display);

   return display->backbuffer_format;
}
Exemplo n.º 23
0
/* Function: al_get_display_refresh_rate
 */
int al_get_display_refresh_rate(void)
{
   ALLEGRO_DISPLAY *display = al_get_current_display();
   ASSERT(display);

   return display->refresh_rate;
}
Exemplo n.º 24
0
/* Function: al_get_display_width
 */
int al_get_display_width(void)
{
   ALLEGRO_DISPLAY *display = al_get_current_display();
   ASSERT(display);

   return display->w;
}
Exemplo n.º 25
0
/* Function: al_get_display_height
 */
int al_get_display_height(void)
{
   ALLEGRO_DISPLAY *display = al_get_current_display();
   ASSERT(display);

   return display->h;
}
Exemplo n.º 26
0
/* Function: al_update_display_region
 */
void al_update_display_region(int x, int y, int width, int height)
{
   ALLEGRO_DISPLAY *display = al_get_current_display();
   ASSERT(display);

   display->vt->update_display_region(display, x, y, width, height);
}
Exemplo n.º 27
0
/* Function: al_flip_display
 */
void al_flip_display(void)
{
   ALLEGRO_DISPLAY *display = al_get_current_display();
   ASSERT(display);

   display->vt->flip_display(display);
}
Exemplo n.º 28
0
/* Function: al_get_frontbuffer
 */
ALLEGRO_BITMAP *al_get_frontbuffer(void)
{
   ALLEGRO_DISPLAY *display = al_get_current_display();
   ASSERT(display);

   return display->vt->get_frontbuffer(display);
}
Exemplo n.º 29
0
/* Function: al_set_render_state
 */
void al_set_render_state(ALLEGRO_RENDER_STATE state, int value)
{
   ALLEGRO_DISPLAY *display = al_get_current_display();

   if (!display)
      return;

   switch (state) {
      case ALLEGRO_ALPHA_TEST:
         display->render_state.alpha_test = value;
         break;
      case ALLEGRO_WRITE_MASK:
         display->render_state.write_mask = value;
         break;
      case ALLEGRO_DEPTH_TEST:
         display->render_state.depth_test = value;
         break;
      case ALLEGRO_DEPTH_FUNCTION:
         display->render_state.depth_function = value;
         break;
      case ALLEGRO_ALPHA_FUNCTION:
         display->render_state.alpha_function = value;
         break;
      case ALLEGRO_ALPHA_TEST_VALUE:
         display->render_state.alpha_test_value = value;
         break;
      default:
         ALLEGRO_WARN("unknown state to change: %d\n", state);
         break;
   }

   if (display->vt && display->vt->update_render_state) {
      display->vt->update_render_state(display);
   }
}
Exemplo n.º 30
0
void Overlay::Flip()
{
    //do the starting timer stuff
    clock_t starttime = clock();
	
	al_lock_mutex(front_mutex);
	{
		al_unlock_bitmap(front);

		if(al_get_bitmap_width(front) != ssState.ScreenW
			|| al_get_bitmap_height(front) != ssState.ScreenH){
				al_destroy_bitmap(front);
				int32_t flags = al_get_new_bitmap_flags();
				if(al_get_current_display() != NULL){
					al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP | ALLEGRO_ALPHA_TEST);
				}
				front = al_create_bitmap(ssState.ScreenW, ssState.ScreenH);
				al_set_new_bitmap_flags(flags);
		}
		
		al_set_target_bitmap(front);

		al_draw_bitmap(back, 0, 0, 0);

		front_data = al_lock_bitmap(front, 
			al_get_bitmap_format(front), ALLEGRO_LOCK_READONLY);
	}
	front_updated = true;
	al_unlock_mutex(front_mutex);

	if(al_get_bitmap_width(back) != ssState.ScreenW
		|| al_get_bitmap_height(back) != ssState.ScreenH){
			al_destroy_bitmap(back);
			int32_t flags = al_get_new_bitmap_flags();
			if(al_get_current_display() != NULL){
				al_set_new_bitmap_flags(al_get_bitmap_flags(al_get_backbuffer(al_get_current_display())));
			}
			back = al_create_bitmap(ssState.ScreenW, ssState.ScreenH);
			al_set_new_bitmap_flags(flags);
	}

	al_set_target_bitmap(back);

    //do the ending timer stuff
    clock_t donetime = clock();
	ssTimers.overlay_time = (donetime - starttime)*0.1 + ssTimers.overlay_time*0.9;
}