Advertisement

Lesson 6 problems

Started by July 21, 2003 07:00 PM
9 comments, last by Ekim_Gram 21 years, 6 months ago
I'm using Visual Studio 6 Enterprise Edition and I'm using the PDF version of the tutorials from the NeHe site. Here's my code for those of you who don't have it:

#include <windows.h>	// Header File for Windows

#include <stdio.h>	// Header File for standard Input/Output library

#include <gl\gl.h>	// Header File for the OpenGL32 library

#include <gl\glu.h>	// Header File for the GLu32 library

#include <gl\glaux.h>  // Header File for the GLaux library


HGLRC hRC=NULL;	// Permanent rendering ocntext

HDC hDC=NULL;	// Private GDI device context

HWND hWnd=NULL;	// Holds out window handle

HINSTANCE hInstance;	// Holds the instance of the application


bool keys[256];	// Array used for the keyboard routine

bool active=TRUE;	// Window active flag set to true by default

bool fullscreen=TRUE;	// fullscreen flag is set to fullscreen mode by default


GLfloat xrot;	// X Rotation

GLfloat yrot;	// Y Rotation

GLfloat zrot;	// Z Rotation


GLuint texture[1];	// Storage for one texture


LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);	// Declaration for WinProc


AUX_RGBImageRec *LoadBMP(char *Filename)	// Loads a bitmap image

{
	FILE *File=NULL;	// File handle

	if (!Filename)	// Make sure a filename was given

		{
		return NULL;	// If not return NULL

		}
	File=fopen(Filename,"x");	// Check to see if the file exists

	if (File)	// Does the file exist?

		{
		fclose(File);	// Close the handle

		return auxDIBImageLoad(Filename);	// Load the Bitmap and return a pointer

		}
	return NULL;	// If load failed return NULL

}

int LoadGLTextures()	// Load bitmaps and convert to textures

{
	int Status=FALSE;	// Status indicator

	AUX_RGBImageRec *TextureImage[1];	// Create storage space for the texture

	memset (TextureImage,0,sizeof(void *)*1);	// Set the pointer to NULL

	// Load the bitmap, check for errors, if bitmap's not found quit

	if (TextureImage[0]=LoadBMP("Data/NeHe.bmp"))
		{
		Status=TRUE;	// Set the status to TRUE

		glGenTextures(1, &texture[0]);	// Create the texture

		
		// Typical texture generation using data from the bitmmap

		glBindTexture(GL_TEXTURE_2D, texture[0]);
		// Generate the texture

		glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);
		glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);	// Linear filtering

		glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);	// Linear filtering

		}
	if (TextureImage[0])	// If texture exists

		{
		if(TextureImage[0]->data)	// If texture image exists

		{
			free(TextureImage[0]->data);	// Free the texture image memory

		}
		free(TextureImage[0]);	// Free the image structure

		}
	return Status;	// Return the status

}

GLvoid ReSizeGLScene (GLsizei width, GLsizei height)	// resize and initialize the gl window

{
	if (height==0)	// prevent a divide by zero by

		{
		height=1;	// making height equal one

		}
	glViewport(0, 0, width, height);	// reset the current viewport

	glMatrixMode(GL_PROJECTION);	// select the projection matrix

	glLoadIdentity();	// Reset the projection matrix

	// calculate the aspect ratio of the window

	gluPerspective(45.0f, (GLfloat)width/(GLfloat)height,0.1f,100.0f);
	glMatrixMode(GL_MODELVIEW);	// select the modelview matrix

	glLoadIdentity();	// reset the modelview matrix

}

int InitGL(GLvoid)	// all setup for OpenGL goes here

{
	if (!LoadGLTextures())	// Jump to texture loading routing

		{
		return FALSE;	// if texture didn't load return FALSE

		}
	glEnable(GL_TEXTURE_2D);	// Enables texture mapping

	glShadeModel(GL_SMOOTH);	// enables smooth shading

	glClearColor(0.0f, 0.0f, 0.0f, 0.5f);	// black background

	glClearDepth(1.0f);	// depth buffer setup

	glEnable(GL_DEPTH_TEST);	// enables depth testing

	glDepthFunc(GL_LEQUAL);	// the type of depth test to do

	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);	// really nice perspective calculations

	return TRUE;	// initializatoin went ok

}

int DrawGLScene(GLvoid)	// Here's where we do all the drawing

{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);	// Clear screen and depth buffer

	glLoadIdentity();	// Reset the current matrix

	glTranslatef(0.0f, 0.0f, -5.0f);	// Move into the screen 5 units

	glRotatef(xrot,1.0f,0.0f,0.0f);	// Rotate on the X axis

	glRotatef(yrot,0.0f,1.0f,0.0f);	// Rotate on the Y axis

	glRotatef(zrot,0.0f,0.0f,1.0f);	// Rotate on the Z axis

	glBindTexture(GL_TEXTURE_2D, texture[0]);	// Select our texture

	glBegin(GL_QUADS);
	// Front Face

	glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f,-1.0f, 1.0f);	// Bottom left of the texture and quad

	glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f,-1.0f, 1.0f);	// Bottom right of the texture and quad

	glTexCoord2f(1.0f, 1.0f);	glVertex3f( 1.0f, 1.0f, 1.0f);	// Top right of the texture and quad

	glTexCoord2f(0.0f, 1.0f);	glVertex3f(-1.0f, 1.0f, 1.0f);	// Top left of the texture and quad

	// Back Face

	glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f,-1.0f,-1.0f);	// Bottom right of the texture and quad

	glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f,-1.0f);	// Top right of the texture and quad

	glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f,-1.0f);	// Top left of the texture and quad

	glTexCoord2f(0.0f, 0.0f);	glVertex3f( 1.0f,-1.0f,-1.0f);	// Bottom left of the texture and quad

	// Top Face

	glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f,-1.0f);	// Top left of the texture and quad

	glTexCoord2f(0.0f, 0.0f);	glVertex3f( 1.0f, 1.0f, 1.0f);	// Bottom left of the texture and quad

	glTexCoord2f(1.0f, 0.0f);	glVertex3f( 1.0f, 1.0f, 1.0f);	// Bottom right of the texture and quad

	glTexCoord2f(1.0f, 0.0f);	glVertex3f( 1.0f,-1.0f,-1.0f);	// Top right of the texture and quad

	// Bottom face

	glTexCoord2f(1.0f, 1.0f);	glVertex3f(-1.0f, 1.0f,-1.0f);	// Top right of the texture and quad

	glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f,-1.0f,-1.0f);	// Top left of the texture and quad

	glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f,-1.0f, 1.0f);	// Bottom left of the texture and quad

	glTexCoord2f(1.0f, 0.0f);	glVertex3f(-1.0f,-1.0f, 1.0f);	// Bottom right of the texture and quad

	// Right face

	glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f,-1.0f,-1.0f);	// Bottom right of the texture and quad

	glTexCoord2f(1.0f, 1.0f);	glVertex3f( 1.0f, 1.0f,-1.0f);	// Top right of the texture and quad

	glTexCoord2f(0.0f, 1.0f);	glVertex3f( 1.0f, 1.0f, 1.0f);	// Top left of the texture and quad

	glTexCoord2f(0.0f, 0.0f);	glVertex3f( 1.0f,-1.0f, 1.0f);	// Bottom left of the texture and quad

	// Left Face

	glTexCoord2f(0.0f, 0.0f);	glVertex3f(-1.0f,-1.0f,-1.0f);	// Bottom left of the texture and quad

	glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f,-1.0f, 1.0f);	// Bottom right of the texture and quad

	glTexCoord2f(1.0f, 1.0f);	glVertex3f(-1.0f, 1.0f, 1.0f);	// Top right of the texture and quad

	glTexCoord2f(0.0f, 1.0f);	glVertex3f(-1.0f, 1.0f,-1.0f);	// Top left of the texture and quad

	glEnd();
	xrot+=0.3f;	// X axis rotation

	yrot+=0.2f;	// Y axis rotation

	zrot+=0.4f;	// Z axis rotation

	return true;	// Keep going

}
GLvoid KillGLWindow(GLvoid)	// properly kill the window

{
	if (fullscreen)	// are we in fullscreen mode?

		{
		ChangeDisplaySettings(NULL,0);	// if so switch back to the desktop

		ShowCursor(TRUE);	// show mouse pointer

		}
	if (hRC)	// do we have a rendering context?

		{
		if (!wglMakeCurrent(NULL,NULL))	// are we able to release the DC and RC contexts?

		{
			MessageBox(NULL,"Release of DC and RC failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
		}
		if (!wglDeleteContext (hRC))	// are we able to delete the RC?

		{
			MessageBox(NULL,"Release rendering context failed.","SHUTDOWN ERROR",MB_OK |
				MB_ICONINFORMATION) ;
		}
		hRC=NULL;	// set RC to NULL

		}
	if (hDC && !ReleaseDC(hWnd,hDC))	// are we able to release the DC

		{
		MessageBox(NULL,"Release device context failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
		hDC=NULL;	// set the DC to NULL

		}
	if (hWnd && !DestroyWindow(hWnd))	// are we able to destrou the window?

		{
		MessageBox(NULL,"Could not release hWnd.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
		hWnd=NULL;	// Set hWnd to NULL

		}
	if (!UnregisterClass("OpenGL",hInstance))	// are we able to unregister class

		{
		MessageBox(NULL,"Could not unregister class.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
		hInstance=NULL;	// set hInstance to NULL

		}
}
BOOL CreateGLWindow(char* title, int width, int height, int bits, bool fullscreenflag)
{
	GLuint PixelFormat;	// holds the results after searching for a match

	WNDCLASS wc;	// window class structure

	DWORD dwExStyle;	// window extended style

	DWORD dwStyle;	// window style

	RECT WindowRect;	// grabs rectangle upper left / lower right values

	WindowRect.left=(long)0;	// set left value to 0

	WindowRect.right=(long)width;	// set right value to requested width

	WindowRect.top=(long)0;	// set top value to 0

	WindowRect.bottom=(long)height;	// set bottom value to requested height

	fullscreen=fullscreenflag;	// set the global fullscreen flag

	hInstance = GetModuleHandle(NULL);	// grab an instance for our window

	wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;	// redraw or move, and own DC for window

	wc.lpfnWndProc = (WNDPROC) WndProc;	// WndProc handles messages

	wc.cbClsExtra = 0;	// no extra window data

	wc.cbWndExtra = 0;	// no extra window data

	wc.hInstance = hInstance;	// set the instance

	wc.hIcon = LoadIcon(NULL, IDI_WINLOGO);	// load the default icon

	wc.hCursor = LoadCursor(NULL, IDC_ARROW);	// load the arrow pointer

	wc.hbrBackground = NULL;	// no background required for GL

	wc.lpszMenuName = NULL;	// we don't want a menu

	wc.lpszClassName = "OpenGL";	// set the class name

	if (!RegisterClass(&wc))	// attempt to register the window class

		{
		MessageBox(NULL,"Failed to register the window class.","ERROR",MB_OK | MB_ICONEXCLAMATION);
		return FALSE;	//exit and return FALSE

		}
	if (fullscreen)	// attempt fullscreen mode?

		{
		DEVMODE dmScreenSettings;	// device mode

		memset(&dmScreenSettings,0,sizeof(dmScreenSettings));	// make sure memory's cleared

		dmScreenSettings.dmSize = sizeof(dmScreenSettings);	// size of the devmode structure

		dmScreenSettings.dmPelsWidth = width;	// selected screen width

		dmScreenSettings.dmPelsHeight = height;	// selected screen height

		dmScreenSettings.dmBitsPerPel = bits;	// selected bits per pixel

		dmScreenSettings.dmFields = DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;
		// Try to set delected mode and get results. NOTE: CDS_FULLSCREEN gets rid of start bar

		if (ChangeDisplaySettings(&dmScreenSettings,CDS_FULLSCREEN)!=DISP_CHANGE_SUCCESSFUL)
		{
			// If the mode fials, offer two options. Quit or run in a window

			if (MessageBox(NULL,"The requested fullscreen mode is not supported by\nYour video card. Use Windowed mode instead?","NeHe GL",MB_YESNO|MB_ICONEXCLAMATION)==IDYES)
			{
				fullscreen=FALSE;	// select windowed mode (Fullscreen=FALSE)

			}
			else
			{
				// Pop up a message box letting user know the program is closing

				MessageBox(NULL,"Program will now close.","ERROR",MB_OK|MB_ICONSTOP);
				return FALSE;	// exit and return FALSE

			}
		}
		}
	if (fullscreen)	// are we still in fullscreen mode?

		{
		dwExStyle=WS_EX_APPWINDOW;	// window extended class

		dwStyle=WS_POPUP;	// windows style

		ShowCursor(FALSE);	// hide mouse pointer

		}
	else
		{
		dwExStyle=WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;	// window extended style

		dwStyle=WS_OVERLAPPEDWINDOW;	//windows style

		}
	AdjustWindowRectEx(&WindowRect, dwStyle, FALSE, dwExStyle);	// adjust window to requested size

	if (!(hWnd=CreateWindowEx( dwExStyle,	// extended window style

		"OpenGL",	// class name

		title,	// window title

		WS_CLIPSIBLINGS |	// required window style

		WS_CLIPCHILDREN |	// required window style

		dwStyle,	// selected window style

		0, 0,	// window position

		WindowRect.right-WindowRect.left,	// Calculate adjusted window width

		WindowRect.bottom-WindowRect.top,	// Calculate adjusted window height

		NULL,	// no parent window

		NULL,	// no menu

		hInstance,	// instance

		NULL)))	// don't pass anything to WM_CREATE

		{
		KillGLWindow();	// Reset the display

		MessageBox(NULL,"Window Creation Error.","ERROR",MB_OK|MB_ICONEXCLAMATION);
		return FALSE;	// return FALSE

		}
	static PIXELFORMATDESCRIPTOR pfd =	// pfd tells widnws how we want things to be

		{
		sizeof(PIXELFORMATDESCRIPTOR),	// size of this pixel format descriptor

			1,	// version number

			PFD_DRAW_TO_WINDOW |	// format must support window

			PFD_SUPPORT_OPENGL |	// format must support OpenGL

			PFD_DOUBLEBUFFER,	// must support double buffering

			PFD_TYPE_RGBA,	// Request an RGBA format

			bits,	// select our color depth

			0, 0, 0, 0, 0, 0,  // color bits ignored

			0,  // no alpha buffer

			0,	// shift bit ignored

			0,  // no accumulation buffer

			0, 0, 0, 0,  // accumulation bits ignored

			16,  // 16bit stencil buffer

			0,  // no auxiliary buffer

			PFD_MAIN_PLANE,	// main drawing layer

			0,	// reserved

			0, 0, 0,  // layer masks ignored

			};
		if (!(hDC=GetDC(hWnd)))	// did we get a device context?

		{
			KillGLWindow();	// Reset the display

			MessageBox(NULL,"Can't create a GL device context.","ERROR",MB_OK|MB_ICONEXCLAMATION);
			return FALSE;	// return FALSE

		}
		if (!(PixelFormat=ChoosePixelFormat(hDC,&pfd)))	// did windows find a matching pixel format?

		{
			KillGLWindow();	// Reset the display

			MessageBox(NULL,"Can't find a suitable PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION);
			return FALSE;	// return FALSE

		}
		if (!SetPixelFormat(hDC,PixelFormat,&pfd))	// are we able to set the pixel format?

		{
			KillGLWindow();	// Reset the display

			MessageBox(NULL,"Can't set the PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION);
			return FALSE;	// return FALSE

		}
		if (!(hRC=wglCreateContext(hDC)))	// are we able to get a rendering context?

		{
			KillGLWindow();	// Reset the display

			MessageBox(NULL,"Can't create a GL rendering context.","ERROR",MB_OK|MB_ICONEXCLAMATION);
			return FALSE;	// return FALSE

		}
		if (!wglMakeCurrent(hDC,hRC))	// try to activate the rendering context

		{
			KillGLWindow();	// Reset the display

			MessageBox(NULL,"Can't activate the GL rendering context.","ERROR",MB_OK|MB_ICONEXCLAMATION);
			return FALSE;	// return FALSE

		}
		ShowWindow(hWnd,SW_SHOW);	// show the window

		SetForegroundWindow(hWnd);	// Slightly higher priority

		SetFocus(hWnd);	// sets keyboartd focus to the window

		ReSizeGLScene(width, height);	// set up our perspective GL screen

		if (!InitGL())	// initialize our newly created GL window

		{
			KillGLWindow();	// Reset the display

			MessageBox(NULL,"Initialization failed.","ERROR",MB_OK|MB_ICONEXCLAMATION);
			return FALSE;	// return FALSE

		}
		return TRUE;	// success

		}
		LRESULT CALLBACK WndProc( HWND hWnd,	// handle for this window

			UINT uMsg,	// message for this window

			WPARAM wParam,	// additional message information

			LPARAM lParam)	// additional message information

		{
			switch (uMsg)
			{
	case WM_ACTIVATE:	// watch for window activate message

		{
			if (!HIWORD(wParam))	// check minimization state

			{
				active=TRUE;	// program is active

			}
			else
			{
				active=FALSE;	// program is no longer active

			}
			return 0;	// return to message loop

		}
		case WM_SYSCOMMAND:	// intercept system commands

			{
				switch(wParam)	// check system calls

				{
				case SC_SCREENSAVE:	// scrensaver trying to start?

				case SC_MONITORPOWER:	// monitor trying to enter powersave?

					return 0;	// prevent this from happening

				}
				break;	// exit

			}
		case WM_CLOSE:	// did we recieve a close message?

			{
				PostQuitMessage(0);	// send a quit message

				return 0;	// jump back

			}
		case WM_KEYDOWN:	// is a key being held down?

			{
				keys[wParam] = TRUE;	// if so, mark it as TRUE

				return 0;	// jump back

			}
		case WM_KEYUP:	// has a key been released?

			{
				keys[wParam] = FALSE;	// if so, mark it as FALSE

				return 0;	// jump back

			}
		case WM_SIZE:	//resize the OpenGL window

			{
				ReSizeGLScene(LOWORD(lParam),HIWORD(lParam));	// LoWord=Width, HiWord=Height

				return 0;	// jump back

			}
			}
			// Pass ALL unhandled messages to DefWindowProc

			return DefWindowProc(hWnd,uMsg,wParam,lParam);
			}
			int WINAPI WinMain(	HINSTANCE hInstance,	// instance

				HINSTANCE hPrevInstance,	// previous instance

				LPSTR lpCmdLine,	// command line parameters

				int nCmdShow)	// window show state

			{
				MSG msg;	// windows message

				BOOL done=FALSE;	// bool variable to exit loop

				// Ask the user which screen mode they prefer

				if (MessageBox(NULL,"Would you like to run in fullscreen mode?", "Start FullScreen?",MB_YESNO|MB_ICONQUESTION)==IDNO)
				{
					fullscreen=FALSE;	// windowed mode

				}
				// create our OpenGL window

				if (!CreateGLWindow("NeHe's OpenGL Framework",640,480,16,fullscreen))
			{
			return 0;	// quit if window was not created

			}
			while(!done)	// loop that runs until done=TRUE

			{
				if (PeekMessage(&msg,NULL,0,0,PM_REMOVE))	// is there a message waiting?

				{
					if (msg.message==WM_QUIT)	// have we recieved a quit message?

					{
						done=TRUE;	// if so done=TRUE

					}
					else	// if not, deal with window messages

					{
						TranslateMessage(&msg);	// translate the message

						DispatchMessage(&msg);	// dispatch the message

					}
				}
				else	// if there are no messages

				{
					// Draw the scene, watch for ESC key and quit messages from DrawGLScene()

					if (active)	// program active?

					{
						if (keys[VK_ESCAPE])	// was ESC pressed?

						{
							done=TRUE;	// ESC signalled a quit

						}
						else	// not time to quit, update screen

						{
							DrawGLScene();	// draw the scene

							SwapBuffers(hDC);	// swap buffers (Double buffering)

						}
					}
					if (keys[VK_F1])	// is F1 being pressed?

					{
						keys[VK_F1]=FALSE;	// if so, make key FALSE

						KillGLWindow();	// kill our current window

						fullscreen=!fullscreen;	// toggle fullscren / windowed mode

						// recreate our OpenGL window

						if (!CreateGLWindow("NeHe's OpenGL Tutorial",640,480,16,fullscreen))
						{
							return 0;	// quit if window was not created

						}
					}
				}
			}
			// shutdown

			KillGLWindow();	// kill the window

			return (msg.wParam);	// exit the program

			}
I get no compiler errors when I build it but whenever I try to run it I get the "Initialization failed" box that is supposed to run when InitGl() doesn't go the right way:

	if (!InitGL())	// initialize our newly created GL window

	{
		KillGLWindow();	// Reset the display

		MessageBox(NULL,"Initialization failed.","ERROR",MB_OK|MB_ICONEXCLAMATION);
		return FALSE;	// return FALSE

	}
The code for the window is from lesson 1.
There's no town drunk here, we all take turns. Velocity Gaming Force [edited by - Ekim_Gram on July 21, 2003 8:02:12 PM] [edited by - Ekim_Gram on July 21, 2003 8:02:59 PM]
Do you have the Nehe picture? If not, create a new folder, place a picture in it, and change the pathname for your code.

AUX_RGBImageRec *TextureImage[1]; // Create storage space for the texture memset (TextureImage,0,sizeof(void *)*1); // Set the pointer to NULL // Load the bitmap, check for errors, if bitmap''s not found quit if (TextureImage[0]=LoadBMP("Data/NeHe.bmp")) <<<--Right here!
Also, your picture MUST have a width and height that are a power of 2.
Advertisement
Yea.. make sure you are loading the image and remeber if you use your own image it has to be the right size, another suggestion not related to the code but very important...please improve your coding style if you write functions all together like that it makes it really annoying to read a couple of blank lines here and there make the code more readable...maybe it''s because I''m tired but I found it hard to go through the code...Anyways I''m hitting the sack C ya.
The monkeys are listening...
I have the bitmap image and I even tried just deleting the Data folder and putting the bitmap in the same folder as the project so the line now reads: if (TextureImage[0]=LoadBMP("/NeHe.bmp")) But I wasn't sure if that would work so I got rid of the "/" but that still didn't work. I've gone through the code over and over but I still can't find whats wrong with it.

EDIT: I just tried using the code from lesson 6 on the site that I downloaded and I still got the same error.



There's no town drunk here, we all take turns.
Velocity Gaming Force

[edited by - Ekim_Gram on July 22, 2003 10:57:41 AM]
had that same problem friend, make sure you have in your code /data/NeHe.bmp, thats what i did and it worked , i had the slashes the wrong way
it was dumb :S oh well if that doesnt work i dno wht it is, but im sure youll figure it out after some people post and hepl you, they did for me, didnt give me the right answer(for that question) but i still got it, and they helped me lots before, so im sure youll get it keep trying

c ya
Yay opengl! im on me way to maybe making a REAL bad mario kart knock off! ACE!
Aha! I found the problem. The line:
File=fopen(Filename,"x");	// Check to see if the file exists


the "x" was supposed to be an "r". Thanks for the help anyway.



There''s no town drunk here, we all take turns.
Velocity Gaming Force
Advertisement
ooh! Enterprise edition!
I am getting the same error now! It worked fine with NeHe''s one. All I did was add a different picture (.bmp) of size 1024x768. It works with the NeHe pic, but not with this one.
I tried all the things you said, but it still fails it. Is it only compatible with perfectly square textures?
Will J
The textures do not have to be square, but they have to be a power of two, in both dimensions... (64, 128, 256, 512, 1024, etc.)
I am having the same problem(reviving old threads ). Instead of getting an intialization error though, the cube appears as a green cube and the bitmap is not present. I have tried using different bitmaps, but it still doesn''t seem to work, I have also tried different paths, and have copied the code precisley from the tutorial. I originaly tried mapping it on my own, but just ended up copying the code since I was getting the same error. Any suggestions would be great. Thanks.

This topic is closed to new replies.

Advertisement