sdl

Proper way to scale an SDL Surface without clipping?

给你一囗甜甜゛ 提交于 2019-12-01 01:10:03
问题 what is the proper way to scale an SDL Surface? I found one explanation online but it required redrawing the Surface pixel by pixel. It seems like there should be some way of doing this natively through SDL rather than redrawing the image like that. I haven't been able to find anything in the SDL documentation that covers this. I am able to resize surfaces without any problem by modifying the surfaces width and height, but the resulting surface is clipped. 回答1: SDL doesn't support scaled

A way to make keyboard event queue both responsive and not take whole CPU power

时间秒杀一切 提交于 2019-11-30 22:15:49
I am making an Sdl game, it's 2d shooter. I am using SDL to import surfaces and OpenGL to draw them on the screen (doing so because it works way faster than just SDL). I've got two threads running, one for processing stuff and rendering, and another one for input. Basically, the processing one is taking 1-2% of my CPU, while the input loop takes 25% (on quad-core, so it's 1 full core). I tried doing SDL_Delay(1) before each while (SDL_PollEvent(&keyevent)) and it works! Reduces CPU load to 3% for whole process. However, there's a nasty side effect. The whole program input is handicapped: it

How can I move the camera correctly in 3D space?

ぃ、小莉子 提交于 2019-11-30 21:08:24
What I want to do: I am trying to figure out how to make the camera work like this: Mouse movement: camera rotates Up/Down key: camera moves forward/backwards; forward means the direction the camera is facing Left/Right key: camera moves sideways Q/E key: camera moves up and down Since I have a lot of code, I will do my best to try to explain how I did it, without too much code. The project I'm working on is very large, and has a pretty big library with many classes and types that would make it hard to understand. The problem I have managed to almost get this working, however after moving

Undefined reference to WinMain@16 when using SDL

冷暖自知 提交于 2019-11-30 18:52:05
I've been having a lot of trouble getting everything working so that I can start developing on Windows, as apposed to Linux, which is what I normally use when coding. I'm having a rather bizarre issue when trying to compile an SDL program. As soon as I include the SDL library, the program refuses to compile, giving me this error: c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../libmingw32.a<main.o>: In function 'main': C:\MinGW\msys\1.0\src\mingwrt/../mingw/main.c:73: undefined reference to 'WinMain@16' collect2: ld returned 1 exist status I am using MinGW on console. To give an example, using

How do I draw text using OpenGL, SDL and C++?

喜你入骨 提交于 2019-11-30 18:35:19
I heard about SDL_TFF which I read about here but I don't understand how am I supposed to connect the TrueType2 library. Maybe there is something better out there? I came across this great guide on linking in SDL extensions for those new to SDL, which you may find useful. That said, when I had your problem, I eventually went with FTGL as the way SDL-ttf produces an SDL-Surface with its font rendered on it overcomplicated matters in my situation. This may not be the case in your situation though 来源: https://stackoverflow.com/questions/52431/how-do-i-draw-text-using-opengl-sdl-and-c

Unable to link to SDL2 functions using MinGW

爱⌒轻易说出口 提交于 2019-11-30 17:44:49
I'm relatively new to programming and I've decided to give SDL a try, but I'm a bit stuck. I haven't been able to build the project in codeblocks and I get 'undefined reference' to all SDL functions. I've seen a lot of similar questions here, but none of the solutions seems to help. I've already added the \include\SDL2 and the \lib folders to search directories, I've added SDL2Main and SDL2 to link libraries in linker options, I've even added -mwindows to other linker options. Also, I tried linking against the 64-bit version as well, but things got even worse. Here's my source code, pretty

A way to make keyboard event queue both responsive and not take whole CPU power

寵の児 提交于 2019-11-30 17:28:03
问题 I am making an Sdl game, it's 2d shooter. I am using SDL to import surfaces and OpenGL to draw them on the screen (doing so because it works way faster than just SDL). I've got two threads running, one for processing stuff and rendering, and another one for input. Basically, the processing one is taking 1-2% of my CPU, while the input loop takes 25% (on quad-core, so it's 1 full core). I tried doing SDL_Delay(1) before each while (SDL_PollEvent(&keyevent)) and it works! Reduces CPU load to 3%

Printf is not printing anything to output? C++ SDL

我的未来我决定 提交于 2019-11-30 14:54:24
问题 I am trying to use "printf" in my Visual C++ project however it is not working. Using Lazy Foo's tutorial, I set up SDL in my project, but when I play it, printf doesnt do anything. #include "SDL.h" #include <stdio.h> int main( int argc, char* args[] ) { printf("Testing"); return 0; } The output looks like this: The program '[4664] SDL Testing.exe: Native' has exited with code 0 (0x0). And that's about it. What could be wrong? 回答1: SDL by default redirects stdout to a file, stdout.txt . You

软件系统发展演变过程

為{幸葍}努か 提交于 2019-11-30 13:49:04
1、引言 “以铜为镜,可以正衣冠;以古为镜,可以知兴替;以人为镜,可以明得失。”,知道历史,明白为什么会出现这些问题,历史上又是如何解决这些问题,现在还存在哪些问题。在学习某个知识点的时候也是如此。 在学习的路上总是会让人盲目,大家都说好,那就是好,套以现成,拿以卖弄,问不知所以然,贻笑大方。学习需要深入,学习一个技术,要知道技术的历史交替、兴衰胜败,然后分析,理解,总结,完善。 2、发展历程 上图由上而下的顺序就是软件架构的发展历程。 结构化 几乎每个程序员最初学习变成语言的时候写的都是结构化代码 public class Demo { public static void main(String[] args) { int a = 1; String b = "hello"; System.out.println(b); for (int i = 0; i < 3; i++) { if (i == a) { System.out.println(b); } } } } 唯一入口main方法,自上而下顺序执行,定义变量,循环,判断,得到结果,结束。 结构化架构就是如此,分为多个模块互相独立,其中一个是入口模块(main),其中操作就是其他子模块(方法),入口模块调用子模块的方式运行。 但是在日益复杂的需求下,这种架构很难满足,但是并非被淘汰,因为结构简单,并且独立

Printf is not printing anything to output? C++ SDL

老子叫甜甜 提交于 2019-11-30 12:11:05
I am trying to use "printf" in my Visual C++ project however it is not working. Using Lazy Foo's tutorial, I set up SDL in my project, but when I play it, printf doesnt do anything. #include "SDL.h" #include <stdio.h> int main( int argc, char* args[] ) { printf("Testing"); return 0; } The output looks like this: The program '[4664] SDL Testing.exe: Native' has exited with code 0 (0x0). And that's about it. What could be wrong? SDL by default redirects stdout to a file, stdout.txt . You should find it in your program's working directory. Bring up the projects properties, go to linker->system-