C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 30th, 2004, 02:10 PM
nolachrymose nolachrymose is offline
The Forest
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Posts: 321 nolachrymose User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
GLUT Crashing

Hi all,

I've started to use the GLUT library, and have run across a problem. While my program compile fine, it crashes about five seconds after it begins running. I get an exception error 0xc0000005, and I don't know how to fix it. I looked up the error on Google, and it says that the exception indicates an attempt to access memory which is out of bounds, but in my program I don't see how that's relevant (unless there is an error in the GLUT library itself, which I don't know about).

I'm running Dev-C++ 4.9.8.0 on Windows XP Home. The code I've used is below (it is just a copy of the code given from a tutorial at http://www.lighthouse3d.com):

Code:
#include <gl/glut.h>
#include <gl/gl.h>

void RenderScene(void);

int main(int argc,char **argv)
{
	glutInit(&argc,argv);
	glutInitDisplayMode(GLUT_DEPTH | GLUT_SINGLE | GLUT_RGBA);
	glutInitWindowPosition(100,100);
	glutInitWindowSize(320,320);
	glutCreateWindow("Testing GLUT");
	glutDisplayFunc(RenderScene);
	glutMainLoop();
	
	return 0;
}

void RenderScene(void)
{
	glClear(GL_COLOR_BUFFER_BIT);
	glBegin(GL_TRIANGLES);
		glVertex3f(-0.5,-0.5,0.0);
		glVertex3f(0.5,0.0,0.0);
		glVertex3f(0.0,0.5,0.0);
	glEnd();
	glFlush();
}


Any help is greatly appreciated. Thank you in advance.

Happy coding!

Reply With Quote
  #2  
Old July 30th, 2004, 03:20 PM
jim mcnamara jim mcnamara is offline
......@.........
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jun 2004
Posts: 1,327 jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 15 h 24 m 56 sec
Reputation Power: 49
Can you run in debug mode to find where it's crashing - I don't see anything weird.

Reply With Quote
  #3  
Old July 30th, 2004, 04:21 PM
nolachrymose nolachrymose is offline
The Forest
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Posts: 321 nolachrymose User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
I tried to run it in debug mode, but it immediately crashes when I begin. Therefore, I must assume the error is at glutMainLoop(), as I see a window that is rendered with the "scene" set by the RenderScene() function.
Perhaps my makefile may shed some light? Maybe I set the project up incorrectly? In any case, here's the makefile:

Code:
# Project: GLUTest
# Makefile created by Dev-C++ 4.9.8.0

CPP  = g++.exe
CC   = gcc.exe
WINDRES = windres.exe
RES  = 
OBJ  = main.o $(RES)
LINKOBJ  = main.o $(RES)
LIBS =  -L"C:/DevCpp/lib" -lglut32 -lglu32 -lopengl32 ../../WINDOWS/system32/glut32.dll ../../WINDOWS/system32/glu32.dll ../../WINDOWS/system32/opengl32.dll 
INCS =  -I"C:/DevCpp/include"  -I"C:/DevCpp/include/SDL" 
CXXINCS =  -I"C:/DevCpp/include/c++"  -I"C:/DevCpp/include/c++/mingw32"  -I"C:/DevCpp/include/c++/backward"  -I"C:/DevCpp/include"  -I"C:/DevCpp/include/SDL" 
BIN  = glutest.exe
CXXFLAGS = $(CXXINCS)-D_WCHAR_T_DEFINED   -mwindows
CFLAGS = $(INCS)  -mwindows

.PHONY: all all-before all-after clean clean-custom

all: all-before glutest.exe all-after


clean: clean-custom
	rm -f $(OBJ) $(BIN)

$(BIN): $(LINKOBJ)
	$(CPP) $(LINKOBJ) -o "glutest.exe" $(LIBS)

main.o: main.cpp
	$(CPP) -c main.cpp -o main.o $(CXXFLAGS)


Thank you for attempting to help me.

Happy coding!

Reply With Quote
  #4  
Old July 31st, 2004, 04:10 AM
Analyser's Avatar
Analyser Analyser is offline
*bounce*
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2002
Location: Delft, The Netherlands
Posts: 511 Analyser User rank is Sergeant Major (2000 - 5000 Reputation Level)Analyser User rank is Sergeant Major (2000 - 5000 Reputation Level)Analyser User rank is Sergeant Major (2000 - 5000 Reputation Level)Analyser User rank is Sergeant Major (2000 - 5000 Reputation Level)Analyser User rank is Sergeant Major (2000 - 5000 Reputation Level)Analyser User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Days 21 h 47 m 19 sec
Reputation Power: 38
Send a message via ICQ to Analyser
Coincidentally I just started learning OpenGL just a few days ago. So I'm no expert, but I'll give it a shot

First off, the code you posted works fine for me, in Linux. No crashes whatsoever. Maybe I'll try it on my Windows box later.

The only thing I can spot is that glutInitDisplayMode()'s argument contains a GLUT_RGBA, whereas all my examples show only GLUT_RGB. Also, if that doesn't work, try calling it with -only- GLUT_RGB:

Code:
glutInitDisplayMode(GLUT_RGB);


That's all I can think of so far. A few side notes though: you don't have to include gl.h, since glut.h already does it for you. And if you ever want to port your code to UNIX or Linux, try using <GL/glut.h> instead of <gl/glut.h>; both UNIX and Linux are case-sensitive (I had to change that to be able to compile the code in Linux).

Good luck!
__________________
"A poor programmer is he who blames his tools."
http://analyser.oli.tudelft.nl/

Reply With Quote
  #5  
Old July 31st, 2004, 09:45 AM
nolachrymose nolachrymose is offline
The Forest
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Posts: 321 nolachrymose User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Well, I don't have to include gl.h for the main function(), but my entire RenderScene() function is built from OpenGL methods. Then again, I don't know a good deal about the functions provided by the GLUT library, so I may be able to take the GL functions and transpose them to GLUT functions.
Thanks for the tip about case-sensitive file systems in *nix, but what I'm doing right now is just or fun -- I don't plan on releasing anything, much less on *nix systems (as I don't have any to test on).

I tried modifying from GLUT_RGBA to GLUT_RGB, but it still crashed with the same exception. I'm so lost.
Thank you for the suggestion, though!

I may just have to go back to WinMain/WndProc -- ugh.

Happy coding!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > GLUT Crashing


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2010 by Developer Shed. All rights reserved. DS Cluster 10 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek