SDL render

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
coldev
Posts: 3
Joined: Fri Jul 21, 2006 7:43 pm

SDL render

Post by coldev »

sdl render , with problems
http://fenixworld.se32.com/e107_plugins ... 2.m8ee.zip

draw colors not correctly :
please help us..

this is code :
---------------------------------



void RecuperarSuperficieDibujo(char *puntero, int pitch)//recupera el render y lo dibuja en SDL
{

int ancho= Mitextura->getSize ().Width;
int alto= Mitextura->getSize ().Height;


s16 *MiZbuffer=(s16 *)Mitextura->lock ();

/*
int x,y;
for (x=1;x<ancho;x++)
for (y=1;y<alto;y++)
((s16 *)puntero)[x + pitch*y] = A1R5G5B5toA8R8G8B8(((s16*)MiZbuffer)[y*ancho + x]);
*/

int destPitch = pitch;
//s16* destData = reinterpret_cast<s16*>(puntero);
char *destData = (puntero);

for (int x=0; x<ancho; ++x)
for (int y=0; y<alto; ++y)
if (x < ancho && y < alto)
{
s16 c = MiZbuffer[y*ancho +x];
destData[y* destPitch + x] =
((c >> 10)&0x1F)<<11 |
((c >> 5)&0x1F) << 6 |
((c)&0x1F);
}


Mitextura->unlock ();
}
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

What? :shock: :?
Maybe try to explain what your problem is, what the app should do and you translate the code comments. I'm not able to help here with the information as is.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Looks like he's trying to convert A1R5G5B5 data to R5G6B5. The big problem is that the destData pointer is only a byte and he's stuffing 16 bits of data in.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Ok, in that case use 2*x to add.But be aware that this routine does not check the texture format, so you might meet very different formats as well.
coldev
Posts: 3
Joined: Fri Jul 21, 2006 7:43 pm

in where?

Post by coldev »

hybrid wrote:Ok, in that case use 2*x to add.But be aware that this routine does not check the texture format, so you might meet very different formats as well.
in that part ? please write the code ..

thank you very much.

void Irrch2SDL(char *mypointer, int pitch)//draw in sdl
{

int width= Mitexture->getSize ().Width;
int height= Mitexture->getSize ().Height;


s16 *MiZbuffer=(s16 *)Mitexture->lock ();

/*
int x,y;
for (x=1;x<ancho;x++)
for (y=1;y<alto;y++)
((s16 *)mipointer)[x + pitch*y] = A1R5G5B5toA8R8G8B8(((s16*)MiZbuffer)[y*ancho + x]);
*/

int destPitch = pitch;
//s16* destData = reinterpret_cast<s16*>(puntero);
char *destData = (mypointer);

for (int x=0; x<width; ++x)
for (int y=0; y<height; ++y)
if (x < width && y < height)
{
s16 c = MiZbuffer[y*width +x];
destData[y* destPitch + x] =
((c >> 10)&0x1F)<<11 |
((c >> 5)&0x1F) << 6 |
((c)&0x1F);
}


Mitexture->unlock ();
}
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

The very last use of x, but destPitch has to be correct also. Better use the s16* as currently commented out. Or check the ColorConverter methods available in Irrlicht. They do similar things with different byte sizes.
Post Reply