|
@@ -1050,31 +1050,36 @@ void OpenGLBackend::Paint()
|
|
|
|
|
|
/**
|
|
|
* Draw mouse cursor on screen.
|
|
|
*/
|
|
|
void OpenGLBackend::DrawMouseCursor()
|
|
|
{
|
|
|
if (!this->cursor_in_window) return;
|
|
|
|
|
|
/* Draw cursor on screen */
|
|
|
_cur_dpi = &_screen;
|
|
|
for (uint i = 0; i < _cursor.sprite_count; ++i) {
|
|
|
SpriteID sprite = _cursor.sprite_seq[i].sprite;
|
|
|
for (uint i = 0; i < this->cursor_sprite_count; ++i) {
|
|
|
SpriteID sprite = this->cursor_sprite_seq[i].sprite;
|
|
|
|
|
|
/* Sprites are cached by PopulateCursorCache(). */
|
|
|
if (this->cursor_cache.Contains(sprite)) {
|
|
|
Sprite *spr = this->cursor_cache.Get(sprite);
|
|
|
|
|
|
this->RenderOglSprite((OpenGLSprite *)spr->data, _cursor.sprite_seq[i].pal,
|
|
|
_cursor.pos.x + _cursor.sprite_pos[i].x + UnScaleByZoom(spr->x_offs, ZOOM_LVL_GUI),
|
|
|
_cursor.pos.y + _cursor.sprite_pos[i].y + UnScaleByZoom(spr->y_offs, ZOOM_LVL_GUI),
|
|
|
this->RenderOglSprite((OpenGLSprite *)spr->data, this->cursor_sprite_seq[i].pal,
|
|
|
this->cursor_pos.x + this->cursor_sprite_pos[i].x + UnScaleByZoom(spr->x_offs, ZOOM_LVL_GUI),
|
|
|
this->cursor_pos.y + this->cursor_sprite_pos[i].y + UnScaleByZoom(spr->y_offs, ZOOM_LVL_GUI),
|
|
|
ZOOM_LVL_GUI);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void OpenGLBackend::PopulateCursorCache()
|
|
|
{
|
|
|
static_assert(lengthof(_cursor.sprite_seq) == lengthof(this->cursor_sprite_seq));
|
|
|
static_assert(lengthof(_cursor.sprite_pos) == lengthof(this->cursor_sprite_pos));
|
|
|
|
|
|
if (this->clear_cursor_cache) {
|
|
|
/* We have a pending cursor cache clear to do first. */
|
|
|
this->clear_cursor_cache = false;
|
|
|
this->last_sprite_pal = (PaletteID)-1;
|
|
|
|
|
|
Sprite *sp;
|
|
@@ -1082,13 +1087,19 @@ void OpenGLBackend::PopulateCursorCache(
|
|
|
OpenGLSprite *sprite = (OpenGLSprite *)sp->data;
|
|
|
sprite->~OpenGLSprite();
|
|
|
free(sp);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
this->cursor_pos = _cursor.pos;
|
|
|
this->cursor_sprite_count = _cursor.sprite_count;
|
|
|
this->cursor_in_window = _cursor.in_window;
|
|
|
|
|
|
for (uint i = 0; i < _cursor.sprite_count; ++i) {
|
|
|
this->cursor_sprite_seq[i] = _cursor.sprite_seq[i];
|
|
|
this->cursor_sprite_pos[i] = _cursor.sprite_pos[i];
|
|
|
SpriteID sprite = _cursor.sprite_seq[i].sprite;
|
|
|
|
|
|
if (!this->cursor_cache.Contains(sprite)) {
|
|
|
Sprite *old = this->cursor_cache.Insert(sprite, (Sprite *)GetRawSprite(sprite, ST_NORMAL, &SimpleSpriteAlloc, this));
|
|
|
if (old != nullptr) {
|
|
|
OpenGLSprite *sprite = (OpenGLSprite *)old->data;
|