像素两难:选择正确的图形API [英] Pixel dilemma: Choosing the right graphics API

查看:442
本文介绍了像素两难:选择正确的图形API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望具有破坏地形滚屏2D游戏。我的做法是有地形为BMP,并有机会获得每一个像素。

I want to make a sidescrolling 2D game with destructible terrain. My approach is having the terrain as a BMP and having access to each pixel.

不过,我有选择正确的图形API为我的游戏的一个问题。

However I have a problem with choosing the right graphics API for my game.

我已经考虑了几种选择:

I have already considered several options:

  • SDL

我开始写作比赛的SDL,我有我位图混合到屏幕上每一帧地形的表面。不幸的是这是非常缓慢的,而当更多的地形是可见它变得更慢。我有30 FPS在屏幕上绘制只有一个位图的时候。

I started writing the game in SDL, I had the terrain as surface which I blitted onto the screen every frame. Unfortunately it was very slow, and it became even slower when more of the terrain was visible. I had 30 FPS when drawing only one bitmap on the screen.

  • GDI

我看到一个类似我想打一场比赛。它使用GDI并且可以通过操纵像素的像素。 速度似乎O.K.但作为SDL使用GDI作为后端的Windows,为什么我不能只是使用SDL?

I have seen a game similar to the one I want to make. It uses GDI and can manipulate pixel by pixel. The speed seems O.K. but as SDL uses GDI as backend on Windows, why can I not just use SDL?

  • 在SDL + OpenGL的

速度非常不错,altough我有技术问题 - 我不能操纵纹理不再当它被加载到OpenGL中,并打破了我的整个计划

Speed is very good, altough I have technical problems - I can't manipulate the texture anymore when it is loaded into OpenGL, and that breaks my whole plan

如前所述:我需要访问到被drawed图像的每个像素,并绘制本身应该是足够快了1280 * 500像素的地形得以顺利渲染

As mentioned before: I need to have access to every pixel of the image that is drawed, and drawing itself should be fast enough for a 1280 * 500 pixel terrain to be rendered smoothly.

推荐答案

在2014年,尝试 SDL2 - 它被说成是硬件加速

In year 2014, try SDL2 - it is said to be hardware accelerated.

不过,我不能告诉你正确的像素策略什么。似乎是<一href="http://wiki.libsdl.org/MigrationGuide#If_your_game_just_wants_to_get_fully-rendered_frames_to_the_screen"相对=nofollow>推荐的方式是上传你的内存表面视频纹理在每一帧

However, I can't tell you anything about the right pixel strategy. Seems like the recommended way is to upload you memory surface to video textureon every frame.

这篇关于像素两难:选择正确的图形API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆