sdl

Is there an acceptable limit for memory leaks?

孤街醉人 提交于 2019-12-03 06:53:52
问题 I've just started experimenting with SDL in C++, and I thought checking for memory leaks regularly may be a good habit to form early on. With this in mind, I've been running my 'Hello world' programs through Valgrind to catch any leaks, and although I've removed everything except the most basic SDL_Init() and SDL_Quit() statements, Valgrind still reports 120 bytes lost and 77k still reachable. My question is: Is there an acceptable limit for memory leaks, or should I strive to make all my

Creating an OpenGL 3.2/3.x context in SDL 1.3

故事扮演 提交于 2019-12-03 06:17:45
I'm facing a problem where SDL says it does not support OpenGL 3.x contexts. I am trying to follow this tutorial: Creating a Cross Platform OpenGL 3.2 Context in SDL (C / SDL) . I am using GLEW in this case, but I couldn't get gl3.h to work with this either. This is the code I ended up with: #include <glew.h> #include <SDL.h> int Testing::init() { if(SDL_Init(SDL_INIT_EVERYTHING) < 0) { DEBUGLINE("Error initializing SDL."); printSDLError(); system("pause"); return 1; // Error } //Request OpenGL 3.2 context. SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); SDL_GL_SetAttribute(SDL_GL

SDL embed image inside program executable

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-03 06:08:20
问题 Is it possible to embed an image within a program using SDL which can be used at run time. For example, I have a program which brings up a splash screen on startup containing the logo and copyright information. Rather than having this image in a bitmap file and using SDL_LoadBMP to load it to a SDL_Surface. I would like to have the image embedded in the program binary, to stop someone potentially changing the splash image and copyright name. Does anyone have any suggestions on ways to do this

Keep window active while being dragged (SDL on Win32)

倖福魔咒の 提交于 2019-12-03 06:05:07
At first my code set up the SDL environment, and proceeded to update the OpenGL context, without performing any SDL_Event processing whatsoever. This causes the window, as long as it was open, to appear to Windows to be unresponsive. The window flickers a bit. The titlebar would get "(Not Responding)" appended to it, and upon clicking inside the window it becomes grayed out, as Windows does this by default on non responsive windows. However in this state (even as and after it becomes grayed out), the OpenGL display continues to update and animate, and here's the kicker, it even does so while

SDL_PollEvent vs SDL_WaitEvent

六眼飞鱼酱① 提交于 2019-12-03 05:47:27
问题 So I was reading this article which contains 'Tips and Advice for Multithreaded Programming in SDL' - https://vilimpoc.org/research/portmonitorg/sdl-tips-and-tricks.html It talks about SDL_PollEvent being inefficient as it can cause excessive CPU usage and so recommends using SDL_WaitEvent instead. It shows an example of both loops but I can't see how this would work with a game loop. Is it the case that SDL_WaitEvent should only be used by things which don't require constant updates ie if

SDL 1.3/2.0 setting up

六眼飞鱼酱① 提交于 2019-12-03 05:37:17
I have been using sdl 1.2 for the past several months(On windows).I am thinking about migrating to 1.3. So I used cmake and codeblocks to create the static and dynamic libray.now I am confused how to compile the a program.I included the sdl.h header..added the static library in the linker.But when I try to compile lots of undefined errors keep occuring: D:\using font\sdl_2test\main.c||In function 'SDL_main':| D:\using font\sdl_2test\main.c|9|warning: passing argument 6 of 'SDL_CreateWindow' makes integer from pointer without a cast| D:\GameDev\SDL-2.0\SDL-2.0.0-6799\include\SDL_video.h|405

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

╄→гoц情女王★ 提交于 2019-12-03 05:20:45
Using just a given SDL_Window* and SDL_Renderer*, how can I create and save a screenshot in SDL 2.0? Neil Flodin 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 in saveScreenshotBMP(string), SDL_GetError() - " << SDL_GetError() << "\n"; } else { unsigned

SDL / OpenGL: Implementing a “Loading thread”

不打扰是莪最后的温柔 提交于 2019-12-03 03:29:40
I currently try to implement a "Loading thread" for a very basic gaming engine, which takes care of loading e.g. textures or audio while the main thread keeps rendering a proper message/screen until the operation is finished or even render regular game scenes while loading of smaller objects occurs in background. Now, I am by far no OpenGL expert, but as I implemented such a "Loading" mechanism I quickly found out that OGL doesn't like access to the rendering context from a thread other than the one it was created on very much. I googled around and the solution seems to be: "Create a second

SDL2: Generate fully transparent texture

匿名 (未验证) 提交于 2019-12-03 02:56:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: How using SDL_CreateTexture create transparent texture? By default I'm creating texure with such code: SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888,SDL_TEXTUREACCESS_TARGET, x, y); And then I'm paining on this texture with redirecting output to this texture. However at the end what I want to render this on screen any (nonupdated) pixel is black. I have tried different ways with using of: SDL_RenderClear(_Renderer); or even with drawing and on created texture with painting transparent Rect with different blending modes but all I had

error: &#039;SDL init failure, reason is: No available video device&#039; when launching AVD

匿名 (未验证) 提交于 2019-12-03 02:52:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Hey guys, this is killing me. Every time I try to run my Android app in Eclipse, I'm getting the error: [2011-05-24 23:11:04 - app] Android Launch! [2011-05-24 23:11:04 - app] adb is running normally. [2011-05-24 23:11:04 - app] Performing droid.blah.app activity launch [2011-05-24 23:11:04 - app] Automatic Target Mode: launching new emulator with compatible AVD 'default' [2011-05-24 23:11:04 - app] Launching a new emulator with Virtual Device 'default' [2011-05-24 23:11:04 - Emulator] SDL init failure, reason is: No available video device I