Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

BeginOpenGL

Examples won´t work with new DevC++ 4.9.8.0??

This topic is 5299 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello I´m new to C++ as well as OpenGL. I´ve just downloaded yesterday, the new Bloodshed DevC++ 4.9.8.0 IDE with the Mingw32 compiler. So I thought I´d try out some of the NeHe OpenGl lessons. I tried to compile the Sources for lesson3, lesson5 and lessson10 but, they won´t compile. At first glance, it seems I get the same two errors when trying to compile these lessons. I think it´s " no such file exists " or something like that. I was really hoping to learn both some c++, as well as some OpenGL from these lessons. Does anybody have a solutiuon for compiling NeHe´s lessons with this new DevC++ compiler? Here´s the compile log output: ***************************************************************** Compiler: Default compiler Building Makefile: "C:\Dev-Cpp\lesson01\Makefile.win" Executing make... make.exe -f "C:\Dev-Cpp\lesson01\Makefile.win" all g++.exe -c Lesson1.cpp -o ../L101/Lesson1.o -I"C:/DEV-CPP/include/c++" -I"C:/DEV-CPP/include/c++/mingw32" -I"C:/DEV-CPP/include/c++/backward" -I"C:/DEV-CPP/include" Lesson1.cpp:12:69: gl\glaux.h: No such file or directory g++.exe ../L101/Lesson1.o -o "..\L101\Lesson1.exe" -L"C:/DEV-CPP/lib" -mwindows -lopengl32 -lglu32 -lglaux -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32 G__~1.EXE: ../L101/Lesson1.o: No such file or directory Execution terminated *************************************************************** Okay, so what does all this gibberish mean?....and most importantly, how do I fix it? Here´s the code for DevC++, as it was downloaded:
**************************************************************
 /*
 *		This Code Was Created By Jeff Molofee 2000
 *		A HUGE Thanks To Fredric Echols For Cleaning Up
 *		And Optimizing This Code, Making It More Flexible!
 *		If You've Found This Code Useful, Please Let Me Know.
 *		Visit My Site At nehe.gamedev.net
 */

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

#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


HDC			hDC=NULL;		// Private GDI Device Context

HGLRC		hRC=NULL;		// Permanent Rendering Context

HWND		hWnd=NULL;		// Holds Our 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 Set To Fullscreen Mode By Default


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


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

{
	glShadeModel(GL_SMOOTH);							// Enable 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 Testing To Do

	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);	// Really Nice Perspective Calculations

	return TRUE;										// Initialization 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 Modelview Matrix

	return TRUE;										// Everything Went OK

}

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 DC To NULL

	}

	if (hWnd && !DestroyWindow(hWnd))					// Are We Able To Destroy 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

	}
}

/*	This Code Creates Our OpenGL Window.  Parameters Are:					*
 *	title			- Title To Appear At The Top Of The Window				*
 *	width			- Width Of The GL Window Or Fullscreen Mode				*
 *	height			- Height Of The GL Window Or Fullscreen Mode			*
 *	bits			- Number Of Bits To Use For Color (8/16/24/32)			*
 *	fullscreenflag	- Use Fullscreen Mode (TRUE) Or Windowed Mode (FALSE)	*/
 
BOOL CreateGLWindow(char* title, int width, int height, int bits, bool fullscreenflag)
{
	GLuint		PixelFormat;			// Holds The Results After Searching For A Match

	WNDCLASS	wc;						// Windows 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 On Size, 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;											// Return FALSE

	}
	
	if (fullscreen)												// Attempt Fullscreen Mode?

	{
		DEVMODE dmScreenSettings;								// Device Mode

		memset(&dmScreenSettings,0,sizeof(dmScreenSettings));	// Makes 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 Selected Mode And Get Results.  NOTE: CDS_FULLSCREEN Gets Rid Of Start Bar.

		if (ChangeDisplaySettings(&dmScreenSettings,CDS_FULLSCREEN)!=DISP_CHANGE_SUCCESSFUL)
		{
			// If The Mode Fails, Offer Two Options.  Quit Or Use Windowed Mode.

			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;		// Windowed Mode Selected.  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;									// Return FALSE

			}
		}
	}

	if (fullscreen)												// Are We Still In Fullscreen Mode?

	{
		dwExStyle=WS_EX_APPWINDOW;								// Window Extended Style

		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 True Requested Size


	// Create The Window

	if (!(hWnd=CreateWindowEx(	dwExStyle,							// Extended Style For The Window

								"OpenGL",							// Class Name

								title,								// Window Title

								dwStyle |							// Defined Window Style

								WS_CLIPSIBLINGS |					// Required Window Style

								WS_CLIPCHILDREN,					// Required Window Style

								0, 0,								// Window Position

								WindowRect.right-WindowRect.left,	// Calculate Window Width

								WindowRect.bottom-WindowRect.top,	// Calculate Window Height

								NULL,								// No Parent Window

								NULL,								// No Menu

								hInstance,							// Instance

								NULL)))								// Dont 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 Windows 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 Z-Buffer (Depth Buffer)  

		0,											// No 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 Keyboard 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)									// Check For Windows Messages

	{
		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 The Message Loop

		}

		case WM_SYSCOMMAND:							// Intercept System Commands

		{
			switch (wParam)							// Check System Calls

			{
				case SC_SCREENSAVE:					// Screensaver Trying To Start?

				case SC_MONITORPOWER:				// Monitor Trying To Enter Powersave?

				return 0;							// Prevent From Happening

			}
			break;									// Exit

		}

		case WM_CLOSE:								// Did We Receive 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 Structure

	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 While done=FALSE

	{
		if (PeekMessage(&msg,NULL,0,0,PM_REMOVE))	// Is There A Message Waiting?

		{
			if (msg.message==WM_QUIT)				// Have We Received 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 Fullscreen / Windowed Mode

				// Recreate Our OpenGL Window

				if (!CreateGLWindow("NeHe's OpenGL Framework",640,480,16,fullscreen))
				{
					return 0;						// Quit If Window Was Not Created

				}
			}
		}
	}

	// Shutdown

	KillGLWindow();									// Kill The Window

	return (msg.wParam);							// Exit The Program

}
Thank You BeginOpenGL edit: put the code in a source box. [edited by - SiCrane on April 17, 2004 5:39:32 PM]

Share this post


Link to post
Share on other sites
Advertisement
You are missing a header file by the name of "glaux.h" and for the "Lesson1.o" missing error, just hit "rebuild all". The glaux file you could probably find somewhere on the internet ,although it is not used very much. When including source code within these forums it is advisable to type the following tags before and after without the spaces.
[s o u r c e]

[/ s o u r c e]

Share this post


Link to post
Share on other sites
Xiachunyi


Thank you for your reply. The following libs I included in the DevC++ IDE in the following Menu Tab: Projects/ProjectOptions/Parameters, and they are:


-lopengl32 -lglu32 -lglaux -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32


I checked in the lib folder of DevC++ 4.9.8.0 and found the following library:

   
libglaux.a


By any chance, is this the "glaux" lib of which you are refferring to? Or is there another glaux lib which I should check for? Libglaux.a was there all along and the lesson examples would´nt compile.

Thanks

BeginOpenGL


PS I tried to compile it in another way and it´s asking for gl/glaux.h not libglaux.a. I´ll do a search and see if this is the problem.


[edited by - BeginOpenGL on April 14, 2004 6:21:22 PM]

[edited by - BeginOpenGL on April 14, 2004 6:31:33 PM]

Share this post


Link to post
Share on other sites


Okay, i found a glaux.h file and downloaded it but, it was to work with mesa 3d. It did´nt help to compile the examples so, I deleted it.

Then at this link: http://molhanec.net/devpaks.php , I found a glaux.h devpack installation which installed the glaux.h file in the Include/GL directory of DevC++ 4.9.8.0. But, after putting the reference in Project options for includes using the correct path, it did´nt help to compile the lessons either.

Hmmmm, I´m stumped.

Meanwhile, I made my first Simple 3d engine with the following code. I use the word "3d Engine " very loosely.



/**************************
* Includes
*
**************************/


#include <windows.h>
#include <gl/gl.h>


/**************************
* Function Declarations
*
**************************/


LRESULT CALLBACK WndProc (HWND hWnd, UINT message,
WPARAM wParam, LPARAM lParam);
void EnableOpenGL (HWND hWnd, HDC *hDC, HGLRC *hRC);
void DisableOpenGL (HWND hWnd, HDC hDC, HGLRC hRC);


/**************************
* WinMain
*
**************************/


int WINAPI WinMain (HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int iCmdShow)
{
WNDCLASS wc;
HWND hWnd;
HDC hDC;
HGLRC hRC;
MSG msg;
BOOL bQuit = FALSE;
float theta = 0.0f;

/* register window class */
wc.style = CS_OWNDC;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor (NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH) GetStockObject (BLACK_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = "GLSample";
RegisterClass (&wc);

/* create main window */
hWnd = CreateWindow (
"GLSample", "OpenGL Sample",
WS_CAPTION | WS_POPUPWINDOW | WS_VISIBLE,
0, 0, 1024, 768,
NULL, NULL, hInstance, NULL);

/* enable OpenGL for the window */
EnableOpenGL (hWnd, &hDC, &hRC);

/* program main loop */
while (!bQuit)
{
/* check for messages */
if (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
{
/* handle or dispatch messages */
if (msg.message == WM_QUIT)
{
bQuit = TRUE;
}
else
{
TranslateMessage (&msg);
DispatchMessage (&msg);
}
}
else
{
/* OpenGL animation code goes here */

glClearColor (0.0f, 1.0f, 0.0f, 0.0f);
glClear (GL_COLOR_BUFFER_BIT);

glPushMatrix ();
glRotatef (theta, 1.0f, 1.0f, 1.0f);
glBegin (GL_TRIANGLES);
glColor3f (1.0f, 0.0f, 0.0f); glVertex2f (0.0f, 1.0f);
glColor3f (0.0f, 1.0f, 0.0f); glVertex2f (0.87f, -0.5f);
glColor3f (0.0f, 0.0f, 1.0f); glVertex2f (-0.87f, -0.5f);
glEnd ();
glPopMatrix ();

SwapBuffers (hDC);

theta += 1.0f;
Sleep (1);
}
}

/* shutdown OpenGL */
DisableOpenGL (hWnd, hDC, hRC);

/* destroy the window explicitly */
DestroyWindow (hWnd);

return msg.wParam;
}


/********************
* Window Procedure
*
********************/


LRESULT CALLBACK WndProc (HWND hWnd, UINT message,
WPARAM wParam, LPARAM lParam)
{

switch (message)
{
case WM_CREATE:
return 0;
case WM_CLOSE:
PostQuitMessage (0);
return 0;

case WM_DESTROY:
return 0;

case WM_KEYDOWN:
switch (wParam)
{
case VK_ESCAPE:
PostQuitMessage(0);
return 0;
}
return 0;

default:
return DefWindowProc (hWnd, message, wParam, lParam);
}
}


/*******************
* Enable OpenGL
*
*******************/


void EnableOpenGL (HWND hWnd, HDC *hDC, HGLRC *hRC)
{
PIXELFORMATDESCRIPTOR pfd;
int iFormat;

/* get the device context (DC) */
*hDC = GetDC (hWnd);

/* set the pixel format for the DC */
ZeroMemory (&pfd, sizeof (pfd));
pfd.nSize = sizeof (pfd);
pfd.nVersion = 1;
pfd.dwFlags = PFD_DRAW_TO_WINDOW |
PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = 24;
pfd.cDepthBits = 16;
pfd.iLayerType = PFD_MAIN_PLANE;
iFormat = ChoosePixelFormat (*hDC, &pfd);
SetPixelFormat (*hDC, iFormat, &pfd);

/* create and enable the render context (RC) */
*hRC = wglCreateContext( *hDC );
wglMakeCurrent( *hDC, *hRC );

}


/******************
* Disable OpenGL
*
******************/


void DisableOpenGL (HWND hWnd, HDC hDC, HGLRC hRC)
{
wglMakeCurrent (NULL, NULL);
wglDeleteContext (hRC);
ReleaseDC (hWnd, hDC);
}




The steps I used to create it are roughfly:

1. Created a new folder inside the main DevC++ folder and called it OpenGL.
2. Opened a new project in the above folder, deleted the automatic main.cpp code and copied the above code in it´s place.
3. Saved everything.
4. Created a new Icon for the executable inside the Project Menu dialog box and dumped it in the OpenGL folder.
5. Create another new folder inside the above folder and called it OpenGL01EXE. This folder´s path is referenced in Project/Project Options/Build Options as the path to dump the object file as well as the compiled OpenGL01.EXE standalone executable. Thereby separating it from all the source files.
6. Dumped the following library names in: Projects/ProjectOptions/Parameters, and they are:
-lopengl32 -lglu32 -lglaux -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32
7.Also gave the following command line option to the compiler:
-D__GNUWIN32__ -W -DWIN32 -DNDEBUG -D_WINDOWS -D_MBCS
It´s done in the same place in the Project dialog box as step 6. But, in the compiler whitespace instead of the linker whitespace.
8. Went up to the menu again and clicked Execute/compile. The resulting object file and OpenGl01.EXE were output to the second folder I had created(OpenGLEXE folder), as specified.
9. Double clicked on the OpenGL01.EXE icon and executed the app.


Well, do´nt pay too much attention to me but, it compiled without any errors or warnings. It´s a rotating triangle.

Meanwhile, can someone tell me where I can find a copy of glaux.h that will work with the Mingw32 compiler that came with DEvC++ ?? Or what do I need to do to run the examples.


Thanks

BeginOpenGL








Share this post


Link to post
Share on other sites
quote:
Original post by BeginOpenGL
Meanwhile, can someone tell me where I can find a copy of glaux.h that will work with the Mingw32 compiler that came with DEvC++ ?? Or what do I need to do to run the examples.
I''m pretty sure there isn''t one.

However, if you look at the bottom of the tutorials, you''ll see that someone ported them to Dev-C++ (it''s in the downloads).

Share this post


Link to post
Share on other sites
The following should work because I use to use it for loading bitmaps.

/*++ BUILD Version: 0004 // Increment this if a change has global effects

Copyright (c) 1985-95, Microsoft Corporation

Module Name:

glaux.h

Abstract:

Procedure declarations, constant definitions and macros for the OpenGL
Auxiliary Library.

--*/


#ifndef __GLAUX_H__
#define __GLAUX_H__

/*
* (c) Copyright 1993, Silicon Graphics, Inc.
* ALL RIGHTS RESERVED
* Permission to use, copy, modify, and distribute this software for
* any purpose and without fee is hereby granted, provided that the above
* copyright notice appear in all copies and that both the copyright notice
* and this permission notice appear in supporting documentation, and that
* the name of Silicon Graphics, Inc. not be used in advertising
* or publicity pertaining to distribution of the software without specific,
* written prior permission.
*
* THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
* AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
* FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
* GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
* SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
* KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
* LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
* THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
* ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
* POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
*
* US Government Users Restricted Rights
* Use, duplication, or disclosure by the Government is subject to
* restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
* (c)(1)(ii) of the Rights in Technical Data and Computer Software
* clause at DFARS 252.227-7013 and/or in similar or successor
* clauses in the FAR or the DOD or NASA FAR Supplement.
* Unpublished-- rights reserved under the copyright laws of the
* United States. Contractor/manufacturer is Silicon Graphics,
* Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
*
* OpenGL(TM) is a trademark of Silicon Graphics, Inc.
*/


#include <windows.h>
#include <GL/gl.h>
#include <GL/glu.h>

#ifdef __cplusplus
extern "C" {
#endif

/*
** ToolKit Window Types
** In the future, AUX_RGBA may be a combination of both RGB and ALPHA
*/


#define AUX_RGB 0
#define AUX_RGBA AUX_RGB
#define AUX_INDEX 1
#define AUX_SINGLE 0
#define AUX_DOUBLE 2
#define AUX_DIRECT 0
#define AUX_INDIRECT 4

#define AUX_ACCUM 8
#define AUX_ALPHA 16
#define AUX_DEPTH24 32 /* 24-bit depth buffer */
#define AUX_STENCIL 64
#define AUX_AUX 128
#define AUX_DEPTH16 256 /* 16-bit depth buffer */
#define AUX_FIXED_332_PAL 512
#define AUX_DEPTH AUX_DEPTH16 /* default is 16-bit depth buffer */

/*
** Window Masks
*/


#define AUX_WIND_IS_RGB(x) (((x) & AUX_INDEX) == 0)
#define AUX_WIND_IS_INDEX(x) (((x) & AUX_INDEX) != 0)
#define AUX_WIND_IS_SINGLE(x) (((x) & AUX_DOUBLE) == 0)
#define AUX_WIND_IS_DOUBLE(x) (((x) & AUX_DOUBLE) != 0)
#define AUX_WIND_IS_INDIRECT(x) (((x) & AUX_INDIRECT) != 0)
#define AUX_WIND_IS_DIRECT(x) (((x) & AUX_INDIRECT) == 0)
#define AUX_WIND_HAS_ACCUM(x) (((x) & AUX_ACCUM) != 0)
#define AUX_WIND_HAS_ALPHA(x) (((x) & AUX_ALPHA) != 0)
#define AUX_WIND_HAS_DEPTH(x) (((x) & (AUX_DEPTH24 | AUX_DEPTH16)) != 0)
#define AUX_WIND_HAS_STENCIL(x) (((x) & AUX_STENCIL) != 0)
#define AUX_WIND_USES_FIXED_332_PAL(x) (((x) & AUX_FIXED_332_PAL) != 0)

/*
** ToolKit Event Structure
*/


typedef struct _AUX_EVENTREC {
GLint event;
GLint data[4];
} AUX_EVENTREC;

/*
** ToolKit Event Types
*/

#define AUX_EXPOSE 1
#define AUX_CONFIG 2
#define AUX_DRAW 4
#define AUX_KEYEVENT 8
#define AUX_MOUSEDOWN 16
#define AUX_MOUSEUP 32
#define AUX_MOUSELOC 64

/*
** Toolkit Event Data Indices
*/

#define AUX_WINDOWX 0
#define AUX_WINDOWY 1
#define AUX_MOUSEX 0
#define AUX_MOUSEY 1
#define AUX_MOUSESTATUS 3
#define AUX_KEY 0
#define AUX_KEYSTATUS 1

/*
** ToolKit Event Status Messages
*/

#define AUX_LEFTBUTTON 1
#define AUX_RIGHTBUTTON 2
#define AUX_MIDDLEBUTTON 4
#define AUX_SHIFT 1
#define AUX_CONTROL 2

/*
** ToolKit Key Codes
*/

#define AUX_RETURN 0x0D
#define AUX_ESCAPE 0x1B
#define AUX_SPACE 0x20
#define AUX_LEFT 0x25
#define AUX_UP 0x26
#define AUX_RIGHT 0x27
#define AUX_DOWN 0x28
#define AUX_A ''A''
#define AUX_B ''B''
#define AUX_C ''C''
#define AUX_D ''D''
#define AUX_E ''E''
#define AUX_F ''F''
#define AUX_G ''G''
#define AUX_H ''H''
#define AUX_I ''I''
#define AUX_J ''J''
#define AUX_K ''K''
#define AUX_L ''L''
#define AUX_M ''M''
#define AUX_N ''N''
#define AUX_O ''O''
#define AUX_P ''P''
#define AUX_Q ''Q''
#define AUX_R ''R''
#define AUX_S ''S''
#define AUX_T ''T''
#define AUX_U ''U''
#define AUX_V ''V''
#define AUX_W ''W''
#define AUX_X ''X''
#define AUX_Y ''Y''
#define AUX_Z ''Z''
#define AUX_a ''a''
#define AUX_b ''b''
#define AUX_c ''c''
#define AUX_d ''d''
#define AUX_e ''e''
#define AUX_f ''f''
#define AUX_g ''g''
#define AUX_h ''h''
#define AUX_i ''i''
#define AUX_j ''j''
#define AUX_k ''k''
#define AUX_l ''l''
#define AUX_m ''m''
#define AUX_n ''n''
#define AUX_o ''o''
#define AUX_p ''p''
#define AUX_q ''q''
#define AUX_r ''r''
#define AUX_s ''s''
#define AUX_t ''t''
#define AUX_u ''u''
#define AUX_v ''v''
#define AUX_w ''w''
#define AUX_x ''x''
#define AUX_y ''y''
#define AUX_z ''z''
#define AUX_0 ''0''
#define AUX_1 ''1''
#define AUX_2 ''2''
#define AUX_3 ''3''
#define AUX_4 ''4''
#define AUX_5 ''5''
#define AUX_6 ''6''
#define AUX_7 ''7''
#define AUX_8 ''8''
#define AUX_9 ''9''

/*
** ToolKit Gets and Sets
*/

#define AUX_FD 1 /* return fd (long) */
#define AUX_COLORMAP 3 /* pass buf of r, g and b (unsigned char) */
#define AUX_GREYSCALEMAP 4
#define AUX_FOGMAP 5 /* pass fog and color bits (long) */
#define AUX_ONECOLOR 6 /* pass index, r, g, and b (long) */

/*
** Color Macros
*/


#define AUX_BLACK 0
#define AUX_RED 13
#define AUX_GREEN 14
#define AUX_YELLOW 15
#define AUX_BLUE 16
#define AUX_MAGENTA 17
#define AUX_CYAN 18
#define AUX_WHITE 19

extern float auxRGBMap[20][3];

#define AUX_SETCOLOR(x, y) (AUX_WIND_IS_RGB((x)) ? \
glColor3fv(auxRGBMap[(y)]) : glIndexf((y)))

/*
** RGB Image Structure
*/


typedef struct _AUX_RGBImageRec {
GLint sizeX, sizeY;
unsigned char *data;
} AUX_RGBImageRec;

/*
** Prototypes
*/


void APIENTRY auxInitDisplayMode(GLenum);
void APIENTRY auxInitPosition(int, int, int, int);

/* GLenum APIENTRY auxInitWindow(LPCTSTR); */
#ifdef UNICODE
#define auxInitWindow auxInitWindowW
#else
#define auxInitWindow auxInitWindowA
#endif
GLenum APIENTRY auxInitWindowA(LPCSTR);
GLenum APIENTRY auxInitWindowW(LPCWSTR);

void APIENTRY auxCloseWindow(void);
void APIENTRY auxQuit(void);
void APIENTRY auxSwapBuffers(void);

typedef void (CALLBACK* AUXMAINPROC)(void);
void APIENTRY auxMainLoop(AUXMAINPROC);

typedef void (CALLBACK* AUXEXPOSEPROC)(int, int);
void APIENTRY auxExposeFunc(AUXEXPOSEPROC);

typedef void (CALLBACK* AUXRESHAPEPROC)(GLsizei, GLsizei);
void APIENTRY auxReshapeFunc(AUXRESHAPEPROC);

typedef void (CALLBACK* AUXIDLEPROC)(void);
void APIENTRY auxIdleFunc(AUXIDLEPROC);

typedef void (CALLBACK* AUXKEYPROC)(void);
void APIENTRY auxKeyFunc(int, AUXKEYPROC);

typedef void (CALLBACK* AUXMOUSEPROC)(AUX_EVENTREC *);
void APIENTRY auxMouseFunc(int, int, AUXMOUSEPROC);

int APIENTRY auxGetColorMapSize(void);
void APIENTRY auxGetMouseLoc(int *, int *);
void APIENTRY auxSetOneColor(int, float, float, float);
void APIENTRY auxSetFogRamp(int, int);
void APIENTRY auxSetGreyRamp(void);
void APIENTRY auxSetRGBMap(int, float *);

/* AUX_RGBImageRec * APIENTRY auxRGBImageLoad(LPCTSTR); */
#ifdef UNICODE
#define auxRGBImageLoad auxRGBImageLoadW
#else
#define auxRGBImageLoad auxRGBImageLoadA
#endif
AUX_RGBImageRec * APIENTRY auxRGBImageLoadA(LPCSTR);
AUX_RGBImageRec * APIENTRY auxRGBImageLoadW(LPCWSTR);

#ifdef UNICODE
#define auxDIBImageLoad auxDIBImageLoadW
#else
#define auxDIBImageLoad auxDIBImageLoadA
#endif
AUX_RGBImageRec * APIENTRY auxDIBImageLoadA(LPCSTR);
AUX_RGBImageRec * APIENTRY auxDIBImageLoadW(LPCWSTR);

void APIENTRY auxCreateFont(void);
/* void APIENTRY auxDrawStr(LPCTSTR); */
#ifdef UNICODE
#define auxDrawStr auxDrawStrW
#else
#define auxDrawStr auxDrawStrA
#endif
void APIENTRY auxDrawStrA(LPCSTR);
void APIENTRY auxDrawStrW(LPCWSTR);

void APIENTRY auxWireSphere(GLdouble);
void APIENTRY auxSolidSphere(GLdouble);
void APIENTRY auxWireCube(GLdouble);
void APIENTRY auxSolidCube(GLdouble);
void APIENTRY auxWireBox(GLdouble, GLdouble, GLdouble);
void APIENTRY auxSolidBox(GLdouble, GLdouble, GLdouble);
void APIENTRY auxWireTorus(GLdouble, GLdouble);
void APIENTRY auxSolidTorus(GLdouble, GLdouble);
void APIENTRY auxWireCylinder(GLdouble, GLdouble);
void APIENTRY auxSolidCylinder(GLdouble, GLdouble);
void APIENTRY auxWireIcosahedron(GLdouble);
void APIENTRY auxSolidIcosahedron(GLdouble);
void APIENTRY auxWireOctahedron(GLdouble);
void APIENTRY auxSolidOctahedron(GLdouble);
void APIENTRY auxWireTetrahedron(GLdouble);
void APIENTRY auxSolidTetrahedron(GLdouble);
void APIENTRY auxWireDodecahedron(GLdouble);
void APIENTRY auxSolidDodecahedron(GLdouble);
void APIENTRY auxWireCone(GLdouble, GLdouble);
void APIENTRY auxSolidCone(GLdouble, GLdouble);
void APIENTRY auxWireTeapot(GLdouble);
void APIENTRY auxSolidTeapot(GLdouble);

/*
** Window specific functions
** hwnd, hdc, and hglrc valid after auxInitWindow()
*/

HWND APIENTRY auxGetHWND(void);
HDC APIENTRY auxGetHDC(void);
HGLRC APIENTRY auxGetHGLRC(void);

/*
** Viewperf support functions and constants
*/

/* Display Mode Selection Criteria */
enum {
AUX_USE_ID = 1,
AUX_EXACT_MATCH,
AUX_MINIMUM_CRITERIA
};
void APIENTRY auxInitDisplayModePolicy(GLenum);
GLenum APIENTRY auxInitDisplayModeID(GLint);
GLenum APIENTRY auxGetDisplayModePolicy(void);
GLint APIENTRY auxGetDisplayModeID(void);
GLenum APIENTRY auxGetDisplayMode(void);

#ifdef __cplusplus
}
#endif

#endif /* __GLAUX_H__ */

Just copy and paste it into a new header file, label it "glaux.h", and store it in your "gl" folder.

If it throws up errors, please post them so we can get it working.

Share this post


Link to post
Share on other sites

Xiachunyi

Thank you again for your input. But, that´s the very same glaux.h I downloaded yesterday from [url]http://molhanec.net/devpaks.php [/url].

I compared both of them side by side, by firing up two text editors and dumping my glaux.h and your glaux.h respecteviley, into Notepad and MS Word. They are the exact same thing and don´t help in compiling the NeHe lessons even though I had installed it correctly into the Include/Gl folder of the Dev C++ 4.9.8.0 distribution. But, at leat I know now that it can be invoked to load up sum bitmaps. Thanks again for that tip.

However, Ill check the parameters I put into the Project/Project Options dialog box. I´m probably doing something wrong that will turn out to be simple.... Well, i just started learning OpenGl yesterday and I just know a little basic and next to no C++.

Thanks

BeginOpenGL

Share this post


Link to post
Share on other sites
Okay everybody


I figured out what was wrong. The glaux.h file I got from: http://molhanec.net/devpaks.php "does" work. At least with the lessons I compiled, which were, 3,5 and 10....I think.

If anybody else needs it, you can get it from that link above. Or, copy xiachunyi´s glaux.h above and paste it in MS Notepad. Then, "save as" "glaux.h" , including the colons before and after, right into the Includes/GL folder. Right along with gl.h, glext.h and glu.h, which allready come with the Dev C++ 4.9.8.0 download.

For some reason, when I gave the path to output the final object file as well as the final standalone.EXE in the Project/Project Options/Build Options dialog box, it sometimes put ../MyFolder and sometimes it just put MyFolder. Well, for the above lessons, just MyFolder without the forward slash or the preceeding dots seemed to work. Also, I did´nt have to give the path to the libraries or includes in the Project/Project Options/Directories dialog box. It´s done automatically. Also, maybe specifying a c++ compiler in Project/Project Optons hlped....Not too sure which or all of the above finally helped to do the trick.

But, meanwhile I could´nt compile the NeHe lessons, I went ahead and expanded on the simple 3D Engine example, which originally came with the DecC++ download and is in one of the above posts. The first example put a flat triangle sppining in 3d space.

Version .0000002, called Dev C++ 4.9.8.0 3D Engine, puts up an entire pyramid rotating in 3d space......Well, at least I got a basic idea of vertices, transformations and C++ in general working out the code, which, by the way, I commented.


/**************************
* Includes
*
**************************/

/*These includes seem to be automatically used by the Dev C compiler,*/
/*without having to type in their path in the Project/Project Options/Directories/Include Directories*/
/*dialog box*/
#include <windows.h>
#include <gl/gl.h>


/**************************
* Function Declarations
*
**************************/


LRESULT CALLBACK WndProc (HWND hWnd, UINT message,
WPARAM wParam, LPARAM lParam);
void EnableOpenGL (HWND hWnd, HDC *hDC, HGLRC *hRC);
void DisableOpenGL (HWND hWnd, HDC hDC, HGLRC hRC);


/**************************
* WinMain
*
**************************/


int WINAPI WinMain (HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int iCmdShow)
{
WNDCLASS wc;
HWND hWnd;
HDC hDC;
HGLRC hRC;
MSG msg;
BOOL bQuit = FALSE;
/*´declare the var theta, to be used as an angle in rotations*/
float theta = 0.0;

/* register window class */
wc.style = CS_OWNDC;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor (NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH) GetStockObject (BLACK_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = "GLSample";
RegisterClass (&wc);

/* create main window */
hWnd = CreateWindow (
"GLSample", "DEV C++ 4.9.8.0 3D Engine",
WS_CAPTION | WS_POPUPWINDOW | WS_VISIBLE,
0, 0, 1024, 768,
NULL, NULL, hInstance, NULL);

/* enable OpenGL for the window */
EnableOpenGL (hWnd, &hDC, &hRC);

/* program main loop */
while (!bQuit)
{
/* check for messages */
if (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
{
/* handle or dispatch messages */
if (msg.message == WM_QUIT)
{
bQuit = TRUE;
}
else
{
TranslateMessage (&msg);
DispatchMessage (&msg);
}
}
else
{
/* OPEN GL ANIMATION CODE FOR PRIMITIVES GOES BELOW */

/*Set the Background color to black*/
glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
/*Clear previous frame color buffer to enable drawing of next frame*/
glClear (GL_COLOR_BUFFER_BIT);
/*Clear previous frame depth buffer to enable drawing of next frame*/
glClear (GL_DEPTH_BUFFER_BIT);
/*Clear existing internal tansformations by loading identity matrix*/
glLoadIdentity ();
/*move all vertices(the pyramid) 1 unit forward on z axis*/
glTranslatef (0, 0, -1);
/*rotate(spin) pyramid around it´s vertical Y axis*/
glRotatef (theta, 0, 1, 0);
/*access OpenGl´s matrix stack to save transformations*/
glPushMatrix ();
/*Join vertex 1,2,3..1,3,4 and 1,4,5(vertice 1 is common to the rest)*/
glBegin (GL_TRIANGLE_FAN);
/*assign color and position in 3d space to each vertex thru its 3 coords*/
glColor3f (0,.5, 1); glVertex3f ( 0, 1, 0);
glColor3f (1, .5, 0); glVertex3f (-1,-1, 1);
glColor3f (1, .3, 1); glVertex3f ( 1,-1, 1);
glColor3f (.2, 0, 1); glVertex3f ( 1,-1,-1);
glColor3f (0, 1, 0); glVertex3f (-1,-1,-1);
glColor3f (1, .7, 0); glVertex3f (-1,-1, 1);
glEnd ();
/*restore OpenGl´s matrix stack transformations to continue to translatef*/
glPopMatrix ();
/*Make the pyramid visible*/
SwapBuffers (hDC);

theta += .5;
Sleep (1);
}
}

/* shutdown OpenGL */
DisableOpenGL (hWnd, hDC, hRC);

/* destroy the window explicitly */
DestroyWindow (hWnd);

return msg.wParam;
}


/********************
* Window Procedure
*
********************/


LRESULT CALLBACK WndProc (HWND hWnd, UINT message,
WPARAM wParam, LPARAM lParam)
{

switch (message)
{
case WM_CREATE:
return 0;
case WM_CLOSE:
PostQuitMessage (0);
return 0;

case WM_DESTROY:
return 0;

case WM_KEYDOWN:
switch (wParam)
{
case VK_ESCAPE:
PostQuitMessage(0);
return 0;
}
return 0;

default:
return DefWindowProc (hWnd, message, wParam, lParam);
}
}


/*******************
* Enable OpenGL
*
*******************/


void EnableOpenGL (HWND hWnd, HDC *hDC, HGLRC *hRC)
{
PIXELFORMATDESCRIPTOR pfd;
int iFormat;

/* get the device context (DC) */
*hDC = GetDC (hWnd);

/* set the pixel format for the DC */
ZeroMemory (&pfd, sizeof (pfd));
pfd.nSize = sizeof (pfd);
pfd.nVersion = 1;
pfd.dwFlags = PFD_DRAW_TO_WINDOW |
PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = 24;
pfd.cDepthBits = 16;
pfd.iLayerType = PFD_MAIN_PLANE;
iFormat = ChoosePixelFormat (*hDC, &pfd);
SetPixelFormat (*hDC, iFormat, &pfd);

/* create and enable the render context (RC) */
*hRC = wglCreateContext( *hDC );
wglMakeCurrent( *hDC, *hRC );

}


/******************
* Disable OpenGL
*
******************/


void DisableOpenGL (HWND hWnd, HDC hDC, HGLRC hRC)
{
wglMakeCurrent (NULL, NULL);
wglDeleteContext (hRC);
ReleaseDC (hWnd, hDC);
}


Here are the possible steps to compile it in DEV C++:

1. Created a new folder inside the main DevC++ folder and called it DEVOpenGL.

2. Opened a new project in the above folder, and gave it a name. Deleted the automatically generated main.cpp code and copied the above code in it´s place.

3. Saved everything.

4. Created a new Icon for the executable inside the Project Menu dialog box and dumped it in the DevOpenGL folder along with two Private files that are´nt supposed to be edited.

5. Create another new folder inside the above folder and called it DevOpenGL01EXE. This folder´s path is referenced in Project/Project Options/Build Options as the path to dump the object file as well as the compiled OpenGL01.EXE standalone executable. Thereby separating it from all the source files.

6. Dumped the following library names in:
Projects/ProjectOptions/Parameters, and they are:
(I´m not too sure if I need all of them, but it compiles)
-lopengl32 -lglu32 -lglaux -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32

7.Also gave the following command line option to the compiler:
(Not too sure what this does, but, it works too.)
-D__GNUWIN32__ -W -DWIN32 -DNDEBUG -D_WINDOWS -D_MBCS
It´s done in the same place in the Project dialog box as step 6. But, in the compiler whitespace instead of the linker whitespace.

8. Get rid of the console by specifying in the Project/Project Options/General dialog box WIN32GUI instead of Console.

9. Going with the regular default compiler as compared to specifying a C++ compiler in Project/Project Options/Compiler did´nt seem to make any difference.

10. Went up to the menu again and clicked Execute/compile. The resulting object file and OpenGl01.EXE were output to the second folder I had created(DevOpenGLEXE folder), as specified.

11. Double clicked on the DevOpenGL01.EXE icon and executed the app.

If it´s not too much of a bother, can someone with Dev C++ please tell me if they could follow the above procedure and compile that code without any errors or warnings.


Thanks

BeginOpenGL







[edited by - BeginOpenGL on April 15, 2004 4:46:09 PM]

[edited by - BeginOpenGL on April 17, 2004 5:45:08 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by Xiachunyi
If it throws up errors, please post them so we can get it working.


i've done the copying(exactly) and stuff and these are the errors i get, which seem to be with the glaux.h file not my cpp file:

Compiler: Default compiler
Building Makefile: "C:\Documents and Settings\young\My Documents\c++\pong\Makefile.win"
Executing make...
make.exe -f "C:\Documents and Settings\young\My Documents\c++\pong\Makefile.win" all
g++.exe -c Lesson1.cpp -o Lesson1.o -I"C:/Program Files/Dev-Cpp/include/c++" -I"C:/Program Files/Dev-Cpp/include/c++/mingw32" -I"C:/Program Files/Dev-Cpp/include/c++/backward" -I"C:/Program Files/Dev-Cpp/include"

In file included from Lesson1.cpp:12:
C:/Program Files/Dev-Cpp/include/gl/glaux.h:453: `y' was not declared in this
scope
C:/Program Files/Dev-Cpp/include/gl/glaux.h:453: ISO C++ forbids declaration of
`glColor3fv' with no type
C:/Program Files/Dev-Cpp/include/gl/glaux.h:453: `int glColor3fv' redeclared as
different kind of symbol

C:/Program Files/Dev-Cpp/include/gl/gl.h:1133: previous declaration of `void
glColor3fv(const GLfloat*)'
C:/Program Files/Dev-Cpp/include/gl/glaux.h:453: syntax error before `:' token
C:/Program Files/Dev-Cpp/include/gl/glaux.h:469: ISO C++ forbids declaration of
`AUX_RGBImageRec' with no type

C:/Program Files/Dev-Cpp/include/gl/glaux.h:563: syntax error before `*' token

C:/Program Files/Dev-Cpp/include/gl/glaux.h:565: syntax error before `*' token

C:/Program Files/Dev-Cpp/include/gl/glaux.h:578: syntax error before `*' token

C:/Program Files/Dev-Cpp/include/gl/glaux.h:580: syntax error before `*' token

C:/Program Files/Dev-Cpp/include/gl/glaux.h:693: parse error before `}' token

make.exe: *** [Lesson1.o] Error 1

Execution terminated



[edited by - knowledge on April 17, 2004 10:14:48 AM]

Share this post


Link to post
Share on other sites


Knowledge


Well, let´s try the simplest possible approach, first. Then move on to more complicated "possible solutions".

You probably allready know this, but maybe this could be where the problem lies.

Go to yourDEVC+/include/GL folder and right mouse button click on the glaux.h file. A little dialog box should pop up. Slide down to where it says - properties-. Left mouse button click on properties. Make sure the glaux.h file´s extension is really H.
So that it should read GLAUX.H .

Also, I downloaded the glaux,h file from that link I gave above. So, I did´nt have to worry about loosing the word wrap or fromat of xyunchis glaux.h code above. Because, when you first paste it into MS Notepad , all of the code runs off to the right in extremely long sentences.

To fix that, just paste it first into MS WORD 6.0, which will preserve the copied code´s word wrap and format so that it does´nt run off in long sentences. Instead, it looks just like xyunchis code up above.

Then, re-paste it into MS Notepad. It should now have the correct format and not be in huge sentences but, look like xyunchis code up above. Then, click the -save as- option. When the dialog box pops up asking the user where to save the file to, type "glaux.h" , making sure to include the colons before and after. In short type it like you see it. Like so "glaux.h" .
Save it right into the DevC/Include/Gl folder.

Double click the file and make sure it has the correct extension, like explained. It should read GLAUX.H in the Windowa properties dialog box.


Well, I know it´s a very simple approach, but, maybe that´s where the problem lies.

If that´s no the problem then, maybe somebody else could step in and help.

BeginOpenGL

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!