#include <assert.h>
#include <GL/glut.h>
#include "glfb.h"
+#include "voxscape.h"
int init(void);
+void cleanup(void);
void display(void);
void idle(void);
void reshape(int x, int y);
#define FB_H 480
unsigned int fb[FB_W * FB_H];
+struct voxscape *vox;
+
int main(int argc, char **argv)
{
if(init() == -1) {
return 1;
}
+ atexit(cleanup);
glutMainLoop();
return 0;
int init(void)
{
- int i, j, xor, r, g, b;
- unsigned int *ptr;
-
- ptr = fb;
- for(i=0; i<FB_H; i++) {
- for(j=0; j<FB_W; j++) {
- xor = i ^ j;
- r = (xor >> 1) & 0xff;
- g = xor & 0xff;
- b = (xor << 1) & 0xff;
- *ptr++ = b | (g << 8) | (r << 16);
- }
+ if(!(vox = vox_open("data/height.png", "data/color.png"))) {
+ return -1;
}
-
- win_width = glutGet(GLUT_WINDOW_WIDTH);
- win_height = glutGet(GLUT_WINDOW_HEIGHT);
+ vox_framebuf(vox, FB_W, FB_H, fb);
+ vox_proj(vox, 45, 5, 100);
+ vox_view(vox, 512, 512, 0);
glfb_setup(FB_W, FB_H, GLFB_RGBA32, FB_W * 4);
return 0;
}
+void cleanup(void)
+{
+ vox_free(vox);
+}
+
void display(void)
{
+ vox_render(vox);
+
glfb_update(fb);
glfb_display();