我一直在试图围绕SDL的基础知识,我对看似简单的东西感到难过.
SDL_MapRGB()需要const SDL_PixelFormat*,我用SDL_PixelFormatEnum我的项目创建纹理unit32.但我找不到任何转换它的方法SDL_MapRGB().
这可能比使用更简单SDL_MapRGB(),但这个问题仍然会让我感到困惑,因为你可以轻松地将其转换为另一种方式.
不相关,但是如果你想知道剩下的代码,那么你就去吧.
#include <SDL.h>
SDL_Window *sdlWindow;
SDL_Renderer *sdlRenderer;
int main( int argc, char *args[] )
{
int w = 640;
int h = 480;
Uint32 format = SDL_PIXELFORMAT_RGB888;
SDL_CreateWindowAndRenderer(w, h, 0, &sdlWindow, &sdlRenderer);
SDL_Texture *sdlTexture = SDL_CreateTexture(sdlRenderer, format, SDL_TEXTUREACCESS_STREAMING, w, h);
extern uint32_t *pixels;
for (int x = 0; x < w; x++) {
for (int y = 0; y < h; y++) {
pixels[x + …Run Code Online (Sandbox Code Playgroud) 我第一次发布在这里,但我必须知道这个简单的代码安静有什么问题:
#include <iostream>
using namespace std;
int main()
{
double test = (1 / 2) * 2;
cout << test << endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
当我运行它显示0的代码时,如果我要投射某些东西,它会发生,无论我使用什么编译器,如果'1'被划分为某种形式的小数,它甚至会返回更奇怪的结果.