 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
Giuliano
Joined: 13 Sep 2005 Posts: 78
|
Posted: Sun Apr 16, 2006 10:45 pm Post subject: Oldschool Lib Drawing On Image |
|
|
I have just started to work with OSLIB and I am unable to draw to an image. I understand that the image that is drawn to must be in VRAM. Therefore I made two functions that will copy the image to VRAM, draw, and copy it back. But they don't work, I get an ugly image back with lots of lines and messed up colors. Has anyone gotten this to work ?
Here is my code
| Code: |
void ImageFillRect(OSL_IMAGE *img,int x1,int y1,int x2,int y2,unsigned long color) {
OSL_IMAGE *tmp;
tmp=tmp=oslCreateImageCopy(img,OSL_IN_VRAM);
oslSetDrawBuffer(tmp);
oslDrawFillRect(x1,y1,x2,y2,color);
oslCopyImage(img,tmp);
oslSetDrawBuffer(OSL_DEFAULT_BUFFER);
oslDeleteImage(tmp);
}
void DrawImageOnImage(OSL_IMAGE *srcimg, int srcX, int srcY, int width, int height, OSL_IMAGE *destimg, int destX, int destY) {
OSL_IMAGE *tmp;
tmp=oslCreateImageCopy(destimg,OSL_IN_VRAM);
oslSetDrawBuffer(tmp);
oslSetImageTileSize(srcimg,srcX,srcY,width,height);
oslDrawImageXY(srcimg,destX,destY);
oslCopyImage(destimg,tmp);
oslSetDrawBuffer(OSL_DEFAULT_BUFFER);
oslDeleteImage(tmp);
}
|
Edit: I am trying this on a newly created image btw. I noticed that if you clear the image (oslClearImage) first then it works. But the problem is that I want the image to be transparent everywhere besides where I draw (this will be a layer of a map) and clearing it with oslClearImage(image,RGBA(0,0,0,0)); just makes the image completely blank even after I draw on it. |
|
| Back to top |
|
 |
Brunni
Joined: 08 Oct 2005 Posts: 186
|
Posted: Mon Apr 17, 2006 4:43 am Post subject: |
|
|
Yes, that's a problem, drawing to an image is very limited as the alpha component is never written by the GPU.
I'm desperately trying to find a solution but nobody can help me (like in this drowning topic)
This would be so useful... :-( _________________ Sorry for my bad english
Oldschool library for PSP - PC version released |
|
| Back to top |
|
 |
Giuliano
Joined: 13 Sep 2005 Posts: 78
|
Posted: Mon Apr 17, 2006 5:11 am Post subject: |
|
|
| well I kind of want the alpha component to be skipped .. but if the image is created empty and then drawn to , it's messed up .. if it is cleared first, it is okay |
|
| Back to top |
|
 |
Brunni
Joined: 08 Oct 2005 Posts: 186
|
Posted: Mon Apr 17, 2006 6:50 pm Post subject: |
|
|
When you do oslCreateImage, the resulting image is not empty, it contains random data (what was at this VRAM area before).
That includes alpha, which might be set to anything. So, if it's 0 (and it's most likely 0) this means transparent, so the pixel will not be drawn, whatever its color is. You might also have some semi-transparent pixels and so on, resulting in a messed up image. It's why you need to clear it before ;)
But maybe I misunderstood your problem? _________________ Sorry for my bad english
Oldschool library for PSP - PC version released |
|
| Back to top |
|
 |
Giuliano
Joined: 13 Sep 2005 Posts: 78
|
Posted: Mon Apr 17, 2006 9:08 pm Post subject: |
|
|
| That's correct .. it's just that I don't want to draw any transparent pixels anyways (using OSL_FX_FLAT) so I thought that I wouldnt be affected by that problem you posted in the other thread since the pixel should be drawn at all. I don't draw any semi-transparent pixels, it's either transparent or opaque. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|