相关疑难解决方法(0)

Determine correct pixel format for SDL_CreateTexture()?

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, …

c sdl sdl-2

5
推荐指数
1
解决办法
130
查看次数

如何用sdl2快速绘制像素网格?

我有以下函数,可以在窗口上绘制像素网格,我正在使用 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)

c++ sdl-2

0
推荐指数
1
解决办法
3697
查看次数

什么是SDL_Surface?

我正在按照lazyfoo http://lazyfoo.net/tutorials/SDL/01_hello_SDL/index2.php的教程进行操作, 并在绘制到屏幕时使用'曲面'.它是什么,它与SDL_Texture类似?它与缓冲区有关吗?

c++ sdl

-1
推荐指数
1
解决办法
4029
查看次数

标签 统计

c++ ×2

sdl ×2

sdl-2 ×2

c ×1