|
This thread is locked; no one can reply to it. |
1
2
|
A little help with open layer |
FMC
Member #4,431
March 2004
|
I'm making a Qix clone, basically i have an image covered by another image, everytime you complete a shape that shape gets erased from the upper image, showing the one underneath. What i do is simply: Canvas::SetTo(gdata.mask); //i set the drawing surface to the upper image Canvas::SetPixelWriteMode( ALPHA_ONLY ); a.Draw( Rgba(255,255,255)); //a is the shape polygon, drawing with alpha should make a "hole" // Set the screen as the active canvas // Canvas::SetTo( SCREEN_BACKBUF );
problem is that as soon as i call Canvas::SetTo(gdata.mask); the upper image disappears!??? [FMC Studios] - [Caries Field] - [Ctris] - [Pman] - [Chess for allegroites] |
Fladimir da Gorf
Member #1,565
October 2001
|
To render textured polygons, you could use the new TexturedPoly. You shouldn't call Canvas::SetTo after you've drawn to the screen, or otherwise it won't work with some hardware (I think this should be in the manual, but maybe not...) To clip to arbitary regions, I recommend drawing to the alpha channel of the screen and using Blenders::Set( GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA ); OpenLayer has reached a random SVN version number ;) | Online manual | Installation video!| MSVC projects now possible with cmake | Now alvailable as a Dev-C++ Devpack! (Thanks to Kotori) |
FMC
Member #4,431
March 2004
|
Well, before using Canvas::SetTo i call GfxRend::RefreshScreen();,shouldn't this fix it? Am i wrong or TexturedPoly isn't in the 2.0 release? Anyway i'm attaching source and binary (allegro 4.2) so that you can have a better idea of what my problem is P.S. I've found a bug in LineStrip: if two points are too close it gets rendered weirdly, is this a known issue? [edit]too big (600k) to attach... linky [FMC Studios] - [Caries Field] - [Ctris] - [Pman] - [Chess for allegroites] |
CursedTyrant
Member #7,080
April 2006
|
Quote: Well, before using Canvas::SetTo i call GfxRend::RefreshScreen();,shouldn't this fix it? RTFM? In fact, it can only make matters worse. Quoted from OL Manual: Quote: GfxRend::RefreshScreen can still be used for backwards compability but it's highly deprecated as it may mess up your code if you use Canvas as well. So if you use Canvas, it's best to use only Canvas, not RefreshScreen. Call Canvas::Refresh() instead. And no, I did not find TexturedPoly in the newest release of OL either (I had to comment out the #include in OpenLayer.hpp). --------- |
FMC
Member #4,431
March 2004
|
Well, i usually check the fucking demos, and there GfxRend::RefreshScreen() is still used Anyway Canvas::Refresh doesn't help. [FMC Studios] - [Caries Field] - [Ctris] - [Pman] - [Chess for allegroites] |
Fladimir da Gorf
Member #1,565
October 2001
|
TexturedPoly can be found in the latest SVN version. Could you post the whole code so that I can check it out? OpenLayer has reached a random SVN version number ;) | Online manual | Installation video!| MSVC projects now possible with cmake | Now alvailable as a Dev-C++ Devpack! (Thanks to Kotori) |
FMC
Member #4,431
March 2004
|
Attached with second post [FMC Studios] - [Caries Field] - [Ctris] - [Pman] - [Chess for allegroites] |
Fladimir da Gorf
Member #1,565
October 2001
|
OK, I'm blind Quote: P.S. I've found a bug in LineStrip: if two points are too close it gets rendered weirdly, is this a known issue? That's already fixed in SVN, too. OpenLayer has reached a random SVN version number ;) | Online manual | Installation video!| MSVC projects now possible with cmake | Now alvailable as a Dev-C++ Devpack! (Thanks to Kotori) |
CursedTyrant
Member #7,080
April 2006
|
I believe he meant this: http://www.savefile.com/files.php?fid=6916957 --------- |
FMC
Member #4,431
March 2004
|
To clear things up i have: underneath image:{"name":"15ph.jpg","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/e\/6\/e64f2ade9c31d490b4b88a2deb21f3c0.jpg","w":320,"h":240,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/e\/6\/e64f2ade9c31d490b4b88a2deb21f3c0"} upper image (gdata.mask):{"name":"22bk1.jpg","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/b\/6\/b6302bef5c6df54675aad140dc584212.jpg","w":320,"h":240,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/b\/6\/b6302bef5c6df54675aad140dc584212"} i should get: {"name":"30vt.jpg","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/2\/1\/21cc7298c130ba11413a7c9f2a8c406a.jpg","w":640,"h":480,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/2\/1\/21cc7298c130ba11413a7c9f2a8c406a"} instead i get:{"name":"45hz.jpg","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/6\/2\/62b990cf1de789827f45ea4ca91206fa.jpg","w":640,"h":480,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/6\/2\/62b990cf1de789827f45ea4ca91206fa"} [FMC Studios] - [Caries Field] - [Ctris] - [Pman] - [Chess for allegroites] |
Fladimir da Gorf
Member #1,565
October 2001
|
Quote:
Canvas::SetPixelWriteMode( ALPHA_ONLY ); The problem is that you're rendering "visibility" instead of "invisibility". The following code works for me: Canvas::SetTo(gdata.mask); Canvas::SetPixelWriteMode( ALPHA_ONLY ); Blenders::Push(); Blenders::Set( COPY_BLENDER ); a.Draw( Rgba::INVISIBLE ); Blenders::Pop(); // Set the screen as the active canvas // Canvas::SetTo( SCREEN_BACKBUF ); Note that the code requires the latest SVN version (COPY_BLENDER and other advanced Blenders stuff aren't in 2.0). OpenLayer has reached a random SVN version number ;) | Online manual | Installation video!| MSVC projects now possible with cmake | Now alvailable as a Dev-C++ Devpack! (Thanks to Kotori) |
FMC
Member #4,431
March 2004
|
There is something fishy going on... even if i comment out a.Dwaw as soon as i call Canvas::SetTo(gdata.mask); the upper image disappears... [FMC Studios] - [Caries Field] - [Ctris] - [Pman] - [Chess for allegroites] |
Fladimir da Gorf
Member #1,565
October 2001
|
Have you downloaded the latest version from the SVN repository yet? Your program works fine for me with the code I posted. OpenLayer has reached a random SVN version number ;) | Online manual | Installation video!| MSVC projects now possible with cmake | Now alvailable as a Dev-C++ Devpack! (Thanks to Kotori) |
FMC
Member #4,431
March 2004
|
Updated with SVN and used your code, everything is fine, thank you P.S. Examples still use the deprecated GfxRend::RefreshScreen [FMC Studios] - [Caries Field] - [Ctris] - [Pman] - [Chess for allegroites] |
Fladimir da Gorf
Member #1,565
October 2001
|
Quote: P.P.S. it would be nice if you had the berlios link in your sig Damn right, I wonder why I haven't thought of that... Now the link points there instead of SF.net. Quote: P.S. Examples still use the deprecated GfxRend::RefreshScreen OK, I should take all those out. OpenLayer has reached a random SVN version number ;) | Online manual | Installation video!| MSVC projects now possible with cmake | Now alvailable as a Dev-C++ Devpack! (Thanks to Kotori) |
Neil Walker
Member #210
April 2000
|
Quote: OK, I should take all those out. I already have (and fixed some more examples), though I haven't updated the SVN yet Neil. wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie |
FMC
Member #4,431
March 2004
|
A couple things i noted: 1)void CopyFromScreen(int x, int y ) prints 3 numbers in the console (no idea of why it does) 2)the manual should specify that SetPixelWriteMode( COLOR_ONLY ); is NOT the default when canvas is set to a bitmap; right now it says it is the default. [FMC Studios] - [Caries Field] - [Ctris] - [Pman] - [Chess for allegroites] |
Fladimir da Gorf
Member #1,565
October 2001
|
The numbers are probably some debugging stuff I've forgot there. About the PixelWriteMode - in the manual I can see it says: Quote: COLOR_AND_ALPHA - Both the color value and alpha channel are affected (Default for Bitmaps) Maybe you're looking at an older one? OpenLayer has reached a random SVN version number ;) | Online manual | Installation video!| MSVC projects now possible with cmake | Now alvailable as a Dev-C++ Devpack! (Thanks to Kotori) |
FMC
Member #4,431
March 2004
|
I'm using the docs in your sig I'm getting some unexpected behaviour, i'm not sure if it's my fault:
draw_info code:
I'm trying to get a magnifying lens effect Mouse cursor gdata.bcursors[0]: Mask used: gdata.bcursors[1]: what i get: {"name":"image18hm.jpg","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/7\/7\/77d75a1abf5ad005ed008395e57eea8d.jpg","w":644,"h":508,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/7\/7\/77d75a1abf5ad005ed008395e57eea8d"} Various problems: Thanks for all the help and for the great lib you provided [FMC Studios] - [Caries Field] - [Ctris] - [Pman] - [Chess for allegroites] |
Fladimir da Gorf
Member #1,565
October 2001
|
There's a better an much more efficient way to do this (it's a "fake" way, but anyways). - Make a circular textured polygon (during the startup) which has a texture the size of the lense Did I explain it well enough? OpenLayer has reached a random SVN version number ;) | Online manual | Installation video!| MSVC projects now possible with cmake | Now alvailable as a Dev-C++ Devpack! (Thanks to Kotori) |
FMC
Member #4,431
March 2004
|
Perfectly Where can i find TexturedPoly? [edit] Poly lens; //declared somewhere Bitmap texture_lens; //attached to lens ... blit_all_but_mouse_cursor(); texture_lens.CopyFromScreen( where_mouse_is ); ... and here i am at a loss, how do i stretch a polygon?
[FMC Studios] - [Caries Field] - [Ctris] - [Pman] - [Chess for allegroites] |
Fladimir da Gorf
Member #1,565
October 2001
|
Quote:
Where can i find TexturedPoly? Unfortunately it's not in the manual yet, but it's just: TexturedPoly myPoly( textureImage ); // Then use myPoly just like if it was a Poly To pre-cache the texture nodes in loading-time, you can call myPoly.Construct() when you've finished building the polygon. Quote: and here i am at a loss, how do i stretch a polygon? Using a Placement, for example, you can do this after you've constructed the new myPoly: myPoly.TransformBy( Placement( Vec2D( 0.0, 0.0 ), 0.0, stretchFactor )); where stretchFactor is 1.5 in your case. EDIT: I implemented Ellipse::ToPolygon just for you (In SVN now, as well as documentation for TexturedPoly) OpenLayer has reached a random SVN version number ;) | Online manual | Installation video!| MSVC projects now possible with cmake | Now alvailable as a Dev-C++ Devpack! (Thanks to Kotori) |
FMC
Member #4,431
March 2004
|
Thanks again for all the help so in init: then, the drawing code: draw_all_that_has_to_be_drawn(); gdata.bcursors[1].CopyFromScreen(mpos.x-30, mpos.y-30); gdata.myPoly->TransformBy( Placement( Vec2D(0.0, 0.0), 0.0, 1.0)); gdata.myPoly->Draw(1.0); Canvas::Refresh();
Problem is that with any value different from 1.0 it doesn't draw [FMC Studios] - [Caries Field] - [Ctris] - [Pman] - [Chess for allegroites] |
Fladimir da Gorf
Member #1,565
October 2001
|
Quote: Problem is that with any value different from 1.0 it doesn't draw Well, that's odd. Maybe I've messed up the placement somehow. Quote: Also, do you suggest to recreate it everycicle with new coordinates or simply move it arount with TransformBy( Placement( Vec2D())? It's best to move it with Placement, that's much more efficient. OpenLayer has reached a random SVN version number ;) | Online manual | Installation video!| MSVC projects now possible with cmake | Now alvailable as a Dev-C++ Devpack! (Thanks to Kotori) |
FMC
Member #4,431
March 2004
|
Fixed! gdata.myPoly->TransformBy( Placement( Vec2D(mpos.x+161, mpos.y+121), 0.0, 1.5)); i forgot to also call gdata.myPoly->TransformBy( Placement( Vec2D(-mpos.x-161, -mpos.y-121), 0.0, 1.0/1.5)); which resetted things for the next cycle Only thing that remains to fix is some sort of weird corruption when "magnifying" text and translucent rectangles. Here you can see what i mean The drawing code is quite slim now...:
[FMC Studios] - [Caries Field] - [Ctris] - [Pman] - [Chess for allegroites] |
|
1
2
|