Example #1
0
ofRectangle ofxFenster::getBounds(){
	toContext();
	x = getX();
	y = getY();
	width = getWidth();
	height = getHeight();
	toMainContext();
	return ofRectangle(x, y, width, height);
}
Example #2
0
void ofxFenster::toggleFullscreen(){
	toContext();
	if(isFullscreen){
		glutPositionWindow(origSize.x, origSize.y);
		glutReshapeWindow(origSize.width, origSize.height);
		isFullscreen = false;
	}else{
		origSize = getBounds();
		glutFullScreen();
		getBounds();
		isFullscreen = true;
	}
	toMainContext();
}
Example #3
0
void ofxFenster::draw(bool force){
	int t= ofGetElapsedTimeMillis();
	if (t>nextWinDraw || force) {
		nextWinDraw = t+1000/fpsDraw;
		//ofSetVerticalSync(true);
		//ofSetFrameRate(64);
		ofEnableAlphaBlending();

		toContext();
		glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
		int w, h;
		
		w = width;
		h = height;
		
		h = h > 0 ? h : 1;
		// set viewport, clear the screen
		glViewport( 0, 0, w, h );
		
		float halfFov, theTan, screenFov, aspect;
		screenFov 		= 60.0f;
		
		float eyeX 		= (float)w / 2.0;
		float eyeY 		= (float)h / 2.0;
		halfFov 		= PI * screenFov / 360.0;
		theTan 			= tanf(halfFov);
		float dist 		= eyeY / theTan;
		float nearDist 	= dist / 10.0;	// near / far clip plane
		float farDist 	= dist * 10.0;
		aspect 			= (float)w/(float)h;
		
		glMatrixMode(GL_PROJECTION);
		glLoadIdentity();
		gluPerspective(screenFov, aspect, nearDist, farDist);
		
		glMatrixMode(GL_MODELVIEW);
		glLoadIdentity();
		gluLookAt(eyeX, eyeY, dist, eyeX, eyeY, 0.0, 0.0, 1.0, 0.0);
		
		glScalef(1, -1, 1);           // invert Y axis so increasing Y goes down.
		glTranslatef(0, -h, 0);       // shift origin up to upper-left corner.	
		
		listener->fensterDraw();
		static ofxFensterEvent e;
		e.fenster = this;
		ofNotifyEvent(ofxFensterEvents.draw, e);
		toMainContext();
	}
};
Example #4
0
int ofxFenster::getHeight(){
	if(!hasGlut)toContext();
	height = glutGet(GLUT_WINDOW_HEIGHT);
	if(!hasGlut)toMainContext();
	return height;
}
Example #5
0
int ofxFenster::getWidth(){
	if(!hasGlut)toContext();
	width = glutGet(GLUT_WINDOW_WIDTH);
	if(!hasGlut)toMainContext();
	return width;
}
Example #6
0
int ofxFenster::getY(){
	toContext();
	y = glutGet(GLUT_WINDOW_Y);
	toMainContext();
	return y;	
}
Example #7
0
int ofxFenster::getX(){
	toContext();
	x = glutGet(GLUT_WINDOW_X);
	toMainContext();
	return x;
};
Example #8
0
void ofxFenster::setBounds(int x, int y, int w, int h){
	toContext();
	glutReshapeWindow(w, h);
	glutPositionWindow(x,y);
	toMainContext();
};
Example #9
0
void ofxFenster::setBackground(int r, int g, int b, int a){
	toContext();
	glClearColor(r, g, b, a);
	toMainContext();
};