sdl

SDL Smoother movement in game

試著忘記壹切 提交于 2021-01-28 12:09:24
问题 I have got a small problem with my game. It is not a big deal but I'd love to sort this out. So this is my input processing function: void MainGame::processInput() { SDL_Event evnt; while (SDL_PollEvent(&evnt)) { switch (evnt.type) { case SDL_QUIT: _gameState = GameState::EXIT; break; case SDL_MOUSEMOTION: break; case SDL_KEYDOWN: switch (evnt.key.keysym.sym) { case SDLK_RIGHT: player.movePlayer(1); break; case SDLK_LEFT: player.movePlayer(2); break; } } } } and it works just fine, but as you

gperftools and pprof do not print my function names. Need advice on how to fix this

徘徊边缘 提交于 2021-01-28 07:20:27
问题 I'm currently writing a game in C++ using SDL on Ubuntu. I recently multithreaded my engine, so I switched from profiling with valgrind/callgrind to gperftools. I have gotten it to work, but it will not print my own function names. Oddly enough, it recognizes SDL function names (I've seen the reverse happening on a few threads online; shared library functions not having their names found). kcachegrind Output I run my program, and the execute the following two commands in order to get this:

No audio with SDL/C++

半城伤御伤魂 提交于 2021-01-28 05:11:05
问题 void LoadMusic(string path); Mix_Music* gMusic = NULL; LoadMusic("Music/bubble-bobble.mp3"); if(Mix_PlayingMusic() == 0) { Mix_PlayMusic(gMusic, -1); } if(Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 2048) < 0) { cout << "Mixer could not initialise. error: " << Mix_GetError(); return false; } Mix_FreeMusic(gMusic); gMusic = NULL; void LoadMusic(string path) { gMusic = Mix_LoadMUS(path.c_str()); if(gMusic == NULL) { cout << "Failed to load background music! Error: " << Mix_GetError() << endl; }

SDL2 main game loop

丶灬走出姿态 提交于 2021-01-27 07:08:37
问题 My question popped out while reading the tutorials on SDL2, on lazyfoo.net and the code is being copied from this page int main( int argc, char* args[] ) { //Start up SDL and create window if( !init() ) { printf( "Failed to initialize!\n" ); } else { //Load media if( !loadMedia() ) { printf( "Failed to load media!\n" ); } else { //Main loop flag bool quit = false; //Event handler SDL_Event e; //While application is running while( !quit ) { //Handle events on queue while( SDL_PollEvent( &e ) !

How to wrap C structs in Cython for use in Python?

天大地大妈咪最大 提交于 2021-01-27 04:07:33
问题 For a bit of learning experience, I'm trying to wrap a few parts of SDL (1.2.14) in Cython in an extension for Python 3.2. I am having a problem figuring out how to wrap C structs straight into Python, being able to access its attributes directly like: struct_name.attribute For example, I want to take the struct SDL_Surface: typedef struct SDL_Rect { Uint32 flags SDL_PixelFormat * format int w, h Uint16 pitch void * pixels SDL_Rect clip_rect int refcount } SDL_Rect; And be able to use it like

SDL2_image not found

做~自己de王妃 提交于 2021-01-22 07:41:02
问题 I am trying to compile the following code which has the headers: #include <SDL2/SDL.h> #include <SDL2_image/SDL_image.h> However after running the following makefile: g++ -std=c++11 src/main.cpp -lSDL2 -lSDL2_image I get the following error: fatal error: SDL2_image/SDL_image.h: No such file or directory #include <SDL2_image/SDL_image.h> Any suggestions? Not entirely sure about my installation of SDL_image. I am running this on Ubuntu. 回答1: This problem can be solved through installing libsdl2

SDL2_image not found

冷暖自知 提交于 2021-01-22 07:40:06
问题 I am trying to compile the following code which has the headers: #include <SDL2/SDL.h> #include <SDL2_image/SDL_image.h> However after running the following makefile: g++ -std=c++11 src/main.cpp -lSDL2 -lSDL2_image I get the following error: fatal error: SDL2_image/SDL_image.h: No such file or directory #include <SDL2_image/SDL_image.h> Any suggestions? Not entirely sure about my installation of SDL_image. I am running this on Ubuntu. 回答1: This problem can be solved through installing libsdl2

SDL2_image not found

僤鯓⒐⒋嵵緔 提交于 2021-01-22 07:38:05
问题 I am trying to compile the following code which has the headers: #include <SDL2/SDL.h> #include <SDL2_image/SDL_image.h> However after running the following makefile: g++ -std=c++11 src/main.cpp -lSDL2 -lSDL2_image I get the following error: fatal error: SDL2_image/SDL_image.h: No such file or directory #include <SDL2_image/SDL_image.h> Any suggestions? Not entirely sure about my installation of SDL_image. I am running this on Ubuntu. 回答1: This problem can be solved through installing libsdl2

SDL2_image not found

拥有回忆 提交于 2021-01-22 07:37:34
问题 I am trying to compile the following code which has the headers: #include <SDL2/SDL.h> #include <SDL2_image/SDL_image.h> However after running the following makefile: g++ -std=c++11 src/main.cpp -lSDL2 -lSDL2_image I get the following error: fatal error: SDL2_image/SDL_image.h: No such file or directory #include <SDL2_image/SDL_image.h> Any suggestions? Not entirely sure about my installation of SDL_image. I am running this on Ubuntu. 回答1: This problem can be solved through installing libsdl2

ffmpeg 教程学习笔记(1)

╄→尐↘猪︶ㄣ 提交于 2021-01-14 10:58:19
ffmpeg 教程学习笔记 音频播放不正常问题 文章目录 ffmpeg 教程学习笔记 音频播放不正常问题 前言 一、开发环境 二、修改过程 1.导入头文件 2.定义一个全局变量,用于存储重采样的标准(属性) 3.在设置完 wanted_spec 的属性参数并打开音频文件之后,为上面我们所新定义的采样标准初始化。 4.修改官方例程中的解码函数 audio_decode_frame() 总结 前言 最近在学习 ffmpeg 官网例程,例程3之后的播放音频部分总是有问题,表现为:代码可以编译通过,但播放时音频都是杂音,隐隐约约能够听出旋律(我哭了。。。)。 经过多方查找终于找到了原因 ------- 没有进行音频重采样! 一、开发环境 ffmpeg 4.1 + sdl 1.2.15 + vs2015 二、修改过程 1.导入头文件 因为是要进行重采样,所以要将相应的头文件包含进来。 # include <libswresample/swresample.h> 2.定义一个全局变量,用于存储重采样的标准(属性) AVFrame wanted_frame ; 3.在设置完 wanted_spec 的属性参数并打开音频文件之后,为上面我们所新定义的采样标准初始化。 wanted_frame . format = AV_SAMPLE_FMT_S16 ; wanted_frame . sample