Dark Bit Factory & Gravity

PROGRAMMING => C / C++ /C# => Topic started by: slippy on July 11, 2007

Title: splitscreen ogl questions
Post by: slippy on July 11, 2007
Hey dudes,

I'm looking for a method to do some kind of splitscreen with OpenGL and C++ ... now ... as I'm really new to OGL coding I was just wondering how this might be done.

What I'm trying to do is an intro which has four sub-screens where different oldskool stuff is presented ... to get a clearer understanding of what I'm talking about ... here's a link to my big idol ... http://www.pouet.net/prod.php?which=30055

of course my idea is not the same as well as I won't get the quality of this kick-ass prod ... but I'm really curious about how it's done ...

my (poor) idea was to do four quad planes where each of these planes get's it's own (dynamic) texture ... that textures should then be updated each frame to display its own oldskool effects (like scrollers, starfields, plasmas aso. - these could be softrendered in the texture area) ...

with some research I found keywords like FBO (framebuffer objects), Offscreen-Rendering and dynamic textures ...

As I'm going to learn OpenGL I also refered the NeHe tuts ... and this beloved forum here of course. Rbraz posted some code to draw to a texture - just thought, that this one could come in handy ... but as soon as I call his texture generation method every frame it slows down my sample program horribly ...

I'm really looking forward to get some tips or coding techniques on this ...

Thanks in advance dudes,

SLiPPY
Title: Re: splitscreen ogl questions
Post by: va!n on July 11, 2007
you dont need to render each part to a texture... afaik you can use and change the glViewPort (http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=42)

But i know there is a very small gl command to do very easy real splitscreens... the name is a bit wired... if i remember the gl command i will post ist.


EDITED:
Just check out this command for splitscreens ^^   glScissor() - How this is what you are looking for. good luck
Title: Re: splitscreen ogl questions
Post by: Rbz on July 11, 2007
@Slippy: I guess that keops have used glViewPort in his 64kb intro, try looking into nehe lesson 42 as va!n suggested.
Title: Re: splitscreen ogl questions
Post by: slippy on July 14, 2007
hey ho ...

just asked Keops/Eqx if he could help me out a bit ... he told me to use

glTexSubImage2D

... well I just wrote a little test app (as proof-of-concept for myself) which uses this method to render (softrendered pixelbuffers) stuff to my texture ...

could you please test this and give me some feedback about the speed on your system?

you may use the keys SPACE, E (env-texmapping), B (background) to play around with it ...

the texture on the objects is the one you see as background ...

Greets,
SLiPPY



Title: Re: splitscreen ogl questions
Post by: va!n on July 14, 2007
Mhhh sorry.. i dont really get the point... i thought you want to code any splitscreen thing... i cant see anything of this in your example... i your example i can just turn on/off different effects/layers...

Would be nice if you can display the FPS for testing, so people can tell you how smooth or not it will work ^^ Here it seems to works fine (very smooth) but i cant tell you the FPS ^^
Title: Re: splitscreen ogl questions
Post by: taj on July 15, 2007
Slippy,

runs quite slowly here. Maybe 10-15fps, hard to tell. I don't know what you are trying to achieve exactly, but in anycase make sure your texture and subtexture area are powers of two or on some cards, your demo will run very slowly. A common mistake is to declare a texture the same size as the graphics window which is deadly in many cases.

Chris
Title: Re: splitscreen ogl questions
Post by: va!n on July 15, 2007
@Slippy:
Ok, just a personal question... i am trying to learn how to use textures to display any stuff instead to use images/sprites in any size like in good old coding days where textures was a unknown world.

In my actual project i am creating a 640x320 sized texture instead a 1024x512 or 512x256 texture or something like this! I will try to explain why i used this way and where i have the problem to solve it...

I need a 640x320 sized texture (color white) with an logo x,y centered on the texture for blending (titlelogo)...  If i would create a 512x256 texture for example and draw the logo on this texture, i need to resize this 512x256 texture to fit on the 640x320 area.... Resizing the texture means, the generated and drawn logo on the texture may look shit...  Or does people really doing this by using a 1024x512 texture and using only the 640x320 area? O.O 

Another problem is, when having something like a 640x320 sized plasmaeffect... i would create and use a 640x320 texture (when i dont draw directly to the screen)... So, does i have to use a 1024x512 Texture?  I heard some older cards may have problems when the texture width and height are not equal or > 512  !?

On my machine i dont have any problems yet when using 640x320 textures ^^

Title: Re: splitscreen ogl questions
Post by: Jim on July 16, 2007
With OpenGL you simply must use power-of-2 textures for it to be compatible with everything.  There are loads of cards/drivers that don't support anything else.
To make your example work, allocate a 1024x512 texture, put the 640x320 image in the top-left-hand corner using glTexSubimage2D, and then draw a quad with that texture, but setting the uv coordinates to
(0,0)
(640/1024),0 = (0.625,0)
(640/1024,320/512) = (0.625,0.625)
(0,320/512)

Best to turn off bilinear filtering first (use GL_NEAREST I think it is).  You can use the spare bits of the texture for other smaller sprites.

Jim
Title: Re: splitscreen ogl questions
Post by: va!n on July 16, 2007
ah ok... thanks.. i still thought some cards dont support texture > 512 ... i will give it a try (btw, using DX9 ^^ atm)
Title: Re: splitscreen ogl questions
Post by: Jim on July 17, 2007
I've just been reading the specs from www.opengl.org (http://www.opengl.org).  It seems any driver that supports OpenGL 2.0 and above must support non-power-2 textures for all source/destination textures.  Either that, or it must support the ARB_texture_non_power_of_two extension.

I would think that 512 would be rather a small maximum texture size these days, most cards supporting 1k,2k,4k at least, but sadly there's no guarantees for it being that big.  I'm not sure how one finds out what the maximum size is supported.  Anyone?

As I understand it, what you want to do is draw a 640x320 image in system memory, upload it using glTexSubImage2D, and then blit it to the screen (maybe with some fx)?  If so, that makes sense.

Jim
Title: Re: splitscreen ogl questions
Post by: taj on July 17, 2007
I've just been reading the specs from www.opengl.org (http://www.opengl.org).  It seems any driver that supports OpenGL 2.0 and above must support non-power-2 textures for all source/destination textures.  Either that, or it must support the ARB_texture_non_power_of_two extension.

True Jim but in experience shows that just because its supported doesn't mean it works well. This is one of those features in transition from "works well some places" to "works well everywhere". I'd say for a compo, its safe but for release somewhere like pouet you are just asking for trouble. There are certainly lots of cards out there that will drop <10 fps with non power of two. EOS.

Heres a classic example I had recently. I was drawing points and putting shaders on the points on my x1800. Lovely worked a treat. Then I set the point width to 10.0 and bang. 1 frame every 30-60 seconds. But it was compliant :-)

Chris