From 3c0a3b8413ee58a3e5678075c862e95f7c8395c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=95=D0=B3=D0=BE=D1=80=20=D0=9B=D1=8C=D0=B2=D0=BE=D0=B2?= Date: Mon, 27 Mar 2023 11:25:27 +0300 Subject: =?UTF-8?q?=D0=9D=D0=B0=D1=87=D0=B0=D0=BB=D1=8C=D0=BD=D1=8B=D0=B9?= =?UTF-8?q?=20=D0=BA=D0=BE=D0=BC=D0=BC=D0=B8=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test2.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 test2.c (limited to 'test2.c') diff --git a/test2.c b/test2.c new file mode 100644 index 0000000..13703c2 --- /dev/null +++ b/test2.c @@ -0,0 +1,59 @@ +#include +#include +#include +#include +#include +#include + +Uint32 mixSDLColors(Uint32 back, Uint32 front, SDL_PixelFormat *fmt, float alpha) +{ + Uint32 ch1, ch2, sum = 0; + // mask = fmt->Rmask; + ch1 = back & fmt->Rmask; + ch2 = front & fmt->Rmask; + // sum += ch2; + sum += (ch1 + ch2) >> 1; + printf("%i", sum); + + ch1 = back & fmt->Gmask; + ch2 = front & fmt->Gmask; + // sum += ch2; + sum += (ch1 + ch2) >> 1; + printf("%i", sum); + + ch1 = back & fmt->Bmask; + ch2 = front & fmt->Bmask; + // sum += ch2; + sum += (ch1 + ch2) >> 1; + printf("%i", sum); + + return sum; +} + +int main(){ + SDL_Window *window = NULL; + SDL_Surface *s = NULL; + // SDL_Renderer *renderer = NULL; + + SDL_Init(SDL_INIT_VIDEO); + + window = SDL_CreateWindow("test", + SDL_WINDOWPOS_UNDEFINED, + SDL_WINDOWPOS_UNDEFINED, + 960, + 512, + 0); + s = SDL_GetWindowSurface(window); + + Uint32 a = 0; // 0x000000 + Uint32 b = pow(2, 24) - 1; // 0xffffff + printf("0x808080 = %i", mixSDLColors(a, b, s->format, 0)); + + // renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED); + // SDL_Texture *sky = NULL; + // sky = IMG_LoadTexture(renderer, "/home/pupkich/Gameproj/textures/toxicclouds512.bmp"); + // SDL_RenderCopy(renderer, sky, NULL, NULL); + // SDL_RenderPresent(renderer); + // SDL_DestroyTexture(sky); + // SDL_Delay(200); +} \ No newline at end of file -- cgit v1.2.3