sdl-2

How to render fonts and text with SDL2 efficiently?

本小妞迷上赌 提交于 2019-12-17 22:47:03
问题 Saw this post here about using SDL_ttf to render text in a game. However that approach requires calling SDL_CreateTextureFromSurface(), along with the SDL_FreeSurface() and SDL_DestroyTexture() every single frame. Is creating textures (and probably subsequently having to send them to the GPU) every frame something that can significally impact my performance? would it be wiser to use SDL_ttf only to create a texture with my whole rendered charset and then to blit from there myself, character

Static-linking of SDL2 libraries

别等时光非礼了梦想. 提交于 2019-12-17 22:16:50
问题 I am using Windows 7, Code::Blocks and MinGW. I have little to no experience when it comes to compiling/building anything, especially when Code::Blocks doesn't use makefiles. I downloaded SDL2-devel-2.0.0-mingw.tar.gz (SDL Development Libraries) from http://www.libsdl.org/tmp/download-2.0.php, and I'd like to create a standalone executable using SDL2 libraries, but so far I've always had to bundle the SDL2.dll file with the executable to make it work. I've heard that I can not static-link

SDL2: LNK1561: entry point must be defined

限于喜欢 提交于 2019-12-17 18:33:56
问题 I want to compile this code: #include <SDL.h> int main(int argc, char* argv[]) { return 0; } But it can't be linked: Error 1 error LNK1561: entry point must be defined There is some strange code in this library: http://hg.libsdl.org/SDL/file/75726efbf679/include/SDL_main.h #define main SDL_main Also I added SDL2.lib;SDL2main.lib to Project Settings => Linker => Input. What can I do to run this project? VS 2012 SP3, empty C++ project. 回答1: According to this thread on Dream.In.Code: Right click

SDL2 program only works if Renderer is created with SDL_RENDERER_SOFTWARE

独自空忆成欢 提交于 2019-12-17 17:15:18
问题 I've written a program using C++ and SDL2 which: creates a window gets the window's surface creates a renderer for the window renders some filled rectangles onto the window creates a texture from the window's surface clears the screen renders some filled circles onto the window creates a second texture from the window's surface enters an event loop, where every time a key is pressed: if circles are currently being displayed, SDL_RenderCopy() is used to copy the squares texture to the window.

What is an SDL renderer?

怎甘沉沦 提交于 2019-12-17 14:58:59
问题 I'm starting with SDL2 and having some trouble trying to understand what an SDL_Renderer is. What is it? What does it do? What's the difference between SDL_Renderer, SDL_Window, SDL_Surface and SDL_Texture and how they are related? I had issues with this when trying to understand this introductory code: #include <iostream> #include <SDL2/SDL.h> int main() { /* Starting SDL */ if (SDL_Init(SDL_INIT_EVERYTHING) != 0) { std::cout << "SDL_Init Error: " << SDL_GetError() << std::endl; return 1; }

Kivy error (python 2.7) : sdl2 import error

妖精的绣舞 提交于 2019-12-17 14:56:49
问题 I'm trying to use kivy on my Python 2.7 project (in a PyCharm - Windows 10 environment), but I get the following error. If someone can help me ? Thanks ! PS : I tried many times uninstalling/reinstalling libraries etc and doing what suggested on posts like this one, but it doesn't work : Kivy not working (Error: Unable to find any valuable Window provider.) [INFO ] [Logger ] Record log in C:\Users\cyril\.kivy\logs\kivy_18-03-25_0.txt C:\Users\cyril\venv\lib\site-packages\kivy\modules\__init__

How to use SDL2 and SDL_image with cmake

让人想犯罪 __ 提交于 2019-12-17 06:38:10
问题 I'm looking for the simplest way to compile a c++ program using SDL2 and SDL_image with cmake. Here is my best attempt, after hours of searching: CMakeLists.txt project(shooter-cmake2) cmake_minimum_required(VERSION 2.8) set(SOURCES shooter.cpp classes.cpp utils.cpp ) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") add_executable(${PROJECT_NAME} ${SOURCES}) INCLUDE(FindPkgConfig) PKG_SEARCH_MODULE(SDL2 REQUIRED sdl2) PKG_SEARCH_MODULE(SDL2_image REQUIRED sdl2_image) INCLUDE_DIRECTORIES($

unresolved external symbol __imp__fprintf and __imp____iob_func, SDL2

心不动则不痛 提交于 2019-12-16 23:57:52
问题 Could someone explain what the __imp__fprintf and __imp____iob_func unresolved external means? Because I get these errors when I'm trying to compile: 1>SDL2main.lib(SDL_windows_main.obj) : error LNK2019: unresolved external symbol __imp__fprintf referenced in function _ShowError 1>SDL2main.lib(SDL_windows_main.obj) : error LNK2019: unresolved external symbol __imp____iob_func referenced in function _ShowError 1>E:\Documents\Visual Studio 2015\Projects\SDL2_Test\Debug\SDL2_Test.exe : fatal

unresolved external symbol __imp__fprintf and __imp____iob_func, SDL2

蹲街弑〆低调 提交于 2019-12-16 23:56:32
问题 Could someone explain what the __imp__fprintf and __imp____iob_func unresolved external means? Because I get these errors when I'm trying to compile: 1>SDL2main.lib(SDL_windows_main.obj) : error LNK2019: unresolved external symbol __imp__fprintf referenced in function _ShowError 1>SDL2main.lib(SDL_windows_main.obj) : error LNK2019: unresolved external symbol __imp____iob_func referenced in function _ShowError 1>E:\Documents\Visual Studio 2015\Projects\SDL2_Test\Debug\SDL2_Test.exe : fatal

Interpreting valgrind output for a C++/SDL2 program

北慕城南 提交于 2019-12-14 03:22:30
问题 Hi can somebody please explain what this valgrind output means and how I should go about fixing this ?? The output I am posting currently is a part of the actual terminal output. The rest is also similar and mostly the same errors are listed. This is for a C++ program using SDL2. The relevant code is really long so I will add whatever is asked in comments. Is this happening due to some SDL_Surface* s? But I made sure to free all of those before returning from main(). Also, my SDL_Window* is