Held_OT
YaBB Newbies
Offline
Posts: 7
Re: multiscreening (4 screens) on one machine...
Reply #3 - Jan 24th , 2008, 8:17am
Ok, after trying around a bit I found a way to do this really fast and smooth... I'm using the PGraphicsOffscreenGL-approach I found somewhere on this site and adjusted the render-method to create 4 quads filling the screen and mapping the content to those quads so that the overlapping fits my needs. After some testing I even got the alpha-masking to work. It works just fine and runs at >60fps... I guess this thread can be closed now... ------------------------------------------- void render(PGraphicsOffscreenGL pg) { start(); gl.glUniform2fARB(offsetTex, 1.0 / pg.width, 1.0 / pg.height); gl.glUniform2fARB(destRes, width, height); int w_h = off_screen_width/2; int h_h = off_screen_height/2; pgl.beginGL(); gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL); gl.glMatrixMode(GL.GL_PROJECTION); gl.glPushMatrix(); gl.glLoadIdentity(); gl.glOrtho(0.0, width, 0.0, height, -100.0, +100.0); gl.glMatrixMode(GL.GL_MODELVIEW); gl.glPushMatrix(); gl.glLoadIdentity(); gl.glViewport(0, 0, width, height); gl.glEnable(GL.GL_TEXTURE_2D); gl.glBindTexture(GL.GL_TEXTURE_2D, pg.getDrawTex()); gl.glColor4f(1.0, 1.0, 1.0, 1.0); gl.glBegin(GL.GL_QUADS); gl.glTexCoord2f(0.0, 0.0); gl.glVertex2f(0.0, 0.0); gl.glTexCoord2f(0.5, 0.0); gl.glVertex2f(w_h, 0.0); gl.glTexCoord2f(0.5, 0.5); gl.glVertex2f(w_h, h_h); gl.glTexCoord2f(0.0, 0.5); gl.glVertex2f(0.0, h_h); gl.glEnd(); gl.glBegin(GL.GL_QUADS); gl.glTexCoord2f(ol_x_h, 0.0); gl.glVertex2f(w_h, 0.0); gl.glTexCoord2f(ol_x_f, 0.0); gl.glVertex2f(off_screen_width, 0.0); gl.glTexCoord2f(ol_x_f, 0.5); gl.glVertex2f(off_screen_width, h_h); gl.glTexCoord2f(ol_x_h, 0.5); gl.glVertex2f(w_h, h_h); gl.glEnd(); gl.glBegin(GL.GL_QUADS); gl.glTexCoord2f(0.0, ol_y_h); gl.glVertex2f(0.0, h_h); gl.glTexCoord2f(0.5, ol_y_h); gl.glVertex2f(w_h, h_h); gl.glTexCoord2f(0.5, ol_y_f); gl.glVertex2f(w_h, off_screen_height); gl.glTexCoord2f(0.0, ol_y_f); gl.glVertex2f(0.0, off_screen_height); gl.glEnd(); gl.glBegin(GL.GL_QUADS); gl.glTexCoord2f(ol_x_h, ol_y_h); gl.glVertex2f(w_h, h_h); gl.glTexCoord2f(ol_x_f, ol_y_h); gl.glVertex2f(off_screen_width, h_h); gl.glTexCoord2f(ol_x_f, ol_y_f); gl.glVertex2f(off_screen_width, off_screen_height); gl.glTexCoord2f(ol_x_h, ol_y_f); gl.glVertex2f(w_h, off_screen_height); gl.glEnd(); gl.glEnable(GL.GL_BLEND); gl.glBlendFunc(GL.GL_ZERO, GL.GL_SRC_ALPHA); gl.glBindTexture(GL.GL_TEXTURE_2D, alphaTex[0]); gl.glBegin(GL.GL_QUADS); gl.glTexCoord2f(0.0, 0.0); gl.glVertex2f(0.0, 0.0); gl.glTexCoord2f(0.5, 0.0); gl.glVertex2f(w_h, 0.0); gl.glTexCoord2f(0.5, 0.5); gl.glVertex2f(w_h, h_h); gl.glTexCoord2f(0.0, 0.5); gl.glVertex2f(0.0, h_h); gl.glEnd(); gl.glBegin(GL.GL_QUADS); gl.glTexCoord2f(0.5, 0.0); gl.glVertex2f(w_h, 0.0); gl.glTexCoord2f(1.0, 0.0); gl.glVertex2f(width, 0.0); gl.glTexCoord2f(1.0, 0.5); gl.glVertex2f(width, h_h); gl.glTexCoord2f(0.5, 0.5); gl.glVertex2f(w_h, h_h); gl.glEnd(); gl.glBegin(GL.GL_QUADS); gl.glTexCoord2f(0.0, 0.5); gl.glVertex2f(0.0, h_h); gl.glTexCoord2f(0.5, 0.5); gl.glVertex2f(w_h, h_h); gl.glTexCoord2f(0.5, 1.0); gl.glVertex2f(w_h, height); gl.glTexCoord2f(0.0, 1.0); gl.glVertex2f(0.0, height); gl.glEnd(); gl.glBegin(GL.GL_QUADS); gl.glTexCoord2f(0.5, 0.5); gl.glVertex2f(w_h, h_h); gl.glTexCoord2f(1.0, 0.5); gl.glVertex2f(width, h_h); gl.glTexCoord2f(1.0, 1.0); gl.glVertex2f(width, height); gl.glTexCoord2f(0.5, 1.0); gl.glVertex2f(w_h, height); gl.glEnd(); gl.glDisable(GL.GL_BLEND); gl.glActiveTexture(GL.GL_TEXTURE0); gl.glBindTexture(GL.GL_TEXTURE_2D, 0); stop(); gl.glMatrixMode(GL.GL_PROJECTION); gl.glPopMatrix(); gl.glMatrixMode(GL.GL_MODELVIEW); gl.glPopMatrix(); pgl.endGL(); } ---------------------------------------------