Copiado el tutorial 5 de Jailgames Vintage en YouTube, pero algo sigue fallando
This commit is contained in:
36
paleta.cpp
36
paleta.cpp
@@ -1,22 +1,8 @@
|
||||
#include <SDL2/SDL.h>
|
||||
|
||||
struct ARGB
|
||||
{
|
||||
Uint8 b, g, r, a;
|
||||
};
|
||||
#include "jUnit.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
SDL_Init(SDL_INIT_EVERYTHING);
|
||||
|
||||
SDL_Window *w = SDL_CreateWindow("pixels", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, SDL_WINDOW_SHOWN);
|
||||
SDL_Renderer *r = SDL_CreateRenderer(w, -1, 0);
|
||||
SDL_RenderSetLogicalSize(r, 320, 240);
|
||||
SDL_Texture *t = SDL_CreateTexture(r, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, 320, 240);
|
||||
|
||||
ARGB *pixels;
|
||||
int pitch;
|
||||
|
||||
init();
|
||||
SDL_Event sdlEvent;
|
||||
bool exit = false;
|
||||
while (!exit)
|
||||
@@ -28,22 +14,8 @@ int main(int argc, char *argv[])
|
||||
exit = true;
|
||||
break;
|
||||
}
|
||||
update();
|
||||
jFlip();
|
||||
}
|
||||
|
||||
SDL_LockTexture(t, nullptr, (void **)&pixels, &pitch);
|
||||
|
||||
for (int i = 0; i < 76800; ++i)
|
||||
{
|
||||
pixels[i].b = rand() % 256;
|
||||
pixels[i].g = rand() % 256;
|
||||
pixels[i].r = rand() % 256;
|
||||
pixels[i].a = 255;
|
||||
}
|
||||
|
||||
SDL_UnlockTexture(t);
|
||||
|
||||
SDL_RenderCopy(r, t, nullptr, nullptr);
|
||||
|
||||
SDL_RenderPresent(r);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user