Category : sdl-2

I’m trying to catch this event when the xbox reactivates the game (for instance after coming from home or store). I’m using the following code (without success) to catch that event: int Application::EventWatch( void* pThis, const SDL_Event* event) { if (event->type == SDL_APP_DIDENTERFOREGROUND) { int resolutions = Screen::GetNumAvailableResolutions(); for (int i = 0; i < ..

Read more

I want to implement a resource loader, and conceptually, it feels like all the resources in SDL2 are the same; you need to free the resource when finished, SDL_Texture* with SDL_DestroyTexture, Mix_Music* with Mix_FreeMusic, Mix_Chunk* with Mix_FreeChunk, TTF_Font* with TTF_CloseFont. All that changes is the name of the "deleter" function, so I would like to ..

Read more

So i’ve been looking all over the place and trying to figure out how to set this up. I am using MacOS 11 and i’m trying to get SDL2 to work on my laptop. My CMakeLists.txt file looks like this cmake_minimum_required(VERSION 3.19) project(SDL_practice) set(CMAKE_CXX_STANDARD 14) # includes cmake/FindSDL2.cmake set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) find_package(SDL2 REQUIRED) include_directories(${SDL2_INCLUDE_DIR}) set(SOURCE_FILES main.cpp) ..

Read more

i cant seem to figure out how to avoid persistant collision if the player has keys ive gotten it to work, but if they have no keys then life just drains from the player continuously void playerEnemyCollide(SDL_Rect playerRect, SDL_Rect enemyRect) { `//make the moving rectangle a constant` const SDL_Rect& PLAYER_RECT = playerRect; `//make the solid ..

Read more

I am following a tutorial from https://www.youtube.com/watch?v=QQzAHcojEKg&list=PLhfAbcv9cehhkG7ZQK0nfIGJC_C-wSLrx and Visual Studio gives me this error: "invalid or corrupt file: cannot read at 0x368" Here are my Visual Studio Project Settings: C/C++: General: Additional Include Directories: C:My Operating SystemC++SDL2include;%(AdditionalIncludeDirectories) Linker: General: Output File: $(OutDir)$(TargetName)$(TargetExt) Linker: Input: Additional Dependencies: C:My Operating SystemC++SDL2libx64SDL2.lib;C:My Operating SystemC++SDL2libx64SDL2main.lib;SDL2.dll;%(AdditionalDependencies) Source: Windows Que..

Read more

I’m trying to create an sdl2 project using clion. The problem is [email protected] error: enter image description here CMakeList.txt: cmake_minimum_required(VERSION 3.19) project(tesx) add_executable(tesx main.cpp) include_directories(SDL2-2.0.14/x86_64-w64-mingw32/include) link_libraries(SDL2-2.0.14/x86_64-w64-mingw32/lib) main.cpp: #include <stdio.h> #include "SDL2/SDL.h" int main(int argc, char* argv[]) { SDL_Init(SDL_INIT_VIDEO); printf("hello"); SDL_Quit(); return 0; } I get this error: ====================[ 构建 | tesx | Release-MinGW ]=============================== "D:Program ..

Read more