summaryrefslogtreecommitdiff
path: root/src/core/device.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/device.c')
-rw-r--r--src/core/device.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/core/device.c b/src/core/device.c
index b9c024c..9e4a6eb 100644
--- a/src/core/device.c
+++ b/src/core/device.c
@@ -75,6 +75,10 @@ void ssr_init(ssr_Config* conf) {
memset(state.zbuffer, 0xff, sizeof(uint)*config.width*config.height);
}
+float ssr_getaspect() {
+ return (float)config.width / config.height;
+}
+
int ssr_getframebufferw() {
return config.width;
}
@@ -204,8 +208,11 @@ void ssr_clearcolor(Color color) {
memset(state.framebuffer, 0, state.buffersize);
}
else {
- for (int i = 0; i < config.width*config.height; ++i)
- state.framebuffer[i] = color;
+ uint size = config.width * sizeof(Color);
+ for(int x = 0; x < config.width; ++x)
+ state.framebuffer[x] = color;
+ for (int y = 1; y < config.height; ++y)
+ ssrM_copy(&state.framebuffer[config.width * y], state.framebuffer, size);
}
}
@@ -242,10 +249,10 @@ bool ssr_testdepthf(uint x, uint y, float depth) {
void ssrU_viewport(Vec2* p, Vec2* out) {
ssr_assert(p && out);
float halfw = config.width / 2.f, halfh = config.height / 2.f;
- out->x = (int)(p->x * halfw + halfw);
- out->y = (int)(halfh - p->y * halfh);
- //out->x = (int)((p->x + 1) * (halfw - 0.5f));
- //out->y = (int)((1 - p->y) * (halfh - 0.5f));
+ //out->x = (int)round(p->x * halfw + halfw);
+ //out->y = (int)round(halfh - p->y * halfh);
+ out->x = (int)round((p->x + 1) * (halfw - 0.5f));
+ out->y = (int)round((1 - p->y) * (halfh - 0.5f));
}
void ssr_bindvertices(Vert* verts, int nverts, uint* indices, int nprims) {