sdl

My C++ OpenGL SDL program is not working as I expected

孤人 提交于 2019-12-12 10:04:37
问题 I have just started learning OpenGL and I am attempting to make a game of pong. I'm having trouble getting the paddle to appear on the screen and I can't fathom out why: I thought with this code it should appear in the top left corner and move when down and up keys are pressed. main.cpp - #include <SDL/SDL.h> #include <SDL/SDL_opengl.h> #include "classes.h" #include "functions.h" int main (int argc, char *argv[]) { init_everything(); PlayerPaddle paddle; bool quit = false; while( quit ==

Member initialization of a data structure's members

安稳与你 提交于 2019-12-12 09:09:04
问题 I just ran into an awkward issue that has an easy fix, but not one that I enjoy doing. In my class's constructor I'm initializing the data members of a data member. Here is some code: class Button { private: // The attributes of the button SDL_Rect box; // The part of the button sprite sheet that will be shown SDL_Rect* clip; public: // Initialize the variables explicit Button(const int x, const int y, const int w, const int h) : box.x(x), box.y(y), box.w(w), box.h(h), clip(&clips[CLIP

C calling function on contents of linked list

痴心易碎 提交于 2019-12-12 04:35:55
问题 I am using GLib to manage a linked list. I am declaring 2 structs and the placing them in a linked list as follows. Asteroid asteroid = {0,0,50,50,50} Asteroid asteroids = {0,0,200,200,50}; GList *asteroidList = NULL; asteroidList = g_list_append(asteroidList, &asteroid); asteroidList = g_list_append(asteroidList, &asteroids); Then i use the following function to traverse the list and calla function that draws the struct to the screen as a circle as follows void drawAsteroids(){ GList *list =

g++: No such file or directory?

放肆的年华 提交于 2019-12-12 04:03:20
问题 (On Linux, trying to set up SDL) I'm having a time with makefiles, I'm finding them hard to learn. Here is the error I'm getting. g++: error: game.exe: No such file or directory make: *** [game.exe] Error 1 Here is my makefile. (Any suggestions on making it better would be great. I've just kind of slapped together whatever I could find to work.) #Game Make file TARGET = game.exe OBJS = App.o\ App_OnInit.o\ App_OnEvent.o\ App_OnLoop.o\ App_OnRender.o \ App_OnCleanup.o\ SDL_CFLAGS := $(shell

Error when trying to run Kivy app with Python27: raise Exception('SDL2: Unable to load image')

痞子三分冷 提交于 2019-12-12 03:57:47
问题 I've been making a few Kivy apps and they work fine with Python34 but for some reason the suddenly stopped working with Python27, after nothing had even changed in the code. I've looked all over for a solution, and have tried adding things to the Path, uninstalling and reinstalling gstreamer, updating Python, updating kivy, updating dependences etc. and nothing has solved it! This is the output I get on the console: [WARNING ] [Image ] Unable to load image <C:\Python27\lib\site-packages\kivy

How to output multiple sounds with SDL?

心不动则不痛 提交于 2019-12-12 02:52:23
问题 I have a library to decode some audio data into PCM and it works fine with Alsa. I chose SDL to abstract the audio output because SDL is platform-independent. I rewrote it to use SDL to output the audio and it works. However, I want to output multiple sounds simultaneously and SDL only supports one sound per time. What should I do? I can use other audio library if it is free, lightweight and supports Linux, Windows XP and Android 2.3. EDIT: Instead of decoding the entire audio data and

SDL_GetKeyboardState not working

ε祈祈猫儿з 提交于 2019-12-12 02:46:38
问题 I am trying to make a controller for a game with SDL 2(didn't want to ask on gamedev since it is not a game issue directly) I use SDL_GetKeyboardEvent to see if the navigation arrows are being pressed but it apparently doesn't work, it is supposed to print a value 1 or -1 if one of those keys is pressed but it doesn't it just prints 0 even if I hold the key down for several seconds, it is like it doesn't detect that the key is being pressed. I searched all over the internet and this is how

Is there a 2D graphics API with both pixel perfect drawing and 2D hardware acceleration? [closed]

被刻印的时光 ゝ 提交于 2019-12-12 02:37:04
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . We are in the first stages of making a 2D game at the moment, which will focus on destructible environments and objects. However, we have already encountered serious problems with the choice of the right graphics API At the moment, we use SDL - but the problem we see with it is that it isn't really performant,

SDL doesn't compile in native enviroment

亡梦爱人 提交于 2019-12-12 01:52:05
问题 I'm trying to compile this piece of code with SDL #include <SDL.h> int main(int argc, char * argv[]){ return 0; } The file itself compiles fine with g++ -c main.cpp -ISDL/include But compiling with following command in cygwin using g++ g++ -o test main.o -lSDL2 -lSDL2main -L SDL/lib/x64 produces this huge error... it seems to me like a problem of SDL itself... $ g++ -o test main.o -lSDL2 -lSDL2main -L SDL/lib/x64 Warning: corrupt .drectve at end of def file SDL/lib/x64/SDL2main.lib(./x64

convert Cartesian width and height to Isometric

一世执手 提交于 2019-12-12 01:16:16
问题 I'm trying to create an Isometric game in the SDL graphics library. When you render in SDL you require a source rectangle and a destination rectangle. The source rectangle is the portion of the texture you have loaded that you wish to render and the destination rectangle is the area on the screen you are rendering to. Rectangles simply consist of 4 properties, X position, Y position, Width, and Height. Now say I have a Cartesian destination rectangle with these coordinates: X=20, Y=10, Width