Opengl Spazzing out for no reason

Started by
19 comments, last by 21st Century Moose 9 years, 5 months ago

So I'm making a c++ and opengl app, with bone transformations, and it is spazzing out for no reason. And I really mean no reason. I spent weeks on this app without any problems. Character walked etc, looked nice. Today I added shadows to the shader, no problem. Later on it started going crazy. like the matrices were totally distorted and the screen is raped with random triangles going crazy. Seizure inspiring.

Luckilly I had backed up this program about 8 times. Every single other previous version is doing the exact same thing. No other project is acting this way.

What the hell is going on? I can't find any problem in the code. This happened right after nvidia update, so not sure how to go about fixing this...

EDIT: If i Freeze the animation (as in only render same animtime constantly), it still spazzes out. What the hell is going on?? Doesn't happen when I negate the bone transformations from the shader though.

Advertisement
Could be a lot. Have you tried a clean reboot of the system just to get that out of the way?

Alternatively, it sounds like you are walking into undefined behavior (either on the C++ side or the way you are treating OpenGL), but that is really hard to say without any code.

The thing is this exact code worked perfectly earlier. I even went through my backups, and they all have the same problem, despite all working perfectly fine when I copied them.

I rebooted yes.

This is what I don't understand:

It's the bone transformations giving the error. I take them out, it all works fine.

if I set the bone transforms only once in the beginning and don't touch them at all, it still spazzes. If they are unchanged, the entire scene should just be the exact same image throughout, but for some reason the poly's go spastic. Makes absolutely no sense.

I can only agree with BitMaster. You are probably seeing undefined behavior either in OpenGL or C++. You are lucky though, since you can clearly see the error with 100% reproduction rate no less.

Perhaps first start with trying the project out on a different computer.

I dont have another computer available to me right now.

Another thing I did was test another app with bone transformations and it worked fine.

The difference between these two apps is the one with the problems is initialized with sdl, the working app with glut.


void GRAPHICSMANAGER::InitializeGraphics(int width, int height, const std::string& title, bool fullscreen)
{
	SDL_Init(SDL_INIT_EVERYTHING);

	SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
	SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
	SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
	SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
	SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 32);
	SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
	SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);

	m_fullscreen = fullscreen;

	if (m_fullscreen)
	{
		m_screenWidth	= GetSystemMetrics(SM_CXSCREEN);
		m_screenHeight	= GetSystemMetrics(SM_CYSCREEN);

		m_window = SDL_CreateWindow(title.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, m_screenWidth, m_screenHeight, SDL_WINDOW_FULLSCREEN | SDL_WINDOW_OPENGL);
	}
	else
	{
		m_screenWidth = width;
		m_screenHeight = height;

		m_window = SDL_CreateWindow(title.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, m_screenWidth, m_screenHeight, SDL_WINDOW_OPENGL);
	}
	
	m_glContext = SDL_GL_CreateContext(m_window);

	GLenum status = glewInit();

	if (status != GLEW_OK)
		std::cerr << "Glew failed to initialize!\n";

	glEnable(GL_DEPTH_TEST);

	//glEnable(GL_BLEND);
	//glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
}

Maybe it's this? I don't know

I'm adding "Spazzing Out" to my list of JIRA bug types!

If all your previous working versions are broken too, then the update changed something. But it could have been there all along and the new driver speed up exposed the problem. I would start with a new version, and slowly add in the code piece by piece testing at each step until you find the problem.

With things like this, 99% of the time, even when you know it isn't your code, it is impossible that your code is wrong, it must be the driver or the update, it's your code.

I think, therefore I am. I think? - "George Carlin"
My Website: Indie Game Programming

My Twitter: https://twitter.com/indieprogram

My Book: http://amzn.com/1305076532

Texture ID = 3452816845.

I'm starting to think more and more that the driver fucked up SDL applications that dare use bone transforms

EDIT: Ok, to add to the confusion - When i run debug mode, the application looks different than running from the .exe.

Debug mode, model is normal, walking, poly's spazzing out.

Run from exe, model is completely distorted, bones are way off, and poly's are spazzing out as well. Also no texture?????

What in the actual fuck is going on?

It's highly unlikely that something is actively trying to sabotage you. Again, every sign points to undefined behavior on your part especially since it happened "right after nvidia update" and now also happens to your old code. Something in the driver probably changed. The previously unnoticed error you made now consistently produces problems, that's a very common result of invoking undefined behavior somewhere.

While it's not unheard of for graphics drivers to contain the occasional bug you would still need some more investigation instead of saying "it worked before, so it must work now".

Edit: The fact that Release and Debug mode show such differences further suggests undefined behavior, probably because uninitialized memory (which will look very differently in Debug and Release builds) is used somewhere.

Well I'm happy to report that I was right all along.

After downloading and installing the driver, turns out i needed to go into my system, and tell the gpu to update its driver (again?). I don't understand this driver business, but all I know now is that it works.

I appreciate all your help. I actually found and tweaked a few little things in my code because you guys made me look.

:)

Hello everyone, I'm appropriately bumping this thread because once again, opengl is spazzing out just as it did before, only this time if i manually go into system and tell it to update it says I have the latest version, so I can't do what I did last time. Please help, as I cannot do anything productive with this happening

This topic is closed to new replies.

Advertisement