sdl-image

How to use SDL2 and SDL_image with cmake

让人想犯罪 __ 提交于 2019-12-17 06:38:10
问题 I'm looking for the simplest way to compile a c++ program using SDL2 and SDL_image with cmake. Here is my best attempt, after hours of searching: CMakeLists.txt project(shooter-cmake2) cmake_minimum_required(VERSION 2.8) set(SOURCES shooter.cpp classes.cpp utils.cpp ) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") add_executable(${PROJECT_NAME} ${SOURCES}) INCLUDE(FindPkgConfig) PKG_SEARCH_MODULE(SDL2 REQUIRED sdl2) PKG_SEARCH_MODULE(SDL2_image REQUIRED sdl2_image) INCLUDE_DIRECTORIES($

glReadPixels swaps blue and red

梦想与她 提交于 2019-12-12 05:08:01
问题 I'm trying to save a screen region from opengl into a bitmap. I've tried using FreeImage, and SDL_Image, and they both require me to swap red and blue channels. Of course, that brings me to suspect that glReadPixels is the problem here... I have this sample code: bool CaptureScreenRegionToFile ( uint32_t In_X, uint32_t In_Y, uint32_t In_Width, uint32_t In_Height, std::string In_Filename ) { GLubyte* ImageData = ( GLubyte* ) malloc ( In_Width * In_Height * 3 ); glPixelStorei ( GL_PACK

SDL draw PNG image from raw image data string

扶醉桌前 提交于 2019-12-11 17:46:07
问题 I've setup a PNG resource file in my SDL2 project for Windows 32bit in C++. HRSRC hRes = FindResource(0, MAKEINTRESOURCE(IMGID), "PNG"); if (!hRes) { Log::Error("Find resource IMGID"); return; } HGLOBAL hData = LoadResource(0, hRes); if (!hData) { Log::Error("Load resource IMGID"); return; } DWORD dataSize = SizeofResource(0, hRes); char* data = (char*)LockResource(hData); std::string result; result.assign(data, dataSize); The result variable contains all the characters of the PNG image (if

Xcode SDL resources folder

偶尔善良 提交于 2019-12-08 05:34:07
问题 I am making a SDL project in Xcode and I have a folder called resources where my images are stored. For my SDL application to access these images with SDL_LoadBMP the resources folder needs to be in the same folder as the executable file. I don't want to have to copy and paste my resources into the "/Users/admin/Library/Developer/Xcode/DerivedData/SDL_app-awvygturnguyeqgwpjowmouadbjf/Build/Products/Debug" folder every time I want to run an application (I don't know why all the random

SDL_Image IMG_Load fails on png with: “Failed loading libpng16-16.dll:”

落爺英雄遲暮 提交于 2019-12-07 03:32:01
问题 Whenever I try to load a PNG using SDL_Image's IMG_Load function it gives the error Failed loading libpng16-16.dll: . I have all the right dll's in the right path and I can use other parts of SDL_Image, but for some reason it can't load the libpng dll. How can I fix this? Any help is appreciated. 回答1: See my article "SDL2: Loading Images with SDL_image": If you're going to run from Visual Studio, make sure the image is in the same folder as your main.cpp file; otherwise if you're running

SDL: How to blit a surface onto one created with SDL_CreateRGBSurface correctly?

二次信任 提交于 2019-12-06 15:29:25
问题 I'm trying to blit a surface created by IMG_Load (SDL_image) onto one created via SDL_CreateRGBSurface . When both surfaces are loaded with IMG_Load , this works fine, but not when the target surface was created using SDL_CreateRGBSurface . By experimentation, I figured out that if I call SDL_SetAlpha on the source surface, it suddenly works fine. The documentation is a bit lacking, but how I understand it, the way I call it below should clear the SDL_SRCALPHA flag, presumably set by IMG_Load

SDL_Image IMG_Load fails on png with: “Failed loading libpng16-16.dll:”

萝らか妹 提交于 2019-12-05 08:05:22
Whenever I try to load a PNG using SDL_Image's IMG_Load function it gives the error Failed loading libpng16-16.dll: . I have all the right dll's in the right path and I can use other parts of SDL_Image, but for some reason it can't load the libpng dll. How can I fix this? Any help is appreciated. See my article " SDL2: Loading Images with SDL_image ": If you're going to run from Visual Studio, make sure the image is in the same folder as your main.cpp file; otherwise if you're running straight from the executable, the image should be in the same folder with it. Needless to say, what I wrote

How to fix 'The procedure entry point SDL_RWclose could not be located in the dynamic link library'

让人想犯罪 __ 提交于 2019-12-02 07:06:10
问题 I'm trying to draw a png image to a window using the SDL_image extension, but it gives me an "Entry Point Not Found" error I'm using SDL (2.0.9) and SDL_Image (2.0.5) I've copied the following bin files to the executable directory libjpeg-9.dll libpng16-16.dll libtiff-5.dll libwebp-7.dll SDL2.dll SDL2_image.dll zlib1.dll main.cpp extract #include <iostream> #include <SDL.h> #include <SDL_image.h> int main( int argc, char* args[] ) { SDL_Texture* test_tex; SDL_Window* window = NULL; SDL

How to statically compile an SDL game on Windows

╄→尐↘猪︶ㄣ 提交于 2019-11-28 04:25:19
I have been trying to produce a statically linked "single binary" version of my game for windows. I want to link with sdl, sdl_image and sdl_mixer which in turn pull in a few support libraries. Unfortunately I haven't found a way to get them all to compile and link using cygwin/mingw/gcc. As far as I can tell all existing public versions are only shared libraries / dlls. Please note that I'm not talking about licencing here. The source will be open thus the GPL/LGPLness of sdl is not relevant. When compiling your project, you need to make just a couple changes to your makefile. Instead of sdl

How to use SDL2 and SDL_image with cmake

廉价感情. 提交于 2019-11-27 03:58:33
I'm looking for the simplest way to compile a c++ program using SDL2 and SDL_image with cmake. Here is my best attempt, after hours of searching: CMakeLists.txt project(shooter-cmake2) cmake_minimum_required(VERSION 2.8) set(SOURCES shooter.cpp classes.cpp utils.cpp ) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") add_executable(${PROJECT_NAME} ${SOURCES}) INCLUDE(FindPkgConfig) PKG_SEARCH_MODULE(SDL2 REQUIRED sdl2) PKG_SEARCH_MODULE(SDL2_image REQUIRED sdl2_image) INCLUDE_DIRECTORIES(${SDL2_INCLUDE_DIRS} ${SDL2IMAGE_INCLUDE_DIR}) TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${SDL2_LIBRARIES} $