XAMOS
  • Cocoon
    Cocoon
    Mequa
    Posts: 51 from 2012/3/30
    Would anyone be interested in a hardware-accelerated version of XAMOS for MorphOS, using OpenGL?
    This should perform much better on MorphOS - almost all of the poor performance at present is due to unaccelerated SDL drawing.

    I need some help with a TinyGL-compatible method of rendering an SDL surface to the GL framebuffer.

    For unaccelerated SDL I use SDL_BlitSurface().

    This line will need replacing with OpenGL routines when using hardware acceleration (software rendering will be kept as a fallback mode). There are several methods I've encountered online for standard OpenGL.

    I'd like a link, if possible, to a routine compatible with MorphOS TinyGL for blitting an SDL surface to the GL framebuffer. Then XAMOS may just fly on MorphOS. :-)

    [ Edited by Mequa 27.08.2012 - 01:51 ]
  • »27.08.12 - 01:27
    Profile
  • Cocoon
    Cocoon
    Mequa
    Posts: 51 from 2012/3/30
    OK, here's my provisional routine. Works smoothly on my i7 PC, but with hefty CPU usage, so it's likely inefficient at the moment. But at least OpenGL is now working with XAMOS (on some platforms). I still get a blank screen on my netbook, however.

    When I build for MorphOS the program starts "meditating" after launch.

    Code:
    void GameEngineWrapper::displaywithopengl(int x, int y, int w, int h, SDL_Surface* surface)
    {
    GLuint texture;
    GLenum texture_format;
    SDL_Surface* alphasurface = SDL_DisplayFormatAlpha(surface);
    GLint nOfColors = alphasurface->format->BytesPerPixel;

    if (alphasurface->format->Rmask == 0x000000ff)
    texture_format = GL_RGBA;
    else
    texture_format = GL_BGRA;

    glGenTextures(1, &texture);
    glBindTexture(GL_TEXTURE_2D, texture);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexImage2D(GL_TEXTURE_2D, 0, nOfColors, alphasurface->w, alphasurface->h, 0, texture_format, GL_UNSIGNED_BYTE, alphasurface->pixels);
    SDL_FreeSurface(alphasurface);

    glBegin(GL_QUADS);
    glTexCoord2i(0, 0); glVertex3f(x, y, 0.0f);
    glTexCoord2i(1, 0); glVertex3f(x+w, y, 0.0f);
    glTexCoord2i(1, 1); glVertex3f(x+w, y+h, 0.0f);
    glTexCoord2i(0, 1); glVertex3f(x, y+h, 0.0f);
    glEnd();
    glDeleteTextures(1, &texture);
    }


    Anything in the above which is objectionable for TinyGL in particular? Of course, I'd appreciate any general OpenGL improvements for other platforms too. :-)
  • »27.08.12 - 04:59
    Profile
  • Cocoon
    Cocoon
    Mequa
    Posts: 51 from 2012/3/30
    Right, the solution to the performance issue was to convert SDL surfaces to OpenGL textures in advance, rather than every frame which is incredibly slow (an i7 can do it smoothly, nothing else can). This is likely to eat a lot of VRAM though.

    I just did a build on MorphOS 3.1, the default example now runs full speed with only 50% CPU usage on my Mac Mini G4 1.5GHz. I still need to fix some texture corruption issues (most likely caused by non-power-of-2 textures) and a few other issues, however it appears to be progressing well. Soon it will run fast enough on MorphOS for XAMOS games - watch this space!

    One problem - drawing functions are likely to be very slow, due to conversion between SDL surfaces and OpenGL textures, until a workaround is found. Sprites and screen scrolling will be fast enough though.
  • »27.08.12 - 10:25
    Profile
  • Cocoon
    Cocoon
    Mequa
    Posts: 51 from 2012/3/30
    I'm having problems with graphical corruption on MorphOS 3.1 on my Mac Mini G4 1.5GHz. The problem seems to occur when using OpenGL textures larger than 1024x1024 (as used for the background image in the default XAMOS example - textures are rounded up to the next power-of-two):

    xamos_mos_bug.png

    There are also colour (and alpha channel) endianness issues at present which should be relatively easy to fix.
    When ran on an SDL screen on MorphOS, it is pretty smooth though now with less than 50% CPU load. :-D

    (An Intel Atom netbook with WinXP does better - less than 5% CPU load with no graphics corruption.)

    [ Edited by Mequa 28.08.2012 - 02:59 ]
  • »28.08.12 - 03:55
    Profile
  • Cocoon
    Cocoon
    Mequa
    Posts: 51 from 2012/3/30
    Experimental TinyGL support can be enabled in the next XAMOS release (0.28) by command line option:
    > XAMOS -useopengl
    Which will load the default example.

    This will be off by default on all platforms at this stage.

    To select an example using GL:
    > XAMOS -launcher -useopengl

    To launch the Breakout demo with GL:
    > XAMOS example/XAMOSOut.xamos -useopengl

    Command line options can be used in any order. They will not be case sensitive in XAMOS 0.28 (except filenames on *nix platforms).

    I'll post here when this build and source is available on SourceForge (coming very soon), if anyone wants to try and debug it for MorphOS. I'd recommend avoiding -useopengl on MorphOS for now though, until several issues are fixed.

    [ Edited by Mequa 30.08.2012 - 08:19 ]
  • »30.08.12 - 09:17
    Profile
  • Cocoon
    Cocoon
    Mequa
    Posts: 51 from 2012/3/30
    XAMOS 0.28 is now available for MorphOS (and other platforms).

    OpenGL support has endianness issues on PPC platforms at the moment, so has wrong colours. I'd appreciate any help on this for MorphOS (and other PPC platforms).

    As above, use XAMOS -useopengl to test the experimental OpenGL mode.


    To massively improve the performance of XAMOS on MorphOS, with or without TinyGL, select the PowerSDL options when XAMOS is running to run in a SDL screen. Then restart XAMOS. (Alternatively click the button to go fullscreen).

    It appears the performance issues only happen when running XAMOS in a window on the Ambient screen. It is much faster and smoother on a SDL screen. Try it. :-D
  • »05.09.12 - 04:11
    Profile