PocketMatrix forums

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

What's wrong?

Hello, i've jusi installed EasyCe 1.5 and trying to use this.
I've use VC6.0, and PocketPC emulator (with Gapi emu).

My app source:

#include "EasyCE.h"

void main()
{
     
     unsigned short* buffer = (unsigned short*)getbuffer();      
     while (clicked()) { update(); };

     
     while (!clicked()) { update(); };

     PIXEL* dest;
     ACHAR* file="images/skyshot.tga";
     int w = 320;
     int h = 240;
     bool tgaload( ACHAR* file, int w,  int h, PIXEL* dest );


     ASprite sprite(320, 240, 320, (PIXEL*) dest );


     ASprite::settarget( buffer );
     sprite.setpos(0,0);
     

     sprite.draw();
     update();
     
}

Build ok.
But when i run this on the emu, and click on the screen, this error displayed:

The instuction at "0x00407694" referenced memory at "0xcccccccc". The memory could not be read.

What's wrong?

Sorry - i am absolutely newbie in c++ :-)

Thank's for possible help.

p.s. Examples with previous version of EasyCE, such as "sampleapp" and others ran OK.

hi Max!
I'm a newbie too, that's why I'm trying to help. I wanna learn myself :)
So what in my opinion is happening here is that you load the tga image to an unitialized adress. You use the tgaload funct before of setting up any memory space for "dest"
Can it be?

Plz excuse my english. I am. . .
yeah, you will definately need to allocate a block of memory equal to the size of the image you are trying to load. if you know that your sprite is a 256*256 image, then:

// create the block of memory for the sprite
PIXEL* source = new PIXEL[256 * 256];

once created, load your image to the block of memory you just allocated.  remember to free this block of memory when done:

// free the memory
delete source;

hope this helps.

- Ketamien
is this right?

(not works too :-))

void main()
{
     
     unsigned short* buffer = (unsigned short*)getbuffer();

     PIXEL* dest = new PIXEL[240 * 80];
     
     int w = 240;
     int h = 80;
     ACHAR* file = "sprite.tga";

     bool tgaload(ACHAR* file, int w, int h, PIXEL *dest);

     ASprite sprite(240, 80, 240, dest );


     ASprite::settarget( buffer );
     sprite.setpos(0,0);
     sprite.draw();
     update();
                       

     
     while (clicked()) { update(); };

     
     while (!clicked()) { update(); };



     
     
}
GeoffSulcer · 21 Nov 2001, 11:53 UTC
Hi,

One thing I see:


      bool tgaload(ACHAR* file, int w, int h, PIXEL *dest);


What you have here is the declaration of the function tgaload.  What you want is a call to the function.

tgaload(file, w, h, dest);

or better:

if(!tgaload(file, w, h, dest)
{
   //file was not read
   //handle this gracefully
}

Oh, thank you, my angel !!!

:-)))

2 Phantom:

Maybe you'll need organize special forum for lamers like me?
:-)

Max
Max,

Absolutely not. Everyone has to start somewhere, especially with a new library. The problems you encounter are valuable input for the next version of EasyCE, I would like to make things as intuitive as possible. One day I will also pick up the writing of tutorials again, and for these I also need to know what things people find to be hard to comprehend. So by all means, don't go away and don't stop asking stupid questions. :) BTW, I didn't have to answer a single stupid question myself. :)

BTW, register. :)

- Jacco.