Texture stops rendering - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: iPhone, iPad & iPod Game Development (/forum-11.html)
+--- Thread: Texture stops rendering (/thread-9214.html)
Texture stops rendering - klaars - Jul 26, 2011 06:41 PM
I've just recently picked up opengl and have ran into a problem that I need some help with. Basically, when I start up my app, a rectangle is supposed to render on the screen with a texture bound to it. Without the texture, I can get the whole texture to fill in perfectly with the colour blue. But when I apply a texture, some of the texture fades out.
I've been playing around with it and noticed that this happens only when I increase the amount of triangles used to form the rectangle. It also seems to happen if I make the rectangle ridiculously big.
The texture is a simple 512x512 jpg image so I don't think that the image itself is the issue.
I've created a sample project with most of my game logic stripped out. (This project was made with the help of 71squared.com's tutorials).
Here's the file: http://dl.dropbox.com/u/21820920/Example.zip
All code relative to this texture problem can be found in the following files in the project:
There is a setCurrentVertices method in the MenuScene.m file. When I create the vertices for the shapes I only store the top values of the shape. I use setCurrentVertices to fill an array with both the top and bottom vertices of the shape.
Another thing I've noticed is that if I comment out the background and the call to the shared render manager at the start of the renderScene method, I run into an error. The program pauses and I'm brought to the drawBezier method in Primitives.m with the error message "Thread 1: Program received signal: 'EXC_BAD_ACCESS'". I'm not really sure why this is happening.. but I think it most likely is related to my original problem. I added a comment to the method so that it's easy to find what I'm referring to.
Here's a picture of my desired output: http://dl.dropbox.com/u/21820920/expectedResult.jpg
I can't stress enough how much I would really appreciate any help on this matter!! (I've been struggling with this for over a month now :/)
Hopefully this issue is related to some stupid mistake that I made somewhere in the code and can easy be fixed!
RE: Texture stops rendering - AndyKorth - Jul 27, 2011 08:56 AM
It looks like vertex colors are being set that are causing the drawBezier call to fade out to transparent (alpha).
I modified the background a bit.
I guess you have to disable the vertex coloring stuff, if that's an optin, or pass glColorPointers along with the glVertexPointer. I'm probably the wrong person to ask, but I bet Keith will see this and correct me.
By the way, welcome to the forums, and fantastic writeup for your first post. You managed to include all the relevant details, the entire project, and you can spell words! It's very refreshing!
RE: Texture stops rendering - klaars - Jul 29, 2011 08:46 AM
Thanks for the quick reply and positive feedback
I tried to list all of the relevant information so that it would be easier on the people trying to help me out (I hate it when someone just lists a code block in a huge app and expects someone to be able to fix the problem instantly ).
Good idea about changing the background, I've done the same. It makes such a big difference!
At one point I added color pointers to the draw function but I couldn't get it to work right. I'll take another look at it, that could very well solve my problem. But if that doesn't solve it... is there anything else that could explain the behavior I'm experiencing?