Save viewport matrix in a variable
This commit is contained in:
parent
41c30256b7
commit
95d474c956
@ -4,6 +4,7 @@
|
||||
#include "utils.h"
|
||||
#include "vec.h"
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define TRIANGLE_VERTICES 3
|
||||
|
||||
@ -211,7 +212,8 @@ internal V3f get_barycentric_coords(V3f a, V3f b, V3f c, V3f p) {
|
||||
|
||||
internal V3f get_viewport_vertex(const V3f *vertex, const Image *img) {
|
||||
V4f vh = {.x = vertex->x, .y = 0.0f - vertex->y, .z = vertex->z, .w = 1.0f};
|
||||
vh = mat4x4_mul_vec4(viewport(vh.x, vh.y, img->width, img->height), vh);
|
||||
M4x4f vp = viewport(vh.x, vh.y, img->width, img->height);
|
||||
vh = mat4x4_mul_vec4(vp, vh);
|
||||
|
||||
V3f output = project_vec4(vh);
|
||||
output.x = clamp(output.x, 0.0f, img->width);
|
||||
|
Loading…
Reference in New Issue
Block a user