summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorepoch <epoch@hacking.allowed.org>2017-01-07 14:35:32 -0600
committerepoch <epoch@hacking.allowed.org>2017-01-07 14:35:32 -0600
commit9bce2bd89973ab2ebc7d5f9a67f76ba87b8efb2c (patch)
tree73b38e7ef82d8e22e899463d1cdc95c26790912c
parent03c135688893423cf3fde2c0576ff64407eab6aa (diff)
downloadhackvr-9bce2bd89973ab2ebc7d5f9a67f76ba87b8efb2c.tar.gz
hackvr-9bce2bd89973ab2ebc7d5f9a67f76ba87b8efb2c.zip
fixed the aspect ratio detection and default values of various things.
-rw-r--r--src/config.h1
-rw-r--r--src/graphics_x11.c28
2 files changed, 18 insertions, 11 deletions
diff --git a/src/config.h b/src/config.h
index 324d815..9e4962e 100644
--- a/src/config.h
+++ b/src/config.h
@@ -15,6 +15,7 @@
#define MAX_SIDES 8
#define WIDTH 1024
#define HEIGHT 768
+#define DEFAULT_MINIMAP 0
#define FORCE_REDRAW 1
#endif
diff --git a/src/graphics_x11.c b/src/graphics_x11.c
index aea7dff..45994dd 100644
--- a/src/graphics_x11.c
+++ b/src/graphics_x11.c
@@ -333,16 +333,18 @@ int graphics_init() {
gra_global.mapxoff=gra_global.width/2;
gra_global.mapyoff=gra_global.height/2;
- gra_global.drawminimap=0;
+ gra_global.drawminimap=DEFAULT_MINIMAP;
gra_global.draw3d=1;
gra_global.force_redraw=FORCE_REDRAW;//use this for checking proper fps I guess.
+
+//this should be in graphics.c ?
camera.zoom=30.0l;
camera.xr=270;
- camera.yr=270;
+ camera.yr=90;
camera.zr=0;
global.mmz=1;
camera.p.x=0;
- camera.p.z=6;
+ camera.p.z=-6;
camera.p.y=5;
return 0;
}
@@ -361,27 +363,30 @@ int graphics_event_handler() {
// if(e.xexpose.count == 0) redraw=1;
// break;
case MotionNotify:
+ printf("# MotionNotify\n");
XQueryPointer(x11_global.dpy,x11_global.w,&root,&child,&gra_global.rmousex,&gra_global.rmousey,&gra_global.mousex,&gra_global.mousey,&mask);
redraw=1;
break;
case ButtonPress:
+ printf("# ButtonPress\n");
redraw=1;
gra_global.buttonpressed=e.xbutton.button;//what's this for? mouse?
break;
case ButtonRelease:
+ printf("# ButtonRelease\n");
redraw=1;
gra_global.buttonpressed=0;//what's this for???
break;
case ConfigureNotify:
+ printf("# ConfigureNotify\n");
redraw=1;
XGetGeometry(x11_global.dpy,x11_global.w,&root,&global.x,&global.y,&gra_global.width,&gra_global.height,&gra_global.border_width,&gra_global.depth);
- if(gra_global.width / (gra_global.split_screen / (gra_global.red_and_blue ? gra_global.split_screen : 1 )) / AR_W * AR_H != gra_global.height) {
- if(gra_global.width / AR_W * AR_H == gra_global.height) {
- printf("math doesn't work.\n");
- }
- printf("# DERPY WM CANT TAKE A HINT %d / %d / %d * %d = %d != %d\n",gra_global.width,gra_global.split_screen,gra_global.width / (gra_global.red_and_blue ? gra_global.split_screen : 1) / AR_W * AR_H,AR_W,AR_H,gra_global.height);
- if(gra_global.width / (gra_global.split_screen / (gra_global.red_and_blue ? gra_global.split_screen : 1)) / AR_W * AR_H < gra_global.height) {
- gra_global.height=gra_global.width / (gra_global.split_screen / (gra_global.red_and_blue ? gra_global.split_screen : 1)) / AR_W * AR_H;
+ if(gra_global.height * AR_W / AR_H != gra_global.width / (gra_global.split_screen / (gra_global.red_and_blue ? gra_global.split_screen : 1))) {
+ // height / AR_H * AR_W = width / (ss / (rab ? ss : 1))
+ printf("# %d != %d for some reason. probably your WM not respecting aspect ratio hints or calculating based on them differently. (would cause an off-by-one or so)\n",gra_global.height * AR_W / AR_H , gra_global.width / (gra_global.split_screen / (gra_global.red_and_blue ? gra_global.split_screen : 1)));
+
+ if(gra_global.width / (gra_global.split_screen / (gra_global.red_and_blue ? gra_global.split_screen : 1)) * AR_H / AR_W < gra_global.height) {
+ gra_global.height=gra_global.width / (gra_global.split_screen / (gra_global.red_and_blue ? gra_global.split_screen : 1)) * AR_H / AR_W;
} else {
gra_global.width=gra_global.height * AR_H / AR_W * (gra_global.split_screen / (gra_global.red_and_blue ? gra_global.split_screen : 1));
}
@@ -390,6 +395,7 @@ int graphics_event_handler() {
gra_global.mapyoff=gra_global.height/2;
break;
case KeyPress:
+ printf("# KeyPress\n");
redraw=1;
if(keypress_handler(XLookupKeysym(&e.xkey,0)) == -1) {
printf("# exiting\n");
@@ -397,7 +403,7 @@ int graphics_event_handler() {
}
break;
default:
- //printf("# received event with type: %d\n",e.type);
+// printf("# received unknown event with type: %d\n",e.type);
break;
}
}