#endif
rend_init();
- load_options("retroray.cfg");
- app_resize(opt.xres, opt.yres);
app_vsync(opt.vsync);
if(opt.fullscreen) {
app_fullscreen(1);
int numpix = x * y;
int prev_numpix = win_width * win_height;
- dbgmsg("reshape(%d, %d)\n", x, y);
-
if(!framebuf || numpix > prev_numpix) {
void *tmp;
if(!(tmp = realloc(framebuf, numpix * sizeof *framebuf))) {
if(cur_scr && cur_scr->reshape) {
cur_scr->reshape(x, y);
}
+
+ app_redisplay(0, 0, 0, 0);
}
void app_keyboard(int key, int press)
#include "logger.h"
#include "scene.h"
+#define CFGFILE "retroray.cfg"
+
enum {
KEY_BACKSP = 8,
KEY_ESC = 27,
__djgpp_nearptr_enable();
#endif
+ if(!have_mouse()) {
+ fprintf(stderr, "No mouse detected. Make sure the mouse driver is installed\n");
+ return 1;
+ }
+
init_logger();
if(read_cpuid(&cpuid) == 0) {
init_timer(0);
kb_init();
- if(!have_mouse()) {
- fprintf(stderr, "No mouse detected. Make sure the mouse driver is installed\n");
- return 1;
- }
+ load_options(CFGFILE);
if((env = getenv("RRLOG"))) {
if(tolower(env[0]) == 'c' && tolower(env[1]) == 'o' && tolower(env[2]) == 'm'
return 1;
}
- if((vmidx = vid_findmode(640, 480, 32)) == -1) {
+ if((vmidx = vid_findmode(opt.xres, opt.yres, opt.bpp)) == -1) {
return 1;
}
if(!(vmem = vid_setmode(vmidx))) {
return 1;
}
- win_width = 640;
- win_height = 480;
+ win_width = opt.xres;
+ win_height = opt.yres;
win_aspect = (float)win_width / (float)win_height;
if(app_init() == -1) {
#include <assert.h>
#include "miniglut.h"
#include "app.h"
+#include "options.h"
#include "rtk.h"
#include "logger.h"
int main(int argc, char **argv)
{
glutInit(&argc, argv);
- glutInitWindowSize(640, 480);
+
+ load_options(CFGFILE);
+
+ glutInitWindowSize(opt.xres, opt.yres);
glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
glutCreateWindow("RetroRay");
void app_swap_buffers(void)
{
+ glViewport(0, 0, win_width, win_height);
+
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
+ glOrtho(0, win_width, win_height, 0, -1, 1);
- glRasterPos2i(-1, 1);
+ glRasterPos2i(0, 0);
glPixelZoom(1, -1);
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0.5f);
glDrawPixels(win_width, win_height, GL_BGRA, GL_UNSIGNED_BYTE, framebuf);
glDisable(GL_ALPHA_TEST);
+ glDisable(GL_DEPTH_TEST);
+ glDisable(GL_LIGHTING);
+ glBegin(GL_LINE_LOOP);
+ glColor3f(1, 0, 0);
+ glVertex2f(0, 0);
+ glVertex2f(win_width, 0);
+ glVertex2f(win_width, win_height);
+ glVertex2f(0, win_height);
+ glEnd();
+
if(rband.width | rband.height) {
- glOrtho(0, win_width, win_height, 0, -1, 1);
glPushAttrib(GL_ENABLE_BIT);
glDisable(GL_DEPTH_TEST);
#define DEF_XRES 640
#define DEF_YRES 480
+#define DEF_BPP 32
#define DEF_VSYNC 1
#define DEF_FULLSCR 0
#define DEF_MOUSE_SPEED 50
struct options opt = {
- DEF_XRES, DEF_YRES,
+ DEF_XRES, DEF_YRES, DEF_BPP,
DEF_VSYNC,
DEF_FULLSCR,
DEF_MOUSE_SPEED, DEF_SBALL_SPEED,
opt.xres = ts_lookup_int(cfg, "options.video.xres", DEF_XRES);
opt.yres = ts_lookup_int(cfg, "options.video.yres", DEF_YRES);
+ opt.bpp = ts_lookup_int(cfg, "options.video.bpp", DEF_BPP);
opt.vsync = ts_lookup_int(cfg, "options.video.vsync", DEF_VSYNC);
opt.fullscreen = ts_lookup_int(cfg, "options.video.fullscreen", DEF_FULLSCR);
fprintf(fp, "\tvideo {\n");
WROPT(2, "xres = %d", opt.xres, DEF_XRES);
WROPT(2, "yres = %d", opt.yres, DEF_YRES);
+ WROPT(2, "bpp = %d", opt.bpp, DEF_BPP);
WROPT(2, "vsync = %d", opt.vsync, DEF_VSYNC);
WROPT(2, "fullscreen = %d", opt.fullscreen, DEF_FULLSCR);
fprintf(fp, "\t}\n");
#define OPTIONS_H_
struct options {
- int xres, yres;
+ int xres, yres, bpp;
int vsync;
int fullscreen;
int dirty;
if(need_relayout(w)) {
- dbgmsg("calc layout %s\n", w->any.text ? w->any.text : "?");
calc_layout(w);
}
void free_scene(struct scene *scn)
{
- int i;
-
if(!scn) return;
+ scn_clear(scn);
+
+ darr_free(scn->objects);
+ darr_free(scn->lights);
+ darr_free(scn->mtl);
+ free(scn);
+}
+
+void scn_clear(struct scene *scn)
+{
+ int i;
+
for(i=0; i<darr_size(scn->objects); i++) {
free_object(scn->objects[i]);
}
- darr_free(scn->objects);
+ darr_clear(scn->objects);
for(i=0; i<darr_size(scn->lights); i++) {
free_light(scn->lights[i]);
}
- darr_free(scn->lights);
+ darr_clear(scn->lights);
for(i=0; i<darr_size(scn->mtl); i++) {
mtl_destroy(scn->mtl[i]);
free(scn->mtl[i]);
}
- darr_free(scn->mtl);
-
- free(scn);
+ darr_clear(scn->mtl);
}
int scn_add_object(struct scene *scn, struct object *obj)
struct scene *create_scene(void);
void free_scene(struct scene *scn);
+void scn_clear(struct scene *scn);
+
int scn_add_object(struct scene *scn, struct object *obj);
int scn_rm_object(struct scene *scn, int idx);
int scn_num_objects(const struct scene *scn);
cgm_minverse(proj_matrix_inv);
rtk_resize(toolbar, win_width, TOOLBAR_HEIGHT);
+
+ inval_vport();
}
static void mdl_keyb(int key, int press)
int id = (intptr_t)cls;
switch(id) {
+ case TBN_NEW:
+ scn_clear(scn);
+ inval_vport();
+ break;
+
case TBN_SEL:
case TBN_MOVE:
case TBN_ROT: