Using wglAllocateMemoryNV (VAR) correctly...

Hi…
I’m using VertexArrayRange and AGP memory, and I have this problem:

first, I started my engine on fullscreen or windowed mode, but when I try to switch to windowed (from fullscreen) or viceversa, I can’t get the AGP VAR memory again…

I’m using a ‘Graphics object’, that when it’s created, initializes OpenGL, gets AGP
VAR mem, etc… when I switch to fullscreen or windowed, this object is destroyed (closing OpenGL, feeing any VAR memory I have allocated before, etc) and re-created
(again, initializing OpengGL, and getting VAR mem)…

I’m using it right? or I have to use wglAllocateMemoryNV only, for example, at
the program start?

Why is it that I can get the AGP VAR mem again only when I destroy and re-create my graphic object in the same mode (for example, windowed)…?? and when I change I can’t… Any idea…?

Maybe I’m ignoring some rule about using this extension…

(I forgot to say that I don’t have any problem with VideoMem VAR doing the same things…)

I’m using w2k and VC++ 6.

Well, thanks !

  • Royconejo.

You can allocate only one AGP VAR buffer.

You should be able to free it at any time and then reallocate it, but you can allocate only one. You should only need one, anyhow.

  • Matt

Thanks…

Yes, I’m using just one AGP buffer.
It’s allocated when the graphic object is created, and freed when it’s deleted…

The problem appears when I change the screen resolution… (when I start in one mode, close it, and change to another), when I do that, I can’t allocate AGP memory again…

It works fine when I don’t change the video mode…

That’s why I’m asking if there is something I’m doing wrong…

  • Royconejo.

Can you give the exact sequence of events? (context create/destroy, VAR memory alloc/free, modeswitch, etc.)

  • Matt

When the object is created:

  1. if FullScreen, sets the choosen video mode.

  2. adjust the main window properties.

  3. GetDC with the main window, SetPixelFormat, wglCreateContext and wglMakeCurrent.

  4. Check and init the GL extensions, getting the function pointers…

  5. Set the basic OpenGL options, that won’t change during the game (like smooth shading)

  6. ShowWindow, UpdateWindow, SetForegroundWindow, etc on the main window.

  7. and finally sets the GL viewport…

At this point, the object is initialized, and I could alloc VAR memory (either AGP or Video)…


when it’s destroyed…

  1. I free the VAR memory (if it was allocated).

  2. if fullscreen, ChangeDisplaySettings to the desktop mode…

  3. wglMakeCurrent to NULL, and wglDeleteContext.

  4. and finally, I release the main window DC

I can create, alloc AGP VAR mem and delete this object many times, and everything works fine, except when I change the video mode (the 1st. step in the constructor…)
When I do that, wglAllocateMemoryNV fails…

Well, thanks for your help…!

  • Royconejo.

note: when the user wants to switch to fullscreen or windowed, I just =! that bool variable, delete the object, and create it again…

That’s why I was speaking of ‘switching’ on the 1st. message…

Can’t say I know what the problem would be.

  • Matt

Ok, I’ll re-design my VAR mem allocator system…

I know that I can get AGP memory without initialize OpenGL, but what about video memory?
it’s the same? What happen If I alloc some amount of vidmem, and then change the video mode? as far as I know, the entire contents of the vidmem are lost… (that’s why I integrate the VAR allocator with the graphic object)…

And before wglFreeMemoryNV:

. Should I disable the extension?
. Should I call glVertexArrayRange (NULL, 0)
(to disable the buffer/pointer)

well… thanks again…

  • Royconejo.

[This message has been edited by royconejo (edited 02-19-2001).]