erebus

diff src/main.cc @ 8:e2d9bf168a41

semi-works ...
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 24 May 2014 06:12:57 +0300
parents 9621beb22694
children d38e13d6063c
line diff
     1.1 --- a/src/main.cc	Sat May 24 02:27:08 2014 +0300
     1.2 +++ b/src/main.cc	Sat May 24 06:12:57 2014 +0300
     1.3 @@ -44,8 +44,8 @@
     1.4  
     1.5  static bool init()
     1.6  {
     1.7 -	width = glutGet(GLUT_WINDOW_WIDTH);
     1.8 -	height = glutGet(GLUT_WINDOW_HEIGHT);
     1.9 +	width = glutGet(GLUT_WINDOW_WIDTH) / 2;
    1.10 +	height = glutGet(GLUT_WINDOW_HEIGHT) / 2;
    1.11  
    1.12  	if(!(erb = erb_init())) {
    1.13  		return false;
    1.14 @@ -62,6 +62,7 @@
    1.15  	glutIdleFunc(idle);
    1.16  	erb_begin_frame(erb, 0);
    1.17  
    1.18 +	glEnable(GL_TEXTURE_2D);
    1.19  	return true;
    1.20  }
    1.21  
    1.22 @@ -74,14 +75,14 @@
    1.23  {
    1.24  	static unsigned char *defpix;
    1.25  
    1.26 -	width = xsz;
    1.27 -	height = ysz;
    1.28 +	width = xsz / 2;
    1.29 +	height = ysz / 2;
    1.30  
    1.31 -	if(xsz <= rtex_width && ysz <= rtex_height) {
    1.32 +	if(width <= rtex_width && height <= rtex_height) {
    1.33  		return;
    1.34  	}
    1.35 -	rtex_width = next_pow2(xsz);
    1.36 -	rtex_height = next_pow2(ysz);
    1.37 +	rtex_width = next_pow2(width);
    1.38 +	rtex_height = next_pow2(height);
    1.39  
    1.40  	printf("resizing framebuffer texture: %dx%d\n", rtex_width, rtex_height);
    1.41  
    1.42 @@ -125,16 +126,13 @@
    1.43  static void display()
    1.44  {
    1.45  	if(render_pending) {
    1.46 -		if(erb_render(erb, 128) == 0) {
    1.47 +		if(erb_render(erb, 64) == 0) {
    1.48  			render_pending = false;
    1.49  			glutIdleFunc(0);
    1.50  		}
    1.51  		update_rect(0, 0, width, height, erb_get_framebuffer(erb));
    1.52  	}
    1.53  
    1.54 -	glBindTexture(GL_TEXTURE_2D, rtex);
    1.55 -	glEnable(GL_TEXTURE_2D);
    1.56 -
    1.57  	float maxu = (float)width / (float)rtex_width;
    1.58  	float maxv = (float)height / (float)rtex_height;
    1.59  
    1.60 @@ -145,8 +143,6 @@
    1.61  	glTexCoord2f(0, 0); glVertex2f(-1, 1);
    1.62  	glEnd();
    1.63  
    1.64 -	glDisable(GL_TEXTURE_2D);
    1.65 -
    1.66  	glutSwapBuffers();
    1.67  	assert(glGetError() == GL_NO_ERROR);
    1.68  }