Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
206 user(s) are online (196 user(s) are browsing Forums)

Members: 0
Guests: 206

more...

Support us!

Headlines

 
  Register To Post  

(1) 2 »
Multitexturing in minigl/SDL?
Quite a regular
Quite a regular


See User information
Hi everybody,

I'm messing around with OpenGL support in SDL for my compile of SDLMAME.

I managed to get it to compile by removing the line
#define GL_ARB_multitexture 1
in GL/gl.h.
Before I removed that I had an error where it didn't know what PFNGLACTIVETEXTUREARBPROC was. By removing the define, the GL/glext.h adds the prototype itself, and defines GL_ARB_multitexture explicitly.

The problem is that MAME just displays white blocks instead of letters, or a big white square for the screen - which sounds like it's unable to render textures.

What's going on here? MiniGL is saying in its header that it supports multitexturing, but it doesn't compile unless I disable the minigl multitexturing bit.

So is multitexturing supported or not? Is this the problem? Is it possible to disable it?

Can anyone help and shed any light on this?

Thanks!

--
Ian Gledhill
ian.gledhill@btinternit.com (except it should be internEt of course...!)
Check out my company's shop: http://www.mutant-caterpillar.co.uk/shop/ - specialising in Sinclair Spectrums but will be adding Amigas!
Go to top
Re: Multitexturing in minigl/SDL?
Quite a regular
Quite a regular


See User information
Spirantho,
Multi texturing can be done under MiniGL.
I use it in the AmiDARK Engine for some special effects.

I use it this way :
Quote:

// 1st layer texture ( ID0 )
glActiveTexture(GL_TEXTURE0);
glEnable( GL_TEXTURE_2D );
UpdateMyImagePTR( ImageIndex );
TrueIndex = MyImagePTR->TrueImageIndex;
glBindTexture( GL_TEXTURE_2D, ImageTexture[ TrueIndex
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );
...

...
// 2nd layer texture ( ID1 )
glActiveTexture(GL_TEXTURE1);
glEnable( GL_TEXTURE_2D );
UpdateMyImagePTR( mRaster[ RasterID ].iRaster );
TrueIndex = MyImagePTR->TrueImageIndex;
glBindTexture( GL_TEXTURE_2D, ImageTexture[ TrueIndex ] );
...

...
// Mix the two textures.
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_ADD); //Add RGB with RGB
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PREVIOUS);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);
//------------------------
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_ADD); //Add ALPHA with ALPHA
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PREVIOUS);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, GL_PREVIOUS);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA);
...

...
// Render
glBegin( GL_QUADS );
glMultiTexCoord2f( GL_TEXTURE0, tcx1, tcy1 ); // Top-Left
glMultiTexCoord2f( GL_TEXTURE1, 0.0, yrp1 ); // Top-Left yrp1
glVertex2f( (float)xf1, (float)yf1 );
glMultiTexCoord2f( GL_TEXTURE0, tcx2, tcy1 ); // Top-Right
glMultiTexCoord2f( GL_TEXTURE1, 1.0, yrp1 ); // Top-Right yrp1
glVertex2f( (float)xf2, (float)yf1 );
glMultiTexCoord2f( GL_TEXTURE0, tcx2, tcy2 ); // Bottom-Right
glMultiTexCoord2f( GL_TEXTURE1, 1.0, yrp2 ); // Bottom-Right yrp2
glVertex2f( (float)xf2, (float)yf2 );
glMultiTexCoord2f( GL_TEXTURE0, tcx1, tcy2 ); // Bottom-Left
glMultiTexCoord2f( GL_TEXTURE1, 0.0, yrp2 ); // Bottom-Left yrp2
glVertex2f( (float)xf1, (float)yf2 );
glEnd();


And it works perfectly.

Concerning SDL ... I don't know.

Kindest Regards,
AmiDARK


Edited by AmiDARK on 2013/3/3 16:35:46
All we have to decide is what to do with the time that is given to us.
Go to top
Re: Multitexturing in minigl/SDL?
Not too shy to talk
Not too shy to talk


See User information
PFNGLACTIVETEXTUREARBPROC is used to obtain the glActiveTexture() function (a gl extension)
like that
wglActiveTexture = (PFNGLACTIVETEXTUREARBPROC) wglGetProcAddress((LPCSTR)"glActiveTextureARB");

But glActiveTexture() is builtin minigl

wglActiveTexture=glActiveTexture;



Go to top
Re: Multitexturing in minigl/SDL?
Home away from home
Home away from home


See User information
Quote:

thellier wrote:
PFNGLACTIVETEXTUREARBPROC is used to obtain the glActiveTexture() function (a gl extension)
like that
wglActiveTexture = (PFNGLACTIVETEXTUREARBPROC) wglGetProcAddress((LPCSTR)"glActiveTextureARB");

But glActiveTexture() is builtin minigl

wglActiveTexture=glActiveTexture;


*GetProcAddress() can also be used with MiniGL. It will simply return a pointer to the built-in function.

Hans

Join Kea Campus' Amiga Corner and support Amiga content creation
https://keasigmadelta.com/ - see more of my work
Go to top
Re: Multitexturing in minigl/SDL?
Quite a regular
Quite a regular


See User information
Thanks for the feedback.
I think now it's something different. When it calls glTexImage2D it returns an Invalid Operation error. Even when I force the width and height to 256, and tell it to use GL_BGRA and GL_UNSIGNED_INT_8_8_8_8_REV specifically, it still returns this.

I'm suspecting MiniGL or Warp3D or something doesn't quite support what SDL expects....

--
Ian Gledhill
ian.gledhill@btinternit.com (except it should be internEt of course...!)
Check out my company's shop: http://www.mutant-caterpillar.co.uk/shop/ - specialising in Sinclair Spectrums but will be adding Amigas!
Go to top
Re: Multitexturing in minigl/SDL?
Home away from home
Home away from home


See User information
Quote:

Spirantho wrote:
Thanks for the feedback.
I think now it's something different. When it calls glTexImage2D it returns an Invalid Operation error. Even when I force the width and height to 256, and tell it to use GL_BGRA and GL_UNSIGNED_INT_8_8_8_8_REV specifically, it still returns this.

I'm suspecting MiniGL or Warp3D or something doesn't quite support what SDL expects....


Are you setting the internal format parameter to GL_BGRA? Or the format paramter? MiniGL doesn't support GL_BGRA for internal texture formats (textureformat.c SelectInternalFormat()), but can unpack texture data in GL_BGRA and GL_UNSIGNED_INT_8_8_8_8_REV (unpack.c SelectUnpacker()). Make sure that internalformat = GL_RGBA.

Hans

Join Kea Campus' Amiga Corner and support Amiga content creation
https://keasigmadelta.com/ - see more of my work
Go to top
Re: Multitexturing in minigl/SDL?
Quite a regular
Quite a regular


See User information
Yes, the internal format is set to GL_RGBA.

I found that if I set the format to the number of bytes (3 or 4) and set the type to GL_UNSIGNED_BYTE then the glTexImage2D works, and so do the subsequent bindings (though I think the glTexSubImage2D is still failing). However, it does actually render something! Garbage, of course, but something.


--
Ian Gledhill
ian.gledhill@btinternit.com (except it should be internEt of course...!)
Check out my company's shop: http://www.mutant-caterpillar.co.uk/shop/ - specialising in Sinclair Spectrums but will be adding Amigas!
Go to top
Re: Multitexturing in minigl/SDL?
Just can't stay away
Just can't stay away


See User information
@spirantho

I remember having the problem with text rendered as blocks when doing the Descent Rebirth port. The non-gl version would render correctly, but the gl version would render only blocks. Probably a related problem. If you find the solution, don´t hide it for yourself ;)

Go to top
Re: Multitexturing in minigl/SDL?
Not too shy to talk
Not too shy to talk


See User information
Is it possible to test myself your mame binary ?

THANKS

Alain Thellier

Go to top
Re: Multitexturing in minigl/SDL?
Quite a regular
Quite a regular


See User information
Sure, I'll get one on-line when I get a moment for you to try!

Thanks!

--
Ian Gledhill
ian.gledhill@btinternit.com (except it should be internEt of course...!)
Check out my company's shop: http://www.mutant-caterpillar.co.uk/shop/ - specialising in Sinclair Spectrums but will be adding Amigas!
Go to top
Re: Multitexturing in minigl/SDL?
Quite a regular
Quite a regular


See User information
I've put a build here:
http://www.retroreview.com/iang/mame_ogl.lha

when you run it, use a script such as:

stack 2048000
set SDLMAME_DESKTOPDIM=320x240
mametiny circus -video opengl -w

Use -video soft if you want to run it with the (working) software renderer.

--
Ian Gledhill
ian.gledhill@btinternit.com (except it should be internEt of course...!)
Check out my company's shop: http://www.mutant-caterpillar.co.uk/shop/ - specialising in Sinclair Spectrums but will be adding Amigas!
Go to top
Re: Multitexturing in minigl/SDL?
Home away from home
Home away from home


See User information
Quote:

Spirantho wrote:
Yes, the internal format is set to GL_RGBA.

I found that if I set the format to the number of bytes (3 or 4) and set the type to GL_UNSIGNED_BYTE then the glTexImage2D works, and so do the subsequent bindings (though I think the glTexSubImage2D is still failing). However, it does actually render something! Garbage, of course, but something.


Setting the format to 3 or 4 makes absolutely no sense, so I don't know why that's even working. However, I was wrong about GL_BGRA and GL_UNSIGNED_INT_8_8_8_8_REV being supported as a source format. Well, it is supported, but not by glTexImage2D. To find the list of supported source formats, have a look at the SelectUnpacker() function in textureconvert.c (which is distinct from MGLSelectUnpacker() in unpack.c).

My suggestion would be to workaround this by manually converting the pixel data from ARGB to RGBA, and then call glTexImage2D() with format = GL_RGBA, and type = GL_UNSIGNED_BYTE.

Hans

Join Kea Campus' Amiga Corner and support Amiga content creation
https://keasigmadelta.com/ - see more of my work
Go to top
Re: Multitexturing in minigl/SDL?
Quite a regular
Quite a regular


See User information
Right, we're getting somewhere now.
With Wazp3d it crashed for some reason, but I didn't look into why. With Warp3D though, using those changes, it worked! All the colours were wrong, of course, but it worked, and gave a hefty speed-up!

Question is what to do about it.
Where can I get the source to minigl latest version? It would be better to add support rather than hacking and slowing down MAME... it may well fix Descent Rebirth too!

--
Ian Gledhill
ian.gledhill@btinternit.com (except it should be internEt of course...!)
Check out my company's shop: http://www.mutant-caterpillar.co.uk/shop/ - specialising in Sinclair Spectrums but will be adding Amigas!
Go to top
Re: Multitexturing in minigl/SDL?
Quite a regular
Quite a regular


See User information

All we have to decide is what to do with the time that is given to us.
Go to top
Re: Multitexturing in minigl/SDL?
Not too shy to talk
Not too shy to talk


See User information
@Spirantho

Yes GL apps often create "empty" texs then "fill" them with gltexsubimage()

As Warp3D dont support BGRA (minigl use warp3D) then the simpler is to patch the 2 fonctions something like that


/*==========================================================================*/
void BGRAtoRGBA(UBYTE *pix,ULONG size)
{
register UBYTE a,r,g,b;
register ULONG n;

if(pix)
for(n=0;n<size;n++)
{
b=pix[0];
g=pix[1];
r=pix[2];
a=pix[3];
pix[0]=r;
pix[1]=g;
pix[2]=b;
pix[3]=a;
pix+=4;
}
}
/*==========================================================================*/
void myglTexImage2D(GLenum target,GLint level,GLint components,GLsizei width,GLsizei height,GLint border,GLenum format,GLenum type,const GLvoid *pixels)
{
if(format==GL_BGRA)
{BGRAtoRGBA(pixels,width*height);format=GL_RGBA ;}
glTexImage2D(target,level,components,width,height,border,format,type,*pixels) ;
}
/*==========================================================================*/
void myglTexSubImage2D(GLenum target,GLint level,GLint xoffset,GLint yoffset,GLsizei width,GLsizei height,GLenum format,GLenum type,const GLvoid *pixels)
{
if(format==GL_BGRA)
{BGRAtoRGBA(pixels,width*height);format=GL_RGBA ;}

glTexSubImage2D(target,level,xoffset,yoffset,width,height,format,type,pixels);
}
/*==========================================================================*/

Go to top
Re: Multitexturing in minigl/SDL?
Quite a regular
Quite a regular


See User information
Thanks for that. I believe I found that it did support BGRA though - it was the UNSIGNED_INT_8_8_8_8_REV that it didn't like.

What I did to make it work was to shift each int32 in the texture up by 8 bits.

Seems to work so far.... although I don't think Wazp3D liked it so I think something's not doing what it should.

It's only a stop-gap until we have proper OpenGL support anyway, though.

--
Ian Gledhill
ian.gledhill@btinternit.com (except it should be internEt of course...!)
Check out my company's shop: http://www.mutant-caterpillar.co.uk/shop/ - specialising in Sinclair Spectrums but will be adding Amigas!
Go to top
Re: Multitexturing in minigl/SDL?
Not too shy to talk
Not too shy to talk


See User information

Delete MAME/Wazp3D.cfg

In Wazp3D-Prefs
Set renderer:Compositing2D
try Hack Tex: No safe

Is it better ?

Alain

Sorry I didnt found yet the time to test myself your binary in my sam440


Go to top
Re: Multitexturing in minigl/SDL?
Not too shy to talk
Not too shy to talk


See User information
Quote:

Spirantho wrote:
What I did to make it work was to shift each int32 in the texture up by 8 bits.



This would convert ARGB into RGBA.

Are you sure that your input data is correct? It sounds much like an endianness problem because ARGB is BGRA backwards.

If you load a file which contains raw BGRA data into memory and then read 32bit words from the memory, on a little-endian machine you get BGRA words, but on a big-endian machine you get ARGB words.


Go to top
Re: Multitexturing in minigl/SDL?
Quite a regular
Quite a regular


See User information
This is what puzzles me too. I spent ages faffing around with reversing endianness and eventually via trial and error I found I just needed to shove the bytes up by one. It doesn't make sense, which makes me thing something somewhere is misbehaving (and the fact that Wazp3D renders differently supports this).

I have a new version here by the way:
http://www.retroreview.com/iang/mame_0148u1_ogl.lha

This works (use -video opengl) using the shifted texture.

--
Ian Gledhill
ian.gledhill@btinternit.com (except it should be internEt of course...!)
Check out my company's shop: http://www.mutant-caterpillar.co.uk/shop/ - specialising in Sinclair Spectrums but will be adding Amigas!
Go to top
Re: Multitexturing in minigl/SDL?
Not too shy to talk
Not too shy to talk


See User information
Hello
I have tried your Mame binary with my Sam440
Got some old Mame roms but the majority dont seem to works anymore "blah blah rom xxx.xxx missing"
Found arkanoid roms that wants to run : not a sexy game :-/
1) Run will real Warp3D
2) run with Wazp3D renderer:soft to bitmap... but slowly
3) Start then freeze with Wazp3D renderer:Compositing2D
..... I am investigating


Alain Thellier - Wazp3D




Go to top

  Register To Post
(1) 2 »

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project