-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest_eglstream.cpp
More file actions
78 lines (54 loc) · 1.98 KB
/
Copy pathtest_eglstream.cpp
File metadata and controls
78 lines (54 loc) · 1.98 KB
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
// Copyright 2019 David Butler <croepha@gmail.com>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define NO_DEFINE_IMPLEMENTATION
#include "util_gl.cpp"
#include "render_draw_texture.cpp"
#undef NO_DEFINE_IMPLEMENTATION
void ds_platform_init();
void ds_platform_frame();
bool _debug_ignoring_events;
bool _debug_should_quit;
int main () {
ds_platform_init();
printf("GL_STRINGS: Vendor:%s Renderer:%s Version:%s\n",
glGetString(GL_VENDOR), glGetString(GL_RENDERER), glGetString(GL_VERSION));
_gl_init();
render_draw_texture_init();
u32 texture_name;
s16 size = 400;
{
auto pixels = (u32*)malloc((u32)size*(u32)size*sizeof(u32));
memset(pixels, 0, (u32)size*(u32)size*sizeof(u32));
auto _px = [&](int x, int y) -> u32& {
static u32 _dummmy;
if (x<0 || x>= size ||
y<0 || y>= size ) return _dummmy;
return *(pixels + y * size + x);
};
for (int i=0;i<size/2;i++) {
for (int iw=0;iw<10;iw++) {
_px(i+1, size/2 - i + iw) = 0xFFFFFFFF;
}
}
for (int i=0;i<size/2;i++) {
for (int iw=0;iw<10;iw++) {
_px(size - i-1, size/2 - i + iw) = 0xFFFFFFFF;
}
}
glGenTextures(1, &texture_name);
glBindTexture(GL_TEXTURE_2D, texture_name);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, size, size, 0,
GL_RGBA, GL_UNSIGNED_BYTE, pixels);
glGenerateMipmap(GL_TEXTURE_2D);
free(pixels);
}
while (!_debug_should_quit) {
ds_platform_frame();
glClear(GL_COLOR_BUFFER_BIT);
render_draw_texture(20, 20, size, size, texture_name);
}
}