Strange OpenGL behaviour

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
DarkMarkZX
Posts: 10
Joined: Sat Nov 20, 2010 10:48 pm
Location: Poland, Europe
Contact:

Strange OpenGL behaviour

Post 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
christianclavet
Posts: 1638
Joined: Mon Apr 30, 2007 3:24 am
Location: Montreal, CANADA
Contact:

Post 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>
CuteAlien
Admin
Posts: 9716
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post 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?
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
DarkMarkZX
Posts: 10
Joined: Sat Nov 20, 2010 10:48 pm
Location: Poland, Europe
Contact:

Post 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?
ceyron
Posts: 63
Joined: Tue Mar 03, 2009 5:10 pm
Location: Bucuresti, România

Post 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
Image
DarkMarkZX
Posts: 10
Joined: Sat Nov 20, 2010 10:48 pm
Location: Poland, Europe
Contact:

Post 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.
Image
macron12388
Posts: 126
Joined: Wed Sep 29, 2010 8:23 pm

Post 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.
Midnight
Posts: 1772
Joined: Fri Jul 02, 2004 2:37 pm
Location: Wonderland

Post 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.
Post Reply