亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? init.cpp

?? Quake中的MD2模型導入
?? CPP
字號:
//***********************************************************************//
//																		 //
//		- "Talk to me like I'm a 3 year old!" Programming Lessons -		 //
//                                                                       //
//		$Author:		DigiBen		digiben@gametutorials.com			 //
//																		 //
//		$Program:		MD2 Loader										 //
//																		 //
//		$Description:	Demonstrates how to load a Quake2 MD2 Model		 //
//																		 //
//		$Date:			2/6/02											 //
//																		 //
//***********************************************************************//

#include "main.h"


///////////////////////////////// CREATE TEXTURE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*
/////
/////	This creates a texture in OpenGL that we can texture map
/////
///////////////////////////////// CREATE TEXTURE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*

void CreateTexture(UINT textureArray[], LPSTR strFileName, int textureID)
{
	AUX_RGBImageRec *pBitmap = NULL;
	
	if(!strFileName)									// Return from the function if no file name was passed in
		return;

	pBitmap = auxDIBImageLoad(strFileName);				// Load the bitmap and store the data
	
	if(pBitmap == NULL)									// If we can't load the file, quit!
		exit(0);

	// Generate a texture with the associative texture ID stored in the array
	glGenTextures(1, &textureArray[textureID]);

	// This sets the alignment requirements for the start of each pixel row in memory.
	glPixelStorei (GL_UNPACK_ALIGNMENT, 1);

	// Bind the texture to the texture arrays index and init the texture
	glBindTexture(GL_TEXTURE_2D, textureArray[textureID]);

	// Build Mipmaps (builds different versions of the picture for distances - looks better)
	gluBuild2DMipmaps(GL_TEXTURE_2D, 3, pBitmap->sizeX, pBitmap->sizeY, GL_RGB, GL_UNSIGNED_BYTE, pBitmap->data);

	// Lastly, we need to tell OpenGL the quality of our texture map.  GL_LINEAR_MIPMAP_LINEAR
	// is the smoothest.  GL_LINEAR_MIPMAP_NEAREST is faster than GL_LINEAR_MIPMAP_LINEAR, 
	// but looks blochy and pixilated.  Good for slower computers though.  
		
	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR_MIPMAP_LINEAR);

	// Now we need to free the bitmap data that we loaded since openGL stored it as a texture

	if (pBitmap)										// If we loaded the bitmap
	{
		if (pBitmap->data)								// If there is texture data
		{
			free(pBitmap->data);						// Free the texture data, we don't need it anymore
		}

		free(pBitmap);									// Free the bitmap structure
	}
}

///////////////////////////////// CHANGE TO FULL SCREEN \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*
/////
/////	This changes the screen to FULL SCREEN
/////
///////////////////////////////// CHANGE TO FULL SCREEN \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*

void ChangeToFullScreen()
{
	DEVMODE dmSettings;									// Device Mode variable

	memset(&dmSettings,0,sizeof(dmSettings));			// Makes Sure Memory's Cleared

	// Get current settings -- This function fills our the settings
	// This makes sure NT and Win98 machines change correctly
	if(!EnumDisplaySettings(NULL,ENUM_CURRENT_SETTINGS,&dmSettings))
	{
		// Display error message if we couldn't get display settings
		MessageBox(NULL, "Could Not Enum Display Settings", "Error", MB_OK);
		return;
	}

	dmSettings.dmPelsWidth	= SCREEN_WIDTH;				// Selected Screen Width
	dmSettings.dmPelsHeight	= SCREEN_HEIGHT;			// Selected Screen Height
	
	// This function actually changes the screen to full screen
	// CDS_FULLSCREEN Gets Rid Of Start Bar.
	// We always want to get a result from this function to check if we failed
	int result = ChangeDisplaySettings(&dmSettings,CDS_FULLSCREEN);	

	// Check if we didn't recieved a good return message From the function
	if(result != DISP_CHANGE_SUCCESSFUL)
	{
		// Display the error message and quit the program
		MessageBox(NULL, "Display Mode Not Compatible", "Error", MB_OK);
		PostQuitMessage(0);
	}
}

///////////////////////////////// CREATE MY WINDOW \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*
/////
/////	This function creates a window, but doesn't have a message loop
/////
///////////////////////////////// CREATE MY WINDOW \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*

HWND CreateMyWindow(LPSTR strWindowName, int width, int height, DWORD dwStyle, bool bFullScreen, HINSTANCE hInstance)
{
	HWND hWnd;
	WNDCLASS wndclass;
	
	memset(&wndclass, 0, sizeof(WNDCLASS));				// Init the size of the class
	wndclass.style = CS_HREDRAW | CS_VREDRAW;			// Regular drawing capabilities
	wndclass.lpfnWndProc = WinProc;						// Pass our function pointer as the window procedure
	wndclass.hInstance = hInstance;						// Assign our hInstance
	wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);	// General icon
	wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);		// An arrow for the cursor
	wndclass.hbrBackground = (HBRUSH) (COLOR_WINDOW+1);	// A white window
	wndclass.lpszClassName = "GameTutorials";			// Assign the class name

	RegisterClass(&wndclass);							// Register the class
	
	if(bFullScreen && !dwStyle) 						// Check if we wanted full screen mode
	{													// Set the window properties for full screen mode
		dwStyle = WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
		ChangeToFullScreen();							// Go to full screen
		ShowCursor(FALSE);								// Hide the cursor
	}
	else if(!dwStyle)									// Assign styles to the window depending on the choice
		dwStyle = WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
	
	g_hInstance = hInstance;							// Assign our global hInstance to the window's hInstance

	RECT rWindow;
	rWindow.left	= 0;								// Set Left Value To 0
	rWindow.right	= width;							// Set Right Value To Requested Width
	rWindow.top	    = 0;								// Set Top Value To 0
	rWindow.bottom	= height;							// Set Bottom Value To Requested Height

	AdjustWindowRect( &rWindow, dwStyle, false);		// Adjust Window To True Requested Size

														// Create the window
	hWnd = CreateWindow("GameTutorials", strWindowName, dwStyle, 0, 0,
						rWindow.right  - rWindow.left, rWindow.bottom - rWindow.top, 
						NULL, NULL, hInstance, NULL);

	if(!hWnd) return NULL;								// If we could get a handle, return NULL

	ShowWindow(hWnd, SW_SHOWNORMAL);					// Show the window
	UpdateWindow(hWnd);									// Draw the window

	SetFocus(hWnd);										// Sets Keyboard Focus To The Window	

	return hWnd;
}

///////////////////////////////// SET UP PIXEL FORMAT \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*
/////
/////	This function sets the pixel format for OpenGL.
/////
///////////////////////////////// SET UP PIXEL FORMAT \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*

bool bSetupPixelFormat(HDC hdc) 
{ 
    PIXELFORMATDESCRIPTOR pfd; 
    int pixelformat; 
 
    pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);			// Set the size of the structure
    pfd.nVersion = 1;									// Always set this to 1
														// Pass in the appropriate OpenGL flags
    pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; 
    pfd.dwLayerMask = PFD_MAIN_PLANE;					// We want the standard mask (this is ignored anyway)
    pfd.iPixelType = PFD_TYPE_RGBA;						// We want RGB and Alpha pixel type
    pfd.cColorBits = SCREEN_DEPTH;						// Here we use our #define for the color bits
    pfd.cDepthBits = SCREEN_DEPTH;						// Depthbits is ignored for RGBA, but we do it anyway
    pfd.cAccumBits = 0;									// No special bitplanes needed
    pfd.cStencilBits = 0;								// We desire no stencil bits
 
	// This gets us a pixel format that best matches the one passed in from the device
    if ( (pixelformat = ChoosePixelFormat(hdc, &pfd)) == FALSE ) 
    { 
        MessageBox(NULL, "ChoosePixelFormat failed", "Error", MB_OK); 
        return FALSE; 
    } 
 
	// This sets the pixel format that we extracted from above
    if (SetPixelFormat(hdc, pixelformat, &pfd) == FALSE) 
    { 
        MessageBox(NULL, "SetPixelFormat failed", "Error", MB_OK); 
        return FALSE; 
    } 
 
    return TRUE;										// Return a success!
}

//////////////////////////// RESIZE OPENGL SCREEN \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*
/////
/////	This function resizes the viewport for OpenGL.
/////
//////////////////////////// RESIZE OPENGL SCREEN \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*
void SizeOpenGLScreen(int width, int height)			// Initialize The GL Window
{
	if (height==0)										// Prevent A Divide By Zero error
	{
		height=1;										// Make the Height Equal One
	}

	glViewport(0,0,width,height);						// Make our viewport the whole window
														// We could make the view smaller inside
														// Our window if we wanted too.
														// The glViewport takes (x, y, width, height)
														// This basically means, what our our drawing boundries

	glMatrixMode(GL_PROJECTION);						// Select The Projection Matrix
	glLoadIdentity();									// Reset The Projection Matrix

														// Calculate The Aspect Ratio Of The Window
														// The parameters are:
														// (view angle, aspect ration of the width to the height, 
														//  The closest distance to the camera before it clips, 
				  // FOV		// Ratio				//  The farthest distance before it stops drawing)
	gluPerspective(45.0f,(GLfloat)width/(GLfloat)height, .5f ,150.0f);

	glMatrixMode(GL_MODELVIEW);							// Select The Modelview Matrix
	glLoadIdentity();									// Reset The Modelview Matrix
}

///////////////////////////////// INITIALIZE GL \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*
/////
/////	This function handles all the initialization for OpenGL.
/////
///////////////////////////////// INITIALIZE GL \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*

void InitializeOpenGL(int width, int height) 
{  
    g_hDC = GetDC(g_hWnd);								// This sets our global HDC
														// We don't free this hdc until the end of our program
    if (!bSetupPixelFormat(g_hDC))						// This sets our pixel format/information
        PostQuitMessage (0);							// If there's an error, quit

    g_hRC = wglCreateContext(g_hDC);					// This creates a rendering context from our hdc
    wglMakeCurrent(g_hDC, g_hRC);						// This makes the rendering context we just created the one we want to use

	glEnable(GL_TEXTURE_2D);							// Enables Texture Mapping
	glEnable(GL_DEPTH_TEST);							// Enables Depth Testing

	SizeOpenGLScreen(width, height);					// Setup the screen translations and viewport
}

///////////////////////////////// DE INIT \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*
/////
/////	This function cleans up and then posts a quit message to the window
/////
///////////////////////////////// DE INIT \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*

void DeInit()
{
	if (g_hRC)											
	{
		wglMakeCurrent(NULL, NULL);						// This frees our rendering memory and sets everything back to normal
		wglDeleteContext(g_hRC);						// Delete our OpenGL Rendering Context	
	}
	
	if (g_hDC) 
		ReleaseDC(g_hWnd, g_hDC);						// Release our HDC from memory
		
	if(g_bFullScreen)									// If we were in full screen
	{
		ChangeDisplaySettings(NULL,0);					// If So Switch Back To The Desktop
		ShowCursor(TRUE);								// Show Mouse Pointer
	}

	UnregisterClass("GameTutorials", g_hInstance);		// Free the window class

	PostQuitMessage (0);								// Post a QUIT message to the window
}


///////////////////////////////// WIN MAIN \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*
/////
/////	This function handles registering and creating the window.
/////
///////////////////////////////// WIN MAIN \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hprev, PSTR cmdline, int ishow)
{	
	HWND hWnd;

	// Check if we want full screen or not
	if(MessageBox(NULL, "Click Yes to go to full screen (Recommended)", "Options", MB_YESNO | MB_ICONQUESTION) == IDNO)
		g_bFullScreen = false;
	
	// Create our window with our function we create that passes in the:
	// Name, width, height, any flags for the window, if we want fullscreen of not, and the hInstance
	hWnd = CreateMyWindow("www.GameTutorials.com - MD2 Loader", SCREEN_WIDTH, SCREEN_HEIGHT, 0, g_bFullScreen, hInstance);

	// If we never got a valid window handle, quit the program
	if(hWnd == NULL) return true;

	// INIT OpenGL
	Init(hWnd);													

	// Run our message loop and after it's done, return the result
	return MainLoop();						
}


/////////////////////////////////////////////////////////////////////////////////
//
// * QUICK NOTES * 
//
// This tutorial shows how to load a .MD2 file.  Nothing regarding this tutorial
// was added to this file.  It is the standard file for initialization and texture maps.
// 
// 
// Ben Humphrey (DigiBen)
// Game Programmer
// DigiBen@GameTutorials.com
// Co-Web Host of www.GameTutorials.com
//
//

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
懂色av一区二区三区免费看| 99re这里只有精品首页| 水野朝阳av一区二区三区| 午夜精品福利一区二区三区av | 日韩一级免费一区| 国产女同互慰高潮91漫画| 中文字幕综合网| 一区二区三区在线观看网站| 亚洲品质自拍视频网站| 亚洲成人免费观看| 国产激情视频一区二区在线观看| 韩国av一区二区三区四区| 99精品欧美一区二区三区小说| 亚洲欧洲日产国码二区| 久久99日本精品| 欧美片网站yy| 综合久久久久综合| 欧美主播一区二区三区| 精品国产一区二区三区久久影院 | 欧美精品一区二区久久婷婷| 麻豆91精品视频| 色综合久久88色综合天天免费| 日韩一区二区在线看| 久久精品国产亚洲aⅴ| 欧美高清在线视频| 99天天综合性| 亚洲日本韩国一区| 91精品国产欧美一区二区成人| 久久精品无码一区二区三区 | 国产日产亚洲精品系列| 精品视频在线看| 亚洲不卡av一区二区三区| 精品精品国产高清一毛片一天堂| 亚洲精品国产精华液| 国精品**一区二区三区在线蜜桃| 亚洲欧美日韩久久| 日韩欧美一区二区视频| 视频一区免费在线观看| 日韩理论在线观看| 欧美激情一区不卡| 日韩三级高清在线| 欧美唯美清纯偷拍| 日韩和欧美的一区| 亚洲va国产天堂va久久en| 成人欧美一区二区三区小说| 337p日本欧洲亚洲大胆精品| 国产麻豆午夜三级精品| 欧美影院精品一区| 成人高清视频在线| 香蕉成人啪国产精品视频综合网 | 成人av手机在线观看| 国产一区二区三区精品视频| 国产一区高清在线| 国内精品伊人久久久久av影院| 视频一区视频二区中文| 亚洲二区在线视频| 久久先锋影音av鲁色资源网| 国产欧美一区二区三区在线看蜜臀 | 久久久亚洲精品石原莉奈| 99精品久久免费看蜜臀剧情介绍| 成人午夜av影视| 午夜精品爽啪视频| 天天爽夜夜爽夜夜爽精品视频 | 欧美写真视频网站| 欧美顶级少妇做爰| 亚洲成人资源在线| 亚洲激情图片一区| 日日骚欧美日韩| 国产在线播精品第三| 不卡一区二区中文字幕| 色综合一区二区| 国产成a人亚洲精品| 欧美日韩黄色一区二区| 精品国产乱码久久久久久夜甘婷婷| 久久综合九色综合欧美98| 亚洲国产精品成人久久综合一区| 一区二区三区在线播放| 国产在线不卡一区| 91黄色激情网站| 91免费版在线看| 欧美性极品少妇| 国产欧美日韩另类视频免费观看| 亚洲国产精品嫩草影院| 精品无码三级在线观看视频 | 亚洲日本在线看| 国产麻豆91精品| 日韩午夜小视频| 国产精品久久久久四虎| 亚洲同性同志一二三专区| 狠狠狠色丁香婷婷综合激情| 欧美亚洲禁片免费| 亚洲视频综合在线| 国产精品一线二线三线| 97久久精品人人做人人爽| 日本一区二区三区国色天香| 看电视剧不卡顿的网站| 欧美一个色资源| 日本在线不卡一区| 国产乱人伦偷精品视频不卡| 欧美日韩另类一区| 五月天欧美精品| 日韩视频永久免费| 亚洲国产精品视频| 日韩一区二区在线观看| 国产剧情一区在线| 中文字幕免费不卡| av亚洲产国偷v产偷v自拍| 中文字幕乱码亚洲精品一区| 成人av在线看| 亚洲一区在线观看免费| 国精产品一区一区三区mba视频| 666欧美在线视频| 亚洲欧洲国产日本综合| 99国产精品久| 日韩专区欧美专区| xvideos.蜜桃一区二区| 成人黄色在线网站| 亚洲伊人色欲综合网| 日韩精品一区二区三区中文不卡| 精品一区二区三区欧美| 最新国产成人在线观看| 欧美中文字幕一二三区视频| 天天av天天翘天天综合网色鬼国产| 日韩精品一区二区三区视频播放 | 国产成人av电影在线观看| 亚洲麻豆国产自偷在线| 精品欧美一区二区在线观看 | 91福利区一区二区三区| 日产精品久久久久久久性色| 亚洲视频狠狠干| 精品少妇一区二区| 91在线视频播放地址| 国产一区二区毛片| 免费观看一级特黄欧美大片| 欧美手机在线视频| 高清不卡在线观看av| 美日韩一级片在线观看| 偷拍自拍另类欧美| 亚洲精品视频在线观看网站| 久久亚洲精品国产精品紫薇| 欧美xxxx老人做受| 日韩一区二区三区视频在线观看 | 暴力调教一区二区三区| 蜜臀av性久久久久蜜臀aⅴ四虎| 一区二区不卡在线播放 | 久久精品国产一区二区三区免费看| 中文字幕一区在线| 亚洲四区在线观看| 亚洲国产成人私人影院tom| 337p粉嫩大胆色噜噜噜噜亚洲 | 2021久久国产精品不只是精品| 欧美老肥妇做.爰bbww视频| 8x8x8国产精品| 日韩欧美中文一区| 久久影院电视剧免费观看| 久久综合色一综合色88| 国产精品青草久久| 日韩一区二区在线看| 久久午夜国产精品| 自拍偷拍亚洲欧美日韩| 日韩精品国产欧美| 奇米888四色在线精品| 丁香一区二区三区| 欧美亚一区二区| 欧美日本一道本在线视频| 久久久久久**毛片大全| 最好看的中文字幕久久| 五月婷婷综合激情| 99久久久国产精品免费蜜臀| 欧美男生操女生| 久久久蜜桃精品| 午夜精品福利一区二区三区蜜桃| 国产成人精品一区二区三区四区| 97精品国产露脸对白| 日韩精品一区国产麻豆| 伊人夜夜躁av伊人久久| 国产在线视频一区二区三区| 在线观看国产日韩| 国产日韩影视精品| 欧美aaa在线| 3d动漫精品啪啪| 亚洲人成精品久久久久| 成人一区二区三区| 久久综合色鬼综合色| 日本中文在线一区| 91精品在线观看入口| 亚洲成人先锋电影| 欧美视频一区在线观看| 亚洲男人的天堂在线aⅴ视频| 风间由美性色一区二区三区| 2020国产精品自拍| 蜜臀久久久99精品久久久久久| 欧美午夜片在线看| 一个色在线综合| 99久久精品费精品国产一区二区 | av一区二区久久| 亚洲欧洲一区二区三区| 99免费精品在线| 欧美国产精品一区二区三区| 不卡的av网站|