Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
Posts: 107
Registered: ‎02-15-2012
My Device: Blackberry Playbook 32GB
My Carrier: Virgin Mobile

Re: bbutil_load_texture

thanks sucroid.

Im gonna have a look in to the image library and write it using that, probably a better idea than using bbutil_load_texture() and the bbutil library.

 

I probably should have started using the image library straight away instead using what I had learnt from the C tutorials which DO use the bbutil library.

 

Anyway thanks for your help! Smiley Happy

Michael

Trusted Contributor
Posts: 195
Registered: ‎03-12-2012
My Device: PlayBook
My Carrier: None

Re: bbutil_load_texture

I updated the code snippet. I forgot to paste in the last line. The last line IS VERY IMPORTANT.
Sucroid.com
Sweet Apps for the Fans
Developer
Posts: 107
Registered: ‎02-15-2012
My Device: Blackberry Playbook 32GB
My Carrier: Virgin Mobile

Re: bbutil_load_texture

should i put glDisable(GL_TEXTURE_2D); at the end or is this unnecessary?
Trusted Contributor
Posts: 195
Registered: ‎03-12-2012
My Device: PlayBook
My Carrier: None

Re: bbutil_load_texture

Yes.  The snippet doesn't have it because I still had 3 other textures to load.  The disable texture command comes at the end.  Sorry about the confusion.  Cutting and pasting is always a dangerous thing to do! Smiley Very Happy

Sucroid.com
Sweet Apps for the Fans
Developer
Posts: 107
Registered: ‎02-15-2012
My Device: Blackberry Playbook 32GB
My Carrier: Virgin Mobile

Re: bbutil_load_texture

Yes lol. Thabks. And the first arg of glgentextures must be 1 and not 4.

Im guessing images have to be of sizes to the power of two?

Where can i clip my texture or should I just use transparency for the extra space from the image having to be sizeof power of two?

Glteximage2d has to be the exact size of the image so is there a function i can use after opengl has imported the image since it seems to require input of an image with sizes to the power of two

Trusted Contributor
Posts: 195
Registered: ‎03-12-2012
My Device: PlayBook
My Carrier: None

Re: bbutil_load_texture

Indeed, if you are loading 1 picture, define the texture id array to be of length one and change the 4 to 1.

 

To "extract" the useful part of the image, use the tex coordinates.  For example, you can specify the texture coordinates to be { 0.0, 0.0,   1.0, 0.0,  1.0, 0.5,  0.0, 0.5}.  Then only half the image will be used for binding.  

Sucroid.com
Sweet Apps for the Fans
Developer
Posts: 107
Registered: ‎02-15-2012
My Device: Blackberry Playbook 32GB
My Carrier: Virgin Mobile

Re: bbutil_load_texture

Wonderful!

Thanks sucroid Smiley Happy

Trusted Contributor
Posts: 195
Registered: ‎03-12-2012
My Device: PlayBook
My Carrier: None

Re: bbutil_load_texture

You're welcome.  Have fun!

 

One more tip: If you don't want to waste space and have multiple textures, you could combined the images into one.  What I mean is if you have an image of dimension 500 x 200 and another of 400 x 1024, you can create an image of size 1024 x 1024 and fit these two images in.  That way you don't need to fit the first into 512 x 512 and the second into 1024 x 1024.

Sucroid.com
Sweet Apps for the Fans
Developer
Posts: 107
Registered: ‎02-15-2012
My Device: Blackberry Playbook 32GB
My Carrier: Virgin Mobile

Re: bbutil_load_texture

thanks Smiley Very Happy
Developer
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook
My Carrier: x

Re: bbutil_load_texture

>One more tip: If you don't want to waste space and have multiple textures, you could combined the images into one.  What I mean is if you have an image of dimension 500 x 200 and another of 400 x 1024, you can create an image of size 1024 x 1024 and fit these two images in.  That way you don't need to fit the first into 512 x 512 and the second into 1024 x 1024.

 

I was very surprized/impressed that actually the same approach is used in bbutil loading fonts. So all symbols are represented by *one* image and every single character is drawn by two triangles with tiny piece of texture loaded with this large image.