sdl-2

Memory leak SDL while using SDL_CreateTextureFromSurface

試著忘記壹切 提交于 2019-12-02 05:35:13
I'm learning SDL and I've noticed that I have memory leak when I have this line in my code: m_TextureMap["napis"]= SDL_CreateTextureFromSurface( getRenderer(), textSurface ); I have SDL_FreeSurface(textSurface); right after the first one. When I comment out only this line, there's no memory leak. What am I doing wrong? Is there anything else I need to clean except for SDL_FreeSurface(textSurface) ? P.S. getRenderer is function that returns global SDL renderer, I use this function a lot in other places and I'm sure it doesn't cause leak. m_TextureMap is just a map where I store textures

SDL - window doesn't show anything

橙三吉。 提交于 2019-12-02 05:09:54
问题 I'm doing my first steps in SDL (C++) an took some tutorials from the www. But there is one problem. I have installed SDL2 on my Linux Mint System, compiled the tutorial code: #ifdef __cplusplus #include <cstdlib> #else #include <stdlib.h> #endif #include <stdio.h> #include <SDL2/SDL.h> #include <iostream> int main ( int argc, char** argv ) { if (SDL_Init(SDL_INIT_EVERYTHING) != 0){ std::cout << "SDL_Init Error: " << SDL_GetError() << std::endl; return 1; } SDL_Window *win = SDL_CreateWindow(

Receiving undefined references to various Windows libraries when compiling with SDL 2 and -static?

我的梦境 提交于 2019-12-02 03:20:25
问题 I'm working on a modification of the Wolfenstein 3D engine in SDL2 (using Wolf4SDL as a base) and I've run into a problem - when using -static in the linker options, I get a large variety of undefined references to various things. Here's my build log to show what I mean: -------------- Build: Debug in Lazarus (compiler: GNU GCC Compiler)--------------- i686-w64-mingw32-g++.exe -LC:\SDL2\lib -o Lazarus.exe .objs\alu_cache.o .objs\alu_dbg_mem.o .objs\alu_gfx.o .objs\alu_hud.o .objs\alu_in.o

undefined reference to `WinMain' : When using Cygwin, SDL2 and Netbeans

本秂侑毒 提交于 2019-12-02 03:07:57
问题 any help here would be appreciated. Ive really racked my brains at this, sooo. I have installed cygwin, and Netbeans and have been successfully deving, compiling and running a small SDL-1.2 windows game with no problems. The problem has come now that I have installed SDL2 and am trying to compile. Specifically the linking. Im doing the same as before, adding "libSDL2.a" and "libSDL2main.a" to the linker options for my project in Netbeans; but im getting the "undefined reference to `WinMain'"

SDL - window doesn't show anything

我的未来我决定 提交于 2019-12-02 01:27:22
I'm doing my first steps in SDL (C++) an took some tutorials from the www. But there is one problem. I have installed SDL2 on my Linux Mint System, compiled the tutorial code: #ifdef __cplusplus #include <cstdlib> #else #include <stdlib.h> #endif #include <stdio.h> #include <SDL2/SDL.h> #include <iostream> int main ( int argc, char** argv ) { if (SDL_Init(SDL_INIT_EVERYTHING) != 0){ std::cout << "SDL_Init Error: " << SDL_GetError() << std::endl; return 1; } SDL_Window *win = SDL_CreateWindow("Hello World!", 100, 100, 640, 480, SDL_WINDOW_SHOWN); if (win == NULL){ std::cout << "SDL_CreateWindow

Receiving undefined references to various Windows libraries when compiling with SDL 2 and -static?

孤街浪徒 提交于 2019-12-02 00:45:53
I'm working on a modification of the Wolfenstein 3D engine in SDL2 (using Wolf4SDL as a base) and I've run into a problem - when using -static in the linker options, I get a large variety of undefined references to various things. Here's my build log to show what I mean: -------------- Build: Debug in Lazarus (compiler: GNU GCC Compiler)--------------- i686-w64-mingw32-g++.exe -LC:\SDL2\lib -o Lazarus.exe .objs\alu_cache.o .objs\alu_dbg_mem.o .objs\alu_gfx.o .objs\alu_hud.o .objs\alu_in.o .objs\alu_me_core.o .objs\alu_me_gui.o .objs\alu_me_symbols.o .objs\alu_me_textinput.o .objs\alu_me_tools

SDL 2.0 Key repeat and delay

冷暖自知 提交于 2019-12-02 00:01:05
I'm having a problem with SDL 2.0 keyboard input in pong-like game. When I order to move to the left by pressing left arrow, it is processed by SDL_PollEvents() and responds correctly if the key was pressed once. However, if I keep the key pressed, I get a short delay (as long as Windows key repeat delay) before moving continuously. Here is function processing events: void Event::PlayerEvent (Player &player) { while (SDL_PollEvent (&mainEvent)) { switch (mainEvent.type) { case SDL_KEYDOWN : switch (mainEvent.key.keysym.sym) { case SDLK_ESCAPE : gameRunning = false; break; case SDLK_LEFT :

SDL 2.0 won't initialize. Error: “Failed to connect to the Mir Server”

柔情痞子 提交于 2019-12-01 22:36:52
问题 I am running Ubuntu 14.04, and using Eclipse CDT. In my program, I am trying to initialize SDL and if it doesn't initialize then output the error, but SDL_GetError() returns "Failed to connect to the Mir Server". I am sure SDL is installed correctly since I can successfully initialize SDL on another project. These are the libraries I am using: http://i.imgur.com/SS1mjzQ.png #include <SDL2/SDL.h> #include <iostream> int main(int argc, char* args[]) { if(SDL_Init(SDL_INIT_EVERYTHING) < 0) { std

SDL event handling not working

别等时光非礼了梦想. 提交于 2019-12-01 21:27:07
I'm currently learning SDL by reading Lazy foo tutorials. I'm using code blocks 13.12 on Linux. I'm unable to get event handling to work correctly. I'm basically trying to display an image (which works great), but no matter how many times I click on the close button, it won't close Code: #include <SDL2/SDL.h> #include <stdio.h> //Declaring the main window, the main surface and the image surface SDL_Window *window = NULL; SDL_Surface *scrsurface = NULL; SDL_Surface *imgSurface = NULL; SDL_Event event; int run = 1; //The function where SDL will be initialized int init(); //The function where the

SDL 2.0 won't initialize. Error: “Failed to connect to the Mir Server”

百般思念 提交于 2019-12-01 21:12:27
I am running Ubuntu 14.04, and using Eclipse CDT. In my program, I am trying to initialize SDL and if it doesn't initialize then output the error, but SDL_GetError() returns "Failed to connect to the Mir Server". I am sure SDL is installed correctly since I can successfully initialize SDL on another project. These are the libraries I am using: http://i.imgur.com/SS1mjzQ.png #include <SDL2/SDL.h> #include <iostream> int main(int argc, char* args[]) { if(SDL_Init(SDL_INIT_EVERYTHING) < 0) { std::cout << SDL_GetError() << std::endl; } return 0; } bash$ export DISPLAY=:0 Setting the DISPLAY run