Wednesday, August 26, 2009

Porting DeSmuME to Wii - Part 5 -

When we last left off, we only needed to get OGLRender to compile and then the core of the emulator would be completely (and hopefully successfully) ported.

OGLRender outputs (or renders) video from the emulation using the library OpenGL. OpenGL is ported for just about every major computer operating system out there, so the developers chose it to keep the core of their emulator platform independent. Unfortunately, there is not a version (port) of OpenGL for Wii, but the devkitPPC toolchain does have GX; a graphics rendering library for Wii extremely similiar to OpenGL.

The initial attempt by me and profetylen to port OGLRender was to rewrite all of the OpenGL code as GX code. Since DeSmuME uses all of the major features of OpenGL (shaders, textures, polygons, 2D rendering, 3D rendering, etc.) this was a very daunting task that could potentially take months to complete.

However, profetylen found a project called gl2gx which is a wrapper for GX that looks exactly like OpenGL (so, in some sense, it is a port of OpenGL). I compiled gl2gx, and then profetylen and I compiled OGLRender under gl2gx. There were minimal errors after doing this.

First, GL/glx.h was missing. Actually it's not, it's just named GL/glext.h.

Second, glXGetProcAddress was being used out of scope. The easiest way to fix this was just to redefine glXGetProcAddress:
#define glXGetProcAddress(x)((const GLubyte*)x)

Lastly, glActiveTexture() isn't in gl2gx, so we have to write it ourselves. Profetylen came up with the following code for it:
void glActiveTexture(GLenum texture){
texture = GL_ACTIVE_TEXTURE_ARB;
return;
}


So, now we have the entire core of DeSmuME compiled under libogc. The next step is to write original code that uses the core to emulate ROMs on Wii.

You can grab the latest source revision here: Mediafire

3 comments:

  1. Great Job!, you are the next hero of the "wii homebrew emulators comunity" in spanish forums. Great.

    ReplyDelete
  2. I don´t understand of programming but in the forums that i usually read, the people says that it looks great!

    Good luck with the project!

    ReplyDelete
  3. I wish you the best luck! I now you can do it man!
    Cheers to ''the other site'' community.

    ReplyDelete