Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 06-23-2009, 09:50 PM   #1 (permalink)
Registered Member
 
Join Date: Jun 2009
Location: currently AZ
Posts: 112
kingbombs is on a distinguished road
Send a message via MSN to kingbombs
Default Texture Question

Hey just a quick question

So if the texture is to small for an object that is going to have that texture applied to it, what happens? does it grow in size to fit it or just not be applied at all or leave some parts of it not applied.

on the flip side:
If the texture is larger than the area it is going to be applied to it, then what happens? does it shrink or put the texture on till it covers it then leaves what ever texture is left off.

I seem to have problems with my whole program being covered in the texture rather than just the item being drawn.
If i bind a texture, like:
glVertexPointer(2, GL_FLOAT, 0, squareToBeDrawn);
glBindTexture(GL_TEXTURE_2D, textures[1]);
then do: glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
can i unbind the texture? Because everything not just this square is getting textured. Or am i making a mistake?
Will this draw the square with this texture and then if i unbind it, will all the next set of glDrawArrays() use the last glColor4f() that was used?
kingbombs is offline   Reply With Quote
Old 06-24-2009, 08:59 AM   #2 (permalink)
Tutorial Author
 
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 29
mauriceatron is on a distinguished road
Default

When you turn on texture mapping (or anything at all with glEnable or glEnableClientState, they stay on until you explicitly turn them off.

In your case, you don't want to "unbind" the texture to stop it being rendered on everything, just turn off GL_TEXTURE_2D until you need it again. If you just need a new texture, then call glBindTexture again, this time passing the new texture to use.

glVertexPointer(2, GL_FLOAT, 0, squareToBeDrawn);
glBindTexture(GL_TEXTURE_2D, textures[1]);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

then do:
glDisable(GL_TEXTURE_2D);

to stop having the texture applied to everything.

Hope that helps

Hooroo
Simon
mauriceatron is offline   Reply With Quote
Old 06-24-2009, 09:52 AM   #3 (permalink)
Registered Member
 
Join Date: Jun 2009
Location: currently AZ
Posts: 112
kingbombs is on a distinguished road
Send a message via MSN to kingbombs
Default

Thank you for the reply!

I am going to try it all out in about an hour and will let you know how i do.

But i was wondering if you could answer the top question please? What happens if the textures arn't the right size for the object that they will be applied for?

Also do i have to use: glTexCoordPointer(2, GL_SHORT, 0, squareTextureCoords); (taken from your tutorial)

I didn't understand how its cords are 0,0 0,1 1,0 or 1,1 for your squareTextureCoords
when your actual object that it would have to be applied to went from -1 to 1, not 0 to 1.

The reason i ask about textures not being the right size, is because my squares are 16x24 pixels (im pretty sure they are that size)
but have to be a factor of 2, so either 16x16 or 16x32 is allowed. But then the textures don't exactly match the square size.

Last edited by kingbombs; 06-24-2009 at 09:54 AM.
kingbombs is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 336
8 members and 328 guests
chiataytuday, givensur, ipodphone, jbro, mtl_tech_guy, Punkjumper, vilisei, yomo710
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,649
Threads: 94,113
Posts: 402,881
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Anwerbl
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 09:14 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0