像素两难:选择正确的图形API像素、图形、正确、API

2023-09-07 14:41:58 作者:颜值+已到最强王者

我希望具有破坏地形滚屏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.

不过,我不能告诉你正确的像素策略什么。似乎是推荐的方式是上传你的内存表面视频纹理在每一帧

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.