unsigned int fb[FB_W * FB_H];
int mouse_x, mouse_y, mwarp, mbstate[3];
+int hfilt = VOX_LINEAR, cfilt = VOX_LINEAR;
unsigned int input;
-int32_t pos[2], angle;
+int32_t pos[2], theta, phi;
+int horizon;
struct voxscape *vox;
+#define COLOR_HORIZON 0xcc77ff
+#define COLOR_ZENITH 0x5588cc
+
int main(int argc, char **argv)
{
return -1;
}
vox_framebuf(vox, FB_W, FB_H, fb);
- vox_proj(vox, 45, 1, 200);
- vox_view(vox, pos[0], pos[1], angle);
+ vox_fog(vox, 260, COLOR_HORIZON);
+ vox_filter(vox, hfilt, cfilt);
glfb_setup(FB_W, FB_H, GLFB_RGBA32, FB_W * 4);
return 0;
{
int32_t fwd[2], right[2];
- if(input & INP_LTURN) angle += TURN_SPEED;
- if(input & INP_RTURN) angle -= TURN_SPEED;
+ if(input & INP_LTURN) theta += TURN_SPEED;
+ if(input & INP_RTURN) theta -= TURN_SPEED;
- fwd[0] = -SIN(angle);
- fwd[1] = COS(angle);
+ fwd[0] = -SIN(theta);
+ fwd[1] = COS(theta);
right[0] = fwd[1];
right[1] = -fwd[0];
pos[1] -= right[1];
}
- vox_view(vox, pos[0], pos[1], angle);
+ vox_view(vox, pos[0], pos[1], -30, theta, phi);
}
void display(void)
{
update();
- memset(fb, 0, sizeof fb);
-
vox_render(vox);
- vox_sky_grad(vox, 0xcc77ff, 0x5588cc);
+ vox_sky_grad(vox, COLOR_HORIZON, COLOR_ZENITH);
glfb_update(fb);
glfb_display();
void reshape(int x, int y)
{
+ float aspect = (float)x / y;
+
+ vox_proj(vox, 140, 40 * aspect, 1, 300);
+
glViewport(0, 0, x, y);
win_width = x;
input |= INP_RTURN;
break;
+ case 'h':
+ hfilt ^= 1;
+ printf("filtering: height(%s) color(%s)\n", hfilt ? "linear" : "nearest",
+ cfilt ? "linear" : "nearest");
+ vox_filter(vox, hfilt, cfilt);
+ break;
+
+ case 'c':
+ cfilt ^= 1;
+ vox_filter(vox, hfilt, cfilt);
+ printf("filtering: height(%s) color(%s)\n", hfilt ? "linear" : "nearest",
+ cfilt ? "linear" : "nearest");
+ break;
+
default:
break;
}
if(!(dx | dy)) return;
if(mbstate[0]) {
- angle -= dx << 6;
+ theta -= dx << 6;
+ phi += dy << 8;
+ if(phi < -0x18000) phi = -0x18000;
+ if(phi > 0x18000) phi = 0x18000;
}
}