Displaying multiple layer

Started by
6 comments, last by veeru 19 years ago
I am trying to draw a background image and on the top other object, but i do not need to change the background ever, so i do not want it to be redrawn every time, so is it possible to have multiple Draw() function or mutiple layer in OpenGL?? Thank you very much.
Advertisement
Well think about it this way. When something is drawn on top of the background image, you need to redraw AT LEAST that section of the background again or it will not show up when the object moves.
- A momentary maniac with casual delusions.
If the image is 1 color, then you can (glClearColor).
but if it isnt, i dont think you can.
you cant just have a background image, its a 3D space.
so many ways to draw the background image.
what you can is to draw the background image as a Display List or use Vertex Array and the VBO extension. (not only for the background, these are optimization technologies. you should use it if you dont and there is something (like background) that bothers the FPS).
i dont know if you use both Display List, Vertex Array and the VBO extension it will be even faster. feel free to try and tell me ;)
All I know is that there is a Display List, Vertex Array, VBO extension, NeHe lesson 45 (Vertex Array + VBO extension), and Lighthouse 3D - Display Lists Tutorial (guess the subject)
pex.
Thank you so much for your help. In Nehe's lesson it uses int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) as the entry point. How can i get the LPSTR to give me the command line arguement? How can i get double array that might be passed as an command line arguement?
Simply parse the string at lpCmdLine. It consists of all arguments after the program name as a string.
- A momentary maniac with casual delusions.
Thank you that helps. I came across a function wglCreateLayerContext(), am i able to use this function to create different layer panel for the one window, Does anyone have knowledge about it? I would appreciate if you can help me out or give me simple example would be great.

Thank you very much
Quote:Original post by veeru
Thank you that helps. I came across a function wglCreateLayerContext(), am i able to use this function to create different layer panel for the one window, Does anyone have knowledge about it? I would appreciate if you can help me out or give me simple example would be great.

Thank you very much


I've never used it before, but MSDN has some info: wglCreateLayerContext. Basicly it allows you to create a ogl rendering context for an overlay plane. However there are a few things to keep in mind here.

First you must be working with a dc that has an overlay plane, which means you need to select a pixel format for the window with at least one overlay plane. The bReserved member of the pixel format descriptor encodes the number of layers in the dc. However it doesn't look like you can pass this value to ChoosePixelFormat, so you may need to enumerate the pfds and select the best one manually. There is no guarentee that there is a hardware accelerated pixel format which supports overlays, so be prepared to do without this functionality on those systems.

Also be aware that you will be working with two seperate rendering contexts which do not share state. And by default they will not share display lists or textures either (take a look at wglShareLists).

Now haveing said all that, I strongly recomend that you do not go down this road. Just render all the background stuff that does not change to a texture once and then draw a fullscreen quad with the texture every frame. If this is a static background image then just load that into the texture. If the background stuff changes you will need to update the texture. You would need to provide this functionality anyway for systems that do not have a pfd with an overlay for your dc.

If for some reason this is not fast enough (and you know that drawing this quad is the bottleneck) then consider a dirty rect approach. Maintain an update region and only draw a smaller quad with a portion of the full background texture to patch the dirty region.
Thank you very much for your help. I will try and see if wglCreateLayerContext will work for me or not? Thank you all for help

This topic is closed to new replies.

Advertisement