projects
/
retroray
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
dos port underway
[retroray]
/
src
/
gaw
/
gawswtnl.c
diff --git
a/src/gaw/gawswtnl.c
b/src/gaw/gawswtnl.c
index
2df3ed3
..
c307f8a
100644
(file)
--- a/
src/gaw/gawswtnl.c
+++ b/
src/gaw/gawswtnl.c
@@
-1,5
+1,5
@@
/*
/*
-Deep Runner - 6dof shooter game for the SGI O2.
+RetroRay - integrated standalone vintage modeller/renderer
Copyright (C) 2023 John Tsiombikas <nuclear@mutantstargoat.com>
This program is free software: you can redistribute it and/or modify
Copyright (C) 2023 John Tsiombikas <nuclear@mutantstargoat.com>
This program is free software: you can redistribute it and/or modify
@@
-100,6
+100,11
@@
void gaw_viewport(int x, int y, int w, int h)
st.vport[3] = h;
}
st.vport[3] = h;
}
+void gaw_get_viewport(int *vp)
+{
+ memcpy(vp, st.vport, sizeof st.vport);
+}
+
void gaw_matrix_mode(int mode)
{
st.mmode = mode;
void gaw_matrix_mode(int mode)
{
st.mmode = mode;
@@
-182,7
+187,7
@@
void gaw_rotate(float deg, float x, float y, float z)
{
static float m[16];
{
static float m[16];
- float angle = M_PI * deg / 180.0f;
+ float angle = CGM_PI * deg / 180.0f;
float sina = sin(angle);
float cosa = cos(angle);
float one_minus_cosa = 1.0f - cosa;
float sina = sin(angle);
float cosa = cos(angle);
float one_minus_cosa = 1.0f - cosa;
@@
-261,7
+266,7
@@
void gaw_perspective(float vfov_deg, float aspect, float znear, float zfar)
{
static float m[16];
{
static float m[16];
- float vfov = M_PI * vfov_deg / 180.0f;
+ float vfov = CGM_PI * vfov_deg / 180.0f;
float s = 1.0f / tan(vfov * 0.5f);
float range = znear - zfar;
float s = 1.0f / tan(vfov * 0.5f);
float range = znear - zfar;
@@
-316,6
+321,11
@@
void gaw_alpha_func(int func, float ref)
/* TODO */
}
/* TODO */
}
+void gaw_zoffset(float offs)
+{
+ st.zoffs = offs * 0.1;
+}
+
#define CLAMP(x, a, b) ((x) < (a) ? (a) : ((x) > (b) ? (b) : (x)))
void gaw_clear_color(float r, float g, float b, float a)
#define CLAMP(x, a, b) ((x) < (a) ? (a) : ((x) > (b) ? (b) : (x)))
void gaw_clear_color(float r, float g, float b, float a)
@@
-532,12
+542,14
@@
void gaw_draw_indexed(int prim, const unsigned int *idxarr, int nidx)
if(!vnum) continue;
for(i=0; i<vnum; i++) {
if(!vnum) continue;
for(i=0; i<vnum; i++) {
- if(v[i].w != 0.0f) {
- v[i].x /= v[i].w;
- v[i].y /= v[i].w;
- if(st.opt & (1 << GAW_DEPTH_TEST)) {
- v[i].z /= v[i].w;
- }
+ float oow = 1.0f / v[i].w;
+ v[i].x *= oow;
+ v[i].y *= oow;
+ if(st.opt & (1 << GAW_POLYGON_OFFSET)) {
+ v[i].z += st.zoffs;
+ }
+ if(st.opt & (1 << GAW_DEPTH_TEST)) {
+ v[i].z *= oow;
}
}
}
}
@@
-548,7
+560,7
@@
void gaw_draw_indexed(int prim, const unsigned int *idxarr, int nidx)
void gaw_begin(int prim)
{
st.imm_prim = prim;
void gaw_begin(int prim)
{
st.imm_prim = prim;
- st.imm_pcount = prim;
+ st.imm_pcount = prim_vcount[st.imm_prim];
st.imm_numv = 0;
}
st.imm_numv = 0;
}
@@
-617,18
+629,23
@@
void gaw_texcoord2f(float u, float v)
void gaw_vertex2f(float x, float y)
{
void gaw_vertex2f(float x, float y)
{
- gaw_vertex3f(x, y, 0);
+ gaw_vertex4f(x, y, 0, 1);
}
void gaw_vertex3f(float x, float y, float z)
{
}
void gaw_vertex3f(float x, float y, float z)
{
+ gaw_vertex4f(x, y, z, 1);
+}
+
+void gaw_vertex4f(float x, float y, float z, float w)
+{
float *cptr = st.imm_cbuf + st.imm_numv * 4;
struct vertex *vptr = st.imm_vbuf + st.imm_numv++;
*vptr = st.imm_curv;
vptr->x = x;
vptr->y = y;
vptr->z = z;
float *cptr = st.imm_cbuf + st.imm_numv * 4;
struct vertex *vptr = st.imm_vbuf + st.imm_numv++;
*vptr = st.imm_curv;
vptr->x = x;
vptr->y = y;
vptr->z = z;
- vptr->w = 1.0f;
+ vptr->w = w;
cptr[0] = st.imm_curcol[0];
cptr[1] = st.imm_curcol[1];
cptr[0] = st.imm_curcol[0];
cptr[1] = st.imm_curcol[1];