This site is no longer active and is available for archival purposes only. Registration and login is disabled.

3D working, need to understand Pitch


3D working, need to understand Pitch

Postby Conan » Jul 14, 2002 @ 9:05am

What is Best in Life ?
User avatar
Conan
pm Member
 
Posts: 1309
Joined: Dec 24, 2001 @ 5:16am
Location: the Shades, Ankh-Morpock


Postby Kzinti » Jul 16, 2002 @ 7:32pm

Hi Conan,

I will break down your message in two questions:

Q1: What is the pitch and how to work with it?

A1: The pitch represents the offset in bytes between two row of pixels. A typical error is to use the width of the surface to calculate this offset (where the pitch should be used). You typically won't have to deal with the pitch until you want to use direct access. Basically, you Lock() a surface and the pitch is returned to you. Pixels are then addressed in the following manner:

Pixel(x,y) = (startOfBuffer) + y * pitch + x * 2


Q2: What is Swizzle()/Unswizzle()?

A2: Each device has a different screen orientation (ie: the actual display hardware is mounted sideway on the iPAQ36xx). In fact, the iPAQ36xx has a 320x240 pixels display (not a 240x320!). Doing "rotation" of the backbuffer in real time is slow. Because of this, PocketFrog pre-rotate all surfaces to match the hardware orientation. This is transparent: you draw on a surface using a rasterizer which takes care of this orientation for you.

When doing direct access (or GDI), PocketFrog will rotate the surface to a "normal" orientation by calling Swizzle(). When you have finished updating the surface, PocketFrog rotate the surface back to match the hardware, this is Unswizzle().

Now, there is no need to Swizzle() if you are going to overwrite all the pixels (ex: loading an image, rendering a 3D scene). In the same manner, there is no need to Unswizzle() if you didn't change any of the pixels. This is exposed in the appropriate methods (Lock, Unlock) by the "bDiscard" boolean.

Of course, if the display hardware orientation is already "normal", Swizzle() and Unswizzle() won't do anything (ie: no performance hit).
Kzinti
pm Member
 
Posts: 3238
Joined: Jan 13, 2002 @ 5:23am


Postby BurningSheep » Aug 3, 2002 @ 3:55pm

Do you want custom Snails levels? Click
User avatar
BurningSheep
pm Insider
 
Posts: 1226
Joined: Apr 12, 2002 @ 11:49pm
Location: The Netherlands


Postby Kzinti » Aug 3, 2002 @ 5:12pm

Kzinti
pm Member
 
Posts: 3238
Joined: Jan 13, 2002 @ 5:23am


Postby BurningSheep » Aug 3, 2002 @ 7:31pm

The first method doesn't work on my iPAQ, I'm probably doing something funky. I'm going to try to figure it out later.
It just isn't my day I guess, ActiveSync doesn't even want to install anymore, so debugging on the device is also out of the question at the moment. :\
Do you want custom Snails levels? Click
User avatar
BurningSheep
pm Insider
 
Posts: 1226
Joined: Apr 12, 2002 @ 11:49pm
Location: The Netherlands


Return to PocketFrog & PocketHAL


Sort


Forum Description

SDKs for fast and robust device-independent access to Pocket PC display hardware.

Moderators:

sponge, Kzinti

Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

cron