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.