Questions tagged [sdl-2]
For questions and issues regarding Simple DirectMedia Layer 2 (SDL2). If you're using SDL 1.2, use tag [sdl-1.2]. If you're questioning the library in general, use tag [sdl].
2,720
questions
0
votes
0
answers
8
views
How do I use SDL_UpdateTexture to update part of a texture
For context, I'm using FreeType2 and SDL2 for text rendering. I'm trying to create a "font atlas" (one texture containing all the necessary characters I need to render) and sampling that ...
0
votes
1
answer
19
views
capture double quote on KEYDOWN event with SDL2 in a locale independent way
I'm on Linux, but solution should work on Win and macOS too.
I want to capture 'double quote' on KEYDOWN event with SDL2.
I want to capture it in a locale independent way.
For example " is SHIFT+'...
0
votes
0
answers
37
views
How to include ft2build.h in SDL2 CMake project
I want to compile a CMake project using SDL2 and SDL_ttf library.
I copied "SDL_ttf.c" & "SDL_ttf.h" into my src folder.
(EDIT: removed it, see comments)
I also added this to ...
-1
votes
0
answers
43
views
I am using SDL2 with cpp. I am unable to load any image or Text on my window, even they are placed in the same directory
This is my program that will create window. All my image files or font files are placed inside the directory where the executable for given program is present. Still I face the same problem every time....
2
votes
1
answer
55
views
Link static C libraries with GoLink
I'm trying to make an SDL2 program with NASM and GoLink just for fun but I can't link SDL2main.a and SDL2 to my executable. I'm on a win64 architecture.
My main.asm
[bits 64]
extern ExitProcess
...
-1
votes
0
answers
40
views
sdl2, making enemy move slower
i have thiss program that im working on, its a game that i programmed in sdl2 c++, heres the code
#include <SDL.h>
#include <SDL_image.h>
#undef main
#include <iostream>
#include &...
0
votes
1
answer
65
views
Sprite movement in different screen resolutions are different [closed]
I'm making a 2D game in C and C++ using SDL2. I achieved device independent resolution using the SDL function SDL_RenderSetLogicalSize(renderer, logical_screen_width, logical_screen_height); Where ...
-1
votes
1
answer
56
views
Texture not displaying SDL2 [closed]
I'm trying to make a game in C++ with SDL2, and I can't even get a texture displaying. SDL_GetError() returns nothing.
I'm on a windows 10 pro using Visual Studio.
Here are my 3 files:
main.cpp
#...
0
votes
0
answers
24
views
How SDL_RenderFillRect handle alpha [closed]
It seems SDL_RenderFillRect does not limit alpha within rect provided
SDL_SetRenderDrawColor(gRenderer, 0, 0, 0, 0);
SDL_SetRenderDrawBlendMode(gRenderer, SDL_BLENDMODE_NONE);
SDL_RenderFillRect(...
1
vote
1
answer
92
views
SDL Image display slower then wanted
I want to use SDL2 to display a list of rgb values I have in memory to the screen. But my issue is that to update the screen for even a modestly sized image it takes a long time to preform.
On my ...
0
votes
0
answers
23
views
How to get no of lines with text wrapping with TTF_RenderText_Blended_Wrapped?
The function:
SDL_Surface * TTF_RenderText_Blended_Wrapped(TTF_Font *font,
const char *text, SDL_Color fg, Uint32 wrapLength);
renders the text and wraps it if its width exceed ...
0
votes
0
answers
37
views
SDL2 Undefined symbols for architecture arm64 (M1 Mac)
I have issue with SDL2 on mac now, I'm compiling using makefile with g++ -arch arm64 -std=c++14 -Wall -g, and link all .o and libSDL2*.a with a seperate rule.
The SDL2 is installed with homebrew with ...
0
votes
0
answers
55
views
Getting an error "This was 0x35" in C++ using SDL2
I'm trying to make a simple game engine in C++ and I keep getting a weird error that says "This was 0x35":
I'm using visual studio and SDL2 (although I use it more like SDL). When the error ...
0
votes
1
answer
24
views
CMake Config is Found, but I Cannot Link the Libraries: SDL2_image
I am trying to link against SDL2_image. When I installed sdl2_image, my system was provided with a:
/usr/lib/cmake/SDL2_image/sdl2_iamge-config.cmake
I am able to verify that my CMakeLists.txt does ...
0
votes
0
answers
40
views
Is there a way to render device memory in SDL_window without transferring it to the host?
So I'm crunching numbers with CUDA, and attempting to render the output as an image using SDL2. I am looking for the simplest method possible (in terms of readability) to render memory from the device ...
0
votes
1
answer
55
views
Are SDL's linker options mentioned in the official documentation?
I started using SDL2 library with Code::Blocks IDE under windows. I downloaded the binary files for mingw64 which I use to compile, and I Included the search directories in the Compiler and Linker ...
0
votes
0
answers
51
views
"Symbol(s) not found for architecture x86_64" when linking SDL on macOS? [duplicate]
I'm using an iMac (M1, macOS 12.4) and install the SDL library through brew and it gives me all the Headers and Libraries (libSDL2.a and libSDL2main.a and they are both X64). I move these into my ...
-1
votes
0
answers
42
views
CMAKE and SDL2 undefined reference [duplicate]
When I try to make a CMakeLists.txt look for SDL2 it can find the package and get the SDL2_LIBRARIES and SDL2_INCLUDE_DIRS.
The issue is when I try to compile and build my project that is dependent on ...
-3
votes
0
answers
23
views
undefined reference to 'WinMain@16' solution for oblivious [duplicate]
I am trying to set up SDL project, but unfortunatly I can not find a solution myself.
This is the code that im running:
#include <SDL.h>
int main(int argc, char ** argv)
{
bool quit = false;...
1
vote
0
answers
37
views
How to make a textbox (SDL2)
i would like to know how to create a textbox with SDL2, in C.
I can't figure something out. I've looked for gui libs for SDL2, but they are all written in C++. I've thought of using things like gtk, ...
0
votes
2
answers
70
views
Why does matching this function parameter seprately work, but not with guards. (Haskell)
So, I have been trying to use SDL to make a simple GUI. This is so that I start to understand how to use haskell. In this case, I was using https://github.com/palf/haskell-sdl2-examples/blob/master/...
-2
votes
0
answers
38
views
I'm getting a random intermittent black frame in an SDL2 C++ test that is just drawing shapes and sprites
I am getting random black frames while the program is running. It was created in SDL2 C++. These are some sliders that change the color of the block:
I've added code below.
int main(int, char**) {
...
0
votes
0
answers
89
views
rust : missmatch between given lifetimes and expected lifetimes
I want to make a sdl2 texture manager with bevys ECS but I am running into problems with lifetimes that I don't quite understand or know how to fix.
// the texturemanager a texturecreator to create ...
0
votes
1
answer
19
views
What is the IccProfChanged window event?
In SDL2, when a window is created and shown, the first event that bubbles up is IccProfChanged. I can't find what that event is - what does it mean?
-1
votes
0
answers
69
views
how to render sprites in a raycaster
I am following this tutorial, but using plain C99, SDL2, and SDL_image to create the engine; I have 60fps and no problems rendering the wallls, floor, and cieling. However, I cannot get sprites to ...
2
votes
1
answer
53
views
OpenGL texture from SDL Surface in Go
I'm using go-sdl2 and go-gl and I'm trying to create a gl texture from sdl surface. In C I would do that by calling glTexImage2D with surface->pixels as the last argument. In go-sdl, however, ...
2
votes
1
answer
66
views
SDL2: Why a figure "blinks"?
I'm trying to move a square in a rectangle in SDL, but when i launch it, the rectangle and the square "blinks" until I move the square with up, left, right or down. When the square moves, ...
0
votes
1
answer
48
views
C++ Voronoi styled tile map
I am trying to display map with Voronoi styled map tiles.
It is on 2d array, I set some steps to achieve it:
Divide 2d array map into equal sized squares (tile).
int map_width = 100, map_height = ...
-1
votes
0
answers
56
views
Failed to create window: SDL not configured with OpenGL/GLX support
I'm developing in C++ with NetBeans/CMake on Linux. The software builds but when running there is the following error:
Failed to create window: SDL not configured with OpenGL/GLX support
I've ...
0
votes
1
answer
49
views
Window closes only after clicking exit button multiple times?
When I try to exit the window by clicking the X at the top corner, the program wouldn't end and just continue running. Only after repeatedly clicking the X button, the window managed to close. Why is ...
0
votes
0
answers
55
views
Why does double buffering cause more lag and flickering when resizing the window, using OpenGL and SDL?
I'm using OpenGL and SDL to scale a software-rendered framebuffer of a fixed size (320x240) to the client window size while maintaining the ratio by putting black bars on each side if necessary.
When ...
0
votes
0
answers
29
views
Notification bar is not a part of window
There is a thin bar at the top of the phone screen's that shows battery and clock and notifications.
When I try to run my app in fullscreen, this bar is purely black, meaning if I paint the whole ...
1
vote
1
answer
116
views
Rust-SDL2: Is there a way to draw a singular pixel to screen?
I'm making a project in Rust-SDL2, and I'm not exactly sure how to draw an individual pixel to the window. I tried looking into sdl2::rect::Point, but the documentation is rather confusing for me.
-2
votes
1
answer
54
views
Make an sdl window not show up on the menubar
Im trying to make a widgets application in C with SDL2 and I've been wondering if there is anyway of making an SDL2 window not show up on the menu/window bar?
To hide something like this
Thanks!
0
votes
0
answers
39
views
void * can't be converted to GlobalSDL (Pointer)
Trying to compile some c++ code in Visual Studio I get the error mentioned in the title. The code with the error is taken from an example where it worked fine, but I can't find any differences from ...
0
votes
1
answer
47
views
SDL_SetWindowHitTest - callback & callback_data? (SDL 2.0.5)
Could someone please help me to understand what these two parameters are, and how to interact with/utilize them? The Wiki says that callback is a function - itself - what should the call of it be ...
0
votes
1
answer
51
views
Why is SDL2 creating a window without calling SDL_Init(flag)?
I am coding against SDL2 in C#. I decided to see what would happen when I try to create a window and not call SDL_Init. I still get a window, all the events - mouse movement, buttons, keys up/down, ...
1
vote
0
answers
32
views
How to get SDL error as integer, enum or something else, except string?
I was working on a project using SDL2 and C. When it opens images as SDL_Surface, sometimes when the filename provided is not an image, it would return error message saying that Unsupported image ...
0
votes
0
answers
66
views
how do i add variants as keys in a hashmap
im using the sdl2 rust crate and i want to add events to a hashmap
like in this code snipped
let event_hashmap : HashMap<sdl2::event::Event,i8> = Hashmap::new();
event_hashmap.insert(sdl2::...
0
votes
0
answers
30
views
SDL_SaveBMP and IMG_SaveJPG changing per pixel data, while IMG_SavePNG does not
I was working on a fun project which encoded your files to images. I used SDL2 for doing it. For this I create an SDL_Surface that has more pixels than the size of the file. I create a random offset. ...
0
votes
1
answer
40
views
How to determine if a channel has stopped playing a chunk in SDL2
I am trying to create footstep sounds in sdl2.
It plays fine but it ignores the sound that is already playing in the channel.
So when I move the player the footstep sound plays like a machine gun(it ...
0
votes
0
answers
15
views
long delay when using soupwebsocketconnection on some platform
I want to get an dual-way voice talk program using SDL_Audio and libsoup. I create an server and an client to build it.
The server create a SoupServer and add an websocket handler. The client create a ...
-1
votes
2
answers
54
views
I get oom kills after a while because I redraw an image evry frame
code:
#include"global.h"
#include"tools/entity.h"
#include"tools/input.c"
static const int width = 800;
static const int height = 600;
int main (int argc, char **argv)
{
...
0
votes
1
answer
58
views
Sdl2 window is either transparent or rendering whats behind it on arch linux
The code looks like this:
#include"global.h"
static const int width = 800;
static const int height = 600;
int main (int argc, char **argv)
{
SDL_Init(SDL_INIT_VIDEO);
// Create the ...
0
votes
0
answers
37
views
Call C++ Emscripten binded function with SDL2 in it from JS
I am struggling with running compiled c++ code. I want to call it from JS. The c++ code is below:
#include <stdio.h>
#include <iostream>
#include <vector>
#include <SDL2/SDL.h>
...
0
votes
2
answers
228
views
SDL.h No such file or directory in VSCode
I'm trying to add the relevant "-I"path_to_your_SDL_include_directory"" as outlined in several similar posts such as this one. I have tried three approaches;, adding it to tasks....
0
votes
1
answer
33
views
What am I missing to make this int to char conversion produce the intended effect?
I am making a game in SDL2, and I've decided to add an FPS counter. The number for the counter needs to update every second, and here's how I've accomplished that
bool updateFPS() {
if (...
-1
votes
1
answer
128
views
Cross compile SDL2 in C for Windows on Linux
I have an SDL2 program that I've been developing on Ubuntu that I'd like to compile for windows. Right now I compile and run it with a makefile like this:
OBJECTS = main.o text.o object.o vector.o ...
0
votes
1
answer
70
views
how to change the image when pressing the keyboard on sdl2
I have been working on this game using SDL2.0 and C and hit a snag. As title say, I want to make image change when users press the keyboard, but it doesn't work.So I want to konw where the code is ...