-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsdl2_rendering.txt
79 lines (77 loc) · 2.11 KB
/
sdl2_rendering.txt
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
void
DrawFrameBuffer(SDL_Renderer * sdl_renderer)
{
renderer_t * _renderer = render_ctx->renderer;
unsigned int bi=0, samplestart;
int i, j, cj, imgW = _renderer->imgWidth,
imgH = _renderer->imgHeight;
const int us = _renderer->used_samples, bw = _renderer->bufWidth;
cRGB_t fc;
cRGB_t * fb = _renderer->frameBuffer;
cRGB_t * c = fb;
for (j = imgH; j--; )
{
bi = j * bw;
for (i = imgW; i--; )
{
fc.r = 0.f, fc.g = 0.f, fc.b = 0.f;
samplestart = bi + (i*us);
switch (us) {
case 16:
c = fb + samplestart + 15;
fc.r += c->r; fc.g += c->g; fc.b += c->b;
case 15:
c = fb + samplestart + 14;
fc.r += c->r; fc.g += c->g; fc.b += c->b;
case 14:
c = fb + samplestart + 13;
fc.r += c->r; fc.g += c->g; fc.b += c->b;
case 13:
c = fb + samplestart + 12;
fc.r += c->r; fc.g += c->g; fc.b += c->b;
case 12:
c = fb + samplestart + 11;
fc.r += c->r; fc.g += c->g; fc.b += c->b;
case 11:
c = fb + samplestart + 10;
fc.r += c->r; fc.g += c->g; fc.b += c->b;
case 10:
c = fb + samplestart + 9;
fc.r += c->r; fc.g += c->g; fc.b += c->b;
case 9:
c = fb + samplestart + 8;
fc.r += c->r; fc.g += c->g; fc.b += c->b;
case 8:
c = fb + samplestart + 7;
fc.r += c->r; fc.g += c->g; fc.b += c->b;
case 7:
c = fb + samplestart + 6;
fc.r += c->r; fc.g += c->g; fc.b += c->b;
case 6:
c = fb + samplestart + 5;
fc.r += c->r; fc.g += c->g; fc.b += c->b;
case 5:
c = fb + samplestart + 4;
fc.r += c->r; fc.g += c->g; fc.b += c->b;
case 4:
c = fb + samplestart + 3;
fc.r += c->r; fc.g += c->g; fc.b += c->b;
case 3:
c = fb + samplestart + 2;
fc.r += c->r; fc.g += c->g; fc.b += c->b;
case 2:
c = fb + samplestart + 1;
fc.r += c->r; fc.g += c->g; fc.b += c->b;
case 1:
c = fb + samplestart;
fc.r += c->r; fc.g += c->g; fc.b += c->b;
break;
}
SDL_SetRenderDrawColor(sdl_renderer, (unsigned char)(fc.r * 255.f),
(unsigned char)(fc.g * 255.f),
(unsigned char)(fc.b * 255.f),
0xFF);
SDL_RenderDrawPoint(sdl_renderer, i, j);
}
}
}