sdl

SDL with g++ on OSX Lion

半腔热情 提交于 2019-12-07 14:39:46
问题 Dose anyone know how to set up SDL (simple direct media layer) on OSX Lion so I can compile my code with g++ ? I have read the "readme" that comes with the package and I have placed the frameworks folder in the relevant directory, however, this does not seem to be enough. Can anyone help me ? (I do not want to use Xcode) 回答1: If you're not using XCode, and are compiling SDL projects using gcc , you can run: gcc -o test SDLTest.c `sdl-config --cflags --libs` g++ -o test SDLText.c `sdl-config -

Render TTF SDL2.0 opengl 3.1

回眸只為那壹抹淺笑 提交于 2019-12-07 13:59:58
问题 I'm working with SDL2.0, and using a (semi modern) opengl (3.1). I'm looking to add a text overlay to my application, and to render TTF in the application. How would I go about this using modern OpenGL? EDIT: As per the suggestion of genpfault, I've tried using the SDL_TTF library, but All I'm getting is garbage on screen http://i.stack.imgur.com/FqyCT.png I've attached a gist of my shaders, which are very simple for this program, and also the snipped I'm using to load the text into surface,

【备忘】2018年最新FFmpeg音视频教程视频

£可爱£侵袭症+ 提交于 2019-12-07 11:57:49
百度网盘 第一章 音视频行业的前景及应用场景 第二章 FFmpeg处理流程及常用命令 第三章 FFmpeg之C语言及VIM 第四章 FFmpeg之C语言基础 第五章 FFmpeg多媒体文件处理 第六章 FFmpeg编解码案例 第七章 FFmpeg SDL音视频渲染及PCM播放器开发 第八章 FFmpeg播放器核心功能开发 第九章 FFmpeg在Android的使用 第十章 FFmpeg在IOS下的使用 第十一章 知识点回顾及进阶建议 来源: oschina 链接: https://my.oschina.net/u/3797416/blog/2873594

How to draw a rectangle outline in SDL 2.0

别来无恙 提交于 2019-12-07 10:58:39
问题 I'm trying to draw a rectangle outline in SDL 2.0 in order to use as a selection box. Does anyone know how to make one in SDL 2.0? 回答1: You are looking for the SDL_RenderDrawRect: int SDL_RenderDrawRect(SDL_Renderer* renderer, const SDL_Rect* rect); Typical usage would be: SDL_Rect rectToDraw = {100,100,100,100} // Just some random rect //Set Color of Rect with SDL_SetRenderDrawColor if needed SDL_RenderDrawRect(renderer, &rectToDraw); To draw a filled rect it would then be with SDL

Game jump logic

我们两清 提交于 2019-12-07 08:26:59
问题 I am creating a 2D Mario game. The following function is intended to update a player's position when a particular key is pressed. The player is allowed to move left and right, and jump in the same place, or jump to the left or to the right (to form like an arc). bool updatePlayerPosition(Movement* mov){ if (this->keyPressed(SDLK_RIGHT)) { mov->applyForce(1); // Changes the velocity in X } if (this->keyPressed(SDLK_LEFT)) { mov->applyForce(-1); // Changes the velocity in X } if (this-

Getting SDL_ttf to play nice with SDL2

耗尽温柔 提交于 2019-12-07 08:20:49
问题 I've recently started migrating from using SDL (1.2.15) to SDL2 (2.0.0), and had previously depended on using the extension library SDL_ttf (2.0.11) to render fonts. When I try to use the same text library I used with version one SDL with SDL2 (admittedly not yet officially released), it compiles just fine. When I run the executable, though (I'm using VS2012 for Desktop at the moment), I get the following error: Unhandled exception at 0x6C7D8C24 (SDL2.dll) in test.exe: 0xC0000005: Access

libSDL, CMake and Mac OS X Lion

故事扮演 提交于 2019-12-07 08:00:44
问题 I'm trying to compile a cmake project on my mac, but it depends on the SDL framework. I installed this framework and after cmake then reported to me libSDL was not found I set following export variables myself (as suggested by cmake): export SDL_INCLUDE_DIR=/Library/Frameworks/SDL.framework/ export SDLIMAGE_LIBRARY=/Library/Frameworks/SDL_image.framework/ export SDLIMAGE_INCLUDE_DIR=/Library/Frameworks/SDL_image.framework/Headers Now cmake does it job, but when I run make, I get the following

Blitting a transparent .PNG image onto a screen

萝らか妹 提交于 2019-12-07 06:46:05
问题 Hi there I have a image with a black rectangle drawn on it, and its background is transparent. This file is saved as a png ( clear.png ). Then I have another image which is just a solid red background saved as a jpeg ( background.jpeg ). What I was trying to do is make so that the black rectangle in clear.png show up on top of the solid red background image. This is what I have done.. /*Transparent image*/ #include "SDL/SDL.h" #include "SDL/SDL_image.h" #include <iostream> using namespace std

How to compile an example SDL program written in C?

末鹿安然 提交于 2019-12-07 04:58:37
问题 I'm getting started with SDL and C programming. I have experience with other programming languages, but linking/compiling libraries in C is new to me. I am using Mac 10.8 and have installed latest stable 2.0 using the instructions in the read me ( ./configure; make; make install ). Here is the sample code that I am trying to compile: #include <stdlib.h> #include <stdio.h> #include "SDL.h" int main(void) { if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER) != 0) { fprintf(stderr, "\nUnable to

Passing a shared_ptr through a C interface that takes void *

╄→гoц情女王★ 提交于 2019-12-07 03:52:19
问题 I have a C++ project that uses SDL, in particular SDL Events. I would like to use the event system for incoming network messages just as it is used for UI events. I can define a new event type and attach some arbitrary data (see this example). This is what I would do if I was using ordinary pointers: Uint32 message_event_type = SDL_RegisterEvents(1); /* In the main event loop */ while (SDL_Poll(&evt)) { if (evt.type == message_event_type) { Message *msg = evt.user.data1; handle_message(msg);