Weird OpenGL texture problem

DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #1
I am running across some very strange behavior with opengl textures.

I have recently discovered that the textures from my objects dont show up at times, lately no textures show up.

Today, I have recompiled everything with and without altivec support, and the textures now show up in the altivec build, but not in the other one??? The only code which could possible be related to this is the altivec instructions, but they are only used in the vector code, and it seems correct, except for the textures not showing up. It is not like bad texture coords are generated (the textures are set to wrap), but the textures don't show up.

And, this does not explain why the textures didnt show up until now, but now suddenly do again in the altivec build only.

So, does anybody know what could influence opengl to do this? I am checking for gl errors while loading the textures, etc, and reading the errors every frame, but nothing.

This is really driving me nuts, as I cannot find any apparent error.
Quote this message in a reply
henryj
Unregistered
 
Post: #2
Could be a lot of things. OSX doesn't handle multiple contexts very well at the moment. If your screen saver kicks in while running an ogl app your will sometimes loose all your textures.

Also big (>1024) textures can silently fail to load.
Quote this message in a reply
DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #3
I have textures ranging from 8x8 to 512x512. The texture loading is reported to be ok, as far as I can tell. no GL errors. I do have a TV viewer running at times, which draws to opengl, but here comes the chaos:

I have 2 test apps: one called physicstest, the other graphicstest. The physicstestapp is the one with the problems, at the moment. It basically does the same as the other graphicstest (which works perfectly fine), displaying a bunch of opengl primitives.

ackk. I am gonna need a strait jacket here. Now, after I ran the said graphicstestapp, running the physicstestapp shows the textures!!! This is totally insane. And apparently, no other opengl apps are affected by this crap, only mine. The textures in the two apps are totally unrelated, the console output from texture generation and display shows no hints of any difference.

I should note that as an experiment, I replaced GL_TEXTURE_2D by the RECTANGLE_EXT version, which broke my app (it was fine in the morning). Seeing this i replaced it by GL_TEXTURE_2D again. All the calls needing this parameter are in a single file, yet simply putting the code back did not fix it, as would be expected.

OpenGL is giving me a lot of crap these days. In the beginning of the project, lighting would only work when a single dot was drawn to screen before all else, but this bug vanished, without me fixing it. Now this sht.

To my knowledge, I am following all the damn specs for opengl, setting up views, etc. Why is this happening? And this was happening sporadically since 10.2.1, when I started the project.

I am really getting frustrated by this, it keeps too much time away from getting useful stuff done.
Quote this message in a reply
DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #4
just a little more insanity: while the altivec version seems fixed, the non-altivec version is still broken. Yet I feel no pain in my foot. But I am considering putting a hammer on my desk, maybe it will bring this machine to raison again. Wacko

OpenGL profiler reports the same for both flavors of the app, no errors either.
Quote this message in a reply
henryj
Unregistered
 
Post: #5
I suggest you take a day off. All will become clear.
Quote this message in a reply
kberg
Unregistered
 
Post: #6
I understand your frustration with textures. I had a rather major problem with texture objects under GL and ATi's radeon drivers, where my textures would randomly get corrupted somewhere, somehow... This was a particularily horrible and frustrating problem, as I poured over my code literally hundreds of times looking for anything at all that could be causing this... I found that running my app after being logged in for a long time (a couple days or more) or using mipmaps would greatly increase the probability of this corruption. Worse, this problem persisted across several OS updates (10.2.1 all the way up to 10.2.5). I eventually found my fix by generating my bitmap fonts after loading all my textures?! Any textures loaded after creating bitmap fonts could possibly be corrupted. Well, whatever works I guess...
Quote this message in a reply
DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #7
Well, last night, I did a reboot, then ran that app again. that time, only the G3 version would display the textures, the G4 wouldnt.

This morning, both were miraculously working. Now, since my other apps based on the framework do not seem to display this behavior, I suspect I am not initializing something correctly, hence the random texturing mishap.

Yet, I checked my code, and I cant find any forgotten variables.

Oh well, I will move on, leave this as one of the mysteries of apple engineering.
Quote this message in a reply
Bossa Nova
Unregistered
 
Post: #8
Whoa Dooog.

Your starting to make my head hurt Smile.

Anyway, why not post your app. We can run it on different machines. See how it performs.

You've got some very strange bugs. I hope you figure it out. Its starting to annoy me (and its not even my project Wacko )
Quote this message in a reply
designdb
Unregistered
 
Post: #9
I've been having the same problem, but in a very simple system. I've been running the deep cocoa tutorials, and just bumped into a real stumbling block.

Tutorial 3 is the intro to textures, and tries to use JPGs. he notes that under Jaguar, JPG textures don't work well, but if you convert to BMPs, it shoudl work fine.

The JPG textures display, but do not scale at all, causing them to tesselate along the upper edge of the cube face. the BMP textures do not display at all.

I am running 10.2.4. If I compile the Deep Cocoa sample code, I get the same effect. Anyone have any ideas?

James
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #10
It's not an issue with the file format, so it must be an issue with his loader Smile

I just use QuickTime: http://203.79.121.211/CVS/QTValuePak/
Quote this message in a reply
DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #11
Well, I got more.

I am using Quicktime to load the textures, and I am 100 % sure it works because I use the same code for loading images for displacement maps, and that works all the time, so the image does get to memory, somehow.

Today, having nothing more annoying to do, I started coding a tank game. It is really simple right now, there are 4 cameras in a scene graph, plus a few boxes, one textured.

Now, there is no texture problem with this (but the other app is going haywire, still, and in a third I have just lost the ability to move objects with the mouse Huh ), but I am drawing boxes, and it seems like the face normals and directions somehow get inverted for some (!!!) of them, not all, not always, and only when viewed from certain cameras, disregarding the viewpoint.

I reached the point where debugging is of no help, so I am going back to the design, and extending the 70pgs of documentation I already have by more exact specs of how the different object involved in rendering should interact. Then I will try to implement it. Obviously, some really minor changes in the code are causing this unholy behavior, as 99% code in the 3 apps with the 3 different issues is the same, only a little setup here and there is different.

I doubt you are really interested in seeing what's happening. If I cannot solve this by next week, I will put together some binaries for all to enjoy. I will name it the Heisenberg collection.

I really do hate Heisenberg bugs.
Quote this message in a reply
henryj
Unregistered
 
Post: #12
Like I said you should walk away from your computer for a couple of days. You are just thinking yourself into a deeper and deeper hole. It will all make sense after you have cleared the cobwebs from your mind.

Don't waste your time on design documents, it's pretty clear what you really need is unit tests.
Quote this message in a reply
DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #13
Quote:Originally posted by henryj
...

Don't waste your time on design documents, it's pretty clear what you really need is unit tests.


What do you mean by unit tests?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #14
Quote this message in a reply
henryj
Unregistered
 
Post: #15
Here is an example from my font library that uses cppunit...

[SOURCECODE] void testConstructor()
{
FTPoint point1;

CPPUNIT_ASSERT( point1.x == 0.0f);
CPPUNIT_ASSERT( point1.y == 0.0f);
CPPUNIT_ASSERT( point1.z == 0.0f);

FTPoint point2( 1.0f, 2.0f, 3.0f);

CPPUNIT_ASSERT( point2.x == 1.0f);
CPPUNIT_ASSERT( point2.y == 2.0f);
CPPUNIT_ASSERT( point2.z == 3.0f);

FT_Vector ftVector;
ftVector.x = 4;
ftVector.y = 23;

FTPoint point3( ftVector);

CPPUNIT_ASSERT( point3.x == 4.0f);
CPPUNIT_ASSERT( point3.y == 23.0f);
CPPUNIT_ASSERT( point3.z == 0.0f);
}


void testOperatorEqual()
{
FTPoint point1( 1.0f, 2.0f, 3.0f);
FTPoint point2( 1.0f, 2.0f, 3.0f);
FTPoint point3( -1.0f, 2.3f, 23.0f);

CPPUNIT_ASSERT( point1 == point1);
CPPUNIT_ASSERT( point1 == point2);
CPPUNIT_ASSERT( !(point1 == point3));
}


void testOperatorNotEqual()
{
FTPoint point1( 1.0f, 2.0f, 3.0f);
FTPoint point2( 1.0f, 2.0f, 3.0f);
FTPoint point3( -1.0f, 2.3f, 23.0f);

CPPUNIT_ASSERT( !(point1 != point1));
CPPUNIT_ASSERT( !(point1 != point2));
CPPUNIT_ASSERT( point1 != point3);
}


void testOperatorPlusEquals()
{
FTPoint point1( 1.0f, 2.0f, 3.0f);
FTPoint point2( -2.0f, 21.0f, 0.0f);
FTPoint point3( -1.0f, 23.0f, 3.0f);

point1 += point2;

CPPUNIT_ASSERT( point1 == point3);
}

[/SOURCECODE]

What this tells me is that if I change the FTPoint code and my tests still pass then whetever uses this class will still work as before...

of if I change the FTPoint class and the tests fail, then I have an extremely simple piece of code to debug...

or, if I have something that doesn't work and it uses the FTPoint class and these tests pass, I know it's not this code causing the problem.

Check out FTGL if you want to see a test suite in action.

Unit tests and test first design is the most productive way to write code.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  OpenGL ES Texture Masking airfire 6 14,615 Mar 17, 2014 07:07 PM
Last Post: baioses
  OpenGL ES Texture Compression ajrs84 9 4,003 May 7, 2013 03:36 PM
Last Post: ajrs84
  OpenGL Alpha Channel Problem Moganza 1 2,995 Jan 19, 2013 08:25 AM
Last Post: sealfin
  OpenGL ES Texture Masking dalasjoe sin 0 3,824 Apr 13, 2012 12:17 AM
Last Post: dalasjoe sin
  Texture in OpenGL ES 2 looks pixelated vunterslaush 18 22,949 Aug 30, 2011 09:44 PM
Last Post: Frogblast