3H-GDC m.II **** The results are in ****

Started by
149 comments, last by Binomine 18 years, 8 months ago
Ok then, this will be my basecode (it should compile just fine, the input isn't tied in with the code, but it's not too hard to tie in (make sure you call ShowForeground and SetFocus before creating the input object or the device acquire can fail):

Libraries needed: OpenGL32.lib glu32.lib dxguid.lib dinput.lib dinput8.lib

Input.h
#ifndef H_INPUT#define H_INPUT#include <dinput.h>#include "glheaders.h"#include "point.h"class Input{public:	explicit Input() : mouse_x(), mouse_y() { Init(); }	~Input();	void Update();	Point2d<long> mousePos() const { return Point2d<long>(mouse_x, mouse_y); }	bool leftUp() const { return !mouse_data.rgbButtons[0] && last_mouse.rgbButtons[0]; }	bool rightUp() const { return !mouse_data.rgbButtons[1] && last_mouse.rgbButtons[1]; }	bool leftDown() const { return mouse_data.rgbButtons[0] && !last_mouse.rgbButtons[0]; }	bool rightDown() const { return mouse_data.rgbButtons[1] && !last_mouse.rgbButtons[1]; }	bool rightClick() const { return mouse_data.rgbButtons[1]; }	bool leftClick() const { return mouse_data.rgbButtons[0]; }	float xDrag() const { if(rightClick()) return xMove(); else return 0.0f; }	float yDrag() const { if(rightClick()) return yMove(); else return 0.0f; }	float xMove() const { return static_cast<float>(mouse_data.lX); }	float yMove() const { return static_cast<float>(mouse_data.lY); }	float xMouse() const { return static_cast<float>(mouse_x); }	float yMouse() const { return static_cast<float>(mouse_y); }	char key(const char c) const { return keys[c]; }	char keyDown(const char c) const { return (keys[c] && !last_keys[c]); }	char keyUp(const char c) const { return (!keys[c] && last_keys[c]); }private:	bool Init();	void KillInput();	char last_keys[256];	char keys[256];	DIMOUSESTATE last_mouse;	DIMOUSESTATE mouse_data;	long mouse_x;	long mouse_y;	LPDIRECTINPUT8 lpdi;	LPDIRECTINPUTDEVICE8 keyboard_device;	LPDIRECTINPUTDEVICE8 mouse_device;};#endif


Input.cpp
#include "input.h"Input::~Input(){	KillInput();}bool Input::Init(){	HWND hWnd = GetForegroundWindow();	for(int i = 0; i < sizeof(keys); i++) {		keys = 0;		last_keys = 0;	}	lpdi = 0;	keyboard_device = 0;	mouse_device = 0;	HRESULT hr = DirectInput8Create(GetModuleHandle(0), 									DIRECTINPUT_VERSION,									IID_IDirectInput8,									reinterpret_cast<LPVOID*>(&lpdi),									0);	if(FAILED(hr)) {		MessageBox(0, "DirectInput8Create() failed miserably.", "IT CAN'T BE, BUT IT IS!", MB_OK);		return false;	}	hr = lpdi->CreateDevice(GUID_SysKeyboard, &keyboard_device, 0);	if(FAILED(hr)) { 		MessageBox(0, "createdevice", ".", MB_OK);		KillInput(); 		return false; 	}	hr = keyboard_device->SetDataFormat(&c_dfDIKeyboard);	if(FAILED(hr)) { 		MessageBox(0, "setdataformat", ".", MB_OK);		KillInput(); 		return false; 	}	hr = keyboard_device->SetCooperativeLevel(hWnd, DISCL_FOREGROUND | DISCL_NONEXCLUSIVE);	if(FAILED(hr)) { 		MessageBox(0, "set co-op level failed", ".", MB_OK);		KillInput(); 		return false; 	}	if(keyboard_device) {		hr = keyboard_device->Acquire();		if(FAILED(hr)) {			MessageBox(0, "initial keyboard acquire", "!", MB_OK);			KillInput();			return false;		}	}	hr = lpdi->CreateDevice(GUID_SysMouse, &mouse_device, 0);	if(FAILED(hr)) { 		KillInput(); 		return false; 	}	hr = mouse_device->SetDataFormat(&c_dfDIMouse);	if(FAILED(hr)) { 		KillInput(); 		return false; 	}	hr = mouse_device->SetCooperativeLevel(hWnd, DISCL_FOREGROUND | DISCL_EXCLUSIVE);	if(FAILED(hr)) { 		KillInput(); 		return false; 	}	/*DIPROPDWORD dipdw;	dipdw.diph.dwSize = sizeof(DIPROPDWORD);	dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER);	dipdw.diph.dwObj = 0;	dipdw.diph.dwHow = DIPH_DEVICE;	dipdw.dwData = DIPROPAXISMODE_ABS;	hr = mouse_device->SetProperty(DIPROP_AXISMODE, &dipdw.diph);	if(FAILED(hr)) {		KillInput();		return false;	}*/	if(mouse_device) {		if(FAILED(mouse_device->Acquire())) {			MessageBox(0, "initial mouse acquire", "!", MB_OK);			KillInput();			return false;		}	}	return true;}void Input::KillInput(){	if(keyboard_device) keyboard_device->Unacquire();	if(keyboard_device) keyboard_device->Release();	if(mouse_device) mouse_device->Unacquire();	if(mouse_device) mouse_device->Release();	if(lpdi) lpdi->Release();}void Input::Update(){	HRESULT hr = 0;	for(int i = 0; i < sizeof(keys); i++) {		last_keys = keys;	}	hr = keyboard_device->GetDeviceState(sizeof(keys), static_cast<LPVOID>(&keys));	if(FAILED(hr))	{		if(FAILED(keyboard_device->Acquire())) {			MessageBox(0, "Keyboard died.", "F1 F1!", MB_OK);			PostQuitMessage(0);			return;		}		keyboard_device->GetDeviceState(256, static_cast<LPVOID>(&keys));	}	last_mouse = mouse_data;	hr = mouse_device->GetDeviceState(sizeof(mouse_data), static_cast<LPVOID>(&mouse_data));	if(FAILED(hr))	{		if(FAILED(mouse_device->Acquire())) {			MessageBox(0, "Mouse died.", "F1 F1!", MB_OK);			PostQuitMessage(0);			return;		}		mouse_device->GetDeviceState(sizeof(mouse_data), static_cast<LPVOID>(&mouse_data));	}	mouse_x += mouse_data.lX;	mouse_y += mouse_data.lY;	if(mouse_x > 800) mouse_x = 800;	if(mouse_x < 0) mouse_x = 0;	if(mouse_y > 600) mouse_y = 600;	if(mouse_y < 0) mouse_y = 0;}


Window.h
#ifndef H_WINDOW#define H_WINDOW#define WIN32_LEAN_AND_MEAN#include <windows.h>#include <string>#include "glheaders.h"class OGLWindow{public:	OGLWindow();	OGLWindow(int, int, int, bool, WNDPROC);	~OGLWindow();	HWND GetHWND() const { return hWnd; }	HDC GetHDC() const { return hDC; }	int GetWidth() const { return current_width; }	int GetHeight() const { return current_height; }	int GetBits() const { return current_bits; }	bool GetFullscreen() const { return current_fullscreen; }	void SetWidth(int w) { width = w; }	void SetHeight(int h) { height = h; }	void SetBits(int b) { bits = b; }	void SetFullscreen(bool f) { fullscreen = f; }	bool BuildWindow();private:	HDC hDC;	HGLRC hRC;	HWND hWnd;	WNDPROC WndPrc;	int width;	int height;	int bits;	bool fullscreen;	int current_width;	int current_height;	int current_bits;	bool current_fullscreen;	bool SetupOpenGL();	bool SetFS(bool&);	void KillWindow();	void InitGL();};#endif


Window.cpp
#include <memory>#include "window.h"OGLWindow::OGLWindow() : width(), height(), bits(), fullscreen(), WndPrc(){}OGLWindow::OGLWindow(int w, int h, int b, bool f, WNDPROC wp) : width(w), height(h), bits(b), fullscreen(f), WndPrc(wp){	hDC = 0;	hRC = 0;	if(!BuildWindow()) {		MessageBox(0, "build window", "s", MB_OK);	}}OGLWindow::~OGLWindow(){	KillWindow();}void OGLWindow::InitGL(){	glViewport(0, 0, width, height);	glClearColor(0.0f, 0.0f, 0.0f, 1.0f);	glClearDepth(1.0);	glDepthFunc(GL_LESS);	glEnable(GL_TEXTURE_2D);	glEnable(GL_BLEND);	glBlendFunc(GL_SRC_ALPHA, GL_ONE);	glEnable(GL_DEPTH_TEST);	glShadeModel(GL_SMOOTH);	glMatrixMode(GL_PROJECTION);	glLoadIdentity();	glOrtho(0.0f, (float)width, (float)height, 0.0f, -4.0f, 4.0f);	glMatrixMode(GL_MODELVIEW);}bool OGLWindow::SetFS(bool& fs){	DEVMODE dmScreenSettings;	std::uninitialized_fill_n(&dmScreenSettings, 1, DEVMODE());	dmScreenSettings.dmSize=sizeof(dmScreenSettings);	dmScreenSettings.dmPelsWidth  = width;	dmScreenSettings.dmPelsHeight = height;	dmScreenSettings.dmBitsPerPel = bits;		dmScreenSettings.dmFields=DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;	if (ChangeDisplaySettings(&dmScreenSettings,CDS_FULLSCREEN)!=DISP_CHANGE_SUCCESSFUL) {		if (MessageBox(NULL,"No fullscreen for this mode!","YOUR FAULT",MB_YESNO|MB_ICONEXCLAMATION)==IDYES) {			fs=false;		}		else {			return false;		}	}	return true;}bool OGLWindow::SetupOpenGL(){	unsigned int PixelFormat;	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		current_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))) {		KillWindow();		MessageBox(NULL,"Can't Create A GL Device Context.","ERROR",MB_OK|MB_ICONEXCLAMATION);		return false;	}	if (!(PixelFormat=ChoosePixelFormat(hDC,&pfd))) {		KillWindow();		MessageBox(NULL,"Can't Find A Suitable PixelFormat.","PIXELS ARE EVERYTHING",MB_OK|MB_ICONEXCLAMATION);		return false;	}	if(!SetPixelFormat(hDC,PixelFormat,&pfd)) {		KillWindow();		MessageBox(NULL,"Can't Set The PixelFormat.","OH LORDY",MB_OK|MB_ICONEXCLAMATION);		return false;	}	if (!(hRC=wglCreateContext(hDC))) {		KillWindow();		MessageBox(NULL,"Can't Create A GL Rendering Context.","UNGODLY ERROR",MB_OK|MB_ICONEXCLAMATION);		return false;	}	if(!wglMakeCurrent(hDC,hRC)) {		KillWindow();		MessageBox(NULL,"Can't Activate The GL Rendering Context.","HORRIBLE ERROR",MB_OK|MB_ICONEXCLAMATION);		return false;	}	InitGL();	return true;}bool OGLWindow::BuildWindow(){	DWORD dwExStyle = 0;	DWORD dwStyle = 0;	WNDCLASSEX wndclassx;	RECT WndRect;	WndRect.left = static_cast<long>(0);	WndRect.right = static_cast<long>(width);	WndRect.top = static_cast<long>(0);	WndRect.bottom = static_cast<long>(height);	HINSTANCE hInstance = GetModuleHandle(0);	wndclassx.cbSize = sizeof(wndclassx);	wndclassx.style = CS_HREDRAW | CS_VREDRAW;	wndclassx.lpfnWndProc = WndPrc;	wndclassx.cbClsExtra = 0;	wndclassx.cbWndExtra = 0;	wndclassx.hInstance = hInstance;	wndclassx.hCursor = LoadCursor(0, IDC_ARROW);	wndclassx.hIcon = LoadIcon(0, IDI_WINLOGO);	wndclassx.hIconSm = LoadIcon(0, IDI_WINLOGO);	wndclassx.hbrBackground = 0;	wndclassx.lpszClassName = "^_^";	wndclassx.lpszMenuName = 0;	if(!RegisterClassEx(&wndclassx)) {		MessageBox(0, "RegisterClassEx() failed :-(", "HORRIBLE ERROR!", MB_OK);		return false;	}	if(fullscreen) {		if(!(SetFS(fullscreen))) {			return false;		}	}	if(fullscreen) {					// still fullscreen?		dwExStyle = WS_EX_APPWINDOW;		dwStyle = WS_POPUP;		ShowCursor(true);	} else {		dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;		dwStyle = WS_CAPTION | WS_SYSMENU;	}	AdjustWindowRectEx(&WndRect, dwStyle, 0, dwExStyle);	hWnd = CreateWindowEx(dwExStyle,						  "^_^",						  "^_^",						  dwStyle | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,						  CW_USEDEFAULT,						  CW_USEDEFAULT,						  WndRect.right - WndRect.left,						  WndRect.bottom - WndRect.top,						  0,						  0,						  hInstance,						  0);	if(!(SetupOpenGL())) {		return false;	}	current_width = width;	current_height = height;	current_bits = bits;	current_fullscreen = fullscreen;	return true;}void OGLWindow::KillWindow(){	HINSTANCE hInstance = GetModuleHandle(0);	if(current_fullscreen) {		ChangeDisplaySettings(0,0);		ShowCursor(true);	}	if (hRC)	{		if (!wglMakeCurrent(0, 0)) {			MessageBox(NULL,"Release Of DC And RC Failed.", "AWFUL", MB_OK | MB_ICONINFORMATION);		}		if (!wglDeleteContext(hRC)) {			MessageBox(NULL,"Release Rendering Context Failed.", "SHUTDOWN ERROR", MB_OK | MB_ICONINFORMATION);		}		hRC=0;	}	if (hDC && !ReleaseDC(hWnd, hDC)) {		MessageBox(NULL,"Release Device Context Failed.", "OH NO", MB_OK | MB_ICONINFORMATION);		hDC=0;	}	if (hWnd && !DestroyWindow(hWnd)) {		MessageBox(NULL,"Could Not Release hWnd.", "SOMETHING'S WRONG", MB_OK | MB_ICONINFORMATION);		hWnd=0;	}	if (!UnregisterClass("^_^", hInstance)) {		MessageBox(NULL,"Could Not Unregister Class.", "YOU BROKE MY PROGRAM", MB_OK | MB_ICONINFORMATION);		hInstance=0;	}}


Main.cpp
#include <memory>#include "window.h"LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);int active;int done;int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE prevInstance, PSTR szCmdLine, int iCmdShow){	active = 0;        done = 0;	MSG msg;	std::auto_ptr<OGLWindow> wnd(new OGLWindow(800, 600, 32, 0, WndProc));	ShowWindow(wnd->GetHWND(), iCmdShow);	UpdateWindow(wnd->GetHWND());	while(!done)	{		SwapBuffers(wnd->GetHDC());		if(PeekMessage(&msg,0,0,0,PM_REMOVE))		{			TranslateMessage(&msg);			DispatchMessage(&msg);		}	}	return msg.wParam;}LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam){	switch(iMsg)	{	case WM_ACTIVATE:		if(LOWORD(wParam) == WA_INACTIVE)			active = 0;		else			active = 1;		return 0;	case WM_CLOSE:                done = 1;		PostQuitMessage(0);		return 0;	}	return DefWindowProc(hWnd, iMsg, wParam, lParam);}


Point.h (the only math-base stuff I'll have)
#ifndef H_POINT#define H_POINT#include <limits>template<typename T> class Point2d {public:	template<typename U> Point2d(U nx, U ny) : x_val(nx), y_val(ny) { }	template<typename U> Point2d(U nx) : x_val(nx), y_val() { }	template<typename U> void operator=(const Point2d<U>& rhs) { x_val = rhs.x(); y_val = rhs.y(); }	Point2d() : x_val(), y_val() { }	~Point2d() {}	template<typename U> void operator+=(const Point2d<U>& rhs) { x_val += rhs.x(); y_val += rhs.y(); }	template<typename U> void operator-=(const Point2d<U>& rhs) { x_val += rhs.x(); y_val += rhs.y(); }	template<typename U> void operator*=(const U& rhs) { x_val *= rhs; y_val *= rhs; }	template<typename U> void operator/=(const U& rhs) { x_val /= rhs; y_val /= rhs; }	friend const bool operator==(const Point2d& lhs, const Point2d& rhs);	friend const bool operator!=(const Point2d& lhs, const Point2d& rhs);	friend const Point2d operator*(const Point2d& lhs, const T& rhs);	friend const Point2d operator/(const Point2d& lhs, const T& rhs);	friend const Point2d operator*(const T& lhs, const Point2d& rhs);	friend const Point2d operator/(const T& lhs, const Point2d& rhs);	friend const Point2d operator+(const Point2d& lhs, const Point2d& rhs);	friend const Point2d operator-(const Point2d& lhs, const Point2d& rhs);	T x() { return x_val; }	T y() { return y_val; }	void reset() { x_val -= x_val; y_val -= y_val; }	void set(T& nx, T& ny) { x_val = nx; y_val = ny; }	void set_x(T& nx) { x_val = nx; }	void set_y(T& ny) { y_val = ny; }private:	T x_val;	T y_val;};template<typename T> const bool operator==(const Point2d<T>& lhs, const Point2d<T>& rhs){	return ((rhs.x() - lhs.x()) <= std::numeric_limits<T>::epsilon()) &&		((rhs.y() - lhs.y()) <= std::numeric_limits<T>::epsilon());}template<typename T> const bool operator!=(const Point2d<T>& lhs, const Point2d<T>& rhs){	return (!(lhs == rhs));}template<typename T> const Point2d<T> operator*(const Point2d<T>& lhs, const T& rhs){	return Point2d<T>(lhs.x() * rhs, lhs.y() * T);}template<typename T> const Point2d<T> operator/(const Point2d<T>& lhs, const T& rhs){	return Point2d<T>(lhs.x() / rhs, lhs.y() / rhs);}template<typename T> const Point2d<T> operator*(const T& lhs, const Point2d<T>& rhs){ return rhs*lhs; }template<typename T> const Point2d<T> operator/(const T& lhs, const Point2d<T>& rhs){ return rhs/lhs; }template<typename T> const Point2d<T> operator+(const Point2d<T>& lhs, const Point2d<T>& rhs){	return Point2d<T>(lhs.x() + rhs.x(), lhs.y() + rhs.y());}template<typename T> const Point2d<T> operator-(const Point2d<T>& lhs, const Point2d<T>& rhs){	return Point2d<T>(lhs.x() - rhs.x(), lhs.y() - rhs.y());}#endif


glheaders.h
#ifndef H_GLHEADERS#define H_GLHEADERS#include <windows.h>#include <gl.h>#include <glu.h>#endif
Advertisement
Here's my basecode (which may or may not have errors :[ ). I wasn't sure if font or texture code would be allowed yet so I didn't write any. I'm assuming d3d9.h, windows.h, and tchar.h are included.

Gamedev is being whiney about the source so I'll try splitting it over two posts.


Edit: The rest is in the next post. Don't know why I couldn't put it in one :[.


header file:
class DirectXBase{public:	DirectXBase(HINSTANCE);	~DirectXBase();	// creation and deletion	BOOL Init(BOOL windowed, int BPP, int Width, int Height);	void Shutdown(void);	INT Run();	// Accessors	LPDIRECT3DDEVICE9 GetDevice(){return m_pd3dDevice;}	// generic window handler	static LRESULT CALLBACK DispatchWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)	{		if (message == WM_NCCREATE)		{			CREATESTRUCT* cs = (CREATESTRUCT*)lParam;			SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)cs->lpCreateParams);			return TRUE;		}		else		{			DirectXBase *app = (DirectXBase*)GetWindowLongPtr(hWnd, GWLP_USERDATA);			if (app!=NULL)				return app->WndProc(hWnd, message, wParam, lParam);			else				return DefWindowProc(hWnd, message, wParam, lParam); 		}	}	// class window handler	LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);private:	BOOL bWindowed; // window mode	int  iBpp;		// color depth	int	 iWidth;	// window width	int	 iHeight;   // window height	HWND hWnd;		// device window	HINSTANCE hInst;// application instance	// Direct3D objects	LPDIRECT3D9 m_pD3D;	LPDIRECT3DDEVICE9 m_pd3dDevice;	// intialization flag	BOOL bInit;	// windowing functions	ATOM				RegisterClass(HINSTANCE);	BOOL				InitInstance();	// happy text	char szWindowClass[32];	char szTitle[32];};


[Edited by - DukeAtreides076 on July 22, 2005 8:26:06 PM]
Heres the rest(source file):

#include "StdAfx.h"#include ".\directxbase.h"DirectXBase::DirectXBase(HINSTANCE hInstance){	bInit = FALSE;	// Set pointers to NULL in case something goes wrong	m_pd3dDevice = NULL;	m_pD3D = NULL;	hWnd = NULL;	hInst = hInstance;	strcpy(szWindowClass,"dxsample");	strcpy(szTitle,"3Hour Compo");}DirectXBase::~DirectXBase(void){}BOOL DirectXBase::Init(BOOL windowed, int BPP, int Width, int Height){	// Return Value: TRUE if succeeded, else FALSE	bWindowed = windowed;	iBpp = BPP;	iWidth = Width;	iHeight = Height;	// set up the window	RegisterClass(hInst);	// Perform application initialization:	if (!InitInstance ()) 	{		bInit = FALSE;		return FALSE;	}	// start up Direct3d	if( NULL == ( m_pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) )		return FALSE;	// fill up the present parameters	D3DPRESENT_PARAMETERS d3dpp; 		ZeroMemory( &d3dpp, sizeof(d3dpp) );	d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;	d3dpp.Windowed = bWindowed;	d3dpp.hDeviceWindow = hWnd;	// stencil depth and things	// Uncomment for depth stencil	d3dpp.EnableAutoDepthStencil = FALSE;	//d3dpp.EnableAutoDepthStencil = TRUE;    //d3dpp.AutoDepthStencilFormat = D3DFMT_D24X8;	// Dont wait for the vertical retrace	d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;	// check if its running windowed or fullscreen	if (bWindowed)	{		// we dont need to do much here		d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;		d3dpp.Windowed = TRUE;	}	else 	{		// initial setup		d3dpp.Windowed = FALSE;				// get the color depth		if (iBpp == 32 || iBpp == 24)			d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;		else if (iBpp == 16)			d3dpp.BackBufferFormat = D3DFMT_R5G6B5;		else return FALSE;		// set the requested size		d3dpp.BackBufferHeight = iHeight;		d3dpp.BackBufferWidth  = iWidth;		// now we need to check if the display mode is supported		D3DDISPLAYMODE d3ddm;		BOOL bSupported=FALSE;		// loop through the available adapter modes		UINT count=m_pD3D->GetAdapterModeCount(D3DADAPTER_DEFAULT, d3dpp.BackBufferFormat);		for(UINT i=0; i<count; i++)		{			if( FAILED(m_pD3D->EnumAdapterModes(D3DADAPTER_DEFAULT,											d3dpp.BackBufferFormat,											i, &d3ddm)))				return FALSE;			// check and see if it matches our settings			if (d3ddm.Height == d3dpp.BackBufferHeight && 				d3ddm.Width  == d3dpp.BackBufferWidth)			{				bSupported = TRUE; // its a match, break out of the loop				break;			}		}		// Check for hardware support		if(FAILED( m_pD3D->CheckDeviceType(D3DADAPTER_DEFAULT,                                         D3DDEVTYPE_HAL,                                         d3dpp.BackBufferFormat,                                         d3dpp.BackBufferFormat, 										d3dpp.Windowed)))			return FALSE;		if(!bSupported)    // we didnt find the right mode, call fails			return FALSE;	}	// Create the device	if( FAILED( m_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,								D3DCREATE_SOFTWARE_VERTEXPROCESSING,								&d3dpp, &m_pd3dDevice ) ) )		return FALSE;	bInit = TRUE;	return bInit;}void DirectXBase::Shutdown(){	// release devices kthx~	if( m_pd3dDevice != NULL)     // safe release everything        m_pd3dDevice->Release();    if( m_pD3D != NULL)        m_pD3D->Release();}BOOL DirectXBase::Run(){	// check if we have been initialized	if (!bInit)		return FALSE;	MSG msg;	// Run the message pump	while (TRUE) 	{		if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))		{			if (msg.message == WM_QUIT)				break;			//if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) 			//{				TranslateMessage(&msg);				DispatchMessage(&msg);			//}		}				// DO STUFF HERE		/////////////////////////////////////////////////////		// Clear		m_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,255), 1.0f, 0 );		// Begin the scene		m_pd3dDevice->BeginScene();		// DRAW TEH STUFF~~		/////////////////////////////////////////////////////		// End the scene		m_pd3dDevice->EndScene();		// oMFG PRESENTS 		m_pd3dDevice->Present( NULL, NULL, NULL, NULL );		}	return (int) msg.wParam;}//  PURPOSE: Registers the window class.ATOM DirectXBase::RegisterClass(HINSTANCE hInstance){	WNDCLASSEX wcex;	wcex.cbSize = sizeof(WNDCLASSEX); 	wcex.style			= CS_HREDRAW | CS_VREDRAW;	wcex.lpfnWndProc	= (WNDPROC)DispatchWndProc;	wcex.cbClsExtra		= 0;	wcex.cbWndExtra		= 0;	wcex.hInstance		= hInstance;	wcex.hIcon			= LoadIcon(hInstance, IDI_APPLICATION);	wcex.hCursor		= LoadCursor(NULL, IDC_ARROW);	wcex.hbrBackground	= (HBRUSH)(COLOR_WINDOW+1);	wcex.lpszMenuName	= NULL;	wcex.lpszClassName	= szWindowClass;	wcex.hIconSm		= LoadIcon(wcex.hInstance, IDI_APPLICATION);	return RegisterClassEx(&wcex);}BOOL DirectXBase::InitInstance(){   hWnd = CreateWindow(szWindowClass, szTitle, WS_POPUP|WS_CAPTION|WS_MINIMIZEBOX|WS_SYSMENU,	   0, 0, iWidth, iHeight, NULL, NULL, hInst, this);   if (!hWnd)   {      return FALSE;   }   ShowWindow(hWnd, SW_SHOW);   UpdateWindow(hWnd);   RECT r = {0,0,iWidth,iHeight};   AdjustWindowRect(&r, WS_POPUP|WS_CAPTION|WS_MINIMIZEBOX , FALSE);	   SetWindowPos(hWnd, NULL, 0, 0, r.right, r.bottom, SWP_NOOWNERZORDER);   // No clue why I need this here, but it works   SetWindowText(hWnd, szTitle);   return TRUE;}LRESULT CALLBACK DirectXBase::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam){		PAINTSTRUCT ps;	HDC hdc;	switch (message) 	{	case WM_KEYDOWN:		// OMFG SOMEBUODY PUSHED A BUTTON?~!!?		// QUIT		if (wParam == VK_ESCAPE)			PostQuitMessage(0);	case WM_PAINT:		hdc = BeginPaint(hWnd, &ps);		EndPaint(hWnd, &ps);		break;	case WM_DESTROY:		PostQuitMessage(0);		break;	default:		return DefWindowProc(hWnd, message, wParam, lParam);	}	return 0;}
All the posted base code is approved. No other pre-existing code may be used. Good stuff, guys.

[Formerly "capn_midnight". See some of my projects. Find me on twitter tumblr G+ Github.]

please explain rule 12 for me, i still dont get it after i've asked what others on irc think. What happens when someone wins, chooses a price other than GDNet+ (we can choose if we win in a category with the 'or' word in it?) and isnt already a GDNet+ member?

oh and please update the prices before the contest starts


T2k
Quote:Original post by T2k
please explain rule 12 for me, i still dont get it after i've asked what others on irc think. What happens when someone wins, chooses a price other than GDNet+ (we can choose if we win in a category with the 'or' word in it?) and isnt already a GDNet+ member?

oh and please update the prices before the contest starts


T2k

It means that, if you take the GDNet+, then you might post the game on the showcase.

[Formerly "capn_midnight". See some of my projects. Find me on twitter tumblr G+ Github.]

As per rule 3... I still haven't seen any discussion on the theme or similar. I'd be interested to have this finalised at least an hour or two before the contest starts so there is time to figure out what we might do, so we can spend the 3 hours producing code & art rather than attempting to come up with an idea that fits the theme.

-Mezz
Quote:Original post by Mezz
As per rule 3... I still haven't seen any discussion on the theme or similar. I'd be interested to have this finalised at least an hour or two before the contest starts so there is time to figure out what we might do, so we can spend the 3 hours producing code & art rather than attempting to come up with an idea that fits the theme.

-Mezz


as per Michael Tanczos' suggestion
Quote:Original post by Michael Tanczos
A thought.. perhaps announce a simple theme to void out those who have pre-existing projects but basically anything goes otherwise.

I have a simple theme in mind, I will announce it Sunday morning.

[Formerly "capn_midnight". See some of my projects. Find me on twitter tumblr G+ Github.]

Eastern time by GDNet's clock? For me it reads 10:31:42 which is the same as my time(central), is there something I'm missing here?
Quote:Original post by DerAnged
Eastern time by GDNet's clock? For me it reads 10:31:42 which is the same as my time(central), is there something I'm missing here?

It starts at 1PM central time, unless I'm missing something.

This topic is closed to new replies.

Advertisement