sdl

No stdout.txt with SDL

徘徊边缘 提交于 2019-12-01 17:46:52
问题 I'm working on a little game using C++ with SDL2 using Code::Blocks 12.11 under Windows 7. I'm using the mingw32-gcc compiler and downloaded the standard precompiled Windows distribution of SDL2 (2.0.1 now) and use the i686-w64-mingw32 version. So far stuff is working, I'm getting graphical output and the SDL_ttf extension works too. The only thing that has never worked from the beginning is getting my stdout in a txt file from SDL as intended: Regardless of what I do, I NEVER get stdout.txt

Cross-platform way of yielding a thread in C/C++?

孤人 提交于 2019-12-01 16:19:16
问题 In C and C++ is there a cross-platform way of yielding a thread? Something like sched_yield() or Sleep(0)? Does SDL_Delay(0) always yield or will it return immediately in some implementations? 回答1: Given that neither C nor C++ (up to C++98) has "threads," there is no fully cross-platform way for a thread to yield. In C++0x, there is a function std::this_thread::yield() that can be called to yield. That will be the portable way for a thread to yield, once people start using the C++0x threads

SDL_SaveBMP saves images upside down

南楼画角 提交于 2019-12-01 14:28:40
I have used SDL to save the window image via SDL_SaveBMP . The problem is that the saved image is upside down. The saved image is while it has to be How should I fix the code? screen_shot function: void screen_shot(std::string filename) { int width = glutGet(GLUT_WINDOW_WIDTH); int height = glutGet(GLUT_WINDOW_HEIGHT); SDL_Surface * image = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 24, 0x000000FF, 0x0000FF00, 0x00FF0000, 0); glReadBuffer(GL_FRONT); glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, image->pixels); SDL_SaveBMP(image, filename.c_str()); SDL_FreeSurface(image);

Installing SDL on OSX

三世轮回 提交于 2019-12-01 13:54:46
I downloaded SDL2-2.0.3 . I ran ./configure && make && make install . I've also tried brew install SDL2 . This is my main.c //Using SDL and standard IO #include <SDL2/SDL.h> #include <stdio.h> //Screen dimension constants const int SCREEN_WIDTH = 640; const int SCREEN_HEIGHT = 480; int main( int argc, char* args[] ) { SDL_Window* window = NULL; SDL_Surface* screenSurface = NULL; if (SDL_Init( SDL_INIT_VIDEO ) < 0 ) { printf( "SDL could not initialize! SDL_Error: %s\n", SDL_GetError() ); } } When I run it ~:.make main gcc main.c -o main Undefined symbols for architecture x86_64: "_SDL_GetError"

Installing SDL on OSX

我怕爱的太早我们不能终老 提交于 2019-12-01 13:52:39
问题 I downloaded SDL2-2.0.3 . I ran ./configure && make && make install . I've also tried brew install SDL2 . This is my main.c //Using SDL and standard IO #include <SDL2/SDL.h> #include <stdio.h> //Screen dimension constants const int SCREEN_WIDTH = 640; const int SCREEN_HEIGHT = 480; int main( int argc, char* args[] ) { SDL_Window* window = NULL; SDL_Surface* screenSurface = NULL; if (SDL_Init( SDL_INIT_VIDEO ) < 0 ) { printf( "SDL could not initialize! SDL_Error: %s\n", SDL_GetError() ); } }

OpenGL texture mapping stubbornly refuses to work

若如初见. 提交于 2019-12-01 13:13:12
I'm writing a 2D game using SDL and OpenGL in the D programming language. At the moment it simply tries to render a texture-mapped quad to the screen. Problem is, the whole texture-mapping part doesn't quite seem to work. Despite the texture apparently loading fine (gets assigned a nonzero texture number, doesn't cause glGetError to return values other than zero), the quad is rendered with the last color set in glColor, entirely ignoring the texture. I've looked for common reasons for texture mapping to fail, including this question , to no avail. The image file being loaded is 64x64, a valid

How to set up gl3w on Windows?

∥☆過路亽.° 提交于 2019-12-01 10:40:21
I was looking for a detailed guide to setting up Gl3w, since there are none anywhere I look! GigaBass First of all, download gl3w at https://github.com/skaslev/gl3w Then, download Python 3.x: https://www.python.org/downloads/ Next, run the script. It'll generate gl3w.c in the source folder, and gl3w.h and glcorearb.h in the include/GL/ folder. Take the three of them, and either add them directly to your project, or (easier to do the includes), move them into your project's source files folder, and add the 3 into the project. In your main source AND in your "gl3w.c" source, you want to change

2019ccpc哈尔滨打铜记

 ̄綄美尐妖づ 提交于 2019-12-01 09:02:44
小学生日记: 2019.10.13,哈尔滨,打了个铜 开头 先说结论, 这次失败,我的锅70%,sdl的锅5%,ykh25% Day0 周五, 我们队出现了奇怪的厄运上身 首先是我中途在飞机上数据线突然出现在前面座位上,下了飞机发现数据线丢了( 然后ykh的羽绒服被刮掉了一堆毛 后来sdl比赛的时候也一直激动地拉肚子上厕所 本来我是十分反对今天去吃东北菜的,但是还是架不住饿的诱惑,吃了 一盆 锅包肉 Day1 哈尔滨真的是冷的一笔,我们出发去东北林业大学 学校很大很豪华,风景很美 和女队一起报道完拍了照,就去学校食堂挂机等热身赛了 我队的特色一直是ykh从a读到z,sdl从z读到a,我有代码敲代码,无代码读最短的(毕竟六级没过) 热身赛开始,我先上机敲完了头文件,ykh此时看懂了A题并告诉了我 然后一通操作过掉A题,此时rank40+ 这个时候ykh和sdl都在看B,并且好像有哪一句话没有看懂,让我读一遍看看题意 我看了一遍居然直接看懂了并且脑子过了样例,跟队友讲了一遍就上机过了 此时rank大概铜首,问了下队友c题意,我直接说出了算法并且上机 这题细节有点多,我敲代码的时候出了不少问题,队友正在口胡d题 过了样例之后直接交就过了,此时大概rank仍然是40+ 然后讨论了一会d题发现不可做,就开始了愉快的吹b时间 此时sdl和我争论c题的出处,我就让他上机测试java以及各种c+

Rendering Glitch on Mac OSX El Capitan with OpenGL

不打扰是莪最后的温柔 提交于 2019-12-01 06:42:12
问题 I created a tennis game for OSX using SDL 1.2 + OpenGL 1.1 . Everything was ok till El Capitan. Now, a few textures aren't displayed correctly. The court white lines are now black ; the player textures are all bad ; the energy bars on the left are all black: The white lines on the icons aren't normal. The rainbow texture on the highlighted icon isn't either: How the game should normally looks: So the wrong textures are: the players : they are re-created in-game using different textures, using

2D Platformer Collision Problems With Both Axes

让人想犯罪 __ 提交于 2019-12-01 05:56:44
I'm working on a little 2D platformer/fighting game with C++ and SDL, and I'm having quite a bit of trouble with the collision detection. The levels are made up of an array of tiles, and I use a for loop to go through each one (I know it may not be the best way to do it, and I may need help with that too). For each side of the character, I move it one pixel in that direction and check for a collision (I also check to see if the character is moving in that direction). If there is a collision, I set the velocity to 0 and move the player to the edge of the tile. My problem is that if I check for