在 Irrlicht 内使用 SDL
我知道你可以在 lrrlicht 中做同样的事情,但我想使用 SDL 代码/函数在 Irrlicht 中绘制文本、图像(处理 2d)并使用 Irrlicht 做核心 3D 事情,你如何从 sdl 应用文本或图像对于这个 Irrlicht 引擎,你能给我看一下简单的代码,以便我理解吗?
在 SDL 中您可以执行以下操作:
// I start by declare the SDL video Name
SDL_Surface *screen;
// set the video mode:
screen = SDL_SetVideoMode(640, 480, 32, SDL_DOUBLEBUF | SDL_FULLSCREEN); if (screen == NULL) { printf("Unable to set video mode: %s\n", SDL_GetError()); return 1; }
// I can now display data, image, text on the screen by using the declared SDL video Name " screen "
SDL_BlitSurface(my_image, &src, screen, &dest);
I know you can do the same in lrrlicht, but I want to use SDL code/ functions to draw text, images inside Irrlicht (to handle 2d) and use Irrlicht to do the hardcore 3D thing, how can you apply text or images from sdl to this Irrlicht Engine, can you show me simple code, so that I can understand?
In the SDL you can do such:
// I start by declare the SDL video Name
SDL_Surface *screen;
// set the video mode:
screen = SDL_SetVideoMode(640, 480, 32, SDL_DOUBLEBUF | SDL_FULLSCREEN); if (screen == NULL) { printf("Unable to set video mode: %s\n", SDL_GetError()); return 1; }
// I can now display data, image, text on the screen by using the declared SDL video Name " screen "
SDL_BlitSurface(my_image, &src, screen, &dest);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您正在使用/以 Windows 为目标,并且对 WinApi 有一点熟悉,则可以通过在 Win32 窗口内运行两者,结合使用 SDL 窗口 ID 黑客(另请参阅此线程)并运行 Win32 窗口中的 Irrlicht。您可能面临的唯一问题是在 Win32 窗口中运行 SDL 极其困难且不可预测。
您也许还可以使用 GTK+ 实现类似的结果(出于跨平台目的),但我个人从未在 GTK+ 窗口中成功运行 SDL 或 Irrlicht。
另外,如果您想要像 SDL 这样的轻型图形和媒体库,我可以建议 SFML。它可以在 Win32 和 X/11 窗口中运行,没有任何问题,并且可以轻松地与 Irrlicht 一起工作。
If you are using / targeting Windows , and are a little familiar with the WinApi, you may be able to use SDL with Irrlicht by running both inside a Win32 Window, using a combination of the SDL Window ID Hack (also see this thread) and running Irrlicht in a Win32 Window. The only problems you may face is that running SDL in a Win32 Window is extremely difficult and unpredictable.
You may be also be able to achieve a similar result using GTK+ (for cross-platform purposes), but I have personally never succeeded in running SDL or Irrlicht in a GTK+ Window.
Also, if you want a light graphics and media library like SDL , may I suggest SFML. It can run in Win32 and X/11 windows without any problems and may easily work with Irrlicht.