sdl

C++ union assignment, is there a good way to do this?

一个人想着一个人 提交于 2019-12-23 21:14:40
问题 I am working on a project with a library and I must work with unions. Specifically I am working with SDL and the SDL_Event union. I need to make copies of the SDL_Events, and I could find no good information on overloading assignment operators with unions. Provided that I can overload the assignment operator, should I manually sift through the union members and copy the pertinent members or can I simply come some members (this seems dangerous to me), or maybe just use memcpy() (this seems

Why do certain situations require the use of 'bitwise' operators instead of 'logical' / 'equality' operators?

喜夏-厌秋 提交于 2019-12-23 20:58:59
问题 The other day I was trying to code a small C++ programming using the SDL multimedia library, and I ran into this small snag which I eventually solved through trial and error. The issue is, I understand what I did to solve the problem, but I don't really understand the nature of the problem! The issue was with keyboard event handling in SDL. The code to handle a single key press to exit the program is straight forward and simple. [eventQueue is an SDL_Event structure] //checks for keypress

Why do images loaded to texture with IMG_Load in SDL and OpenGL look bluish?

半世苍凉 提交于 2019-12-23 17:09:13
问题 I'm loading a PNG texture with: void Sprite::setTexture(string f) { SDL_Surface *image = IMG_Load(f.c_str()); if (image == NULL) { this->texture = -1; return; } SDL_DisplayFormatAlpha(image); unsigned object(0); glGenTextures(1, &object); glBindTexture(GL_TEXTURE_2D, object); glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP_TO_EDGE); glTexParameterf(GL

Fully transparent windows in Pygame?

泄露秘密 提交于 2019-12-23 09:09:29
问题 Is it possible to get a fully transparent window in Pygame (see the desktop through it)? I've found how to create a window without a frame, but there doesn't seem to be any obvious way to make it transparent. I'd be willing to tie into system-specific technology/frameworks as long as there are solutions for both Windows and Mac OS X, but I'm not sure which direction to be looking. The only topic I was able to find recommended using wxPython, which isn't something I can do for this particular

C++ error, Calling a class member from a function

一曲冷凌霜 提交于 2019-12-23 04:52:06
问题 I Need help... desperately. I am working on building a game, and I get a compiling error apply_surface was not declared in this scope. the error is in line 95 , in the function User::show() . I don't know what I am doing wrong. EDIT: Now that it is fized, the image "penis", is not showing up on the screen. sorry for the edit. /*This source code copyrighted by Lazy Foo' Productions (2004-2013) and may not be redistributed without written permission.*/ //The headers #include "SDL/SDL.h"

C++ SDL segmentation fault

ぐ巨炮叔叔 提交于 2019-12-23 04:36:49
问题 I had my game working and then decided to try and implement a menu using the following tutorial. I did not use the tutorial to create the game that was in prior tutorials that he created. Whenever I compile and run the program it loads briefly, then closes and says Process terminated with status 3 (0 minutes, 1 seconds) in the build log of code::blocks . UPDATE: I have updated the code for the pastebin link to what I have now, the error I am now getting from the debugger is Program received

Cannot display YUV Overlay on SDL_Surface

帅比萌擦擦* 提交于 2019-12-23 04:33:15
问题 I want to modify ffplay by hiding its SDL video player window. Rather, I want to grab the overlay as pixel-by-pixel bitmaps to be used elsewhere in my program. Now ffplay can be simplified as below: Create SDL_Surface *screen from SDL_SetVideoMode() Create SDL_Overlay *bmp from SDL_CreateYUVOverlay() and associate it with screen repeat until video ends Decode movie frames and populate bmp Render bmp onto screen using SDL_DisplayYUVOverlay() Following hints from this article, I have replaced

SDL Help. Xcode. Build and Run Error

穿精又带淫゛_ 提交于 2019-12-23 03:38:14
问题 I have been going off of this tutorial http://www.noquarterarcade.com/xcode-sdl-development-setup So, I have downloaded both the SDL Runtime Library and the SDL Development Library and put their content in the specified folders. I have made sure that have followed these steps correctly. However, when I click build and run I get an error and 2 warning. Error: 1) Command/Developer/usr/bin/gcc-4.2 failed with exit code 1 Warnings: 1) Directory'/Users/RustyShackleford/Library/Frameworks'

SDLNet Networking Not Working

て烟熏妆下的殇ゞ 提交于 2019-12-23 01:44:34
问题 I am working on a game written in C using SDL. Given that it already uses SDL, SDL_image, and SDL_ttf, I decided to add SDL_mixer and SDL_net to my engine. Getting SDL_mixer set up and working was very easy, but I am having a lot of trouble with SDL_net. To test I created a very simple application with the following rules: Run without arguments act as a TCP server on port 9999 Run with an argument try to connect to the server at the given IP address on port 9999 Here are some of the key lines

Efficient conversion from SDL_Surface to QPixmap

余生长醉 提交于 2019-12-22 18:48:25
问题 I need to extract pixel information and populate a QPixmap to be used in my Qt program. I am currently doing this in a 2-step process. SDL_Surface to Windows .bmp using SDL_SaveBMP() .bmp to QImage QImage to QPixmap I am storing the intermediate .bmp in memory. But overall, I am not happy with this approach because it involves file-format conversion overheads related to .bmp Any better suggestion? Edit: Sharing the final working code, from jrok's answer plus experimenting with pixel formats