mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 19:11:50 +00:00
fix cursors
This commit is contained in:
parent
640cfcc3d0
commit
4e97923cee
2 changed files with 12 additions and 2 deletions
|
|
@ -257,7 +257,13 @@ void window_sdl::setShouldClose(bool flag) {
|
|||
}
|
||||
|
||||
void window_sdl::setCursor(CursorShape shape) {
|
||||
SDL_Cursor *cursor = nullptr;
|
||||
// so it method called each frame, we always recreate cursor.
|
||||
// Refactor it
|
||||
if (cursor) {
|
||||
SDL_DestroyCursor(cursor);
|
||||
cursor = nullptr;
|
||||
}
|
||||
|
||||
switch (shape) {
|
||||
case CursorShape::ARROW:
|
||||
cursor = SDL_CreateSystemCursor(
|
||||
|
|
@ -313,7 +319,6 @@ void window_sdl::setCursor(CursorShape shape) {
|
|||
}
|
||||
if (cursor) {
|
||||
SDL_SetCursor(cursor);
|
||||
SDL_DestroyCursor(cursor);
|
||||
}
|
||||
}
|
||||
void window_sdl::toggleFullscreen() {
|
||||
|
|
@ -321,6 +326,10 @@ void window_sdl::toggleFullscreen() {
|
|||
if (!SDL_SetWindowFullscreen(window, fullscreen)) {
|
||||
logger.error() << "Cant toggle fullscreen window: " << SDL_GetError();
|
||||
}
|
||||
if (!SDL_SyncWindow(window)) {
|
||||
logger.error() << "Cant sync window after toggle fullscreen: "
|
||||
<< SDL_GetError();
|
||||
}
|
||||
}
|
||||
bool window_sdl::isFullscreen() const {
|
||||
return fullscreen;
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ private:
|
|||
|
||||
SDL_Window *window = nullptr;
|
||||
SDL_Renderer *renderer = nullptr;
|
||||
SDL_Cursor *cursor = nullptr;
|
||||
SDL_GLContext context = nullptr;
|
||||
|
||||
std::stack<glm::vec4> scissorStack;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue