PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Smartphone and PocketGL

I have posted this on the official pocketGL forum but it seems very quiet and I also noticed a few familiar names from pocketmatrix so I thought I'd post here as well.

I have recently purchased the full version of PocketGL and I'm hoping to use it with the MS Smartphone platform. I checked with Pierre (the author) prior to purchase that it should work as long as I modify the blit routine to take account of the smartphone screen size (which is 176*220). And that is where I'm getting stuck.

I'm currently only trying to get the demos to work - they run but the screen is all messed up. For example with the solar system demo you can see that things are moving but that the pixels are being drawn in the wrong place - which follows exactly what Pierre said.

The MS Smartphone has an ARM processor and as the device won't correspond to any pocket pc, I assume the Flush_Standard method is being called. I'm assuming that I need to change some of the values in the flush method and also in the blit (which I assume is handled in the blitARM.s file) as well as the DISP_X and DISP_Y values defined in board3D.h.

I know a few people have asked before about different screen sizes so I was wondering if anyone had been successful. Any advice on what values to change where would be greatly appreciated.

Many thanks.
Sorry for not seeing your post on the PGL forum. I only look every couple of days. I am happy to try to help & also very interested as a PGL user who has a bid on a smartphone on ebay at the moment.

Can you post a screen shot or email to ian@sundialsoft.co.uk, also tell me which values you have already changed like dispx & dispy.

I assume you are using V1.2? I'm using V1.0 which has many differences but have the 1.2 upgrade

probably the best answer will come from Dan East if he sees this post & has time to respond.
You will have to rewrite the flush routine(s) you need. It's been a long time since I've used them, but they were hardcoded specifically to blit 320x240. That blit does 3 things. Looks up the actual RGB565 color value in a LUT, copies that to the output buffer, and resets the Z-Buffer.

Dan East
Dan,

Am I correct in assuming that rewriting the flush routines also means modifying the ARM assembler code in blitARM.s?

Also in the Flush_Standard routine there are several values which I can't tell the meaning of. For example:

Dest2 += 319*120;

Where did the 319 and 120 come from? Is 319 the screen width-1 or is that just coincidence. Forgive my ignorance but I have only ever used Gapidraw in previous projects for my blitting - so I've had to pay very little attention to the blitting side of things.

Many thanks.
gevans2000 wrote:

Dest2 += 319*120;



Simple guess : 319 = 320 - 1 and 120 = 240/2

It's very common to use half of the screen width in loop counter, simply because 32 bits = 2 pixels.
Am I correct in assuming that rewriting the flush routines also means modifying the ARM assembler code in blitARM.s?


as far as i remember, PocketGL also includes C-code for the final backbuffer blit. of course in most cases the assembler will be faster...

DANIEL
Yes, it also contains a C version, which can be used in place of the ASM flush. There are a few different versions, depending the device type, and whether or not the display should be reversed (for rendering landscape left as opposed to landscape right). It does blit two pixels (32 bits) at a time.

Dan East
Many thanks to you all. I've managed to get it working using the C code (by disabling the ASM code) and it was just a case of changing the 319 and 120 values to match the dimensions of the Smartphone screen.

I assume that the ASM code would be faster (?) (pocketGL seemed to want to execute it by default) so I'll take a look at that, but at least I have something to work with. :D
gevans2000 wrote:
I assume that the ASM code would be faster (?) (pocketGL seemed to want to execute it by default) so I'll take a look at that, but at least I have something to work with. :D


That's completely dependant on what you're blitting to. If the display controller has on-board DRAM, then the bus speed will be the limiting factor. So the writes to that memory will stall your code, and optimizing it in ASM would probably not help.

It's very important to align your backbuffer (VScreen in PocketGL) to the native orientation of the display buffer, which is not necessarily the same orientation the device is normally used at. PocketGL does not do this - its buffer is always 320x240. That means it will perform very bad on some devices, like the Toshiba e740, which has a 240x320 buffer. PocketGL was really designed around the iPaq 3630, which uses a 320x240 display. You can get around this alignment problem by using PocketHAL, which is extremely fast even when your backbuffer needs to be rotated real-time.

Dan East