View Full Version : image rendering and app rotation issues

04-30-2012, 11:33 AM
Hi all,

Just wondering if anyone can render some assistance in my development issues?

First off is an issue with textures. The app I'm designing copies an image from a SoftSurface onto an IImage, which gets copied to a texture to be wrapped around a model.

The initial image ( a texture map ) is loaded into the IImage, then a for-loop copies pixels from the SoftSurface to the IImage.
This all works swimmingly, except the final image isn't right. instead of the pixels being copied, i get an incredibly stretched version.
Mip-mapping is off and so is anti-aliasing. Iíve attached an image of the problem. Any advice would be much appreciated.


this is the code to copy the image:

for(int x =0;x < canvW;x++)
for(int y =0;y < canvH;y++)
colour = canvas->GetPix(x,y);
inImage->setPixel((262-y),(1568+x),SColor(colour.a, colour.r, colour.g, colour.b),true);
//setpixel isnt set to x,y as the coordinates given translate and rotate to the correct position on IImage
tex = driver->addTexture("TexSkin", inImage);


The second issue it that of adding a popover view to a menu. I have successfully added a popover view that appears on a proton button press, but the popover allways seems to think that the app is running in portrait mode?
I have tried setting the app to landscape only in the target settings, and tried altering bits of the code, but as of yet, have had no success.
Any ideas?

I appriciate these are non-trivial questions, but I am nearing my wits end on trying to resolve these issues. Therefore any help whatsoever would be greatly appriciated.

Thanks very much,


04-30-2012, 11:46 AM
Well, I'm not sure looking at the bmp thing, but I recommend you save it out as raw or a bmp at every stage to verify that it is correct even before that operation, if you haven't. (My SoftSurface has a SaveToBmp() function if you need an example)

For native iOS pop-ups to come up in the right orientation, you might try this:

[[UIApplication sharedApplication] setStatusBarOrientation: UIInterfaceOrientationLandscapeLeft];

Somewhere. (setting to the correct orientation you want) - You'll have to hack the shared iOS app code, I don't have a way to set that from the .cpp side right now... although it should already be setting it correctly somewhere, hrm.

05-08-2012, 11:40 AM
hi Seth,

Thanks for the advice. I still havnt managed to get the rotoation working, but i will work on that.

I have found that the problem occours in the SoftSurface GetPixel function. Using the origanal GetPixel function returns a blank pixel (0,0,0,0), and using my method causes the graphical peculiarities. Below is a copy of the code in GetPix ( made to attempt to resolve the issues with getPixel):

glColourBytes temp;
temp.r = m+pPixels[ (((m_height-1)-y)*(m_usedPitch+m_pitchOffset)+x)];
temp.g = m+pPixels[ (((m_height-1)-y)*(m_usedPitch+m_pitchOffset)+x)+1];
temp.b = m+pPixels[ (((m_height-1)-y)*(m_usedPitch+m_pitchOffset)+x)+2];
temp.a 255;

Its definately an issue with selecting the right data, as if i replace this function to output a blend ( temp.r = x%255 ) it is perfect and smooth.

Any advice? The only thing I can think of is that it is a slightly older version of proton ( cant remember which ), but I cant understand why this is happening :S.



05-08-2012, 03:05 PM
In case enyone else has this issue ( not likely ); in soft surface:

glColorBytes GetPixelv2( int x, int y )
if (m_surfaceType == SURFACE_RGBA)
return *((glColorBytes*)((m_pPixels+(y*m_usedPitch+x*4))) );

return glColorBytes(0,0,0,255);

It may be a little hacky, but it works a treat.



05-11-2012, 02:17 AM
Ahh, yep, my version of GetPixel() returns white if it doesn't know how to handle the surface type - if you had run the game in debug mode it should've asserted with this message.

Thanks for the code, I've added it to GetPixel() you can safely use it as well.

New GetPixel looks like this now:

glColorBytes GetPixel( int x, int y )
switch (m_surfaceType)
return m_palette[m_pPixels[ ( ((m_height-1)-y)*(m_usedPitch+m_pitchOffset)+x)]];

return *((glColorBytes*)((m_pPixels+(y*m_usedPitch+x*4))) );

assert(!"Unhandled pixel type... SSSSEEEEETTTHH!");

return glColorBytes(0,0,0,255);


I should really add handling for SURFACE_RGB also, and then do the same thing for SetPixel but.. well.. :wheelchair: :whistling: :sweatdrop:

05-14-2012, 10:04 AM
Cheers Seth; you're a life saver as usual.

When i finally get this project done, i'll try and get those bits done as a thankyou.


05-15-2012, 02:55 PM
What about the mipmapping for this path ?
So this is another way besided the rttex ?

05-22-2012, 02:45 PM
hi linuxlovelinux99,

sorry, i don't understand what you are asking :confused:
could you explain the question?