Page 1 of 1

Strange OpenGL behaviour

Posted: Sat Nov 20, 2010 11:42 pm
by DarkMarkZX
Hi,
I'm having a problem with the OpenGL renderer. I've made a program consisting of various GUI elements and it worked fine in Software mode. However, when I recently tried changing the driver type from Software to OpenGL, the app would always crash at a random point (usually after a few seconds from starting). I found it really strange, so I stripped the code to the following several lines:

Code: Select all

#ifdef _MSC_VER
// We'll also define this to stop MSVC complaining about sprintf().
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(lib, "Irrlicht.lib")
#endif

// include headers
#include <stdio.h>
#include <stdlib.h>
#include <irrlicht.h>
#include <iostream>

using namespace std;
using namespace irr;


int main()
{
		IrrlichtDevice* device = createDevice(video::EDT_OPENGL);

		if (device == 0)
			return 1;

		device->setWindowCaption(L"test");

		video::IVideoDriver* driver = device->getVideoDriver();

		while (device->run())
		{
			driver->beginScene(true, true, video::SColor(0,200,200,200));
			//cout << "something" << endl;
			driver->endScene();
		}

		device->drop();

	return 0;
}
Even now the program keeps crashing as long as OpenGL is used, but if I uncomment the line where "cout" is used, everything works as expected.
Does anyone know what might be causing this problem? I'm using OpenGL all the time for a game I'm developing and I've never encountered such an issue before...

P.S.
I'm using Irrlicht 1.7.2

Posted: Sun Nov 21, 2010 12:22 am
by christianclavet
Perhaps a memory leak somewhere... Are your sure your .LIB is ok? Do you need to link all thoses?

Code: Select all

#include <stdio.h> 
#include <stdlib.h> 
#include <iostream>

Posted: Sun Nov 21, 2010 12:52 am
by CuteAlien
Very strange. Maybe some mixup of library versions/headers? Check your include and library paths if you really link to the same version against which you compile and also check the dll.

Do you get any warnings on the console?

Posted: Sun Nov 21, 2010 1:09 pm
by DarkMarkZX
christianclavet wrote:Perhaps a memory leak somewhere... Are your sure your .LIB is ok? Do you need to link all thoses?
I tried removing references to <stdio.h> and <stdlib.h>, but it didn't fix the problem.

CuteAlien wrote:Very strange. Maybe some mixup of library versions/headers? Check your include and library paths if you really link to the same version against which you compile and also check the dll.
Double checked it. I even deleted the previous version of SDK just to be sure.

CuteAlien wrote:Do you get any warnings on the console?
None at all.

Could someone try executing the code a few times and let me know if they encounter the same problem?

Posted: Sun Nov 21, 2010 3:54 pm
by ceyron
Could someone try executing the code a few times and let me know if they encounter the same problem?
just tried it, runs fine on linux
also tried it on Windows 7 with gcc, works as expected

Posted: Sun Nov 21, 2010 8:06 pm
by DarkMarkZX
ceyron wrote: just tried it, runs fine on linux
also tried it on Windows 7 with gcc, works as expected
Thanks for checking.
I wonder if it's a video driver issue. What graphic card do you have? I'm running on a Nvidia GTX 275 on Windows 7.

Posted: Sun Nov 21, 2010 9:19 pm
by macron12388
DarkMarkZX wrote:
ceyron wrote: just tried it, runs fine on linux
also tried it on Windows 7 with gcc, works as expected
Thanks for checking.
I wonder if it's a video driver issue. What graphic card do you have? I'm running on a Nvidia GTX 275 on Windows 7.
Hm, sounds very likely, you'd be surprised how many problems are caused by outdated/bad video drivers.

Posted: Sun Nov 21, 2010 10:45 pm
by Midnight
macron12388 wrote:
DarkMarkZX wrote:
ceyron wrote: just tried it, runs fine on linux
also tried it on Windows 7 with gcc, works as expected
Thanks for checking.
I wonder if it's a video driver issue. What graphic card do you have? I'm running on a Nvidia GTX 275 on Windows 7.
Hm, sounds very likely, you'd be surprised how many problems are caused by outdated/bad video drivers.
It's not the drivers.. he probably doesn't know enough to clean->close->reboot.

it's working code (confirmed) the odds are 50-50 or better the card and drivers are fine. It COULD be outdated openGL but it's a last generation card and comes with a good driver.

openGL could be corrupt but come on why post here before actually trying to reinstall the drivers? You can see it's nothing more than your standard irrlicht loop.


msvc

Code: Select all

test - 0 error(s), 0 warning(s)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
and yes it runs.

My guess is that it's a corrupted project file or something.. copy and paste your code into a new project first. if that doesn't work then make sure you've rebooted.. after that takle the driver issue and it that isn't it you either effed something up or you have a bad video card or other hardware. (most likely)

could also be your IDE/compiler, another quick fix.