I am struggling to convert a simple pong game from SDL to SDL2 because I could not find a valid value for the pixel format argument (second parameter 'Uint32 format') when calling SDL_CreateTexture(). Finally I found success by using SDL_PIXELFORMAT_ARGB8888, and I also found that SDL_PIXELFORMAT_UNKNOWN works too. However, after reading a few articles on system endianness and determining byte-order, I'm still unsure how a valid pixel format can be found for a given system without guessing, …
我有以下函数,可以在窗口上绘制像素网格,我正在使用 sdl。
问题是速度太慢了!它使我的程序以 10fps 运行,所以我想我一定做错了什么。
这是我正在使用的代码
void rayTracing(SDL &sdl) {
int nx = 1440;
int ny = 810;
for (int x = 0; x < nx; x++) {
for (int y = 0; y < ny; y++) {
float r = float(x) / float(nx);
float g = float(y) / float(ny);
float b = 0.2;
int ir = int(255.99 * r);
int ig = int(255.99 * g);
int ib = int(255.99 * b);
SDL_SetRenderDrawColor(sdl.renderer.get(), ir, ig, ib, 255);
SDL_RenderDrawPoint(sdl.renderer.get(), x, ny …Run Code Online (Sandbox Code Playgroud) 我正在按照lazyfoo http://lazyfoo.net/tutorials/SDL/01_hello_SDL/index2.php的教程进行操作, 并在绘制到屏幕时使用'曲面'.它是什么,它与SDL_Texture类似?它与缓冲区有关吗?