sdl

main.cpp:(.text+0x5f): undefined reference to

淺唱寂寞╮ 提交于 2019-12-03 21:06:46
I try to compile some exercise from a SDL guide. I compile like this: g++ -o main main.cpp -I/usr/local/include/SDL2 -L/usr/local/lib -lSDL2 and i get this: /tmp/cci2rYNF.o: In function `main': main.cpp:(.text+0x5f): undefined reference to `Game::init(char const*, int, int, int, int, int)' collect2: error: ld returned 1 exit status and my code is: main.cpp #include "Game.h" // our Game object Game* g_game = 0; int main(int argc, char* argv[]) { g_game = new Game(); g_game->init("Chapter 1", 100, 100, 640, 480, 0); while(g_game->running()) { g_game->handleEvents(); g_game->update(); g_game-

Fast file copy with progress

↘锁芯ラ 提交于 2019-12-03 20:46:31
I'm writing an SDL application for Linux, that works from the console (no X server). One function I have is a file copy mechanism, that copies specific files from HDD to USB Flash device, and showing progress of this copy in the UI. To do this, I'm using simple while loop and copying file by 8kB chunks to get copy progress. The problem is, that it's slow. I get to copy a 100 MB file in nearly 10 minutes, which is unacceptable. How can I implement faster file copy? I was thinking about some asynchronous API that would read file from HDD to a buffer and store the data to USB in separate thread,

Best way to rotate an image using SDL?

不羁岁月 提交于 2019-12-03 16:23:24
问题 I am building a game and the main character's arm will be following the mouse cursor, so it will be rotating quite frequently. What would be the best way to rotate it? 回答1: With SDL you have a few choices. Rotate all your sprites in advance (pre-render all possible rotations) and render them like you would any other sprite. This approach is fast, but uses more memory and more sprites. As @Nick Wiggle pointed out, RotSprite is a great tool for generating sprite transoformations. Use something

Can cairo use SDL_Texture as a render target?

冷暖自知 提交于 2019-12-03 12:37:00
问题 Rendering to an SDL_Surface is possible with Cairo, but my application uses SDL_Renderer and SDL_Texture to take advantage of 2D accelerated rendering. I am currently creating an SDL_Surface and copying it to a texture with SDL_CreateTextureFromSurface(), but this process is cumbersome and possibly slow (although it's not a bottleneck.) Is there a direct way to draw to a SDL_Texture? 回答1: I've figured it out. Streaming SDL_Textures can expose the raw pixels in the ARGB8888 format, which is a

SDL Error Undefined symbols for architecture x86_64 “_SDL_main”

自闭症网瘾萝莉.ら 提交于 2019-12-03 12:26:19
I am using C++ with the SDL Cocoa and Foundation framework on my mac os x. I get the following error Undefined symbols for architecture x86_64: "_SDL_main", referenced from: -[SDLMain applicationDidFinishLaunching:] in SDLMain.o ld: symbol(s) not found for architecture x86_64 when I run the following code #import <Foundation/Foundation.h> #import <SDL/SDL.h> #include "SDLMain.h" int main(int argc, const char * argv[]) { SDL_Init(SDL_INIT_EVERYTHING); SDL_SetVideoMode(640,480,32,SDL_DOUBLEBUF); SDL_Event event; bool isRunning = true; while(SDL_PollEvent(&event)){ if(event.type == SDL_QUIT){

C++ SDL segmentation fault

匿名 (未验证) 提交于 2019-12-03 10:24:21
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I had my game working and then decided to try and implement a menu using the following tutorial . I did not use the tutorial to create the game that was in prior tutorials that he created. Whenever I compile and run the program it loads briefly, then closes and says Process terminated with status 3 (0 minutes, 1 seconds) in the build log of code::blocks . UPDATE: I have updated the code for the pastebin link to what I have now, the error I am now getting from the debugger is Program received signal SIGSEGV, Segmentation fault. In TTF

Xcode SDL resources folder

匿名 (未验证) 提交于 2019-12-03 10:24:21
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: 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 characters are in the folder link). I have been following

0xC0000005: Access violation executing location 0x00000000. (OpenGL)

匿名 (未验证) 提交于 2019-12-03 09:02:45
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have looked at several other questions on stack about this and it mentions de-referencing null pointers but I don't understand if that applies to my code. The code crashes at line 33 in the World.cpp when trying to generate a VAO: glGenVertexArrays(1, &vao); giving me the error shown in the title. If I comment out that line the program runs fine. PhaseEngineMain.cpp #include "PhaseEngineMain.h" #include "PhaseEngineController.h" int main(int argc, char *argv[]) { PhaseEngineController engine; engine.start(); return 0; }

SDL fake fullscreen mode on dual monitor setup under linux

匿名 (未验证) 提交于 2019-12-03 08:41:19
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Using SDL 1.3 I want to create fake fullscreen SDL_Window under linux. It is easy if i have only one display. I just got current display mode and created a window. SDL_GetDesktopDisplayMode(0, &mode); SDL_Window *win = SDL_CreateWindow("my window", 0,0,mode.w, mode.h, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_BORDERLESS ); But when i have two displays, things get complicated. The window spreads across multiple monitors. SDL sees only one, double sized virtual display. I tested it with this code int num = SDL_GetNumVideoDisplays();

Learning SDL in C [closed]

人盡茶涼 提交于 2019-12-03 08:19:52
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I know the basics of C and I'm looking into SDL. What I need at this point are some tutorials, documentation or perhaps a book about using the SDL libraries in C, especially about graphics. The problem is that every online resource that I have found deals with C++, where I am looking for resources in C. I have