sdl-2

SDL2 Invalid renderer on SDL_GetWindowSurface and/or SDL_CreateRenderer on OSX

跟風遠走 提交于 2019-12-14 02:22:32
问题 So I've been playing around with SDL2 to see if it would suit my needs. I was following introductory examples (from lazyfoo mostly) and made a simple test. #include <stdio.h> #include <SDL.h> const int SCREEN_WIDTH = 640; const int SCREEN_HEIGHT = 480; int main(int argc, char const *argv[]) { /* The window handle */ SDL_Window* window = NULL; /* The surface contained in the window */ SDL_Surface* screen_surface = NULL; /* Init SDL */ if(SDL_Init(SDL_INIT_VIDEO) < 0) { printf("SDL could not

CMake and MinGW w64 and windows system libraries

瘦欲@ 提交于 2019-12-14 00:41:52
问题 I start to learn CMake. I want to build my application with SDL2 library using MinGW w64. I generate Makefiles and use mingw32-make for building my app. But my app doesn't execute without any messages (my OS is Windows 10). First about I thought that my app doesn't see it dependecies. I try to use DependencyWalker and figure out next. My app doesn't see libriries like API-MS-WIN-CORE-APIQUERY-L1-1-0.DLL API-MS-WIN-CORE-APPCOMPAT-L1-1-0.DLL API-MS-WIN-CORE-APPCOMPAT-L1-1-1.DLL API-MS-WIN-CORE

SDL2: saving image as png error

二次信任 提交于 2019-12-13 20:28:10
问题 I am trying to make a 2d-map editor. Now if my map is finish I want to save it. I tried this: IMG_SavePNG(SDL_GetWindowSurface(window), "C:/Users/<MY_NAME>/Desktop"); but nothing happens. No image get saved and also no error. Here is the creation of my window: SDL_Window* window = SDL_CreateWindow("Famonex", 100, 100, WINDOW_WIDTH, WINDOW_HEIGHT, SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE); Here are my includes: #include <SDL.h> #include <SDL_image.h> #include <SDL_mixer.h> 回答1: Damn I just

SDL2 two windows in different threads

↘锁芯ラ 提交于 2019-12-13 13:44:29
问题 I am trying to create a process with two windows. Each window has a different thread for drawing. The problem is that when I run the program, after a random amount of time something goes wrong and gives me a segmentation fault. Here is my code: main.cpp std::thread *thr1 = new std::thread(thread_func); std::thread *thr2 = new std::thread(thread_func); thread.cpp: Window *win = new Window(display_name, 1024, 768); Renderer *rend = win->CreateRenderer(); Texture *pic = new Texture(rend, path);

Can't access Buildroot staging libraries via ./configure when cross compiling. It fails on test compile.

主宰稳场 提交于 2019-12-13 10:47:45
问题 CASE 1 arm-linux-gcc -v hello.c ==> WORKS CASE 2 arm-linux-gcc -v -L/home/peter/igep2015/09Buildroot/buildroot-2016.02-TRY5/output/staging/usr/lib hello.c ==> DOESN'T WORK ERROR:ld.bfd: cannot find /usr/lib/libc_nonshared.a ERROR:ld.bfd: cannot find /lib/ld-linux.so.3 CASE 3 arm-linux-gcc -v --sysroot=/home/peter/igep2015/09Buildroot/buildroot-2016.02-TRY5/output/host/usr/armeb-buildroot-linux-gnueabi/sysroot/ hello.c ==>WORKS but says it is ignoring sysroot because it cannot find /usr

Displaying the rectangle using a for loop in SDL2 C

二次信任 提交于 2019-12-13 09:45:13
问题 I'm currently using a for loop to create 4 rectangles along the x-axis. When I run the program the image of the rectangle appears for a few millisecond before it disappears. Can you show me what I have to do in order for the image to display on the screen permanently. When I create individual rectangles it display's the image without vanishing. An example will be helpful. Thanks int main(){ int barrack1_xposition = 167,i=1; int cnt_barrack=0; SDL_Window *o = NULL; SDL_Renderer *r = NULL; SDL

Why does my working directory change to C:\Windows\System32 when I use a Console subsystem

半世苍凉 提交于 2019-12-13 07:59:26
问题 I'm using SDL in VS2013 and I'm trying to load an image from the folder that my working directory should be using a relative path. Which is where the .vcxproj files are. However I discovered that the working directory is not the folder it should be, it is actually in C:\Windows\System32. I have realised that this is only the case when I go to linker, system and then change the subsystem to CONSOLE. In a WINDOWS subsystem it uses the correct working directory. Why is this happening and how do

Undefined reference to sdl_function Android Studio

旧时模样 提交于 2019-12-13 07:57:26
问题 I am trying to run my sd l game on Android, I followed lazyfoo's tutorial to run the helloworld , which worked fine, later I imported my project, this project source works fine in windows without any error, but I am now seeing many errors in my files, I am new to android , I feel I have messed up with path's to my source files. below is the error: Android.mk (inside src dir): LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := main SDL_PATH := ../SDL2 LOCAL_C_INCLUDES := $

SDL - invalid texture error on SDL_DestroyTexture()

本秂侑毒 提交于 2019-12-13 05:01:55
问题 I'm making a small "retro-style" 2D platformer game with SDL in C++. I figured that the best way to keep the game at a low resolution, while allowing people with different size monitors to stretch the game window to fit their setup, would be to render everything to a low-res texture and then render that texture to the whole window (with the window size/resolution set by the user). When I run this setup, the game works exactly as it should and renders fine (in both fullscreen and windowed

SDL Init slows the program while code is correct and has run perfectly before

强颜欢笑 提交于 2019-12-13 03:49:27
问题 I have a SDL2 program that works perfectly. But from time to time, when I compile, execute and close several times my program, it slows drastically when calling SDL_Init(). I can still see my console, but it is just very slow and needs 5 minutes to resume. It happens when I use "SDL_INIT_EVERYTHING" as a flag. But after 5 minutes, it runs the program smoothly. But when I use "SDL_INIT_VIDEO | SDL_INIT_EVENTS" as a flag, the program freezes when calling SDL_PollEvent() instead of SDL_Init(). I