summaryrefslogtreecommitdiff
path: root/test2.c
blob: 13703c2315009c82c1d2798a4b30a3a75b1390a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include <SDL2/SDL_timer.h>

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);
}