PocketMatrix forums

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

Help with G_GETPIXEL

Hi Kornalius

You've been quiet today so I thought I'd better start a new thread :D

I'm trying to use G_GETPIXEL to retrieve the color on the screen but I get the following error:

Runtime error
proc:(null)
opcode: G_GETPIXEL

Access violation at 0x4ba1c

As the parameters seem to be just x,y and the return value a color I can't think what I'm doing wrong. Is there some sort of init required before calling it?

gdrawcolor$ = g_getpixel(loword(lParam$),hiword(lParam$));
Did you call InitGameAPI() or G_INIT() before?

G_PIXEL() should work then.
yes i called initgameapi().
im using the same program i PM'd you before the weekend. i have just added a routine to pick up the pixel color at the stylus co-ords when tapping in a pallete rectangle.
I still didn't get a chance to look at program, it will be done tomorrow for sure. I will take a look at the g_getpixel() function at the same time.

Sorry for the delay.
Just did a quick and dirty test and I think you need to do a lock and a unlock after.

Code:
g_lock;
g_getpixel(LOWORD(lParam$), HIWORD(lParam$));
g_unlock;


It didn't give me an error with the g_lock and g_unlock.
I've been using the get/setpixel functions without problems - without locking first...

RenderSprites; has been commented out though. If something were to call frogdisplay::update, it would fail like that. Maybe something is doing that? Just a guess...
There you go, you got it. We need to g_BeginScene() then g_Update() instead of g_lock() and g_unlock().

Thanks fast_rx.
Hmmm... I had assumed that YOUR game framework (i.e. GameProc) automatically called PFrog's GetDisplay() and Update() automatically.

Is that not true?
Hi chaps,

Thanks for the help. Its working now with g_beginscene() and g_update().

At what level do these commands need calling? Should they bracket each seperate set of screen access?
There are called automatically between WM_PAINT event only.