Negative Scaling factor - Moving from DirectX to OpenGL

Hi all,
I have some code that was originally Win32/DirectX 9 and I’m not porting
to Mac OS X ( 10.5 ) and OpenGL.
Most of it appears to work, except negative scaling values. In the DirectX
code it correctly mirrors a sprite, but the same value in OpenGL seems that
the sprite is not even drawn.

Any ideas from the gurus who’ve done this sort of thing before.

Dominique.

I knew this rang a bell.

If I remember right (it’s been a while admittedly) you first need to flip the normal (on 3D objects anyway). You then need to take into account how OpenGL decides if a polygon is a front or back face which depends entirely on the ordering of the vertices. The default is that the order of vertices from the rendering viewpoint is counter-clockwise but this can be set to clockwise.

In short: when you negatively scale, the order of the vertices changes from counter-clockwise to clockwise and OpenGL decides it’s a backface and drops it.

hth, Paul— On Mon, 8/10/09, dominique at savagesoftwaresolutions.com wrote:

From: dominique at savagesoftwaresolutions.com
Subject: [SDL] Negative Scaling factor - Moving from DirectX to OpenGL…
To: sdl at lists.libsdl.org
Date: Monday, August 10, 2009, 7:38 PM
Hi all,
? I have some code that was originally Win32/DirectX 9
and I’m not porting
to Mac OS X ( 10.5 ) and OpenGL.
Most of it appears to work, except negative scaling values.
In the DirectX
code it correctly mirrors a sprite, but the same value in
OpenGL seems that
the sprite is not even drawn.

Any ideas from the gurus who’ve done this sort of thing
before.

Dominique.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

You could also scale the texture coordinates instead of the vertex ones.

El Martes 11 Agosto 2009ES 02:32:44 Paul Duffy escribi?:> I knew this rang a bell.

If I remember right (it’s been a while admittedly) you first need to flip
the normal (on 3D objects anyway). You then need to take into account how
OpenGL decides if a polygon is a front or back face which depends entirely
on the ordering of the vertices. The default is that the order of vertices
from the rendering viewpoint is counter-clockwise but this can be set to
clockwise.

In short: when you negatively scale, the order of the vertices changes from
counter-clockwise to clockwise and OpenGL decides it’s a backface and drops
it.

hth, Paul

— On Mon, 8/10/09, dominique at savagesoftwaresolutions.com wrote:

From: dominique at savagesoftwaresolutions.com
Subject: [SDL] Negative Scaling
factor - Moving from DirectX to OpenGL… To: sdl at lists.libsdl.org
Date: Monday, August 10, 2009, 7:38 PM
Hi all,
? I have some code that was originally Win32/DirectX 9
and I’m not porting
to Mac OS X ( 10.5 ) and OpenGL.
Most of it appears to work, except negative scaling values.
In the DirectX
code it correctly mirrors a sprite, but the same value in
OpenGL seems that
the sprite is not even drawn.

Any ideas from the gurus who’ve done this sort of thing
before.

Dominique.

I knew this rang a bell.

If I remember right (it’s been a while admittedly) you first need to flip
the normal (on 3D objects anyway). You then need to take into account how
OpenGL decides if a polygon is a front or back face which depends
entirely
on the ordering of the vertices. The default is that the order of
vertices
from the rendering viewpoint is counter-clockwise but this can be set to
clockwise.

Isn’t that only the case if “Back Face culling” is enabled? If all Polygons
are in the same direction, you may let OpenGL cull the front or back side,
or none.

In short: when you negatively scale, the order of the vertices changes
from
counter-clockwise to clockwise and OpenGL decides it’s a backface and
dropsOn Tue, 11 Aug 2009 00:32:44 +0000 (GMT), Paul Duffy wrote:
it.

Christoph Nelles

E-Mail : @Christoph_Nelles
Jabber : eazrael at evilazrael.net ICQ : 78819723
MSN : msn at evilazrael.de Yahoo! : eazrael

PGP-Key : ID 0x424FB55B on subkeys.pgp.net
or http://evilazrael.net/pgp.txt

You’re right. That’s quite entry level too, isn’t it. I really need to get back in to doing some proper graphics programming.— On Tue, 8/11/09, Christoph Nelles wrote:

From: Christoph Nelles
Subject: Re: [SDL] Negative Scaling factor - Moving from DirectX to OpenGL…
To: “A list for developers using the SDL library. (includes SDL-announce)”
Date: Tuesday, August 11, 2009, 9:34 AM
On Tue, 11 Aug 2009 00:32:44 +0000 (GMT), Paul Duffy <@Paul_Duffy> wrote:

I knew this rang a bell.

If I remember right (it’s been a while admittedly) you
first need to flip
the normal (on 3D objects anyway). You then need to
take into account how
OpenGL decides if a polygon is a front or back face
which depends
entirely
on the ordering of the vertices. The default is that
the order of
vertices
from the rendering viewpoint is counter-clockwise but
this can be set to
clockwise.

Isn’t that only the case if “Back Face culling” is enabled?
If all Polygons
are in the same direction, you may let OpenGL cull the
front or back side,
or none.

In short: when you negatively scale, the order of the
vertices changes
from
counter-clockwise to clockwise and OpenGL decides it’s
a backface and
drops
it.

Christoph Nelles

E-Mail? ? : evilazrael at evilazrael.de
Jabber? ? : eazrael at evilazrael.net?
? ? ICQ? ? ???: 78819723
MSN? ? ???: msn at evilazrael.de?
? ? ? ???Yahoo!? ? :
eazrael

PGP-Key???: ID 0x424FB55B on
subkeys.pgp.net
or http://evilazrael.net/pgp.txt


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org