static void redraw(void) { ALLEGRO_COLOR color; int w = al_get_display_width(display); int h = al_get_display_height(display); int pw = al_get_bitmap_width(picture); int ph = al_get_bitmap_height(picture); int th = al_get_font_line_height(font); float cx = (w - pw) * 0.5; float cy = (h - ph) * 0.5; ALLEGRO_COLOR white = al_map_rgb_f(1, 1, 1); color = al_map_rgb_f(0.8, 0.7, 0.9); al_clear_to_color(color); color = al_map_rgb(255, 0, 0); al_draw_line(0, 0, w, h, color, 0); al_draw_line(0, h, w, 0, color, 0); al_draw_bitmap(picture, cx, cy, 0); al_draw_textf(font, white, w / 2, cy + ph, ALLEGRO_ALIGN_CENTRE, "Press Space to toggle fullscreen"); al_draw_textf(font, white, w / 2, cy + ph + th, ALLEGRO_ALIGN_CENTRE, "Press Enter to toggle window size"); al_draw_textf(font, white, w / 2, cy + ph + th * 2, ALLEGRO_ALIGN_CENTRE, "Window: %dx%d (%s)", al_get_display_width(display), al_get_display_height(display), (al_get_display_flags(display) & ALLEGRO_FULLSCREEN_WINDOW) ? "fullscreen" : "not fullscreen"); al_flip_display(); }
void SetupViewport(struct Game *game) { game->viewport.width = 320; game->viewport.height = 180; int resolution = al_get_display_width(game->display) / 320; if (al_get_display_height(game->display) / 180 < resolution) resolution = al_get_display_height(game->display) / 180; if (resolution < 1) resolution = 1; if (atoi(GetConfigOptionDefault(game, "SuperDerpy", "letterbox", "1"))) { int clipWidth = 320 * resolution, clipHeight = 180 * resolution; int clipX = (al_get_display_width(game->display) - clipWidth) / 2, clipY = (al_get_display_height(game->display) - clipHeight) / 2; al_set_clipping_rectangle(clipX, clipY, clipWidth, clipHeight); al_build_transform(&game->projection, clipX, clipY, resolution, resolution, 0.0f); al_use_transform(&game->projection); } else if ((atoi(GetConfigOptionDefault(game, "SuperDerpy", "rotate", "1"))) && (game->viewport.height > game->viewport.width)) { al_identity_transform(&game->projection); al_rotate_transform(&game->projection, 0.5*ALLEGRO_PI); al_translate_transform(&game->projection, game->viewport.width, 0); al_scale_transform(&game->projection, resolution, resolution); al_use_transform(&game->projection); int temp = game->viewport.height; game->viewport.height = game->viewport.width; game->viewport.width = temp; } if (game->_priv.console) Console_Unload(game); Console_Load(game); }
void Player::draw() const { const b2Vec2 screen = g.getScreenCorner(); model->skeleton->x = (body->GetPosition().x) * g.pixelpm - screen.x; model->skeleton->y = (body->GetPosition().y + .9) * g.pixelpm - screen.y; skeletonDraw(model); //hp bar al_draw_rectangle(al_get_display_width(g.m.display) / 2 - 102, al_get_display_height(g.m.display) - 62, al_get_display_width(g.m.display) / 2 + 102, al_get_display_height(g.m.display) - 38, al_map_rgb(80, 0, 0), 4); al_draw_filled_rectangle(al_get_display_width(g.m.display) / 2 - 100, al_get_display_height(g.m.display) - 60, al_get_display_width(g.m.display) / 2 - 100 + ((life >= 0) ? life * 2 : 0), al_get_display_height(g.m.display) - 40, al_map_rgb(255, 0, 0)); if(Game::debug) { if(landed) al_draw_filled_circle(al_get_display_width(g.m.display) / 2 + 120, al_get_display_height(g.m.display) - 50, 10, al_map_rgb(0, 255, 0)); } }
void render_welcome_state() { al_draw_bitmap( play_solo_bitmap, play_solo_bounds.x, play_solo_bounds.y, 0 ); al_draw_bitmap( host_game_bitmap, host_game_bounds.x, host_game_bounds.y, 0 ); al_draw_bitmap( join_game_bitmap, join_game_bounds.x, join_game_bounds.y, 0 ); quit_game_bounds.x = al_get_display_width( display ) / 2 - al_get_bitmap_width( quit_game_bitmap ) / 2; quit_game_bounds.y = al_get_display_height( display ) / 5 * 4 - al_get_bitmap_height( quit_game_bitmap ) / 2; quit_game_bounds.width = al_get_bitmap_width( quit_game_bitmap ); quit_game_bounds.height = al_get_bitmap_height( quit_game_bitmap ); al_draw_bitmap( quit_game_bitmap, quit_game_bounds.x, quit_game_bounds.y, 0 ); }
void Renderer::setupProjection(ALLEGRO_TRANSFORM *m) { int dw = al_get_display_width(dpy_); int dh = al_get_display_height(dpy_); // al_perspective_transform(m, -180 * dw / dh, -180, 1, // 180 * dw / dh, 180, 1000); // al_perspective_transform(m, -500, -500, 1, // 500, 500, 10000); double zNear = 0.5, zFar = 1000.0, fov = 90.0, aspect = dw / dh; double left, right; double bottom, top; top = tan (fov*ALLEGRO_PI/360.0)*zNear; bottom = -top; left = aspect*bottom; right = aspect*top; //NBT_Debug("rect: %f %f %f %f", left, top, right, bottom); al_perspective_transform(m, left, top, zNear, right, bottom, zFar); al_set_projection_transform(dpy_, m); }
void Object::getDisplayData() { ALLEGRO_DISPLAY *display = al_get_current_display(); displayW = al_get_display_width(display); displayH = al_get_display_height(display); }
static void sprite_update(Sprite *s) { int w = al_get_display_width(example.display); int h = al_get_display_height(example.display); s->x += s->dx / FPS; s->y += s->dy / FPS; if (s->x < 0) { s->x = -s->x; s->dx = -s->dx; } if (s->x + example.bitmap_size > w) { s->x = -s->x + 2 * (w - example.bitmap_size); s->dx = -s->dx; } if (s->y < 0) { s->y = -s->y; s->dy = -s->dy; } if (s->y + example.bitmap_size > h) { s->y = -s->y + 2 * (h - example.bitmap_size); s->dy = -s->dy; } if (example.bitmap_size > w) s->x = w / 2 - example.bitmap_size / 2; if (example.bitmap_size > h) s->y = h / 2 - example.bitmap_size / 2; }
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; } }
static SCM game_display_height (SCM game_smob) { Game *game = check_game (game_smob); return scm_from_int (al_get_display_height (game->display)); }
void set_mouse_coord (struct mouse_coord *m) { if (m->c.x < 0 || m->c.x >= ORIGINAL_WIDTH || m->c.y < 0 || m->c.y >= ORIGINAL_HEIGHT) return; int x, y; mr_restore_origin (&m->mr); if (! m->c.room) { al_set_mouse_xy (display, m->sx, m->sy); return; } if (! mr_coord (m->c.room, -1, &x, &y)) { mr_center_room (m->c.room); x = mr.x; y = mr.y; } struct mouse_coord m0; get_mouse_coord (&m0); if (m0.x >= 0 && m0.y >= 0 && mr.cell[m0.x][m0.y].room == m->c.room) { x = m0.x; y = m0.y; } int tw, th; mr_get_resolution (&tw, &th); int w = al_get_display_width (display); int h = al_get_display_height (display); int mx = ((ORIGINAL_WIDTH * x + m->c.x + 1) * w) / tw; int my = ((ROOM_HEIGHT * y + m->c.y + 1) * h) / th; mx = min_int (mx, w - 1); my = min_int (my, h - 1); int flags = screen_flags | potion_flags; if (flags & ALLEGRO_FLIP_HORIZONTAL) mx = (w - 1) - mx; if (flags & ALLEGRO_FLIP_VERTICAL) my = (h - 1) - my; if (! al_set_mouse_xy (display, mx, my)) error (0, 0, "%s (%p): cannot set mouse xy coordinates (%i,%i)", __func__, m, mx, my); do { al_get_mouse_state (&mouse_state); } while (mouse_state.x != mx || mouse_state.y != my); mr.select_cycles = SELECT_CYCLES; }
void mr_update_last_settings (void) { int x, y; for (y = mr.h - 1; y >= 0; y--) for (x = 0; x < mr.w; x++) mr.last.cell[x][y].room = mr.cell[x][y].room; mr.last.w = mr.w; mr.last.h = mr.h; mr.last.x = mr.x; mr.last.y = mr.y; mr.last.room = mr.room; mr.last.level = global_level.n; mr.last.em = em; mr.last.vm = vm; mr.last.hgc = hgc; mr.last.hue = hue; mr.last.mouse_pos = mouse_pos; mr.last.display_width = al_get_display_width (display); mr.last.display_height = al_get_display_height (display); mr.full_update = false; if (mr.busy) { mr.busy = false; set_system_mouse_cursor (ALLEGRO_SYSTEM_MOUSE_CURSOR_DEFAULT); } }
void ImGui_ImplAllegro5_NewFrame() { if (!g_Texture) ImGui_ImplAllegro5_CreateDeviceObjects(); ImGuiIO &io = ImGui::GetIO(); // Setup display size (every frame to accommodate for window resizing) int w, h; w = al_get_display_width(g_Display); h = al_get_display_height(g_Display); io.DisplaySize = ImVec2((float)w, (float)h); // Setup time step double current_time = al_get_time(); io.DeltaTime = g_Time > 0.0 ? (float)(current_time - g_Time) : (float)(1.0f/60.0f); g_Time = current_time; // Setup inputs ALLEGRO_KEYBOARD_STATE keys; al_get_keyboard_state(&keys); io.KeyCtrl = al_key_down(&keys, ALLEGRO_KEY_LCTRL) || al_key_down(&keys, ALLEGRO_KEY_RCTRL); io.KeyShift = al_key_down(&keys, ALLEGRO_KEY_LSHIFT) || al_key_down(&keys, ALLEGRO_KEY_RSHIFT); io.KeyAlt = al_key_down(&keys, ALLEGRO_KEY_ALT) || al_key_down(&keys, ALLEGRO_KEY_ALTGR); io.KeySuper = al_key_down(&keys, ALLEGRO_KEY_LWIN) || al_key_down(&keys, ALLEGRO_KEY_RWIN); ImGui_ImplAllegro5_UpdateMouseCursor(); }
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; }
void GameMgr::processInput() { ALLEGRO_EVENT evento; while (!al_is_event_queue_empty(fila_eventos)) { al_clear_to_color(al_map_rgb(0, 0, 0)); // Colorindo a janela de preto al_wait_for_event(fila_eventos, &evento); if (evento.type == ALLEGRO_EVENT_KEY_DOWN) { // uma tecla foi pressionada switch (evento.keyboard.keycode) { case ALLEGRO_KEY_UP: player->trocaDirecao(0); break; case ALLEGRO_KEY_DOWN: player->trocaDirecao(2); break; case ALLEGRO_KEY_LEFT: player->trocaDirecao(3); break; case ALLEGRO_KEY_RIGHT: player->trocaDirecao(1); break; case ALLEGRO_KEY_ENTER: if (evento.keyboard.modifiers | ALLEGRO_KEYMOD_ALT) { auto mode = al_get_display_flags(display); if (mode | ALLEGRO_WINDOWED) { al_set_display_flag(display, ALLEGRO_FULLSCREEN_WINDOW, true); } else { al_set_display_flag(display, ALLEGRO_FULLSCREEN_WINDOW, false); } } break; case ALLEGRO_KEY_Q: case ALLEGRO_KEY_ESCAPE: exit(0); } } else if (evento.type == ALLEGRO_EVENT_MOUSE_BUTTON_DOWN) { // click no mouse if (evento.mouse.x > 0 && evento.mouse.x < 20 && evento.mouse.y > 0 && evento.mouse.y < 20) // cordenadas do botao exit(0); } else if (evento.type == ALLEGRO_EVENT_DISPLAY_RESIZE) { al_acknowledge_resize(display); screen_width = al_get_display_width(display); screen_height = al_get_display_height(display); _redraw = true; } else if (evento.type == ALLEGRO_EVENT_DISPLAY_CLOSE) { // click no mouse exit(0); } else if (evento.type == ALLEGRO_EVENT_TIMER) { if (evento.timer.source == draw_timer) _redraw = true; else if (evento.timer.source == logic_timer) _tick = true; } redraw(); } al_destroy_display(display); // Finaliza a janela }
static void main_loop(ALLEGRO_DISPLAY *display, ALLEGRO_BITMAP *picture) { ALLEGRO_EVENT_QUEUE *queue; ALLEGRO_EVENT event; int new_res; queue = al_create_event_queue(); al_register_event_source(queue, al_get_keyboard_event_source()); al_register_event_source(queue, al_get_display_event_source(display)); while (1) { if (al_is_event_queue_empty(queue)) { redraw(picture); } al_wait_for_event(queue, &event); if (event.type != ALLEGRO_EVENT_KEY_CHAR) { continue; } if (event.keyboard.keycode == ALLEGRO_KEY_ESCAPE) { break; } new_res = cur_res; if (event.keyboard.unichar == '+' || event.keyboard.unichar == ' ' || event.keyboard.keycode == ALLEGRO_KEY_ENTER) { new_res++; if (new_res >= NUM_RESOLUTIONS) new_res = 0; } else if (event.keyboard.unichar == '-') { new_res--; if (new_res < 0) new_res = NUM_RESOLUTIONS - 1; } if (new_res != cur_res) { cur_res = new_res; log_printf("Switching to %dx%d... ", res[cur_res].w, res[cur_res].h); if (al_resize_display(display, res[cur_res].w, res[cur_res].h)) { log_printf("Succeeded.\n"); } else { log_printf("Failed. current resolution: %dx%d\n", al_get_display_width(display), al_get_display_height(display)); } } } al_destroy_event_queue(queue); }
void m_draw_scaled_backbuffer(int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh, MBITMAP *dest) { ALLEGRO_BITMAP *old_target = al_get_target_bitmap(); int old_format = al_get_new_bitmap_format(); al_set_new_bitmap_format(al_get_bitmap_format(al_get_backbuffer(display))); MBITMAP *tmp = m_create_bitmap(sw, sh); int scr_w = al_get_display_width(display); int scr_h = al_get_display_height(display); if (sx+sw > scr_w) { sw = scr_w-sx; } else if (sx < 0) { sw -= sx; sx = 0; } if (sy+sh > scr_h) { sh = scr_h-sy; } else if (sy < 0) { sh -= sy; sy = 0; } #if defined ALLEGRO_RASPBERRYPI || defined ALLEGRO_IPHONE || defined ALLEGRO_ANDROID ALLEGRO_LOCKED_REGION *lr1 = al_lock_bitmap(tmp->bitmap, ALLEGRO_PIXEL_FORMAT_ANY, ALLEGRO_LOCK_WRITEONLY); ALLEGRO_LOCKED_REGION *lr2 = al_lock_bitmap_region( al_get_backbuffer(display), sx, sy, sw, sh, ALLEGRO_PIXEL_FORMAT_ANY, ALLEGRO_LOCK_READONLY ); int pixel_size = al_get_pixel_size(al_get_bitmap_format(al_get_backbuffer(display))); for (int y = 0; y < sh; y++) { uint8_t *d1 = (uint8_t *)lr1->data + lr1->pitch * y; uint8_t *d2 = (uint8_t *)lr2->data + lr2->pitch * y; memcpy(d1, d2, pixel_size*sw); } al_unlock_bitmap(tmp->bitmap); al_unlock_bitmap(al_get_backbuffer(display)); #else m_set_target_bitmap(tmp); al_draw_bitmap_region(al_get_backbuffer(display), sx, sy, sw, sh, 0, 0, 0); #endif m_set_target_bitmap(dest); al_draw_scaled_bitmap( tmp->bitmap, 0, 0, sw, sh, dx, dy, dw, dh, 0 ); m_destroy_bitmap(tmp); al_set_target_bitmap(old_target); al_set_new_bitmap_format(old_format); }
void Dialog::configure_all() { const int xsize = al_get_display_width(display) / this->grid_m; const int ysize = al_get_display_height(display) / this->grid_n; for (std::list<Widget*>::iterator it = this->all_widgets.begin(); it != this->all_widgets.end(); ++it) { (*it)->configure(xsize, ysize, this->x_padding, this->y_padding); } }
static void redraw(void) { int w = al_get_display_width(example.display); int h = al_get_display_height(example.display); int i; int f1, f2; int fh = al_get_font_line_height(example.font); char const *info[] = {"textures", "memory buffers"}; char const *binfo[] = {"alpha", "additive", "tinted", "solid"}; ALLEGRO_COLOR tint = example.white; if (example.blending == 0) { al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_INVERSE_ALPHA); tint = example.half_white; } else if (example.blending == 1) { al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ONE); tint = example.dark; } else if (example.blending == 2) { al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO); tint = example.red; } else if (example.blending == 3) al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO); for (i = 0; i < example.sprite_count; i++) { Sprite *s = example.sprites + i; al_draw_tinted_bitmap(example.bitmap, tint, s->x, s->y, 0); } al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_INVERSE_ALPHA); if (example.show_help) { for (i = 0; i < 5; i++) al_draw_text(example.font, example.white, 0, h - 10 * fh + i * fh * 2 + fh * 0.5, 0, text[i]); } al_draw_textf(example.font, example.white, 0, 0, 0, "count: %d", example.sprite_count); al_draw_textf(example.font, example.white, 0, fh, 0, "size: %d", example.bitmap_size); al_draw_textf(example.font, example.white, 0, fh * 2, 0, "%s", info[example.use_memory_bitmaps]); al_draw_textf(example.font, example.white, 0, fh * 3, 0, "%s", binfo[example.blending]); get_fps(&f1, &f2); al_draw_textf(example.font, example.white, w, 0, ALLEGRO_ALIGN_RIGHT, "FPS: %4d +- %-4d", f1, f2); al_draw_textf(example.font, example.white, w, fh, ALLEGRO_ALIGN_RIGHT, "%4d / sec", (int)(1.0 / example.direct_speed_measure)); }
void ImGui_ImplA5_RenderDrawLists(ImDrawData* draw_data) { int op, src, dst; al_get_blender(&op, &src, &dst); al_set_blender(ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA); for (int n = 0; n < draw_data->CmdListsCount; n++) { const ImDrawList* cmd_list = draw_data->CmdLists[n]; // FIXME-OPT: Unfortunately Allegro doesn't support 32-bits packed colors so we have to convert them to 4 floats static ImVector<ImDrawVertAllegro> vertices; vertices.resize(cmd_list->VtxBuffer.Size); for (int i = 0; i < cmd_list->VtxBuffer.Size; ++i) { const ImDrawVert &dv = cmd_list->VtxBuffer[i]; ImDrawVertAllegro v; v.pos = dv.pos; v.uv = dv.uv; unsigned char *c = (unsigned char*)&dv.col; v.col = al_map_rgba(c[0], c[1], c[2], c[3]); vertices[i] = v; } // FIXME-OPT: Unfortunately Allegro doesn't support 16-bit indices // You can also use '#define ImDrawIdx unsigned int' in imconfig.h and request ImGui to output 32-bit indices static ImVector<int> indices; indices.resize(cmd_list->IdxBuffer.Size); for (int i = 0; i < cmd_list->IdxBuffer.Size; ++i) indices[i] = (int)cmd_list->IdxBuffer.Data[i]; int idx_offset = 0; for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++) { const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i]; if (pcmd->UserCallback) { pcmd->UserCallback(cmd_list, pcmd); } else { ALLEGRO_BITMAP* texture = (ALLEGRO_BITMAP*)pcmd->TextureId; al_set_clipping_rectangle(pcmd->ClipRect.x, pcmd->ClipRect.y, pcmd->ClipRect.z-pcmd->ClipRect.x, pcmd->ClipRect.w-pcmd->ClipRect.y); al_draw_indexed_prim(&vertices[0], g_VertexDecl, texture, &indices[idx_offset], pcmd->ElemCount, ALLEGRO_PRIM_TRIANGLE_LIST); } idx_offset += pcmd->ElemCount; } } // Restore modified state al_set_blender(op, src, dst); al_set_clipping_rectangle(0, 0, al_get_display_width(g_Display), al_get_display_height(g_Display)); }
static duk_ret_t js_ApplyColorMask(duk_context* ctx) { color_t color = duk_require_sphere_color(ctx, 0); float rect_w, rect_h; rect_w = al_get_display_width(g_display); rect_h = al_get_display_height(g_display); if (!is_skipped_frame()) al_draw_filled_rectangle(0, 0, rect_w, rect_h, nativecolor(color)); return 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(); }
int agame_msg(char const * msg, ALLEGRO_FONT * font) { int w = al_get_display_width(display); int h = al_get_display_height(display); // Draw the bounding box al_draw_filled_rounded_rectangle(0, h - h/3.0, w, h, 10, 10, al_map_rgb(120, 120, 120)); al_draw_filled_rounded_rectangle(5, h - h/3.0 + 5, w - 5, h - 5, 10, 10, al_map_rgb(230, 230, 230)); al_draw_rounded_rectangle(5, h - h/3.0 + 5, w - 5, h - 5, 10, 10, al_map_rgb(0, 0, 0), 3); al_draw_justified_text(font, al_map_rgb(0, 0, 0), 10, w - 10, h - h/3.0 + 10, 16, 0, msg); return 1; }
static void add_sprite(void) { if (example.sprite_count < MAX_SPRITES) { int w = al_get_display_width(example.display); int h = al_get_display_height(example.display); int i = example.sprite_count++; Sprite *s = example.sprites + i; float a = rand() % 360; s->x = rand() % (w - example.bitmap_size); s->y = rand() % (h - example.bitmap_size); s->dx = cos(a) * FPS * 2; s->dy = sin(a) * FPS * 2; } }
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); }
void Console_Load(struct Game *game) { game->_priv.font_console = NULL; game->_priv.console = NULL; game->_priv.font_console = al_load_ttf_font(GetDataFilePath(game, "fonts/DejaVuSansMono.ttf"),al_get_display_height(game->display)*0.025,0 ); if (al_get_display_height(game->display)*0.025 >= 16) { game->_priv.font_bsod = al_load_ttf_font(GetDataFilePath(game, "fonts/PerfectDOSVGA437.ttf"),16,0 ); } else { game->_priv.font_bsod = al_load_ttf_font(GetDataFilePath(game, "fonts/DejaVuSansMono.ttf"), al_get_display_height(game->display)*0.025,0 ); } game->_priv.console = al_create_bitmap((al_get_display_width(game->display) / 320) * 320, al_get_font_line_height(game->_priv.font_console)*5); game->_priv.font = al_load_ttf_font(GetDataFilePath(game, "fonts/MonkeyIsland.ttf"), 0 ,0 ); al_set_target_bitmap(game->_priv.console); al_clear_to_color(al_map_rgba(0,0,0,80)); al_set_target_bitmap(al_get_backbuffer(game->display)); }
inline bool initRender() throw() { ALLEGRO_DISPLAY *d; glm::vec3 pos; d = al_get_current_display(); if (!d) return false; this->center_ = glm::vec3(al_get_display_width(d) / 2.0f, al_get_display_height(d) / 2.0f, 0.0f); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(60.0, (double)((this->center_.x * 2.0f) / (this->center_.y * 2.0f)), 1.0, 1000.0); return true; }
static void redraw(void) { ALLEGRO_COLOR black, white; int w, h; white = al_map_rgba_f(1, 1, 1, 1); black = al_map_rgba_f(0, 0, 0, 1); al_clear_to_color(white); w = al_get_display_width(); h = al_get_display_height(); al_draw_line(0, h, w / 2, 0, black, 0); al_draw_line(w / 2, 0, w, h, black, 0); al_draw_line(w / 4, h / 2, 3 * w / 4, h / 2, black, 0); al_flip_display(); }
void draw_mr_select_rect (int x, int y, ALLEGRO_COLOR color) { int w = al_get_display_width (display); int h = al_get_display_height (display); int tw, th; mr_get_resolution (&tw, &th); ALLEGRO_BITMAP *screen = mr.cell[x][y].screen; int sw = al_get_bitmap_width (screen); int sh = al_get_bitmap_height (screen); float dx = ((ORIGINAL_WIDTH * x) * w) / (float) tw; float dy = ((ROOM_HEIGHT * y) * h) / (float) th; float dw = (sw * w) / (float) tw; float dh = (sh * h) / (float) th; al_draw_rectangle (dx, dy, dx + dw, dy + dh, color, 2); }
/** Updates the camera. */ Camera * camera_update(Camera * self, double dt) { ALLEGRO_DISPLAY *display = al_get_current_display(); double dw = al_get_display_width(display); double dh = al_get_display_height(display); double f = tan(self->field_of_view / 2.0); /* Set up orthograĥic transform for UI, etc. */ al_identity_transform(&self->orthographic_transform); al_orthographic_transform(&self->orthographic_transform, 0, 0, -1, dw, dh, 1000); /* Perspective transform for the main screen 3D view. */ al_identity_transform(&self->perspective_transform); /* Back up camera a bit. */ /* Set up a nice 3D view. */ al_translate_transform_3d(&self->perspective_transform, 0, 0, -1); al_perspective_transform(&self->perspective_transform, -1 * dw / dh * f, f, 1, f * dw / dh, -f, 1000); /* al_perspective_transform(&projection, -1 * dw / dh * f, f, 1, f * dw / dh, -f, 1000); */ /* Set up the camera's position and view transform. */ /* al_build_camera_transform(&self->camera_transform, self->position.x, self->position.y, self->position.z, self->look.x , self->look.y , self->look.z , self->up.x , self->up.y , self->up.z ); */ al_identity_transform(&self->camera_transform); al_translate_transform_3d(&self->camera_transform, self->position.x, self->position.y, self->position.z); al_rotate_transform_3d(&self->camera_transform, 0, -1, 0, self->alpha); al_rotate_transform_3d(&self->camera_transform, -1, 0, 0, self->theta); /* Finally move at the set speed. */ self->position = vec3d_add(self->position, vec3d_mul(self->speed, dt)); return self; }
void Menu::wyswietl(grafika & obrazki){ //zminne do wyœwietlania int margines=20; int wybor_pion=(al_get_display_height(obrazki.okno)-margines)/4; int strzalka_y; //czêœæ zwi¹zana z obs³ug¹ klawiatury while (true){ strzalka_y=wybor_pion*polozenie-25; obrazki.wyswietl(strzalka_y); wybierz_sobie_klawisz(); } }