You are not logged in.

#1 2010-01-09 20:46:51

scognito
Member

[RESOLVED] Texture part

Hi,
is possible to create a texture as a part of another one?
Instead of using tiles I need to separate texture, but didn't find such a function on GRRLIB (afaik).

Thanks in advance!

Offline

 

#2 2010-01-10 14:36:42

NoNameNo
Administrator

Re: [RESOLVED] Texture part

yes you can using drawpart, then screen2texture wink

but i think drawpart only could do the job you need

Offline

 

#3 2010-01-10 15:04:00

scognito
Member

Re: [RESOLVED] Texture part

NoNameNo wrote:

yes you can using drawpart, then screen2texture wink

but i think drawpart only could do the job you need

Hi, great hornor to be answered by the author!

The problem is that I want to store the textures in an array, for using them later.
I'm making a port of a game, so it is not my decision....here it is the original code:

extern int grap[161][8], mgrap[51];

mgrap[1] = LoadGraph( "res/brock.png" ) ;

x1=1;

for (t=0;t<=6;t++){
   grap[t][x1] = DerivationGraph( 33*t, 0, 30, 30, mgrap[x1]) ;
   grap[t+30][x1] = DerivationGraph( 33*t, 33, 30, 30, mgrap[x1]) ;
   grap[t+60][x1] = DerivationGraph( 33*t, 66, 30, 30, mgrap[x1]) ;
   grap[t+90][x1] = DerivationGraph( 33*t, 99, 30, 30, mgrap[x1]) ;
}

then he display the image using like:

drawimage(grap[1][1], x, y);

The derivationGraph functions seems to select a certain area of the image stored on mpgaph[1] (in this case) and store it in the grap array.

So my idea is to replace LoadGraph with load texture function, and make "grap" a array of (part of) textures, so I can display the textures easily replacing drawimage.

Or do you have a smart idea? (i'm still searching a better solution tongue)

Thanks in advance!

Last edited by scognito (2010-01-10 15:07:04)

Offline

 

#4 2010-01-11 10:00:53

NoNameNo
Administrator

Re: [RESOLVED] Texture part

i think the easiest way to do your need is, like i said, using GRRLIB_DrawPart and GRRLIB_Screen2Texture

Offline

 

#5 2010-01-11 14:01:16

scognito
Member

Re: [RESOLVED] Texture part

I'm at work and cannot code, but since I have some doubt I'll post the code here to "translate" the code "grap[t][x1] = DerivationGraph( 33*t, 0, 30, 30, mgrap[x1]) ;"

Assuming that (m)grap array are arrays of GRRLIB_texImg I would use something like this?

Code:

GRRLIB_DrawPart  (  0, 0, 33*t, 0, 30, 30, mgrap[x1], 0, 1,1,0)
GRRLIB_Screen2Texture (30, 30, grap[t][x1], true);

I'm not sure about that though...

Offline

 

#6 2010-01-11 14:15:14

NoNameNo
Administrator

Re: [RESOLVED] Texture part

you can have the doc online here : http://grrlib.santo.fr/doc/

your drawpart seems ok, but i am pretty sure your screen2texture is wrong.
should be GRRLIB_Screen2Texture (0, 0, grap[t][x1], true);

and keep in mind that Screen2Texture will grab from x=0, y=0 and will use the Width and Height you declare when you created the empty texture. In your case the width and height of grap.

hope it'll help.

Offline

 

#7 2010-01-11 16:44:07

scognito
Member

Re: [RESOLVED] Texture part

Yeah I read the doc, it is very useful, indeed I was confused about the missing width and height values...what I missed was what you just sayd: "and will use the Width and Height you declare when you created the empty texture".
I think you should add this information for helping other users (if you think it is useful).

Can't wait to try this out at home, thanks!

Offline

 

#8 2010-01-12 10:18:36

scognito
Member

Re: [RESOLVED] Texture part

Ok I got this to almost work, but some part of the block is displayed (out of boundaries), probably because texture size must be multiple of 4? (texture displayed seems bigger than the one I expect).

Another question, can I specify an odd coordinate in drawpart/screen2texture functions?

Last edited by scognito (2010-01-12 12:51:13)

Offline

 

#9 2010-01-12 13:11:40

NoNameNo
Administrator

Re: [RESOLVED] Texture part

from what i remember when i coded it yes you can specifiy odd or even coord, the only obligation you have is to create free texture using a multiply of 4 for width and height !! this is  needed by GX !! not by grrlib !

i dunno how is your texture, but i think you should also disable antialias, since GX will try to antialias the new texture with around pixels, and around pixels are often from the next tile ... it can introduce a little glish around each tile/new texture.

Offline

 

#10 2010-01-12 14:01:39

scognito
Member

Re: [RESOLVED] Texture part

Yes I forgot to say that I know it is a GX problem big_smile
And yes antialias is disabled...I hope to have some screen of the "game" soon, I'll thank you on the credits once finished (if finished tongue).

Offline

 

Board footer

Powered by FluxBB