Lost Password?

Go Back   CodeCall Programming Forum > Software Development > C and C++

C and C++ C and C++ forum for discussing all forms of C except for C#. These languages are powerful low level languages used for creating Operating Systems, Device Drivers, compilers and much more.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-16-2007, 08:16 AM
TkTech TkTech is offline
 
Join Date: Jun 2006
Posts: 894
Last Blog:
Having trouble with yo...
Rep Power: 20
TkTech is on a distinguished road
Send a message via MSN to TkTech
Default OpenGl Problems

A friend of mine has this opengl code, and its a wee bit buggy. Returns a sigserver fault. Anyone see any obvious errors in the line maked //<-bug?

Code:
bool initTerrain()
{
	int i;
	int x, z;
	//GLfloat knots[8] = {0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0};
	
	for(i = 0; i < NUM_TERRAIN; i++)
	{
		terrain[i] = new Terrain;
	}
	
	terrain[0]->SetPrefs("terrain1.bmp", 256, 256, true);
	//terrain[0]->SetPrefs("grass.bmp", 256, 256);
	
	for(i = 0; i < NUM_TERRAIN; i++)
	{
		if(!terrain[i]->Load())
			return false;
		terrain[i]->Scale(0, 20);
		terrainDL[i] = terrain[i]->CreateDL(0,0,0);
	}
	
	userPos.y = terrain[0]->GetHeight((int)userPos.x, (int)userPos.z)+5.0;
	
	for(i = 0; i < NUM_TERRAIN; i++)
		nurbs[i] = gluNewNurbsRenderer();
	
	nurbCoord = (GLfloat *)malloc(sizeof(GLfloat)*terrain[0]->GetLength()*terrain[0]->GetWidth()*3);
	for(x = 0; x < terrain[0]->GetLength(); x++)
	{
		for(z = 0; z < terrain[0]->GetWidth(); z++)
		{
			nurbCoord[x*terrain[0]->GetLength()+z*3] = x;
			nurbCoord[x*terrain[0]->GetLength()+z*3+1] = terrain[0]->GetHeight(x, z);
			nurbCoord[x*terrain[0]->GetLength()+z*3+2] = z;
		}
	}
	
	gluNurbsProperty(nurbs[0], GLU_SAMPLING_TOLERANCE, 25.0);
	gluNurbsProperty(nurbs[0], GLU_DISPLAY_MODE, GLU_FILL);
	
	glNewList(DL_NURBS_1, GL_COMPILE);
		GLfloat knots[8] = {0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0};
		glPushMatrix();
			gluBeginSurface(nurbs[0]);
			gluNurbsSurface(nurbs[0],      //<-BUG This is the line that crashes
						   8, knots, 8, knots,
						   terrain[0]->GetLength()*terrain[0]->GetWidth(),
						   3, nurbCoord,
						   4, 4, GL_MAP2_VERTEX_3);
			gluEndSurface(nurbs[0]);
		glPopMatrix();
	glEndList();
	
	return true;
	
}
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum
Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall

Last edited by TkTech; 01-17-2007 at 08:07 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT -5. The time now is 11:09 AM.

Contest Stats

John ........ 223.00000
dargueta ........ 168.00000
Xav ........ 164.00000
gaylo565 ........ 18.00000
WingedPanther ........ 15.00000
|pH| ........ 15.00000
Johnnyboy ........ 3.00000
navghost ........ 1.00000

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 66%

Ads