GP2X problem

Previous topic - Next topic

Gary

Just for a laugh I thought I would get a project im working on running on the GP2X (well actually I wanted to work on a device smaller than the 1024x768 screen I am using on the PC to make sure that my on screen buttons worked fine on a smaller res screen)

I have one routine that displays the graphics and have altered that to draw to a backscreen sprite and then switch to the main screen, resize the sprite from 1024 x 768 to 320 x 240 and output that single sprite.

If I run the program on the PC I get a nice small version of the larger screen that works perfectly.

When I compile and load it to the GP2X (after setting it to full screen and no pointer) I find that most of the graphics have not been scaled but some of them have and I end up with a totally unuseable screen.

If there a problem with STRETCHSPRITE or multiple screens on the GP2X?

Thanks
Gary

Ian Price

You might be better off using a CREATESCREEN with dimensions of 1024x768 (your pc res) then drawing everything (the buttons, sprites etc.) to it and then use that screen as a sprite, but scale it down to 320x240.

It'll look horrible (probably), but it should work. My GP2Xs are stashed away for now, so I can't give a proper working example at the moment.
I came. I saw. I played.

Gary

so keep it at 1024x768 and full screen and then draw everything to the back screen and then draw that sprite reduced to the front screen?

I will give it a go, thanks

Gary

if thats what you meant then no there is no difference :(

Kitty Hello

No, the screen is 320x240 hardcoded. And so is GRABSPRITE limited.

You should try CREATESCREEN 1, bigx, bigy; USESCREEN 1; Draw...
USESCREEN 0;
STRETCHSPRITE 1,0,0,320,240

Gary

this is what I am doing so far

Code (glbasic) Select
CONSTANT SCREEN_X = 320
CONSTANT SCREEN_Y = 240

SYSTEMPOINTER FALSE
SETSCREEN SCREEN_X,SCREEN_Y,TRUE

CREATESCREEN 1,70,1024,768


That is my set up screen code

then when I draw the screen I do the following

Code (glbasic) Select
USESCREEN 1

(all the graphic draw code here)

USESCREEN -1
STRETCHSPRITE 70,0,0,SCREEN_X,SCREEN_Y
SHOWSCREEN


If I use USESCREEN 0 I just get a black screen on the pc when I test it

Ian Price

#6
Gernot has indeed interpreted my version correctly.

Here's an example that works on pc -

Code (glbasic) Select

LOCAL mx,my,b1,b2, n

CREATESCREEN 1,999,1024,768

USESCREEN 1

FOR n=0 TO 1000
DRAWRECT RND(1024),RND(768),RND(32),RND(32),RGB(RND(255),RND(255),RND(255))
NEXT

USESCREEN -1

WHILE TRUE

MOUSESTATE mx,my,b1,b2

DRAWSPRITE 999,0,0

STRETCHSPRITE 999,mx,my,320,240

SHOWSCREEN

WEND


Use your mouse to move the mini version around to see it properly.
I came. I saw. I played.

Gary

Hi Ian

Just tried it and it works fine on the pc but build it for the GP2X and I just end up with a black screen. It does very briefly flicker the large version on the screen and then nothing, touching the screen which I would have expected to have brought the small version onto the screen does nothing.

I am going to try building some of the example programs and see what happens

Ian Price

I wouldn't expect that code to work on the GP2X as is tbh - that was just a pc example to show how the idea works.

I'll have a look later on a proper GP2X.
I came. I saw. I played.

Gary


Kitty Hello

I tried the GP2X code in my IDE and it seems to work fine. Does it really display a black screen on the real device?

Ian Price

#11
Actually, he's right - I think there's a problem with the CREATESCREEN command on GP2X, as neither STRETCHSPRITE, ZOOMSPRITE or POLYVECTOR scaling (of the created sprite) works correctly on the GP2X (they don't display anything). They are fine on pc.

How odd - I'm sure I've used CREATESCREEN before on GP2X and Wiz without problem.

A bug, methinks.

[EDIT] To confirm my findings I just tried to use DRAWSPRITE on the sprite created with CREATESCREEN, and that is not displayed either.
I came. I saw. I played.

Kitty Hello

Does it work on the Wiz? (If you find time)

Ian Price

I'll check...
I came. I saw. I played.

Ian Price

#14
Right, just tested on Wiz with this code -

Code (glbasic) Select

LOCAL skip

// Create a larger than screen screen
CREATESCREEN 1,999,1024,768

// Draw on this larger screen
USESCREEN 1

// Create chequerboard effect
FOR y=0 TO 768 STEP 64
FOR x=0 TO 1024 STEP 128
DRAWRECT x+skip,y,64,64,RGB(255,255,255)
NEXT

skip=64-skip

NEXT

// Use normal drawing screen for all future operations
USESCREEN -1

// Main loop
WHILE TRUE

// Red background rectangle
DRAWRECT 0,0,320,240,RGB(255,0,0)

// Turn off smoothing/anit-aliasing
SMOOTHSHADING FALSE

// Draw polyvector sprite
STARTPOLY 999
POLYVECTOR 0,0,0,0
POLYVECTOR 320,0,1024,0
POLYVECTOR 320,240,1024,768
POLYVECTOR 0,240,0,768
ENDPOLY

// MENU/RETURN button
IF KEY(28)
// Green background rect
DRAWRECT 0,0,320,240,RGB(0,255,0)
Scale and display sprite created with CREATESCREEN
ZOOMSPRITE 999,-352,-264,0.3125,0.3125
ENDIF

// So you know something's working
PRINT "HELLO",10,10

SHOWSCREEN

WEND

END


POLYVECTOR scaling doesn't work, but ZOOMSPRITE does (need to press MENU button to see it in action).

Both work fine on pc. neither work on GP2X.
I came. I saw. I played.