Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
vs49688 committed Oct 5, 2024
1 parent 8f613fd commit 58c3e88
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
8 changes: 7 additions & 1 deletion drivers/glrend/gstored.c
Original file line number Diff line number Diff line change
Expand Up @@ -482,8 +482,14 @@ static void asdfasfdasd(br_renderer *renderer, br_primitive_heap *heap, struct v
};


/*
* Get the centroid of the points and convert to view-space.
*/
br_vector3 centroid = triangle_centroid(&v0->position, &v1->position, &v2->position);
prim->depth = BrVector3Length(&centroid);
br_vector3 centroid_view;
BrMatrix34ApplyP(&centroid_view, &centroid, &state->matrix.model_to_view);

prim->depth = -BrVector3Length(&centroid_view);

/*
* If the user set a function defer to them.
Expand Down
4 changes: 2 additions & 2 deletions drivers/glrend/gv1buckt.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,12 @@ br_error BR_CMETHOD_DECL(br_geometry_v1_buckets_gl, render)(br_geometry_v1_bucke

StoredGLRenderGroup(geom, (br_renderer *)renderer, groupinfo);
} else if(p->type == BRT_TRIANGLE) {
br_uintptr_t offset = (br_uintptr_t)p->v[0];
br_uintptr_t offset = (br_uintptr_t)p->v[0];
state_stack *state = (state_stack *)p->v[1];
const gl_groupinfo *groupinfo = (gl_groupinfo *)p->v[2];

*renderer->state.current = *state;
void StoredGLRenderTri(br_renderer *renderer, br_intptr_t offset, const gl_groupinfo *groupinfo);
void StoredGLRenderTri(br_renderer *renderer, br_uintptr_t offset, const gl_groupinfo *groupinfo);

StoredGLRenderTri(renderer, offset, groupinfo);

Expand Down
8 changes: 5 additions & 3 deletions drivers/glrend/v1model.c
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ void StoredGLRenderGroup(br_geometry_stored *self, br_renderer *renderer, const



void StoredGLRenderTri(br_renderer *renderer, br_intptr_t offset, const gl_groupinfo *groupinfo)
void StoredGLRenderTri(br_renderer *renderer, br_uintptr_t offset, const gl_groupinfo *groupinfo)
{
state_cache *cache = &renderer->state.cache;
br_device_pixelmap *screen = renderer->pixelmap->screen;
Expand Down Expand Up @@ -427,6 +427,7 @@ void StoredGLRenderTri(br_renderer *renderer, br_intptr_t offset, const gl_group
model.eye_m = cache->model.eye_m;

glBindVertexArray(renderer->trans.vao);
glBindBuffer(GL_ARRAY_BUFFER, renderer->trans.vbo);

/* NB: Flag is never set */
// int model_lit = self->model->flags & V11MODF_LIT;
Expand All @@ -444,13 +445,14 @@ void StoredGLRenderTri(br_renderer *renderer, br_intptr_t offset, const gl_group
BrVector4Set(&model.clear_colour, renderer->pixelmap->asBack.clearColour[0], renderer->pixelmap->asBack.clearColour[1],
renderer->pixelmap->asBack.clearColour[2], renderer->pixelmap->asBack.clearColour[3]);

//glBufferData(GL_UNIFORM_BUFFER, sizeof(model), &model, GL_STATIC_DRAW);
//glDrawElements(GL_TRIANGLES, groupinfo->count, GL_UNSIGNED_SHORT, groupinfo->offset);
glBufferData(GL_UNIFORM_BUFFER, sizeof(model), &model, GL_STATIC_DRAW);
glDrawArrays(GL_TRIANGLES, offset, 3);

renderer->stats.face_group_count++;
renderer->stats.triangles_rendered_count += groupinfo->group->nfaces;
renderer->stats.triangles_drawn_count += groupinfo->group->nfaces;
renderer->stats.vertices_rendered_count += groupinfo->group->nfaces * 3;

glBindVertexArray(0);
}

0 comments on commit 58c3e88

Please sign in to comment.