What's new

Writing an OpenGL N64 GFX plugin...having trouble with PJ64...

Orkin

d1R3c764 & g1|\|64 m4|<3R
Ok, here's the deal. I'm starting an OpenGL GFX plugin for N64 emus (I was doing one in D3D and got pretty far, but now I've decided to move over to OGL), but I'm having trouble getting it to work right with PJ64. I can start a ROM, and it displays fine, but when I try to end the emulation, the emu freezes with a partially drawn ROM selection window.

After putting some debugging code in I found that it's not unsetting the current rendering context, so when the window gets destroyed, OGL throws a fit.

The funny thing is it works fine in other emus (e.g. 1964), no problems unsetting the current context, and no freezing whatsoever.

I'd say it's a problem with PJ64, but I know (at least) Jabo and Azimer got OGL to work with PJ64, so it must be something I'm missing...even though I've tried everything I can think of.

Anyway, if anyone has any ideas, I'd greatly appreciate the help.

Thanks,
Orkin
 

linker

Emutalk Member
Orkin said:
Ok, here's the deal. I'm starting an OpenGL GFX plugin for N64 emus (I was doing one in D3D and got pretty far, but now I've decided to move over to OGL), but I'm having trouble getting it to work right with PJ64. I can start a ROM, and it displays fine, but when I try to end the emulation, the emu freezes with a partially drawn ROM selection window.

After putting some debugging code in I found that it's not unsetting the current rendering context, so when the window gets destroyed, OGL throws a fit.

The funny thing is it works fine in other emus (e.g. 1964), no problems unsetting the current context, and no freezing whatsoever.

I'd say it's a problem with PJ64, but I know (at least) Jabo and Azimer got OGL to work with PJ64, so it must be something I'm missing...even though I've tried everything I can think of.

Anyway, if anyone has any ideas, I'd greatly appreciate the help.

Thanks,
Orkin

I know about this problem. So check this out:

BOOL lgl_Release()
{
DebugMsg("Releasing OpenGL...");
if (hGLRC)
{
if ((!wglMakeCurrent(NULL, NULL)) && (!FALSE))
{
MessageBox(NULL, "wglMakeCurrent() failed!\n", "ERROR", MB_OK|MB_ICONSTOP);
return FALSE;
}
if (!wglDeleteContext(hGLRC))
{
MessageBox(NULL, "wglDeleteContext() failed!\n", "ERROR", MB_OK|MB_ICONSTOP);
return FALSE;
}
hGLRC = NULL;
}
if (hPalette)
{
if(!DeleteObject(hPalette))
{
MessageBox(NULL, "DeleteObject() for hPalette failed!\n", "ERROR", MB_OK|MB_ICONSTOP);
return FALSE;
}
hPalette = NULL;
}
if (hDC)
{
if (!ReleaseDC(gfx.hWnd, hDC))
{
//MessageBox(NULL, "ReleaseDC failed!\n", "ERROR", MB_OK|MB_ICONSTOP);
return FALSE;
}
hDC = NULL;
}

DebugMsg("OpenGL released");
return TRUE;
}
 
OP
Orkin

Orkin

d1R3c764 & g1|\|64 m4|<3R
Thanks for the replies

linker: Umm...I don't really see anything different in the code you posted. Just looks like a regular OpenGL shutdown routine, which I already have, the problem is it's not working right with PJ64.

Quvack: Do you know if there's a way to work around it?

CpU MasteR: Hmm...I guess I should try to track down Azimer...

Even though I'm still have trouble with shutdown, I'm going ahead with development anyway, since I'll eventually figure it out. It doesn't display anything yet, but I got all the basic structure in there (runs through the display lists and all, just doesn't actually process them yet). I think I'm going to spend a little time on a good debugger before I go much further though.
 

Cyberman

Moderator
Moderator
Orkin said:
Thanks for the replies

linker: Umm...I don't really see anything different in the code you posted. Just looks like a regular OpenGL shutdown routine, which I already have, the problem is it's not working right with PJ64.

Quvack: Do you know if there's a way to work around it?

CpU MasteR: Hmm...I guess I should try to track down Azimer...

Even though I'm still have trouble with shutdown, I'm going ahead with development anyway, since I'll eventually figure it out. It doesn't display anything yet, but I got all the basic structure in there (runs through the display lists and all, just doesn't actually process them yet). I think I'm going to spend a little time on a good debugger before I go much further though.

It is always a good idea to have a good debugger! TRUST ME!

I think the cause is PJ64 shuts down .. period including the window context used for the OGL. If you have a way of checking if the emulator is indeed closing the window perhaps you can fork an exception handler that closes the OGL context and then returns letting the window be closed normally?

Cyb
 

linker

Emutalk Member
Orkin said:
Thanks for the replies

linker: Umm...I don't really see anything different in the code you posted. Just looks like a regular OpenGL shutdown routine, which I already have, the problem is it's not working right with PJ64.

Hmm.. it is working for me
 

zilmar

Emulator Developer
Moderator
where are you calling your shutdown rutines from ? you might find you are calling them to late or something ..
 
OP
Orkin

Orkin

d1R3c764 & g1|\|64 m4|<3R
I'm starting OGL in RomOpen, and stopping it in RomClosed.

Should I do it somewhere else?
 
OP
Orkin

Orkin

d1R3c764 & g1|\|64 m4|<3R
In case anyone cares, here are a few shots of tonight's progress...

Here you can see that textures aren't implemented yet
 
OP
Orkin

Orkin

d1R3c764 & g1|\|64 m4|<3R
No lighting either. The funky colors are because I'm interpreting normals as color values at the moment.
 
OP
Orkin

Orkin

d1R3c764 & g1|\|64 m4|<3R
At least the lighting on the castle is right (only 'cause it's static)

I think I'm going to tackle lighting next...
 

Cyberman

Moderator
Moderator
Orkin said:
At least the lighting on the castle is right (only 'cause it's static)

I think I'm going to tackle lighting next...

Well that is a very colorful Super Mario 64!

It's chromatic even ;)

Looks like you are making decent progress, now I'll be interested when you get to fog ;)

Cyb
 

nObedienz

New member
sure wouldnt mind being one of your trustworhty helpers :cool:
I may not be that active on this board, but, when something this
interesting pops up, i just have to be a part of it :D
though my specs might be a little low ???
celeron 400, tnt2riva 32mb, 384mb ram
 

Azimer

Emulator Developer
Moderator
Orkin,

My only solution thus far is to turn off the rombrowser. You can do this in PJ64's settings. I am still investigating workarounds or perhaps work on my own patch for the .exe to make it work right.
 

Top