sdl-2

Reading animated GIFs SDL 2

若如初见. 提交于 2020-01-04 02:07:07
问题 I would like to be able to load GIF animations instead of using sprite sheets and grids in a game I am working on. I believe this will make what I do much easier than now. I've looked it up on Google, but all I found was a library which uses Win32 calls; ergo restricted to Windows. I believe I can do the job if I figure out how I can extract the individual frames and delay values from an animated GIF. As the title says, I am using SDL2 to load my sprites. Any kind of help is appreciated.

Why does linking against both sdl2 and udev cause a segmentation fault?

别来无恙 提交于 2020-01-04 01:53:11
问题 I have the following really dumb C program: #include <SDL2/SDL.h> int main () { SDL_Init(SDL_INIT_VIDEO); } If I compile it and link against sdl2 , all is well: [nix-shell:~/work/on-the-limit]$ gcc oddity.c -lSDL2 -o oddity [nix-shell:~/work/on-the-limit]$ ./oddity However, if I also link against udev ... [nix-shell:~/work/on-the-limit]$ gcc oddity.c -lSDL2 -ludev -o oddity [nix-shell:~/work/on-the-limit]$ ./oddity Segmentation fault ... a segmentation fault happens. gdb has the following to

SDL 2.0 source has 1.3 in it?

*爱你&永不变心* 提交于 2020-01-03 13:51:50
问题 I'm playing around with the SDL 2.0 source code and noticed it has another SDL folder within it that claims to be version 1.3. I'm interested in it because it has source for android, iphone and a few others. The stable version , 1.2, seems to be quite different. My question is this, SDL wiki link This link speaks of SDL_compat.c which may allow code to work for both 1.2 and 2.0. Is this the version I should be using, and should I be coding they way the 2.0 API suggest? I want my code to

What is the difference between an SDL physical key code and an SDL virtual key code?

社会主义新天地 提交于 2020-01-01 04:06:08
问题 The struct SDL_Keysym has SDL_Scancode and SDL_Keycode members. What is the difference between them? The documentation does not really clear it up for me. I tried both and they seem to do the same thing. 回答1: See the SDL documentation. Scancodes represent the physical position of the keys, modeled after a standard QWERTY keyboard, while Keycodes are the character obtained by pressing the key. On an AZERTY keyboard, pressing A will emit a 'Q' scancode and an 'a' keycode. 回答2: Generally,

How do I take and save a BMP screenshot in SDL 2?

ぃ、小莉子 提交于 2020-01-01 01:53:11
问题 Using just a given SDL_Window* and SDL_Renderer*, how can I create and save a screenshot in SDL 2.0? 回答1: Below is a function for saving a screenshot in SDL 2 taken from a library I'm currently writing. bool saveScreenshotBMP(std::string filepath, SDL_Window* SDLWindow, SDL_Renderer* SDLRenderer) { SDL_Surface* saveSurface = NULL; SDL_Surface* infoSurface = NULL; infoSurface = SDL_GetWindowSurface(SDLWindow); if (infoSurface == NULL) { std::cerr << "Failed to create info surface from window

Can't run SDL(2) on Ubuntu, No available video device

故事扮演 提交于 2019-12-31 01:47:09
问题 When i try to run my program i get the following error message: SDL could not initialize! SDL_Error: No available video device I have all the necessary SDL libraries installed and I'm currently running ubuntu 15.10 Here is my simple SDL code: #include <stdio.h> #include "SDL2/SDL.h" //Screen dimension constants const int SCREEN_WIDTH = 640; const int SCREEN_HEIGHT = 480; int main(int argc, char* argv[]) { //The window we'll be rendering to SDL_Window* window = NULL; //The surface contained by

Linking SDL2 and Clion

时光怂恿深爱的人放手 提交于 2019-12-31 01:46:21
问题 I have clion pointing to SDL2 directories and libs, but it fails to link the libraries when I try to build. Any ideas on how to fix this? CMakeLists: cmake_minimum_required(VERSION 3.3) project(cavestory_development) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -lSDL2") set(SDL2_INCLUDE_DIR C:/SDL2-2.0.3/i686-w64-mingw32/include/SDL2) set(SDL2_LIBRARY C:/SDL2-2.0.3/i686-w64-mingw32/lib) find_package(SDL2 REQUIRED) include_directories(${SDL2_INCLUDE_DIR}) set(SOURCE_FILES main.cpp) add

SDL_Texture - Incomplete type

旧时模样 提交于 2019-12-30 08:24:06
问题 a day ago I installed an SDL2 library. It is not in Debian Wheezy yet, so I used configure, make, make install commands. After all, when I try to use SDL_Texture, I get this error: error: forward declaration of ‘SDL_Texture {aka struct SDL_Texture}’ invalid use of incomplete type ‘SDL_Texture {aka struct SDL_Texture}’ After looking for declaration, everything I found are these two lines in SDL_render.h: struct SDL_Texture; typedef struct SDL_Texture SDL_Texture; No definition at all. I think

How to render SDL2 texture into GTK3+ window?

十年热恋 提交于 2019-12-29 10:07:04
问题 I am creating a music player and trying to use GTK3+ for creating user interface. I am using SDL_CreateWindowFrom function to let SDL2 use GTK3+ window rather than creating one but cann't figure out the steps I need to follow in order to render the SDL2 textures into GTK3+ window. Code getting GTK3 window ID window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(window), "---"); gtk_widget_show(window); gdkWin = gtk_widget_get_window(GTK_WIDGET(window)); data-

C++ IMG_LoadTexture() returns null

流过昼夜 提交于 2019-12-25 08:34:10
问题 I'm trying to load a image("carnero.png") but when I use IMG_LoadTexture(), it returns null; Game.h #ifndef GAME_H_ #define GAME_H_ #include <SDL.h> #include <SDL_image.h> #include <windows.h> class Game { public: Game(); ~Game(); void run(); void initGraphics(); void gameLoop(); private: SDL_Window* _window = nullptr; SDL_Renderer* _renderer; SDL_Surface* _surfaceBMP; SDL_Texture* _textureScenario; SDL_Texture* _textureCarnero; SDL_Rect* _scenarioRect; SDL_Rect* _carneroRect; int _width; int