sdl

shared_ptr with incomplete types from library

大城市里の小女人 提交于 2019-12-14 01:41:48
问题 My problem is straightforward: I am using SDL to create a simple simulation and I want to store instances of TTF_Font type in smart pointers (shared_ptr), but I keep getting this error: "invalid application of ‘sizeof’ to incomplete type '_TTF_Font'" Is there any way to use smart pointers with incomplete types from external libraries without incorporating their source code into my program? EDIT: TTF_Font is declared as typedef struct _TTF_Font TTF_Font; _TTF_Font is in turn defined in

Xcode vs. Visual Studio - SDL C++

依然范特西╮ 提交于 2019-12-13 18:43:19
问题 I'm self learning programming using various online tutorials and a couple of books. Currently it's C++. I've done a bit of OpenGL and SDL in the last few days. I have a small program that creates a wall to stop a small square from passing through it. Here's my code: // // main.cpp // SDL_Template // // The headers #include <stdlib.h> #include <string> // SDL headers #include <SDL/SDL.h> #include "SDL_image/SDL_image.h" //#include "SDL/SDL_ttf.h" //#include "SDL/SDL_mixer.h" // Other headers

How to render a pixel array most efficiently to a window in c++?

北战南征 提交于 2019-12-13 15:23:10
问题 So far i have been using SDL 2.0, copy my pixel array into a texture which then gets rendered on the screen. My render method looks like this: for (int i = 0; i < WIDTH*HEIGHT; i++){ pixels[i] = 0xFFFF0000; //pixel Format: AARRGGBB } SDL_UpdateTexture(sdlTexture, NULL, pixels, 800 * sizeof(Uint32)); SDL_RenderClear(renderer); SDL_RenderCopy(renderer, sdlTexture, NULL, NULL); SDL_RenderPresent(renderer); I then measured the time it takes to render it once in nanoseconds (via chrono) and

SDL Mouse position Cropped after resize

老子叫甜甜 提交于 2019-12-13 14:15:16
问题 I'm getting some strange behaviour with the mouse position in SDL. If I re-size the window bigger, the x,y positions from either mouse events, seem to be restricted to the original window Width and Height. If there some function call that I'm missing to tell SDL that the mousing area has increased in size. The relevant parts of the app: void Resize(int width, int height) { WindowWidth = width; WindowHeight = height; /* update OpenGL */ } void Init() { glClearColor(0.f, 0.f, 0.f, 1.f); Resize

Alt-tab from fullscreen SDL

ぃ、小莉子 提交于 2019-12-13 14:13:59
问题 When I run a fullscreen window (C++ with SDL using the SDL_FULLSCREEN flag), alt-tab has no effect. Researching it, I only found posts of people having problems with it. Is there a way to do it consistently across different machines? (I'm running Ubuntu now, but I'd like portability) Does OpenGL handle this better? (considering switching) 回答1: SDL likes to XGrabKeyboard() when fullscreened on X11. This tends to lock out your window manager's hotkeys. Fix SDL or fix your window manager. 来源:

Pygame cannot find include file “sdl.h”

孤者浪人 提交于 2019-12-13 14:06:46
问题 I am trying to build a downloaded Python app on Windows that uses Pygame. I have installed Python 2.5 and Pygame 1.7.1. I am new to Python, but I just tried typing the name of the top level .py file on a Windows console command line. (I'm using Win XP Pro.) This is the message that I get. C:\Python25\include\pygame\pygame.h(68) : fatal error C1083: Cannot open include file: 'SDL.h': No such file or directory I thought that Pygame was built on top of SDL and that a separate SDL install was not

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);

Tiling System C++ SDL

爱⌒轻易说出口 提交于 2019-12-13 12:51:19
问题 I have been working on a tiling system for a video game I've been designing through C++ and SDL. The code is loosely based off of the tutorials available on lazyfoo.net, but with a different system to draw the tiles to the screen. The code works as follows: I have a class called Map that creates an array of another class called Tile . It also has a function called set_tiles that reads numbers from a .map file and copies them to the array of tile 's using two for loops; one for the x's and one

Creating an OpenGL 3.2/3.x context in SDL 1.3

故事扮演 提交于 2019-12-13 11:36:53
问题 I'm facing a problem where SDL says it does not support OpenGL 3.x contexts. I am trying to follow this tutorial: Creating a Cross Platform OpenGL 3.2 Context in SDL (C / SDL). I am using GLEW in this case, but I couldn't get gl3.h to work with this either. This is the code I ended up with: #include <glew.h> #include <SDL.h> int Testing::init() { if(SDL_Init(SDL_INIT_EVERYTHING) < 0) { DEBUGLINE("Error initializing SDL."); printSDLError(); system("pause"); return 1; // Error } //Request

Is it possible to write Tower Defense in C/SDL [closed]

孤者浪人 提交于 2019-12-13 11:27:00
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 6 years ago . I have to write Tower Defense game in ANSI C using SDL library, but the deeper I go into LazyFoo's tutorial, the more I got this