GLdc/GL/flush.h

77 lines
1.6 KiB
C
Raw Normal View History

2020-10-27 13:21:37 +00:00
#pragma once
#include "private.h"
2020-10-27 14:11:34 +00:00
#ifdef __cplusplus
extern "C" {
#endif
#define MAX_STACK 4
2020-10-27 13:21:37 +00:00
#define B000 0
#define B111 7
#define B100 4
#define B010 2
#define B001 1
#define B101 5
#define B011 3
#define B110 6
typedef struct {
2020-11-01 09:05:57 +00:00
/* Remaining vertices in the source list */
2020-10-27 13:21:37 +00:00
int remaining;
/* Current position in the source list */
2020-11-01 09:05:57 +00:00
Vertex* src;
2020-10-27 13:21:37 +00:00
/* Vertex to read from (this may not exist in the source list) */
2020-11-01 09:05:57 +00:00
Vertex* active;
2020-10-27 13:21:37 +00:00
2020-11-01 08:58:18 +00:00
/* Sliding window into the source view */
2020-10-27 13:21:37 +00:00
Vertex* triangle[3];
/* Stack of temporary vertices */
Vertex stack[MAX_STACK];
int8_t stack_idx;
2020-11-01 08:58:18 +00:00
/* < 8. Bitmask of the last 3 vertices */
2020-10-27 21:33:32 +00:00
uint8_t visibility;
uint8_t triangle_count;
uint8_t padding;
2020-10-27 13:21:37 +00:00
} ListIterator;
2020-10-27 14:11:34 +00:00
inline ListIterator* _glIteratorBegin(void* src, int n) {
2020-10-27 13:21:37 +00:00
ListIterator* it = (ListIterator*) malloc(sizeof(ListIterator));
2020-10-27 21:33:32 +00:00
it->remaining = n - 1;
2020-11-01 09:05:57 +00:00
it->active = (Vertex*) src;
it->src = it->active + 1;
2020-10-27 13:21:37 +00:00
it->stack_idx = -1;
it->triangle_count = 0;
it->visibility = 0;
2020-10-27 21:33:32 +00:00
it->triangle[0] = it->triangle[1] = it->triangle[2] = NULL;
2020-10-27 13:21:37 +00:00
return (n) ? it : NULL;
}
2020-10-27 14:37:25 +00:00
GL_FORCE_INLINE GLboolean isVertex(const Vertex* vertex) {
assert(vertex);
2020-10-27 14:37:25 +00:00
return (
vertex->flags == PVR_CMD_VERTEX ||
vertex->flags == PVR_CMD_VERTEX_EOL
);
}
GL_FORCE_INLINE GLboolean isVisible(const Vertex* vertex) {
TRACE();
assert(vertex != NULL);
return vertex->w >= -0.00001f; // && vertex->xyz[2] >= -vertex->w;
2020-10-27 14:37:25 +00:00
}
2020-10-27 14:11:34 +00:00
ListIterator* _glIteratorNext(ListIterator* it);
2020-10-27 13:21:37 +00:00
2020-10-27 14:11:34 +00:00
#ifdef __cplusplus
}
#endif