Jump to content
Compatible Support Forums
Sign in to follow this  
jdulmage

I don't mean to piss everyone off..........

Recommended Posts

Well, Since I haven't reached 58 yet, I'll post some pointless C Code_

 

Code:
#include <stdlib.h>#include <malloc.h>#include <memory.h>#include <tchar.h>#include <stdio.h>#include <windows.h>		// Header File For Windows#include <commctrl.h>#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#include "resource.h"#include <fstream.h>#define NUMBUTTONS 5HDC			hDC=NULL;		// Private GDI Device ContextHGLRC		hRC=NULL;		// Permanent Rendering ContextHWND		hWnd=NULL;		// Holds Our Window HandleHWND		hTBWnd;HINSTANCE	hInstance;		// Holds The Instance Of The ApplicationTBBUTTON TBButtons[5]; //The toolbar we're going to useTBBUTTON another;HBITMAP hBitmap;char szBMPName[]="DEFAULT_TEXTURE";bool	keys[256];			// Array Used For The Keyboard Routinebool	active=TRUE;		// Window Active Flag Set To TRUE By Defaultbool	fullscreen=TRUE;bool	light;								// Lighting ON / OFFbool	lp;									// L Pressed?bool	fp;									// F Pressed?BOOL OpenDialog(HWND hwndOwner, LPSTR filter, LPSTR fil, UINT iFilLen,                LPSTR dlgtitle, LPSTR filtitle, UINT iFilTitleLen);GLuint	texture[3];								// Storage For One Texture ( NEW )GLfloat	xrot;									// X RotationGLfloat	yrot;									// Y RotationGLfloat xspeed;									// X Rotation SpeedGLfloat yspeed;									// Y Rotation SpeedGLfloat	z=-5.0f;								// Depth Into The ScreenGLfloat LightAmbient[]=		{ 0.5f, 0.5f, 0.5f, 1.0f };GLfloat LightDiffuse[]=		{ 1.0f, 1.0f, 1.0f, 1.0f };GLfloat LightPosition[]=	{ 0.0f, 0.0f, 2.0f, 1.0f };GLuint	filter;				// Which Filter To Usevoid DefToolBar(); //Toolbar initialationbool CreateMyWindow(char* title, int width, int height, int bits, bool fullscreenflag); //My Window InitialationLRESULT	CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);	// Declaration For WndProcLRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM);  //Declaration For Abot Dialog boxBOOL OpenDialog(HWND hwndOwner, LPSTR filter, LPSTR fil, UINT iFilLen,                LPSTR dlgtitle, LPSTR filtitle, UINT iFilTitleLen){	OPENFILENAME opfil;    memset((LPOPENFILENAME)&opfil,0,sizeof(opfil));    opfil.lStructSize = sizeof(opfil);    opfil.hInstance = (HINSTANCE)GetWindowLong(hwndOwner,GWL_HINSTANCE);                                           //application instance    opfil.lpstrFilter = filter;                 //filter of files separated by \0    opfil.lpstrFile = fil;                      //absolute path of filename    opfil.nMaxFile = iFilLen;                   //length of filename buffer        opfil.lpstrFileTitle = filtitle;            //filename with no path    opfil.nMaxFileTitle = iFilTitleLen;         //length of filename buffer    opfil.lpstrTitle = dlgtitle;                //title of dialog box    opfil.Flags = OFN_HIDEREADONLY;             //optional flags        return GetOpenFileName(&opfil);    }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,"r");						// 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;	AUX_RGBImageRec *TextureImage[1];		memset(TextureImage,0,sizeof(void *)*1);				// Set The Pointer To NULL	/*int Status=FALSE;							// Status Indicator	char filname[MAX_PATH];  //buffer to hold the filename (with path)    char filtitle[MAX_PATH];  //buffer to hold the filename (without path)    char filter[] = "Texture Files (*.bmp)\0*.bmp\0All files (*.*)\0*.*"; //filename filter    strcpy(filname,""); //make sure that the filename buffer is an empty string                      //if it's not, you will get a CDERR_INVALIDFILENAME	HWND hwnd; //handle of parent window (i.e. main window)	OpenDialog(hwnd,filter,filname,MAX_PATH,"Open file",filtitle,MAX_PATH);*///hBitmap=LoadBitmap(NULL, szBMPName);	TextureImage[0] =auxDIBImageLoad(szBMPName);	Status=TRUE;						// Set The Status To TRUE						// Create Storage Space For The Texture			glGenTextures(3, &texture[0]);					// Create Three Textures			// Create Nearest Filtered Texture	glBindTexture(GL_TEXTURE_2D, texture[0]);	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST); 	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);	glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);	// Create Linear Filtered Texture (bilinear filter)	glBindTexture(GL_TEXTURE_2D, texture[1]);	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);	glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);	// Create MipMapped Texture (AWESOME, SUPER CPU EATER, NINTENDO64 LIKE MIP-MAPPING	glBindTexture(GL_TEXTURE_2D, texture[2]);	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST); 	gluBuild2DMipmaps(GL_TEXTURE_2D, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);	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 Routine	{		return FALSE;							// If Texture Didn't Load Return FALSE	}	glEnable(GL_TEXTURE_2D);						// Enable Texture Mapping	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		glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient);				// Setup The Ambient Light	glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient);				// Setup The Ambient Light	glLightfv(GL_LIGHT1, GL_POSITION,LightPosition);			// Position The Light	glEnable(GL_LIGHT1);							// Enable Light One	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 The Screen And The Depth Buffer	glLoadIdentity();							// Reset The View		glTranslatef(0.0f,0.0f,z);						// Translate Into/Out Of The Screen By z	glRotatef(xrot,1.0f,0.0f,0.0f);						// Rotate On The X Axis By xrot	glRotatef(yrot,0.0f,1.0f,0.0f);						// Rotate On The Y Axis By yrot	glBindTexture(GL_TEXTURE_2D, texture[filter]);				// Select A Texture Based On filter	glBegin(GL_QUADS);	// Front Face		glNormal3f( 0.0f, 0.0f, 1.0f);					// Normal Pointing Towards Viewer		glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f,  1.0f);	// Point 1 (Front)		glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f,  1.0f);	// Point 2 (Front)		glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f,  1.0f,  1.0f);	// Point 3 (Front)		glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f,  1.0f,  1.0f);	// Point 4 (Front)		// Back Face		glNormal3f( 0.0f, 0.0f,-1.0f);					// Normal Pointing Away From Viewer		glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f);	// Point 1 (Back)		glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f,  1.0f, -1.0f);	// Point 2 (Back)		glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f,  1.0f, -1.0f);	// Point 3 (Back)		glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f);	// Point 4 (Back)		// Top Face		glNormal3f( 0.0f, 1.0f, 0.0f);					// Normal Pointing Up		glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f,  1.0f, -1.0f);	// Point 1 (Top)		glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f,  1.0f,  1.0f);	// Point 2 (Top)		glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f,  1.0f,  1.0f);	// Point 3 (Top)		glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f,  1.0f, -1.0f);	// Point 4 (Top)		// Bottom Face		glNormal3f( 0.0f,-1.0f, 0.0f);					// Normal Pointing Down		glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, -1.0f, -1.0f);	// Point 1 (Bottom)		glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, -1.0f, -1.0f);	// Point 2 (Bottom)		glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f,  1.0f);	// Point 3 (Bottom)		glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f,  1.0f);	// Point 4 (Bottom)		// Right face		glNormal3f( 1.0f, 0.0f, 0.0f);					// Normal Pointing Right		glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f);	// Point 1 (Right)		glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f,  1.0f, -1.0f);	// Point 2 (Right)		glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f,  1.0f,  1.0f);	// Point 3 (Right)		glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f,  1.0f);	// Point 4 (Right)		// Left Face		glNormal3f(-1.0f, 0.0f, 0.0f);					// Normal Pointing Left		glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f);	// Point 1 (Left)		glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f,  1.0f);	// Point 2 (Left)		glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f,  1.0f,  1.0f);	// Point 3 (Left)		glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f,  1.0f, -1.0f);	// Point 4 (Left)	glEnd();			// Start Drawing Quads	xrot+=xspeed;								// Add xspeed To xrot	yrot+=yspeed;								// Add yspeed To yrot	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 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	fullscreen=fullscreenflag;			// Set The Global Fullscreen Flag	if (!CreateMyWindow(title,width,height,bits,fullscreen) )			{		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,"OpenGL 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{int wmId, wmEvent;	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_COMMAND:			{				wmId    = LOWORD(wParam); //we create  a menu Handler				wmEvent = HIWORD(wParam); 				// Parse the menu selections:				switch (wmId)        //Switch to menu mesage dispatch				{					case  ID_FILE_EXIT:						PostQuitMessage(0);						break;					case  ID_GLOPTIONS_TEXTUREFILTER_NOFILTER: 			            CheckMenuRadioItem(											(HMENU)GetMenu(hWnd),											ID_GLOPTIONS_TEXTUREFILTER_NOFILTER,											ID_GLOPTIONS_TEXTUREFILTER_MIPMAPMETHOD,											ID_GLOPTIONS_TEXTUREFILTER_LINEARFILTERING,											MF_BYPOSITION);						//CheckMenuItem( (HMENU)GetMenu(hWnd), ID_GLOPTIONS_TEXTUREFILTER_NOFILTER, MF_CHECKED);						filter=0;				// filter set to 0 (no filtering)						break;											case ID_GLOPTIONS_TEXTUREFILTER_LINEARFILTERING:						filter=1;						break;					case ID_GLOPTIONS_TEXTUREFILTER_MIPMAPMETHOD:						filter=2;						break;					case ID_HELP_ABOUTGLWIN:						DialogBox(hInstance, (LPCTSTR)LOGO_BOX, hWnd, (DLGPROC)About);						break;					case ID_GLOPTIONS_LIGHTS:						{							light=!light;				// Toggle Light TRUE/FALSE							if (!light)				// If Not Light							{								glDisable(GL_LIGHTING);		// Disable Lighting								CheckMenuItem( (HMENU)GetMenu(hWnd), ID_GLOPTIONS_LIGHTS, MF_CHECKED);							}							else					// Otherwise							{								glEnable(GL_LIGHTING);		// Enable Lighting								CheckMenuItem( (HMENU)GetMenu(hWnd), ID_GLOPTIONS_LIGHTS, MF_UNCHECKED);															}							break;						}				}			}					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 APIENTRY 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		DialogBox(hInstance, (LPCTSTR)LOGO_BOX, hWnd, (DLGPROC)About);	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("OpenGL Test v 7.0",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 && keys[VK_ESCAPE])			// Active?  Was There A Quit Received?			{				done=TRUE;							// ESC or DrawGLScene Signalled A Quit			}			else									// Not Time To Quit, Update Screen			{				DrawGLScene();						// Reduce Wasted Cycles While Minimized (Draw Scene)				SwapBuffers(hDC);					// Swap Buffers (Double Buffering)			}				// Swap Buffers (Double Buffering)			if (keys['L'] && !lp)				// L Key Being Pressed Not Held?				{				lp=TRUE;				// lp Becomes TRUE				light=!light;				// Toggle Light TRUE/FALSE				if (!light)				// If Not Light					{						glDisable(GL_LIGHTING);		// Disable Lighting					}					else					// Otherwise					{						glEnable(GL_LIGHTING);		// Enable Lighting					}				}			if (!keys['L'])					// Has L Key Been Released?				{					lp=FALSE;				// If So, lp Becomes FALSE				}			if (keys['F'])				// Is F1 Being Pressed?			{				fp=TRUE;				// fp Becomes TRUE					filter+=1;				// filter Value Increases By One					if (filter>2)				// Is Value Greater Than 2?					{						filter=0;			// If So, Set filter To 0					}				}			}						if (!keys['F'])					// Has F Key Been Released?				{					fp=FALSE;				// If So, fp Becomes FALSE				}			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 ( Modified )				if (!CreateGLWindow("NEHE's OPENGL Test v 7.3. Aditional code by Son Gohan (son_gohan@hotmail.com)",640,480,16,fullscreen))				{					return 0;			// Quit If Window Was Not Created				}			}						if (keys[VK_PRIOR])				// Is Page Up Being Pressed?				{					z-=0.02f;				// If So, Move Into The Screen				}						if (keys[VK_NEXT])				// Is Page Down Being Pressed?				{					z+=0.02f;				// If So, Move Towards The Viewer				}			if (keys[VK_UP])				// Is Up Arrow Being Pressed?				{					xspeed-=0.01f;				// If So, Decrease xspeed				}			if (keys[VK_DOWN])				// Is Down Arrow Being Pressed?				{					xspeed+=0.01f;				// If So, Increase xspeed				}			if (keys[VK_RIGHT])				// Is Right Arrow Being Pressed?				{					yspeed+=0.01f;				// If So, Increase yspeed				}			if (keys[VK_LEFT])				// Is Left Arrow Being Pressed?				{					yspeed-=0.01f;				// If So, Decrease yspeed				}			}	// Shutdown	KillGLWindow();									// Kill The Window	return (msg.wParam);							// Exit The Program}LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam){			switch (message)	{		case WM_INITDIALOG:				return TRUE;		case WM_COMMAND:			if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) 			{				EndDialog(hDlg, LOWORD(wParam));				return TRUE;			}			if (LOWORD(wParam) == IDB_EXIT)			{				PostQuitMessage(0);			}			break;						}    return FALSE;}void DefToolBar(){	TBButtons[0].iBitmap=0;	TBButtons[0].idCommand=ID_GLOPTIONS_LIGHTS;	TBButtons[0].fsState=TBSTATE_ENABLED;	TBButtons[0].fsStyle=TBSTYLE_BUTTON;	TBButtons[0].dwData=0L;	TBButtons[0].iString=0;	TBButtons[1].iBitmap=1;	TBButtons[1].idCommand=ID_GLOPTIONS_TEXTUREFILTER_NOFILTER;	TBButtons[1].fsState=TBSTATE_ENABLED;	TBButtons[1].fsStyle=TBSTYLE_BUTTON;	TBButtons[1].dwData=0L;	TBButtons[1].iString=0;		TBButtons[2].iBitmap=2;	TBButtons[2].idCommand=ID_GLOPTIONS_TEXTUREFILTER_MIPMAPMETHOD;	TBButtons[2].fsState=TBSTATE_ENABLED;	TBButtons[2].fsStyle=TBSTYLE_BUTTON;	TBButtons[2].dwData=0L;	TBButtons[2].iString=2;		TBButtons[3].iBitmap=3;	TBButtons[3].idCommand=ID_GLOPTIONS_TEXTUREFILTER_LINEARFILTERING;	TBButtons[3].fsState=TBSTATE_ENABLED;	TBButtons[3].fsStyle=TBSTYLE_BUTTON;	TBButtons[3].dwData=0L;	TBButtons[3].iString=3;	TBButtons[4].iBitmap=4;	TBButtons[4].idCommand=ID_FILE_EXIT;	TBButtons[4].fsState=TBSTATE_ENABLED;	TBButtons[4].fsStyle=TBSTYLE_BUTTON;	TBButtons[4].dwData=0L;	TBButtons[4].iString=3;	}bool CreateMyWindow(char* title, int width, int height, int bits, bool fullscreenflag){	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		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.cbCl***tra		= 0;									// No Extra Window Data	wc.cbWndExtra		= 0;									// No Extra Window Data	wc.hInstance		= hInstance;			wc.hIcon			= LoadIcon(hInstance, (LPCTSTR)ID_MAIN_ICON);			// Load The Default Icon	wc.hCursor			= LoadCursor(NULL, IDC_ARROW);			// Load The Arrow Pointer	wc.hbrBackground	= NULL;									// No Background Required For GL	wc.lpszMenuName		= (LPCSTR)MAIN_MENU;								// 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	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							);		// Create The Window		DefToolBar(); //we initialize toolbar so that we can call createtoolbarex later...	hTBWnd=CreateToolbarEx(hWnd,WS_VISIBLE|WS_CHILD|WS_BORDER                         |TBSTYLE_TOOLTIPS,IDTB_TOOLBAR,                         5,hInstance,IDTB_BITMAP,                         TBButtons,NUMBUTTONS,0,0,16,16,                         sizeof(TBBUTTON));// Dont Pass Anything To WM_CREATE	return TRUE;   }

 

[This message has been edited by Son_Gohan (edited 31 March 2001).]

Share this post


Link to post

*snicker* *snicker* Wow, now I dont feel like such a nerd anymore after seening some code put up. Well, Id probably put some code up if I knew any other than d:\setup ;d=cdrom. Havent used dos since I switched to Win2k.

BTW I know thats not real code anyway. IM interested in the hardware man.

 

Sayanora, suckers! laugh

Share this post


Link to post

I was just being a moron right then. And Im not even stoned on anything. Just imagine how bad Id be if I was.

Share this post


Link to post

Ya...Umm...Ba...Fa...La La La

 

Sashimi...Good Stuff...

 

Give me the Asahi... laugh

 

Mugen C

 

------------------

Dream what you want to dream; go where you want to go; be what you want to be, because you have only one life and one chance to do all the things you want to do!

Share this post


Link to post

Hmm....

 

[This message has been edited by EddiE314 (edited 01 April 2001).]

Share this post


Link to post

I am almost to 200 and 2 more post to go and i firgured i would waste the m here sorry the comp was down

Share this post


Link to post

199 and still goin and goin and goin 1 m,ore after this

1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111

Share this post


Link to post
Guest
This topic is now closed to further replies.
Sign in to follow this  

×