Libretro GL – Modelviewer

By Squarepusher

As a showcase for libretro GL, maister made two quite nice libretro cores that should appeal to demo coders and traditional game developers alike.

Model Viewer

I encouraged Maister to do a libretro GL port of an old project he made a year ago (Model Viewer) as a showcase for libretro GL.

The Model Viewer takes ‘Wavefront’ object models as the ‘ROM’. it then displays these models inside a bare 3D environment.

It is possible to adjust the camera and rotate the model, zoom it in/out, etc.

Right now it is still in a basic phase but you’ll find a great amount of models that you can find on sites like Deviant Art and Free 3D Models (http://thefree3dmodels.com/) should already run unedited.

NOTE: Models that depend on DDS textures (DirectDraw Surface) will appear in the Model Viewer as ‘flat shaded’ for the moment since DDS support is currently a stub.

Below I’ll showcase some models being rendered inside the Model Viewer. Search around for some of these models yourself (some key terms being ‘XNA Lara’ and/or ‘3D Studio Max’). If the model comes with an OBJ/MTL file and a couple of PNG/JPG/TGA images it should more or less work barring some exceptions. (.mesh based models are not supported right now)

The Final Fantasy XIII Vanille model mostly appears correctly in the Model viewer except for a few minor details
The Final Fantasy XIII Vanille model mostly appears correctly in the Model viewer except for a few minor details
Here you see Lightning displayed in the Modelviewer with lots of shader passes applied. Most apparent shader here is the Waterpaint mudlord shader which gives the model a painterly look.
Here you see Lightning displayed in the Modelviewer with lots of shader passes applied. Most apparent shader here is the Waterpaint mudlord shader which gives the model a painterly look.
Modelviewer showin the Final Fantasy X-II Rikku model.
Modelviewer showing the Final Fantasy X-II Rikku model.
Bryan Fury from Tekken Tag Tournament 1 - looks more or less like Bryan - some hue issues here and there.
Bryan Fury from Tekken Tag Tournament 1 – looks more or less like Bryan – some hue issues here and there.
Marshall Law model from Tekken 6
Marshall Law model from Tekken 6

Platforms

Model Viewer right now runs on:

  • PC (Windows/UNIX/OSX)
  • Android
  • iOS
  • Blackberry QNX (BB10/Playbook)

The maximum supported internal resolution at which you can render the models depends on the platform you’re running Model Viewer on. On the mobile platforms we have consciously decided to set the maximum supported resolution at 1024×768 – this should be the native resolution of the iPad 2/iPad Mini and it is doubtful that even on a powerful tablet you’d have much need for 1080p internal resolution anyway.

On PC 1920×1600 is the maximum internal resolution at which you can render these models.

Like all the non-GL based libretro cores, you can apply any amount of shaders that you want.

Model links

I’m not exactly sure how hard-ball game developers are when it comes to these models – but anyways, there is a lot of source material you can find on the Internet.

Some places that supply them is DeviantArt (search for DeviantArt + XNALara-  that should show up a bunch).

Another site that I’ve found includes a lot of useful models is this one (http://thefree3dmodels.com/). Make sure that when downloading a model form there, that it says ‘OBJ’ or something similar. Models that are not in this format can’t be expected to run right now.

Libretro GL starting from RetroArch 0.9.9

By Squarepusher

RetroArch 0.9.9 (to be released later this week) will introduce an important new feature to the libretro API that I’m sure a lot of developers will be interested in.

To date, all libretro cores have used software rendered video. Sure, the frontend (RetroArch in this case) has hardware accelerated drivers (such as an OpenGL driver or a Direct3D driver), but all that really guarantees is that blitting is going through a few API functions that might (or might not ) be hardware accelerated depending on the driver supplied by the vendor. But generally speaking, libretro cores for emulators/games that depend on hardware-accelerated 3D (such as Dolphin, PCSX2, and even N64 emus) were previously impossible on RetroArch.

This is no longer the case with libretro GL. Libretro GL is not a new API – it is merely an extension to the libretro API (that doesn’t break ABI) which allows you to write OpenGL 2.0/ES 2.0 compliant code inside your libretro core.

The way this works is that at the final end of the chain inside the libretro core, everything gets rendered to an FBO (Frame Buffer Object), and this in turn will be passed back to the frontend for final processing.

Which platforms does libretro GL support right now?
The OpenGL subset we are targeting for libretro GL is either OpenGL 2.0 (on desktop) and/or OpenGL ES 2.0 (mobile and/or desktop PC in case you’re using bleeding-edge MESA drivers). This means that any platform that has at least support for either OpenGL 2.0 or OpenGL ES 2.0 should be capable of running libretro cores that depend on GL features.

The following platforms right now are supported:

  • Android
  • iOS
  • Blackberry QNX (BB10/Playbook)
  • Pandora (not tested yet)
  • PC (Windows/UNIX/OSX)

Fixed function or programmable pipeline?

With RetroArch 0.9.9, we will finally support all of the major mobile phone/tablet operating systems (except for Windows RT). This means that your libretro port can now reach a much bigger audience than just PC and/or game consoles.

All of the mobile phones/tablets out on the market today support at least OpenGL ES 2.0 (and in most cases with added extensions support). OpenGL ES 2.0 requires that you move away from deprecated fixed function GL programming. This might be an initial learning curve but the added platform support should eventually be worth it.

Note that nothing is stopping you from writing fixed function GL code – it should theoretically run on RetroArch for PC. However, this would be a bad design decision from a portability perspective since it will automatically cut off all the mobile platforms from being able to run your libretro core.

What about Direct3D / other unsupported platforms right now?

Looking at all the devices out there, it seems pretty clear that the industry as a whole has decided to throw its collective weight behind OpenGL. We therefore (for now) have made the conscious decision not to provide a similar context for Direct3D.

The downsides of this is that it automatically cuts off Xbox 360 support since Direct3D 9 is used for the XDK. I am not sure if it would make sense to eventually provide something similar for D3D or if it would be possible to somehow make a wrapper (from GL ES 2.0/GL 2.0 to D3D9) – but for now Direct3D support is out.

For the time being – PS3 support is out as well. Sony’s implementation of OpenGL (PSGL) was never made OpenGL ES 2.0-compliant – what it is currently is a mishmash of OpenGL ES 1.x and a lot of proprietary performance-related extensions. I found some undocumented functions inside that hinted at some kind of preliminary GL ES 2.0 support, but for now I’m not really confident we can make PSGL work as a GL ES 2.0 backend.

Obviously it is unfortunate that PS3 and Xbox 360 are cut off right now – the two being the only programmable pipeline consoles out there. But OpenGL ES 1.x would just be too limiting (which is what we have on PS3), and Direct3D really is only available on Xbox consoles and Windows/RT at this point – for now it doesn’t really make much sense to us to make a totally different backend just for D3D since on a Windows PC you still have the option of using OpenGL.

How do I make a libretro GL core?

Maister wrote a simple tutorial that should walk you through the steps to get started with making your own libretro GL core.

Link: Implementing a Hardware Accelerated Libretro Core

Maister also made two test cores (ModelViewer and SceneWalker) that shows off what you can do in libretro GL. These two will be the subject of a subsequent article, so stay tuned…