rendered paste body#pragma once
#define WIN32_LEAN_AND_MEAN // Compile only necessary elements
#include <d3d9.h>
#include <d3dx9.h>
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
#include <fstream.h>
// defines for windows
#define WINDOW_CLASS_NAME "D3D Device"
#define TITLE "D3D Template"
#define WINDOW_WIDTH 800 // Need these settings to give 800x600 ex border
#define WINDOW_HEIGHT 600
// Macros
#define KEYDOWN(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0)
#define KEYUP(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 0 : 1)
#define KeyP 80 // P is pressed
// Structures
struct CUSTOMVERTEX
{
D3DXVECTOR3 point; // The 3D position for the vertex.
DWORD color; // The vertex color.
D3DXVECTOR2 uv;
};
#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1)
// --------------------------- Classes ----------------------- //
class Wall // Class definition at global scope
{
public:
// Constructor definition
Wall(float tl_x, float tl_y, float tl_z, DWORD tl_color, float tl_u, float tl_v,
float tr_x, float tr_y, float tr_z, DWORD tr_color, float tr_u, float tr_v,
float br_x, float br_y, float br_z, DWORD br_color, float br_u, float br_v,
float bl_x, float bl_y, float bl_z, DWORD bl_color, float bl_u, float bl_v, int text);
Wall();
void Render();
int Texture;
CUSTOMVERTEX m_Verts[4];
private:
short m_Indexes[6];
};
class Cuboid
{
public:
//Constructor Definition
Cuboid();
Cuboid(float cube_x, float cube_y, float cube_z,
float cube_l, float cube_w, float cube_h,
int text);
void Render();
int Texture;
CUSTOMVERTEX m_Verts1[24];
private:
short m_Indexes1[36];
};
// ----------------------------------------------------------- //
//Globals
extern HWND GameHandle;
extern LPDIRECT3D9 g_pD3D; // Used to create the D3DDevice
extern LPDIRECT3DDEVICE9 d3d_Device; // Our rendering device
extern LPDIRECT3DVERTEXBUFFER9 g_pVB; // Buffer to hold vertices
extern DWORD starttime1, endtime1;
extern D3DXVECTOR3 g_Pos;
extern D3DXMATRIX g_ViewMatrix;
extern float g_SpeedForward;
extern float g_SpeedStrafe;
extern float g_Yaw, g_Pitch, g_Roll;
extern int NumQuads;
extern int NumCubes;
extern int NumTextures;
extern int cubenumber;
extern int MouseCurrentX;
extern int MouseCurrentY;
extern int MouseOriginX;
extern int MouseOriginY;
extern LPDIRECT3DTEXTURE9 pTexture;
extern LPDIRECT3DTEXTURE9 *pTextures;
extern Wall *pQuad;
extern Cuboid *pCube;
extern DWORD starttime, endtime;
// Function Prototypes ////////////////////////////////
void Game_Loop(void);
void Screen_Print(int alpha);
void SetPerspectiveProjection();
void RotateCubeY();
void MoveCubeY();
void UpdateCameraViewMatrix();
void RotatePlaneY(int PlaneNum);
void RotatePlaneY1(int PlaneNum);
void ReadFile();
void ReadFileObject();