diff --git a/COM350/Project2/Project2/Form1.Designer.vb b/COM350/Project2/Project2/Form1.Designer.vb
index 380716e..127636e 100644
--- a/COM350/Project2/Project2/Form1.Designer.vb
+++ b/COM350/Project2/Project2/Form1.Designer.vb
@@ -35,10 +35,19 @@ Partial Class Form1
Me.ComboBox1 = New System.Windows.Forms.ComboBox()
Me.GroupBox3 = New System.Windows.Forms.GroupBox()
Me.TextBox2 = New System.Windows.Forms.TextBox()
+ Me.ListView1 = New System.Windows.Forms.ListView()
+ Me.ColumnHeader1 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader)
+ Me.ColumnHeader2 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader)
+ Me.ColumnHeader3 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader)
+ Me.ColumnHeader4 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader)
+ Me.GroupBox4 = New System.Windows.Forms.GroupBox()
+ Me.Button2 = New System.Windows.Forms.Button()
+ Me.Button3 = New System.Windows.Forms.Button()
Me.MenuStrip1.SuspendLayout()
Me.GroupBox1.SuspendLayout()
Me.GroupBox2.SuspendLayout()
Me.GroupBox3.SuspendLayout()
+ Me.GroupBox4.SuspendLayout()
Me.SuspendLayout()
'
'MenuStrip1
@@ -77,7 +86,7 @@ Partial Class Form1
'
Me.AboutToolStripMenuItem.Name = "AboutToolStripMenuItem"
Me.AboutToolStripMenuItem.ShortcutKeys = CType((System.Windows.Forms.Keys.Alt Or System.Windows.Forms.Keys.A), System.Windows.Forms.Keys)
- Me.AboutToolStripMenuItem.Size = New System.Drawing.Size(152, 22)
+ Me.AboutToolStripMenuItem.Size = New System.Drawing.Size(145, 22)
Me.AboutToolStripMenuItem.Text = "&About"
'
'TextBox1
@@ -143,11 +152,75 @@ Partial Class Form1
Me.TextBox2.Size = New System.Drawing.Size(333, 20)
Me.TextBox2.TabIndex = 0
'
+ 'ListView1
+ '
+ Me.ListView1.Columns.AddRange(New System.Windows.Forms.ColumnHeader() {Me.ColumnHeader1, Me.ColumnHeader2, Me.ColumnHeader3, Me.ColumnHeader4})
+ Me.ListView1.FullRowSelect = True
+ Me.ListView1.GridLines = True
+ Me.ListView1.LabelWrap = False
+ Me.ListView1.Location = New System.Drawing.Point(6, 19)
+ Me.ListView1.Name = "ListView1"
+ Me.ListView1.Size = New System.Drawing.Size(550, 263)
+ Me.ListView1.Sorting = System.Windows.Forms.SortOrder.Ascending
+ Me.ListView1.TabIndex = 5
+ Me.ListView1.UseCompatibleStateImageBehavior = False
+ Me.ListView1.View = System.Windows.Forms.View.Details
+ '
+ 'ColumnHeader1
+ '
+ Me.ColumnHeader1.Text = "File Path"
+ Me.ColumnHeader1.Width = 110
+ '
+ 'ColumnHeader2
+ '
+ Me.ColumnHeader2.Text = "File Size"
+ '
+ 'ColumnHeader3
+ '
+ Me.ColumnHeader3.Text = "Line:Col"
+ Me.ColumnHeader3.Width = 80
+ '
+ 'ColumnHeader4
+ '
+ Me.ColumnHeader4.Text = "Line Text"
+ Me.ColumnHeader4.Width = 285
+ '
+ 'GroupBox4
+ '
+ Me.GroupBox4.Controls.Add(Me.ListView1)
+ Me.GroupBox4.Location = New System.Drawing.Point(12, 178)
+ Me.GroupBox4.Name = "GroupBox4"
+ Me.GroupBox4.Size = New System.Drawing.Size(562, 288)
+ Me.GroupBox4.TabIndex = 6
+ Me.GroupBox4.TabStop = False
+ Me.GroupBox4.Text = "Results"
+ '
+ 'Button2
+ '
+ Me.Button2.Location = New System.Drawing.Point(493, 472)
+ Me.Button2.Name = "Button2"
+ Me.Button2.Size = New System.Drawing.Size(75, 23)
+ Me.Button2.TabIndex = 7
+ Me.Button2.Text = "&Search"
+ Me.Button2.UseVisualStyleBackColor = True
+ '
+ 'Button3
+ '
+ Me.Button3.Location = New System.Drawing.Point(18, 472)
+ Me.Button3.Name = "Button3"
+ Me.Button3.Size = New System.Drawing.Size(75, 23)
+ Me.Button3.TabIndex = 8
+ Me.Button3.Text = "E&xit"
+ Me.Button3.UseVisualStyleBackColor = True
+ '
'Form1
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
- Me.ClientSize = New System.Drawing.Size(587, 478)
+ Me.ClientSize = New System.Drawing.Size(587, 506)
+ Me.Controls.Add(Me.Button3)
+ Me.Controls.Add(Me.Button2)
+ Me.Controls.Add(Me.GroupBox4)
Me.Controls.Add(Me.GroupBox3)
Me.Controls.Add(Me.GroupBox2)
Me.Controls.Add(Me.GroupBox1)
@@ -162,6 +235,7 @@ Partial Class Form1
Me.GroupBox2.ResumeLayout(False)
Me.GroupBox3.ResumeLayout(False)
Me.GroupBox3.PerformLayout()
+ Me.GroupBox4.ResumeLayout(False)
Me.ResumeLayout(False)
Me.PerformLayout()
@@ -179,5 +253,13 @@ Partial Class Form1
Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox
Friend WithEvents GroupBox3 As System.Windows.Forms.GroupBox
Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
+ Friend WithEvents ListView1 As System.Windows.Forms.ListView
+ Friend WithEvents ColumnHeader1 As System.Windows.Forms.ColumnHeader
+ Friend WithEvents ColumnHeader2 As System.Windows.Forms.ColumnHeader
+ Friend WithEvents ColumnHeader3 As System.Windows.Forms.ColumnHeader
+ Friend WithEvents ColumnHeader4 As System.Windows.Forms.ColumnHeader
+ Friend WithEvents GroupBox4 As System.Windows.Forms.GroupBox
+ Friend WithEvents Button2 As System.Windows.Forms.Button
+ Friend WithEvents Button3 As System.Windows.Forms.Button
End Class
diff --git a/COM350/Project2/Project2/Form1.vb b/COM350/Project2/Project2/Form1.vb
index ab00ac0..cd14b7f 100644
--- a/COM350/Project2/Project2/Form1.vb
+++ b/COM350/Project2/Project2/Form1.vb
@@ -1,10 +1,21 @@
Public Class Form1
- Protected searcher As PatternSearcher = New PatternSearcher
+ Protected searcher As PatternSearcher = New PatternSearcher()
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
+ Private Sub ExitToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ExitToolStripMenuItem.Click
+ Application.Exit()
+ End Sub
+
+ Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
+ Application.Exit()
+ End Sub
+
+ Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
+
+ End Sub
End Class
diff --git a/COM350/Project2/Project2/PatternSearcher.vb b/COM350/Project2/Project2/PatternSearcher.vb
index 82a824f..c082026 100644
--- a/COM350/Project2/Project2/PatternSearcher.vb
+++ b/COM350/Project2/Project2/PatternSearcher.vb
@@ -2,9 +2,15 @@
Private _searchResults As SearchResults = New SearchResults
- Public FileType As String
- Public IsCaseSensitive As Boolean
- Public Pattern As String
+ Public Property FileType As String
+ Public Property IsCaseSensitive As Boolean
+ Public Property Pattern As String
+
+ Sub New(FT As String, ICS As Boolean, P As String)
+ FileType = FT
+ IsCaseSensitive = ICS
+ Pattern = P
+ End Sub
Sub Search()
diff --git a/COM380/MFCApplication1/MFCApplication1.sln b/COM380/MFCApplication1/MFCApplication1.sln
new file mode 100644
index 0000000..24a02df
--- /dev/null
+++ b/COM380/MFCApplication1/MFCApplication1.sln
@@ -0,0 +1,20 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2012
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MFCApplication1", "MFCApplication1\MFCApplication1.vcxproj", "{EEB0848C-7330-4A27-96C6-6E979A1223CC}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {EEB0848C-7330-4A27-96C6-6E979A1223CC}.Debug|Win32.ActiveCfg = Debug|Win32
+ {EEB0848C-7330-4A27-96C6-6E979A1223CC}.Debug|Win32.Build.0 = Debug|Win32
+ {EEB0848C-7330-4A27-96C6-6E979A1223CC}.Release|Win32.ActiveCfg = Release|Win32
+ {EEB0848C-7330-4A27-96C6-6E979A1223CC}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/COM380/MFCApplication1/MFCApplication1/MFCApplication1.cpp b/COM380/MFCApplication1/MFCApplication1/MFCApplication1.cpp
new file mode 100644
index 0000000..1a18f01
--- /dev/null
+++ b/COM380/MFCApplication1/MFCApplication1/MFCApplication1.cpp
@@ -0,0 +1,90 @@
+
+// MFCApplication1.cpp : Defines the class behaviors for the application.
+//
+
+#include "stdafx.h"
+#include "MFCApplication1.h"
+#include "MFCApplication1Dlg.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#endif
+
+
+// CMFCApplication1App
+
+BEGIN_MESSAGE_MAP(CMFCApplication1App, CWinApp)
+ ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
+END_MESSAGE_MAP()
+
+
+// CMFCApplication1App construction
+
+CMFCApplication1App::CMFCApplication1App()
+{
+ // support Restart Manager
+ m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_RESTART;
+
+ // TODO: add construction code here,
+ // Place all significant initialization in InitInstance
+}
+
+
+// The one and only CMFCApplication1App object
+
+CMFCApplication1App theApp;
+
+
+// CMFCApplication1App initialization
+
+BOOL CMFCApplication1App::InitInstance()
+{
+ // InitCommonControlsEx() is required on Windows XP if an application
+ // manifest specifies use of ComCtl32.dll version 6 or later to enable
+ // visual styles. Otherwise, any window creation will fail.
+ INITCOMMONCONTROLSEX InitCtrls;
+ InitCtrls.dwSize = sizeof(InitCtrls);
+ // Set this to include all the common control classes you want to use
+ // in your application.
+ InitCtrls.dwICC = ICC_WIN95_CLASSES;
+ InitCommonControlsEx(&InitCtrls);
+
+ CWinApp::InitInstance();
+
+
+ AfxEnableControlContainer();
+
+
+ // Standard initialization
+ // If you are not using these features and wish to reduce the size
+ // of your final executable, you should remove from the following
+ // the specific initialization routines you do not need
+ // Change the registry key under which our settings are stored
+ // TODO: You should modify this string to be something appropriate
+ // such as the name of your company or organization
+ SetRegistryKey(_T("Local AppWizard-Generated Applications"));
+
+ CMFCApplication1Dlg dlg;
+ m_pMainWnd = &dlg;
+ INT_PTR nResponse = dlg.DoModal();
+ if (nResponse == IDOK)
+ {
+ // TODO: Place code here to handle when the dialog is
+ // dismissed with OK
+ }
+ else if (nResponse == IDCANCEL)
+ {
+ // TODO: Place code here to handle when the dialog is
+ // dismissed with Cancel
+ }
+ else if (nResponse == -1)
+ {
+ TRACE(traceAppMsg, 0, "Warning: dialog creation failed, so application is terminating unexpectedly.\n");
+ }
+
+
+ // Since the dialog has been closed, return FALSE so that we exit the
+ // application, rather than start the application's message pump.
+ return FALSE;
+}
+
diff --git a/COM380/MFCApplication1/MFCApplication1/MFCApplication1.h b/COM380/MFCApplication1/MFCApplication1/MFCApplication1.h
new file mode 100644
index 0000000..345204b
--- /dev/null
+++ b/COM380/MFCApplication1/MFCApplication1/MFCApplication1.h
@@ -0,0 +1,32 @@
+
+// MFCApplication1.h : main header file for the PROJECT_NAME application
+//
+
+#pragma once
+
+#ifndef __AFXWIN_H__
+ #error "include 'stdafx.h' before including this file for PCH"
+#endif
+
+#include "resource.h" // main symbols
+
+
+// CMFCApplication1App:
+// See MFCApplication1.cpp for the implementation of this class
+//
+
+class CMFCApplication1App : public CWinApp
+{
+public:
+ CMFCApplication1App();
+
+// Overrides
+public:
+ virtual BOOL InitInstance();
+
+// Implementation
+
+ DECLARE_MESSAGE_MAP()
+};
+
+extern CMFCApplication1App theApp;
\ No newline at end of file
diff --git a/COM380/MFCApplication1/MFCApplication1/MFCApplication1.rc b/COM380/MFCApplication1/MFCApplication1/MFCApplication1.rc
new file mode 100644
index 0000000..c6ce1bd
Binary files /dev/null and b/COM380/MFCApplication1/MFCApplication1/MFCApplication1.rc differ
diff --git a/COM380/MFCApplication1/MFCApplication1/MFCApplication1.vcxproj b/COM380/MFCApplication1/MFCApplication1/MFCApplication1.vcxproj
new file mode 100644
index 0000000..b72afbc
--- /dev/null
+++ b/COM380/MFCApplication1/MFCApplication1/MFCApplication1.vcxproj
@@ -0,0 +1,128 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Release
+ Win32
+
+
+
+ {EEB0848C-7330-4A27-96C6-6E979A1223CC}
+ MFCApplication1
+ MFCProj
+
+
+
+ Application
+ true
+ v110
+ Unicode
+ Static
+
+
+ Application
+ false
+ v110
+ true
+ Unicode
+ Static
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+
+
+ false
+
+
+
+ Use
+ Level3
+ Disabled
+ WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions)
+
+
+ Windows
+ true
+
+
+ false
+ true
+ _DEBUG;%(PreprocessorDefinitions)
+
+
+ 0x0409
+ _DEBUG;%(PreprocessorDefinitions)
+ $(IntDir);%(AdditionalIncludeDirectories)
+
+
+
+
+ Level3
+ Use
+ MaxSpeed
+ true
+ true
+ WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions)
+
+
+ Windows
+ true
+ true
+ true
+
+
+ false
+ true
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ 0x0409
+ NDEBUG;%(PreprocessorDefinitions)
+ $(IntDir);%(AdditionalIncludeDirectories)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Create
+ Create
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/COM380/MFCApplication1/MFCApplication1/MFCApplication1.vcxproj.filters b/COM380/MFCApplication1/MFCApplication1/MFCApplication1.vcxproj.filters
new file mode 100644
index 0000000..e9df162
--- /dev/null
+++ b/COM380/MFCApplication1/MFCApplication1/MFCApplication1.vcxproj.filters
@@ -0,0 +1,63 @@
+
+
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+ {93995380-89BD-4b04-88EB-625FBE52EBFB}
+ h;hpp;hxx;hm;inl;inc;xsd
+
+
+ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
+ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
+
+
+
+
+
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+
+
+ Resource Files
+
+
+
+
+ Resource Files
+
+
+
+
+ Resource Files
+
+
+
\ No newline at end of file
diff --git a/COM380/MFCApplication1/MFCApplication1/MFCApplication1Dlg.cpp b/COM380/MFCApplication1/MFCApplication1/MFCApplication1Dlg.cpp
new file mode 100644
index 0000000..e327724
--- /dev/null
+++ b/COM380/MFCApplication1/MFCApplication1/MFCApplication1Dlg.cpp
@@ -0,0 +1,152 @@
+
+// MFCApplication1Dlg.cpp : implementation file
+//
+
+#include "stdafx.h"
+#include "MFCApplication1.h"
+#include "MFCApplication1Dlg.h"
+#include "afxdialogex.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#endif
+
+
+// CAboutDlg dialog used for App About
+
+class CAboutDlg : public CDialog
+{
+public:
+ CAboutDlg();
+
+// Dialog Data
+ enum { IDD = IDD_ABOUTBOX };
+
+ protected:
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+
+// Implementation
+protected:
+ DECLARE_MESSAGE_MAP()
+};
+
+CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
+{
+}
+
+void CAboutDlg::DoDataExchange(CDataExchange* pDX)
+{
+ CDialog::DoDataExchange(pDX);
+}
+
+BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
+END_MESSAGE_MAP()
+
+
+// CMFCApplication1Dlg dialog
+
+
+
+CMFCApplication1Dlg::CMFCApplication1Dlg(CWnd* pParent /*=NULL*/)
+ : CDialogEx(CMFCApplication1Dlg::IDD, pParent)
+{
+ m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
+}
+
+void CMFCApplication1Dlg::DoDataExchange(CDataExchange* pDX)
+{
+ CDialogEx::DoDataExchange(pDX);
+}
+
+BEGIN_MESSAGE_MAP(CMFCApplication1Dlg, CDialogEx)
+ ON_WM_SYSCOMMAND()
+ ON_WM_PAINT()
+ ON_WM_QUERYDRAGICON()
+END_MESSAGE_MAP()
+
+
+// CMFCApplication1Dlg message handlers
+
+BOOL CMFCApplication1Dlg::OnInitDialog()
+{
+ CDialogEx::OnInitDialog();
+
+ // Add "About..." menu item to system menu.
+
+ // IDM_ABOUTBOX must be in the system command range.
+ ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
+ ASSERT(IDM_ABOUTBOX < 0xF000);
+
+ CMenu* pSysMenu = GetSystemMenu(FALSE);
+ if (pSysMenu != NULL)
+ {
+ BOOL bNameValid;
+ CString strAboutMenu;
+ bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX);
+ ASSERT(bNameValid);
+ if (!strAboutMenu.IsEmpty())
+ {
+ pSysMenu->AppendMenu(MF_SEPARATOR);
+ pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
+ }
+ }
+
+ // Set the icon for this dialog. The framework does this automatically
+ // when the application's main window is not a dialog
+ SetIcon(m_hIcon, TRUE); // Set big icon
+ SetIcon(m_hIcon, FALSE); // Set small icon
+
+ // TODO: Add extra initialization here
+
+ return TRUE; // return TRUE unless you set the focus to a control
+}
+
+void CMFCApplication1Dlg::OnSysCommand(UINT nID, LPARAM lParam)
+{
+ if ((nID & 0xFFF0) == IDM_ABOUTBOX)
+ {
+ CAboutDlg dlgAbout;
+ dlgAbout.DoModal();
+ }
+ else
+ {
+ CDialogEx::OnSysCommand(nID, lParam);
+ }
+}
+
+// If you add a minimize button to your dialog, you will need the code below
+// to draw the icon. For MFC applications using the document/view model,
+// this is automatically done for you by the framework.
+
+void CMFCApplication1Dlg::OnPaint()
+{
+ if (IsIconic())
+ {
+ CPaintDC dc(this); // device context for painting
+
+ SendMessage(WM_ICONERASEBKGND, reinterpret_cast(dc.GetSafeHdc()), 0);
+
+ // Center icon in client rectangle
+ int cxIcon = GetSystemMetrics(SM_CXICON);
+ int cyIcon = GetSystemMetrics(SM_CYICON);
+ CRect rect;
+ GetClientRect(&rect);
+ int x = (rect.Width() - cxIcon + 1) / 2;
+ int y = (rect.Height() - cyIcon + 1) / 2;
+
+ // Draw the icon
+ dc.DrawIcon(x, y, m_hIcon);
+ }
+ else
+ {
+ CDialogEx::OnPaint();
+ }
+}
+
+// The system calls this function to obtain the cursor to display while the user drags
+// the minimized window.
+HCURSOR CMFCApplication1Dlg::OnQueryDragIcon()
+{
+ return static_cast(m_hIcon);
+}
+
diff --git a/COM380/MFCApplication1/MFCApplication1/MFCApplication1Dlg.h b/COM380/MFCApplication1/MFCApplication1/MFCApplication1Dlg.h
new file mode 100644
index 0000000..3025e10
--- /dev/null
+++ b/COM380/MFCApplication1/MFCApplication1/MFCApplication1Dlg.h
@@ -0,0 +1,32 @@
+
+// MFCApplication1Dlg.h : header file
+//
+
+#pragma once
+
+
+// CMFCApplication1Dlg dialog
+class CMFCApplication1Dlg : public CDialogEx
+{
+// Construction
+public:
+ CMFCApplication1Dlg(CWnd* pParent = NULL); // standard constructor
+
+// Dialog Data
+ enum { IDD = IDD_MFCAPPLICATION1_DIALOG };
+
+ protected:
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+
+
+// Implementation
+protected:
+ HICON m_hIcon;
+
+ // Generated message map functions
+ virtual BOOL OnInitDialog();
+ afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
+ afx_msg void OnPaint();
+ afx_msg HCURSOR OnQueryDragIcon();
+ DECLARE_MESSAGE_MAP()
+};
diff --git a/COM380/MFCApplication1/MFCApplication1/ReadMe.txt b/COM380/MFCApplication1/MFCApplication1/ReadMe.txt
new file mode 100644
index 0000000..c126053
--- /dev/null
+++ b/COM380/MFCApplication1/MFCApplication1/ReadMe.txt
@@ -0,0 +1,103 @@
+================================================================================
+ MICROSOFT FOUNDATION CLASS LIBRARY : MFCApplication1 Project Overview
+===============================================================================
+
+The application wizard has created this MFCApplication1 application for
+you. This application not only demonstrates the basics of using the Microsoft
+Foundation Classes but is also a starting point for writing your application.
+
+This file contains a summary of what you will find in each of the files that
+make up your MFCApplication1 application.
+
+MFCApplication1.vcxproj
+ This is the main project file for VC++ projects generated using an application wizard.
+ It contains information about the version of Visual C++ that generated the file, and
+ information about the platforms, configurations, and project features selected with the
+ application wizard.
+
+MFCApplication1.vcxproj.filters
+ This is the filters file for VC++ projects generated using an Application Wizard.
+ It contains information about the association between the files in your project
+ and the filters. This association is used in the IDE to show grouping of files with
+ similar extensions under a specific node (for e.g. ".cpp" files are associated with the
+ "Source Files" filter).
+
+MFCApplication1.h
+ This is the main header file for the application. It includes other
+ project specific headers (including Resource.h) and declares the
+ CMFCApplication1App application class.
+
+MFCApplication1.cpp
+ This is the main application source file that contains the application
+ class CMFCApplication1App.
+
+MFCApplication1.rc
+ This is a listing of all of the Microsoft Windows resources that the
+ program uses. It includes the icons, bitmaps, and cursors that are stored
+ in the RES subdirectory. This file can be directly edited in Microsoft
+ Visual C++. Your project resources are in 1033.
+
+res\MFCApplication1.ico
+ This is an icon file, which is used as the application's icon. This
+ icon is included by the main resource file MFCApplication1.rc.
+
+res\MFCApplication1.rc2
+ This file contains resources that are not edited by Microsoft
+ Visual C++. You should place all resources not editable by
+ the resource editor in this file.
+
+
+/////////////////////////////////////////////////////////////////////////////
+
+The application wizard creates one dialog class:
+
+MFCApplication1Dlg.h, MFCApplication1Dlg.cpp - the dialog
+ These files contain your CMFCApplication1Dlg class. This class defines
+ the behavior of your application's main dialog. The dialog's template is
+ in MFCApplication1.rc, which can be edited in Microsoft Visual C++.
+
+/////////////////////////////////////////////////////////////////////////////
+
+Other Features:
+
+ActiveX Controls
+ The application includes support to use ActiveX controls.
+
+Printing and Print Preview support
+ The application wizard has generated code to handle the print, print setup, and print preview
+ commands by calling member functions in the CView class from the MFC library.
+
+/////////////////////////////////////////////////////////////////////////////
+
+Other standard files:
+
+StdAfx.h, StdAfx.cpp
+ These files are used to build a precompiled header (PCH) file
+ named MFCApplication1.pch and a precompiled types file named StdAfx.obj.
+
+Resource.h
+ This is the standard header file, which defines new resource IDs.
+ Microsoft Visual C++ reads and updates this file.
+
+MFCApplication1.manifest
+ Application manifest files are used by Windows XP to describe an applications
+ dependency on specific versions of Side-by-Side assemblies. The loader uses this
+ information to load the appropriate assembly from the assembly cache or private
+ from the application. The Application manifest maybe included for redistribution
+ as an external .manifest file that is installed in the same folder as the application
+ executable or it may be included in the executable in the form of a resource.
+/////////////////////////////////////////////////////////////////////////////
+
+Other notes:
+
+The application wizard uses "TODO:" to indicate parts of the source code you
+should add to or customize.
+
+If your application uses MFC in a shared DLL, you will need
+to redistribute the MFC DLLs. If your application is in a language
+other than the operating system's locale, you will also have to
+redistribute the corresponding localized resources mfc110XXX.DLL.
+For more information on both of these topics, please see the section on
+redistributing Visual C++ applications in MSDN documentation.
+
+/////////////////////////////////////////////////////////////////////////////
diff --git a/COM380/MFCApplication1/MFCApplication1/Resource.h b/COM380/MFCApplication1/MFCApplication1/Resource.h
new file mode 100644
index 0000000..b1ce99f
--- /dev/null
+++ b/COM380/MFCApplication1/MFCApplication1/Resource.h
@@ -0,0 +1,21 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ generated include file.
+// Used by MFCApplication1.rc
+//
+#define IDR_MAINFRAME 128
+#define IDM_ABOUTBOX 0x0010
+#define IDD_ABOUTBOX 100
+#define IDS_ABOUTBOX 101
+#define IDD_MFCAPPLICATION1_DIALOG 102
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+
+#define _APS_NEXT_RESOURCE_VALUE 129
+#define _APS_NEXT_CONTROL_VALUE 1000
+#define _APS_NEXT_SYMED_VALUE 101
+#define _APS_NEXT_COMMAND_VALUE 32771
+#endif
+#endif
diff --git a/COM380/MFCApplication1/MFCApplication1/res/MFCApplication1.ico b/COM380/MFCApplication1/MFCApplication1/res/MFCApplication1.ico
new file mode 100644
index 0000000..d56fbcd
Binary files /dev/null and b/COM380/MFCApplication1/MFCApplication1/res/MFCApplication1.ico differ
diff --git a/COM380/MFCApplication1/MFCApplication1/res/MFCApplication1.rc2 b/COM380/MFCApplication1/MFCApplication1/res/MFCApplication1.rc2
new file mode 100644
index 0000000..633eca4
Binary files /dev/null and b/COM380/MFCApplication1/MFCApplication1/res/MFCApplication1.rc2 differ
diff --git a/COM380/MFCApplication1/MFCApplication1/stdafx.cpp b/COM380/MFCApplication1/MFCApplication1/stdafx.cpp
new file mode 100644
index 0000000..b96ba9f
--- /dev/null
+++ b/COM380/MFCApplication1/MFCApplication1/stdafx.cpp
@@ -0,0 +1,8 @@
+
+// stdafx.cpp : source file that includes just the standard includes
+// MFCApplication1.pch will be the pre-compiled header
+// stdafx.obj will contain the pre-compiled type information
+
+#include "stdafx.h"
+
+
diff --git a/COM380/MFCApplication1/MFCApplication1/stdafx.h b/COM380/MFCApplication1/MFCApplication1/stdafx.h
new file mode 100644
index 0000000..8c1ebd0
--- /dev/null
+++ b/COM380/MFCApplication1/MFCApplication1/stdafx.h
@@ -0,0 +1,55 @@
+
+// stdafx.h : include file for standard system include files,
+// or project specific include files that are used frequently,
+// but are changed infrequently
+
+#pragma once
+
+#ifndef VC_EXTRALEAN
+#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
+#endif
+
+#include "targetver.h"
+
+#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
+#define _AFX_NO_MFC_CONTROLS_IN_DIALOGS // remove support for MFC controls in dialogs
+
+// turns off MFC's hiding of some common and often safely ignored warning messages
+#define _AFX_ALL_WARNINGS
+
+#include // MFC core and standard components
+#include // MFC extensions
+
+
+#include // MFC Automation classes
+
+
+
+#ifndef _AFX_NO_OLE_SUPPORT
+#include // MFC support for Internet Explorer 4 Common Controls
+#endif
+#ifndef _AFX_NO_AFXCMN_SUPPORT
+#include // MFC support for Windows Common Controls
+#endif // _AFX_NO_AFXCMN_SUPPORT
+
+#include // MFC support for ribbons and control bars
+
+
+
+
+
+
+
+
+
+#ifdef _UNICODE
+#if defined _M_IX86
+#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
+#elif defined _M_X64
+#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
+#else
+#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
+#endif
+#endif
+
+
diff --git a/COM380/MFCApplication1/MFCApplication1/targetver.h b/COM380/MFCApplication1/MFCApplication1/targetver.h
new file mode 100644
index 0000000..87c0086
--- /dev/null
+++ b/COM380/MFCApplication1/MFCApplication1/targetver.h
@@ -0,0 +1,8 @@
+#pragma once
+
+// Including SDKDDKVer.h defines the highest available Windows platform.
+
+// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
+// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
+
+#include
diff --git a/COM380/Project4/Project4/Form1.h b/COM380/Project4/Project4/Form1.h
index 81b9131..6b56cdb 100644
--- a/COM380/Project4/Project4/Form1.h
+++ b/COM380/Project4/Project4/Form1.h
@@ -1,4 +1,5 @@
#pragma once
+#include "stdafx.h"
#include "LottoBall.h"
namespace Project4
@@ -43,12 +44,19 @@ namespace Project4
private: System::Windows::Forms::ToolStripMenuItem^ helpToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ aboutToolStripMenuItem;
private: System::Windows::Forms::GroupBox^ groupBox1;
- private: System::Windows::Forms::TextBox^ textBox6;
- private: System::Windows::Forms::TextBox^ textBox5;
- private: System::Windows::Forms::TextBox^ textBox4;
- private: System::Windows::Forms::TextBox^ textBox3;
- private: System::Windows::Forms::TextBox^ textBox2;
- private: System::Windows::Forms::TextBox^ textBox1;
+ public: System::Windows::Forms::TextBox^ textBox6;
+ private:
+ public: System::Windows::Forms::TextBox^ textBox5;
+ public: System::Windows::Forms::TextBox^ textBox4;
+ public: System::Windows::Forms::TextBox^ textBox3;
+ public: System::Windows::Forms::TextBox^ textBox2;
+ public: System::Windows::Forms::TextBox^ textBox1;
+
+
+
+
+
+
private: System::Windows::Forms::Label^ label6;
private: System::Windows::Forms::Label^ label5;
private: System::Windows::Forms::Label^ label4;
@@ -225,6 +233,7 @@ namespace Project4
//
// radioButton1
//
+ this->radioButton1->AutoCheck = false;
this->radioButton1->AutoSize = true;
this->radioButton1->Location = System::Drawing::Point(51, 86);
this->radioButton1->Name = L"radioButton1";
@@ -394,7 +403,35 @@ namespace Project4
#pragma endregion
public: List^ balls;
- public: volatile static array^ numbers;
+ public: static array^ numbers;
+ public: System::Void affixNumber(int index, int number)
+ {
+ this->numbers[index] = number;
+ switch (index)
+ {
+ case 0:
+ textBox5->Text = number.ToString("D2");
+ break;
+ case 1:
+ textBox4->Text = number.ToString("D2");
+ break;
+ case 2:
+ textBox4->Text = number.ToString("D2");
+ break;
+ case 3:
+ textBox3->Text = number.ToString("D2");
+ break;
+ case 4:
+ textBox2->Text = number.ToString("D2");
+ break;
+ case 5:
+ textBox1->Text = number.ToString("D2");
+ break;
+ case 6:
+ textBox6->Text = number.ToString("D2");
+ break;
+ }
+ }
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
@@ -403,10 +440,10 @@ namespace Project4
for (int i = 0; i < 5; i++)
{
- balls->Add(gcnew LottoBall(1, 75));
+ balls->Add(gcnew LottoBall(1, 75, this));
}
- balls->Add(gcnew LottoBall(1, 15));
+ balls->Add(gcnew LottoBall(1, 15, this));
}
private: System::Void exitToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e)
diff --git a/COM380/Project4/Project4/LottoBall.h b/COM380/Project4/Project4/LottoBall.h
index 770d40d..dec2462 100644
--- a/COM380/Project4/Project4/LottoBall.h
+++ b/COM380/Project4/Project4/LottoBall.h
@@ -1,35 +1,40 @@
-#pragma once
+#include "stdafx.h"
+#include "Form1.h"
-namespace Project4
+using namespace System;
+using namespace System::Collections;
+using namespace System::Collections::Generic;
+using namespace System::Threading;
+using namespace System::Threading::Tasks;
+using namespace System::Data;
+using namespace Project4;
+
+
+public ref class LottoBall
{
- using namespace System;
- using namespace System::Collections;
- using namespace System::Collections::Generic;
- using namespace System::Threading;
- using namespace System::Threading::Tasks;
- using namespace System::Data;
- public ref class LottoBall
- {
+public:
+ LottoBall(int minval, int maxval, Form1^ form1);
+ ~LottoBall();
- public:
- LottoBall(int minval, int maxval);
- ~LottoBall();
+ int getCurrentValue();
+ int num;
- int getCurrentValue();
- int num;
+ System::Void start();
+ System::Void stop();
+ System::Void initThread();
- System::Void start();
- System::Void stop();
+private:
+ int minVal;
+ int maxVal;
+ int seedValue;
- private:
- int minVal;
- int maxVal;
+ Form1^ formptr;
- bool threadStop;
- Thread^ thread;
- System::Void run();
+ Random^ r;
- };
+ bool threadStop;
+ Thread^ thread;
+ System::Void run();
-}
\ No newline at end of file
+};
\ No newline at end of file
diff --git a/COM380/Project4/Project4/LottoBallcpp.cpp b/COM380/Project4/Project4/LottoBallcpp.cpp
index 83882e7..d071725 100644
--- a/COM380/Project4/Project4/LottoBallcpp.cpp
+++ b/COM380/Project4/Project4/LottoBallcpp.cpp
@@ -1,54 +1,59 @@
#include "LottoBall.h"
-#include "Form1.h"
-namespace Project4
+LottoBall::LottoBall(int minval, int maxval, Form1^ form1)
{
+ minVal = minval;
+ maxVal = maxval;
- LottoBall::LottoBall(int minval, int maxval)
+ threadStop = false;
+ num = 0;
+
+ formptr = form1;
+}
+
+LottoBall::~LottoBall()
+{
+ thread->Abort();
+}
+
+System::Void LottoBall::initThread()
+{
+ r = gcnew Random();
+ long long seed = 0;
+ for(int i = 0; i < 100; ++i)
{
- minVal = minval;
- maxVal = maxval;
-
- threadStop = false;
- num = 0;
- thread = gcnew Thread(gcnew ThreadStart(&run));
-
+ seed += r->Next(i, 9999 + i);
}
+ r = gcnew Random(seed);
+ thread = gcnew Thread(gcnew ThreadStart(&this->run));
+}
- LottoBall::~LottoBall()
+System::Void LottoBall::run()
+{
+ String^ threadname = Thread::CurrentThread->Name;
+ int id = 0;
+ Int32::TryParse(threadname, id);
+
+ while (!this->threadStop)
{
- thread->Abort();
+ this->num = r->Next(minVal, maxVal);
+ formptr->affixNumber(id, this->num);
}
+}
- System::Void LottoBall::run()
- {
- Random^ r = gcnew Random();
- String^ threadname = Thread::CurrentThread->Name;
- int id = 0;
- Int32::TryParse(threadname, id);
+int LottoBall::getCurrentValue()
+{
+ return this->num;
+}
- while (!this->threadStop)
- {
- this->num = r->Next(minVal, maxVal);
- Form1::numbers[id] = this->num;
- }
- }
-
- int LottoBall::getCurrentValue()
- {
- return this->num;
- }
-
- System::Void LottoBall::start()
- {
- this->threadStop = false;
- thread->Start();
- }
-
- System::Void LottoBall::stop()
- {
- this->threadStop = true;
- }
+System::Void LottoBall::start()
+{
+ this->threadStop = false;
+ thread->Start();
+}
+System::Void LottoBall::stop()
+{
+ this->threadStop = true;
}
\ No newline at end of file
diff --git a/COM380/Project5/GambleKit.sln b/COM380/Project5/GambleKit.sln
new file mode 100644
index 0000000..f663343
--- /dev/null
+++ b/COM380/Project5/GambleKit.sln
@@ -0,0 +1,20 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual C++ Express 2010
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GambleKit", "GambleKit\GambleKit.vcxproj", "{E6093060-EA31-4FF3-9230-2E9CDF34C694}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {E6093060-EA31-4FF3-9230-2E9CDF34C694}.Debug|Win32.ActiveCfg = Debug|Win32
+ {E6093060-EA31-4FF3-9230-2E9CDF34C694}.Debug|Win32.Build.0 = Debug|Win32
+ {E6093060-EA31-4FF3-9230-2E9CDF34C694}.Release|Win32.ActiveCfg = Release|Win32
+ {E6093060-EA31-4FF3-9230-2E9CDF34C694}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/COM380/Project5/GambleKit/CustomGameLogic/CustomGame.cpp b/COM380/Project5/GambleKit/CustomGameLogic/CustomGame.cpp
new file mode 100644
index 0000000..1f92c64
--- /dev/null
+++ b/COM380/Project5/GambleKit/CustomGameLogic/CustomGame.cpp
@@ -0,0 +1,25 @@
+#include "CustomGame.h"
+
+#include "Pages\MainPage.h"
+
+const wchar_t *CustomGame::settingsFileName = L"..\\Settings.dat";
+
+const wchar_t *CustomGame::screenShotsFileExp = L"..\\Logging\\Plays\\play{0}.jpg";
+
+CustomGame::CustomGame(GkGraphicsDevice *graphicsDevice, GkSoundDevice *soundDevice) :
+ GkGame(graphicsDevice, soundDevice)
+{
+ this->logGamePlay = new GkLogFile(L"..\\Logging\\GamePlay.log");
+
+ //this->settings = new Settings(CustomGame::settingsFileName, this);
+
+ this->AddGamePage(new MainPage(this));
+}
+
+
+CustomGame::~CustomGame(void)
+{
+ delete this->logGamePlay;
+
+ //delete this->settings;
+}
diff --git a/COM380/Project5/GambleKit/CustomGameLogic/CustomGame.h b/COM380/Project5/GambleKit/CustomGameLogic/CustomGame.h
new file mode 100644
index 0000000..9b5379a
--- /dev/null
+++ b/COM380/Project5/GambleKit/CustomGameLogic/CustomGame.h
@@ -0,0 +1,39 @@
+#pragma once
+
+#include "..\Engine\GambleKit.h"
+
+//#include "Settings.h"
+//#include "Dictionary.h"
+
+struct LogRecordGamePlay
+{
+ DateTime time;
+ int bet;
+ int winning;
+};
+
+class MainPage;
+class MainMenuPage;
+
+class CustomGame :
+ public GkGame
+{
+public:
+ static const wchar_t *dataFileName, *settingsFileName;
+ static const wchar_t *screenShotsFileExp;
+
+ bool isPayingCredits;
+ int creditsPayed;
+
+ //Settings *settings;
+
+ GkLogFile *logGamePlay;
+
+ MainPage *mainPage;
+
+ MainMenuPage *mainMenuPage;
+
+ CustomGame(GkGraphicsDevice *graphicsDevice, GkSoundDevice *soundDevice);
+ ~CustomGame(void);
+};
+
diff --git a/COM380/Project5/GambleKit/CustomGameLogic/MainWindow.cpp b/COM380/Project5/GambleKit/CustomGameLogic/MainWindow.cpp
new file mode 100644
index 0000000..5c4c94c
--- /dev/null
+++ b/COM380/Project5/GambleKit/CustomGameLogic/MainWindow.cpp
@@ -0,0 +1,78 @@
+#include "MainWindow.h"
+
+#include "Pages\MainPage.h"
+
+MainWindow::MainWindow(void)
+{
+ if (this->deviceContext == 0)
+ GkOSUtils::ShowMessage("Error creating device context", this->handle);
+ if (this->renderContext == 0)
+ GkOSUtils::ShowMessage("Error creating rendering context", this->handle);
+
+ this->graphicsDevice = new GkGraphicsDevice();
+
+ if (this->graphicsDevice->maxTextureSize < 2048)
+ GkOSUtils::ShowMessage(GkStrings::ToShort(GkStrings::Format(L"Graphics device does not suport textures with dimensions of size at least 2048 pixels.\r\nMaxium supported size is {0}.\r\nSome textures may not be rendered.", GkStrings::IntToString(this->graphicsDevice->maxTextureSize).c_str()).c_str()).c_str());
+ if (!this->graphicsDevice->nonPower2Textures)
+ GkOSUtils::ShowMessage("Graphics device does not support textures of arbitraty dimensions. Application will require more video memory than normal.");
+
+ this->soundDevice = new GkSoundDevice();
+
+ GkFileSystem::SetSource(L"..\\GameData\\", FileSystemMode_Physical);
+
+ this->game = new CustomGame(this->graphicsDevice, this->soundDevice);
+
+ this->SetPosition(0, 0);
+ this->SetSize(800, 600);
+ this->SetActive();
+}
+
+
+MainWindow::~MainWindow(void)
+{
+}
+
+bool MainWindow::Close()
+{
+ delete this->game;
+
+ delete this->soundDevice;
+ delete this->graphicsDevice;
+
+ return true;
+}
+
+void MainWindow::MainLoop()
+{
+ //TODO: timed rendering (main or custom thread, Sleep(frameInterval - renderTime). VSync
+ this->game->NewFrame();
+
+ this->MakeCurrent();
+ this->game->Process();
+ this->game->Render();
+ this->Present();
+
+ // If thre are changes to the settings data, they will automatically be written to disk
+ //this->game->settings->WriteChanges();
+}
+
+void MainWindow::MouseDown(int x, int y, int mouseButtons)
+{
+ this->game->MouseDown(x, y);
+};
+
+void MainWindow::MouseUp(int x, int y, int mouseButtons)
+{
+ this->game->MouseUp(x, y);
+}
+
+void MainWindow::Resize(int width, int height)
+{
+ this->graphicsDevice->SetViewport(0, 0, width, height);
+}
+
+void MainWindow::KeyDown(int keyCode)
+{
+ if (keyCode == VK_ESCAPE)
+ this->DestroyFormWindow();
+}
\ No newline at end of file
diff --git a/COM380/Project5/GambleKit/CustomGameLogic/MainWindow.h b/COM380/Project5/GambleKit/CustomGameLogic/MainWindow.h
new file mode 100644
index 0000000..be6908b
--- /dev/null
+++ b/COM380/Project5/GambleKit/CustomGameLogic/MainWindow.h
@@ -0,0 +1,26 @@
+#pragma once
+
+#include "..\Engine\GambleKit.h"
+
+#include "CustomGame.h"
+
+class MainWindow :
+ public GkOpenGLWindowsForm
+{
+public:
+ GkGraphicsDevice *graphicsDevice;
+ GkSoundDevice *soundDevice;
+
+ CustomGame *game;
+
+ MainWindow::MainWindow(void);
+ MainWindow::~MainWindow(void);
+
+ bool MainWindow::Close();
+ void MainWindow::MainLoop();
+ void MainWindow::MouseDown(int x, int y, int mouseButtons);
+ void MainWindow::MouseUp(int x, int y, int mouseButtons);
+ void MainWindow::Resize(int width, int height);
+ void MainWindow::KeyDown(int keyCode);
+};
+
diff --git a/COM380/Project5/GambleKit/CustomGameLogic/Pages/MainPage.cpp b/COM380/Project5/GambleKit/CustomGameLogic/Pages/MainPage.cpp
new file mode 100644
index 0000000..19934c7
--- /dev/null
+++ b/COM380/Project5/GambleKit/CustomGameLogic/Pages/MainPage.cpp
@@ -0,0 +1,159 @@
+#include "MainPage.h"
+
+#include "..\..\Engine\GambleKit.h"
+
+
+MainPage::MainPage(CustomGame *game)
+ : GkGamePage()
+{
+ // Initialize the variables
+ this->bet = 10;
+ this->lines = 5;
+ this->winning = 0;
+ this->credits = 100;
+
+ // Add the background
+ this->AddEntity(new GkGameAnimation(game->AcquireAnimatedTexture(L"Background.png")));
+
+ // Create the Bet, Lines and Start buttons
+ this->btnBet = (GkGameClickButton*)this->AddEntity(new GkGameClickButton(
+ new GkGameAnimation(game->AcquireAnimatedTexture(L"btn_bet_default.png"), 354, 528),
+ new GkGameAnimation(game->AcquireAnimatedTexture(L"btn_bet_down.png"), 354, 528),
+ new GkGameAnimation(game->AcquireAnimatedTexture(L"btn_bet_disabled.png"), 354, 528)));
+ this->btnLines = (GkGameClickButton*)this->AddEntity(new GkGameClickButton(
+ new GkGameAnimation(game->AcquireAnimatedTexture(L"btn_lines_default.png"), 524, 528),
+ new GkGameAnimation(game->AcquireAnimatedTexture(L"btn_lines_down.png"), 524, 528),
+ new GkGameAnimation(game->AcquireAnimatedTexture(L"btn_lines_disabled.png"), 524, 528)));
+ this->btnStart = (GkGameClickButton*)this->AddEntity(new GkGameClickButton(
+ new GkGameAnimation(game->AcquireAnimatedTexture(L"btn_start_default.png"), 687, 503),
+ new GkGameAnimation(game->AcquireAnimatedTexture(L"btn_start_down.png"), 687, 503),
+ new GkGameAnimation(game->AcquireAnimatedTexture(L"btn_start_disabled.png"), 687, 503)));
+
+ // Create a special counter for the credits, to make them appear to increase gradually for better visual experience
+ GkGameWinningCounter *creditsCounter = (GkGameWinningCounter*)this->AddEntity(new GkGameWinningCounter(&this->credits, 500.0f, 2.0f));
+
+ // Create the Credits, Winning, Bet and Lines text counters and bind them to their respective values. Note that credits is bound to the "creditsCounter"
+ this->AddEntity(new GkGameTextsIntBinding(&creditsCounter->intDisplayValue, 1, this->AddEntity(new GkGameText(game->AcquireAnimatedFontFromMultipleFiles(L"font_main_{0}.png", L"0123456789,.-"), 80, 496, -3, GkGameText::GameTextAlignment_Center))));
+ this->AddEntity(new GkGameTextsIntBinding(&this->winning, 1, this->AddEntity(new GkGameText(game->AcquireAnimatedFontFromMultipleFiles(L"font_main_{0}.png", L"0123456789,.-"), 250, 496, -3, GkGameText::GameTextAlignment_Center))));
+ this->AddEntity(new GkGameTextsIntBinding(&this->bet, 1, this->AddEntity(new GkGameText(game->AcquireAnimatedFontFromMultipleFiles(L"font_main_{0}.png", L"0123456789,.-"), 420, 496, -3, GkGameText::GameTextAlignment_Center))));
+ this->AddEntity(new GkGameTextsIntBinding(&this->lines, 1, this->AddEntity(new GkGameText(game->AcquireAnimatedFontFromMultipleFiles(L"font_main_{0}.png", L"0123456789,.-"), 590, 496, -3, GkGameText::GameTextAlignment_Center))));
+
+ // Create the combinations generator. The combinations generator represents a model of collection of reels. Each of its reels can have a different model
+ // The GkGameReelStripModel is a GkGameReelModel, representing a reel with a fixed sequence of finite number of items. Here, it is used for all the reels of the combination generator.
+ this->combinationsGenerator = new GkGameReelsCombinationGenerator(5, 3);
+ this->combinationsGenerator->SetReelModel(0, new GkGameReelStripModel(3, 6, ReelItem_Cherry, ReelItem_Melon, ReelItem_Cherry, ReelItem_Bell, ReelItem_Cherry, ReelItem_Melon));
+ this->combinationsGenerator->SetReelModel(1, new GkGameReelStripModel(3, 6, ReelItem_Bell, ReelItem_Melon, ReelItem_Bell, ReelItem_Melon, ReelItem_Melon, ReelItem_Cherry));
+ this->combinationsGenerator->SetReelModel(2, new GkGameReelStripModel(3, 6, ReelItem_Cherry, ReelItem_7, ReelItem_Melon, ReelItem_Cherry, ReelItem_7, ReelItem_Bell));
+ this->combinationsGenerator->SetReelModel(3, new GkGameReelStripModel(3, 6, ReelItem_Cherry, ReelItem_Bell, ReelItem_Melon, ReelItem_Bell, ReelItem_Cherry, ReelItem_Bell));
+ this->combinationsGenerator->SetReelModel(4, new GkGameReelStripModel(3, 6, ReelItem_Cherry, ReelItem_Melon, ReelItem_Bell, ReelItem_Cherry, ReelItem_Melon, ReelItem_Bell));
+
+ // Create the visual object for the reels
+ this->reels = (GkGameReels*)this->AddEntity(new GkGameReels(5, 3, 4, 670, 331));
+ this->reels->symbols[ReelItem_Cherry] = game->AcquireAnimatedTexture(L"symbol_cherry.png");
+ this->reels->symbols[ReelItem_Melon ] = game->AcquireAnimatedTexture(L"symbol_melon.png");
+ this->reels->symbols[ReelItem_Bell ] = game->AcquireAnimatedTexture(L"symbol_bell.png");
+ this->reels->symbols[ReelItem_7 ] = game->AcquireAnimatedTexture(L"symbol_7.png");
+ this->reels->x = 62;
+ this->reels->y = 90;
+ this->reels->ApplyReelMap();// (this->game->settings->playerSettings->currentMap);
+ this->reels->SetItemGenerator(this->combinationsGenerator);
+
+ // Load the images used to show a winning line
+ this->lineAnimations[0] = (GkGameAnimation*)this->AddEntity(new GkGameAnimation(game->AcquireAnimatedTexture(L"line123.png"), 112, 255));
+ this->lineAnimations[1] = (GkGameAnimation*)this->AddEntity(new GkGameAnimation(game->AcquireAnimatedTexture(L"line123.png"), 112, 139));
+ this->lineAnimations[2] = (GkGameAnimation*)this->AddEntity(new GkGameAnimation(game->AcquireAnimatedTexture(L"line123.png"), 112, 371));
+ this->lineAnimations[3] = (GkGameAnimation*)this->AddEntity(new GkGameAnimation(game->AcquireAnimatedTexture(L"line45.png"), 112, 139));
+ this->lineAnimations[4] = (GkGameAnimation*)this->AddEntity(new GkGameAnimation(game->AcquireAnimatedTexture(L"line45.png"), 112, 139, true, true, true, false, true));
+
+ // The winnings model defines two things. One is the properties of the symbols - their coefficients and special behaviour. Second - the shape of the winning lines.
+ this->winningsModel = new GkGameWinningsModel(5, 3, 5, 4, 0);
+ this->winningsModel->SetupSymbol(ReelItem_Cherry, 0, GkGameWinningsModel::SymbolFlag_Default, GkGameWinningsModel::SymbolFlag_None, 0, 0, 10, 20, 80);
+ this->winningsModel->SetupSymbol(ReelItem_Melon , 0, GkGameWinningsModel::SymbolFlag_Default, GkGameWinningsModel::SymbolFlag_None, 0, 0, 20, 40, 200);
+ this->winningsModel->SetupSymbol(ReelItem_Bell , 0, GkGameWinningsModel::SymbolFlag_Default, GkGameWinningsModel::SymbolFlag_None, 0, 0, 50, 100, 500);
+ this->winningsModel->SetupSymbol(ReelItem_7 , 0, GkGameWinningsModel::SymbolFlag_Wild, GkGameWinningsModel::SymbolFlag_None, 0, 0, 0, 0, 0);
+ this->winningsModel->SetupLine(0, 1, 1, 1, 1, 1);
+ this->winningsModel->SetupLine(1, 0, 0, 0, 0, 0);
+ this->winningsModel->SetupLine(2, 2, 2, 2, 2, 2);
+ this->winningsModel->SetupLine(3, 0, 1, 2, 1, 0);
+ this->winningsModel->SetupLine(4, 2, 1, 0, 1, 2);
+
+ // The winnings analyzer is used to analyze a combination for winnings, based on a winning model. After an analisys, it holds all the winnings, if any, and detailed information on them.
+ this->winningsAnalyzer = new GkGameWinningsAnalyzer(this->winningsModel);
+
+ this->sndReels = game->AcquireSoundSource(L"reels.wav");
+ this->sndReelStop = game->AcquireSoundSource(L"reel.wav");
+}
+
+
+MainPage::~MainPage(void)
+{
+ delete this->combinationsGenerator;
+ delete this->winningsAnalyzer;
+ delete this->winningsModel;
+}
+
+void MainPage::Process(GkGame *game)
+{
+ if (this->reels->state == Idle)
+ {
+ // Start button - hide the lines, generate a random combination, set it to appear on the reels after spinning, analyze its winning and start the reels
+ if (this->btnStart->IsClicked())
+ {
+ for (int lineIndex = 0; lineIndex < this->winningsModel->numLines; lineIndex++)
+ this->lineAnimations[lineIndex]->visible = false;
+
+ this->credits -= this->bet * this->lines;
+
+ this->combinationsGenerator->GenerateCombination();
+ this->reels->SetItems(this->combinationsGenerator);
+ this->winningsAnalyzer->AnalyzeWinnings(this->combinationsGenerator);
+ this->winningsAnalyzer->MultiplyWinnings(this->bet);
+
+ this->reels->Start();
+
+ game->soundDevice->PlaySourceLooping(this->sndReels);
+ }
+
+ // Bet button - change the bet
+ if (this->btnBet->IsClicked())
+ {
+ this->bet = this->bet % 10 + 1;
+ }
+
+ // Lines button - set which lines in the winnings model are active
+ if (this->btnLines->IsClicked())
+ {
+ this->lines = this->lines % 5 + 1;
+
+ for (int lineIndex = 0; lineIndex < this->winningsModel->numLines; lineIndex++)
+ this->winningsModel->lines[lineIndex].active = lineIndex < this->lines;
+ }
+
+ }
+
+ // Stop the spinning reels when the button is pressed
+ if (this->reels->state == Spinning)
+ {
+ if (this->btnStart->IsClicked())
+ this->reels->Stop();
+ }
+
+ // When reels' state HAS JUST CHANGED to Idle, then show any winning lines, if any, and update combination winning and credits
+ if (this->reels->stateChange == Idle)
+ {
+ for (int winIndex = 0; winIndex < this->winningsAnalyzer->winnings.count; winIndex++)
+ this->lineAnimations[this->winningsAnalyzer->winnings.win[winIndex].lineIndex]->visible = true;
+
+ this->winning = this->winningsAnalyzer->totalWinning;
+ this->credits += this->winning;
+
+ game->soundDevice->PauseSource(this->sndReels);
+ }
+
+ // Sound on every reel stop
+ for (int reelIndex = 0; reelIndex < this->reels->numReels; reelIndex++)
+ if (this->reels->reels[reelIndex].stateChange == PostStopping)
+ game->soundDevice->PlaySource(this->sndReelStop);
+
+ GkGamePage::Process(game);
+}
\ No newline at end of file
diff --git a/COM380/Project5/GambleKit/CustomGameLogic/Pages/MainPage.h b/COM380/Project5/GambleKit/CustomGameLogic/Pages/MainPage.h
new file mode 100644
index 0000000..b22ed9b
--- /dev/null
+++ b/COM380/Project5/GambleKit/CustomGameLogic/Pages/MainPage.h
@@ -0,0 +1,37 @@
+#pragma once
+
+#include "..\CustomGame.h"
+
+class MainPage :
+ public GkGamePage
+{
+public:
+
+ static const int ReelItem_Cherry = 0,
+ ReelItem_Melon = 1,
+ ReelItem_Bell = 2,
+ ReelItem_7 = 3;
+
+
+ GkGameClickButton *btnStart, *btnBet, *btnLines;
+
+ GkGameText *textCredits, *textWinning, *textBet, *textLines;
+
+ GkGameAnimation *lineAnimations[5];
+
+ GkGameReels *reels;
+
+ GkGameReelsCombinationGenerator *combinationsGenerator;
+ GkGameWinningsModel *winningsModel;
+ GkGameWinningsAnalyzer *winningsAnalyzer;
+
+ int bet, lines, winning, credits;
+
+ GkSoundSource *sndReels, *sndReelStop;
+
+ MainPage(CustomGame *game);
+ ~MainPage(void);
+
+ void Process(GkGame *game);
+};
+
diff --git a/COM380/Project5/GambleKit/CustomGameLogic/main.cpp b/COM380/Project5/GambleKit/CustomGameLogic/main.cpp
new file mode 100644
index 0000000..5677363
--- /dev/null
+++ b/COM380/Project5/GambleKit/CustomGameLogic/main.cpp
@@ -0,0 +1,30 @@
+//#define _CRTDBG_MAP_ALLOC
+//#include
+//#include
+
+#include
+
+#include "MainWindow.h"
+
+int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmd, int show)
+{
+ //_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
+
+ GkMaths::Randomize();
+
+ //Dictionary::Initialize();
+ GkImage::Initialize();
+ GkGraphicsDevice::Initialize();
+ GkSoundDevice::Initialize();
+
+ MainWindow mainWindow;
+
+ GkWindowsForm::PerformFormLoop();
+
+ GkSoundDevice::Close();
+ //Dictionary::Close();
+
+ //_CrtDumpMemoryLeaks();
+
+ return 0;
+}
\ No newline at end of file
diff --git a/COM380/Project5/GambleKit/Engine/Base/GkBase.cpp b/COM380/Project5/GambleKit/Engine/Base/GkBase.cpp
new file mode 100644
index 0000000..99c156f
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Base/GkBase.cpp
@@ -0,0 +1,23 @@
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+// GambleKit Copyright (C) 2014 Ivan Donev
+//
+// This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// contact: gamblekit@gmail.com
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+#include "GkBase.h"
+
+
+GkBase::GkBase(void)
+{
+}
+
+
+GkBase::~GkBase(void)
+{
+}
diff --git a/COM380/Project5/GambleKit/Engine/Base/GkBase.h b/COM380/Project5/GambleKit/Engine/Base/GkBase.h
new file mode 100644
index 0000000..3926762
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Base/GkBase.h
@@ -0,0 +1,11 @@
+#pragma once
+
+#include "..\GkDefinitions.h"
+
+class GKDLLCLASS GkBase
+{
+public:
+ GkBase::GkBase(void);
+ virtual GkBase::~GkBase(void);
+};
+
diff --git a/COM380/Project5/GambleKit/Engine/Base/GkBaseReelMap.cpp b/COM380/Project5/GambleKit/Engine/Base/GkBaseReelMap.cpp
new file mode 100644
index 0000000..45a0017
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Base/GkBaseReelMap.cpp
@@ -0,0 +1,126 @@
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+// GambleKit Copyright (C) 2014 Ivan Donev
+//
+// This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// contact: gamblekit@gmail.com
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+#include "GkBaseReelMap.h"
+
+#include "..\OSSpecific\GkOSUtils.h"
+
+GkBaseReelMap::GkBaseReelMap(int numReels, int numReelItems)
+ : GkBase()
+{
+ this->numReels = numReels;
+ this->numReelItems = numReelItems;
+
+ this->reelMap = new int[this->numReels * this->numReelItems];
+ GkOSUtils::ZeroMem(this->reelMap, this->numReels * this->numReelItems * sizeof(int));
+}
+
+
+GkBaseReelMap::~GkBaseReelMap(void)
+{
+ delete[] reelMap;
+}
+
+void GkBaseReelMap::SetSymbol(int reelIndex, int itemIndex, int symbolIndex)
+{
+ this->reelMap[reelIndex * this->numReelItems + itemIndex] = symbolIndex;
+}
+
+int GkBaseReelMap::GetSymbol(int reelIndex, int itemIndex)
+{
+ return this->reelMap[reelIndex * this->numReelItems + itemIndex];
+}
+
+void GkBaseReelMap::SetItems(GkBaseReelMap *reelMap, int startReel, int startItem, int numReels, int numItems)
+{
+ int maxReel = startReel + numReels;
+ int maxItem = startItem + numItems;
+ for (int reelIndex = startReel; reelIndex < maxReel; reelIndex++)
+ {
+ for (int itemIndex = startItem; itemIndex < maxItem; itemIndex++)
+ {
+ this->SetSymbol(reelIndex, itemIndex, reelMap->GetSymbol(reelIndex, itemIndex));
+ }
+ }
+}
+
+void GkBaseReelMap::SetItems(GkBaseReelMap *reelMap)
+{
+ this->SetItems(reelMap, 0, 0, this->numReels, this->numReelItems);
+}
+
+void GkBaseReelMap::SetReelItems(GkBaseReelMap *reelMap, int reelIndex)
+{
+ this->SetItems(reelMap, reelIndex, 0, 1, this->numReelItems);
+}
+
+void GkBaseReelMap::SetItems(const int *reelMap)
+{
+ GkOSUtils::CopyMem(this->reelMap, (void*)reelMap, this->numReels * this->numReelItems * sizeof(int));
+}
+
+void GkBaseReelMap::WriteItems(const int *reelMap)
+{
+ GkOSUtils::CopyMem((void*)reelMap, this->reelMap, this->numReels * this->numReelItems * sizeof(int));
+}
+
+int GkBaseReelMap::CountItems(int reelIndex, int itemIndex)
+{
+ int result = 0;
+ for (int i = 0; i < this->numReelItems; i++)
+ if (this->GetSymbol(reelIndex, i) == itemIndex)
+ result++;
+
+ return result;
+}
+
+int GkBaseReelMap::CountItems(int itemIndex)
+{
+ int result = 0;
+ for (int i = 0; i < this->numReels; i++)
+ result += this->CountItems(i, itemIndex);
+
+ return result;
+}
+
+int GkBaseReelMap::FindFirstSymbol(int reelIndex, int symbolIndex)
+{
+ for (int i = 0; i < this->numReelItems; i++)
+ if (this->GetSymbol(reelIndex, i) == symbolIndex)
+ return i;
+
+ return -1;
+}
+
+bool GkBaseReelMap::ReelEquals(GkBaseReelMap *reelMap, int reelIndex)
+{
+ if (this->numReelItems != reelMap->numReelItems)
+ return false;
+
+ for (int itemIndex = 0; itemIndex < this->numReelItems; itemIndex++)
+ if (this->GetSymbol(reelIndex, itemIndex) != reelMap->GetSymbol(reelIndex, itemIndex))
+ return false;
+
+ return true;
+}
+
+bool GkBaseReelMap::ReelsEquals(GkBaseReelMap *reelMap)
+{
+ if (this->numReels != reelMap->numReels)
+ return false;
+
+ for (int reelIndex = 0; reelIndex < this->numReels; reelIndex++)
+ if (!this->ReelEquals(reelMap, reelIndex))
+ return false;
+
+ return true;
+}
diff --git a/COM380/Project5/GambleKit/Engine/Base/GkBaseReelMap.h b/COM380/Project5/GambleKit/Engine/Base/GkBaseReelMap.h
new file mode 100644
index 0000000..f1688fd
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Base/GkBaseReelMap.h
@@ -0,0 +1,31 @@
+#pragma once
+
+#include "..\GkDefinitions.h"
+
+#include "GkBase.h"
+
+class GKDLLCLASS GkBaseReelMap
+ : public GkBase
+{
+public:
+ int numReels, numReelItems;
+
+ int *reelMap;
+
+ GkBaseReelMap(int numReels, int numReelItems);
+ ~GkBaseReelMap(void);
+
+ virtual void SetSymbol(int reelIndex, int itemIndex, int symbolIndex);
+ virtual int GetSymbol(int reelIndex, int itemIndex);
+ void SetItems(GkBaseReelMap *reelMap, int startReel, int startItem, int numReels, int numItems);
+ void SetItems(GkBaseReelMap *reelMap);
+ void SetReelItems(GkBaseReelMap *reelMap, int reelIndex);
+ void SetItems(const int *reelMap);
+ void WriteItems(const int *reelMap);
+ int CountItems(int reelIndex, int itemIndex);
+ int CountItems(int itemIndex);
+ int FindFirstSymbol(int reelIndex, int symbolIndex);
+ bool ReelEquals(GkBaseReelMap *reelMap, int reelIndex);
+ bool ReelsEquals(GkBaseReelMap *reelMap);
+};
+
diff --git a/COM380/Project5/GambleKit/Engine/GambleKit.h b/COM380/Project5/GambleKit/Engine/GambleKit.h
new file mode 100644
index 0000000..e54a018
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/GambleKit.h
@@ -0,0 +1,57 @@
+#pragma once
+
+#include "Base\GkBase.h"
+#include "Base\GkBaseReelMap.h"
+
+#include "Game\GkGame.h"
+#include "Game\GkGameEntity.h"
+#include "Game\GkGamePage.h"
+#include "Game\GkGameReelModel.h"
+#include "Game\GkGameReelsCombinationGenerator.h"
+#include "Game\GkGameTimer.h"
+#include "Game\GkGameWinningPotentialsAnalyzer.h"
+#include "Game\GkGameWinningsAnalyzer.h"
+#include "Game\GkGameWinningsModel.h"
+
+#include "Game\Entities\GkGameAnimation.h"
+#include "Game\Entities\GkGameButton.h"
+#include "Game\Entities\GkGameReels.h"
+#include "Game\Entities\GkGameStreamingAnimation.h"
+#include "Game\Entities\GkGameText.h"
+#include "Game\Entities\GkGameWinningCounter.h"
+
+#include "Game\Entities\Bindings\GkGameAnimationsSoundBinding.h"
+#include "Game\Entities\Bindings\GkGameButtonsBinding.h"
+#include "Game\Entities\Bindings\GkGameButtonsSoundBinding.h"
+#include "Game\Entities\Bindings\GkGameTextsDateTimeBinding.h"
+#include "Game\Entities\Bindings\GkGameTextsFormatBinding.h"
+#include "Game\Entities\Bindings\GkGameTextsFormatIntBinding.h"
+#include "Game\Entities\Bindings\GkGameTextsIntBinding.h"
+
+#include "Game\Entities\Buttons\GkGameAnimationButton.h"
+#include "Game\Entities\Buttons\GkGameCheckButton.h"
+#include "Game\Entities\Buttons\GkGameClickButton.h"
+
+#include "Game\ReelModels\GkGameReelRandomModel.h"
+#include "Game\ReelModels\GkGameReelStripModel.h"
+
+#include "Graphics\GkAnimatedFont.h"
+#include "Graphics\GkAnimatedTexture.h"
+#include "Graphics\GkGraphicsDevice.h"
+#include "Graphics\GkImage.h"
+#include "Graphics\GkTexture.h"
+
+#include "OSSpecific\GkFileSystem.h"
+#include "OSSpecific\GkOpenGLWindowsForm.h"
+#include "OSSpecific\GkOSUtils.h"
+#include "OSSpecific\GkWindowsForm.h"
+#include "OSSpecific\GkWindowsMutex.h"
+#include "OSSpecific\GkWindowsThread.h"
+
+#include "Sound\GkSoundDevice.h"
+#include "Sound\GkSoundSource.h"
+
+#include "Utils\GkList.h"
+#include "Utils\GkLogFile.h"
+#include "Utils\GkMaths.h"
+#include "Utils\GkStrings.h"
\ No newline at end of file
diff --git a/COM380/Project5/GambleKit/Engine/Game/Entities/Bindings/GkGameAnimationsSoundBinding.cpp b/COM380/Project5/GambleKit/Engine/Game/Entities/Bindings/GkGameAnimationsSoundBinding.cpp
new file mode 100644
index 0000000..eae91df
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Game/Entities/Bindings/GkGameAnimationsSoundBinding.cpp
@@ -0,0 +1,65 @@
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+// GambleKit Copyright (C) 2014 Ivan Donev
+//
+// This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// contact: gamblekit@gmail.com
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+#include "GkGameAnimationsSoundBinding.h"
+
+
+GkGameAnimationsSoundBinding::GkGameAnimationsSoundBinding(GkSoundSource *soundSource, GkSoundDevice *soundDevice, bool looping, int numAnimations, ...)
+ : GkGameEntity()
+{
+ this->soundSource = soundSource;
+ this->soundDevice = soundDevice;
+ this->looping = looping;
+
+ this->numAnimations = numAnimations;
+ GkGameAnimation **parameters = (GkGameAnimation **)((int)&numAnimations + 4);
+ this->animations = new GkGameAnimationsSoundBindingAnimation[numAnimations];
+ for (int i = 0; i < numAnimations; i++)
+ {
+ this->animations[i].animation = parameters[i];
+ this->animations[i].played = false;
+ }
+}
+
+
+GkGameAnimationsSoundBinding::~GkGameAnimationsSoundBinding(void)
+{
+ delete[] this->animations;
+}
+
+void GkGameAnimationsSoundBinding::Process(GkGame *game)
+{
+ for (int i = 0; i < this->numAnimations; i++)
+ {
+ if (this->animations[i].animation->visible && this->animations[i].animation->active)
+ {
+ if (!this->animations[i].played)
+ {
+ if (this->looping)
+ this->soundDevice->PlaySourceLooping(this->soundSource);
+ else
+ this->soundDevice->PlaySource(this->soundSource);
+
+ this->animations[i].played = true;
+ }
+ }
+ else
+ {
+ if (this->looping)
+ {
+ this->soundDevice->PauseSource(this->soundSource);
+ }
+
+ this->animations[i].played = false;
+ }
+ }
+}
\ No newline at end of file
diff --git a/COM380/Project5/GambleKit/Engine/Game/Entities/Bindings/GkGameAnimationsSoundBinding.h b/COM380/Project5/GambleKit/Engine/Game/Entities/Bindings/GkGameAnimationsSoundBinding.h
new file mode 100644
index 0000000..a0d917e
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Game/Entities/Bindings/GkGameAnimationsSoundBinding.h
@@ -0,0 +1,31 @@
+#pragma once
+
+#include "..\..\..\GkDefinitions.h"
+
+#include "..\GkGameAnimation.h"
+#include "..\..\..\Sound\GkSoundDevice.h"
+
+struct GkGameAnimationsSoundBindingAnimation
+{
+ GkGameAnimation *animation;
+ bool played;
+};
+
+class GKDLLCLASS GkGameAnimationsSoundBinding :
+ public GkGameEntity
+{
+public:
+ GkSoundDevice *soundDevice;
+ GkSoundSource *soundSource;
+
+ int numAnimations;
+ GkGameAnimationsSoundBindingAnimation *animations;
+
+ bool looping;
+
+ GkGameAnimationsSoundBinding(GkSoundSource *soundSource, GkSoundDevice *soundDevice, bool looping, int numAnimations, ...);
+ ~GkGameAnimationsSoundBinding(void);
+
+ void Process(GkGame *game);
+};
+
diff --git a/COM380/Project5/GambleKit/Engine/Game/Entities/Bindings/GkGameButtonsBinding.cpp b/COM380/Project5/GambleKit/Engine/Game/Entities/Bindings/GkGameButtonsBinding.cpp
new file mode 100644
index 0000000..d558460
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Game/Entities/Bindings/GkGameButtonsBinding.cpp
@@ -0,0 +1,115 @@
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+// GambleKit Copyright (C) 2014 Ivan Donev
+//
+// This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// contact: gamblekit@gmail.com
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+#include "GkGameButtonsBinding.h"
+
+
+GkGameButtonsBinding::GkGameButtonsBinding(int numGameButtons, ...)
+{
+ GkGameButton **parameters = (GkGameButton **)((int)&numGameButtons + 4);
+ this->numGameButtons = numGameButtons;
+ this->gameButtons = new GkGameButton*[numGameButtons];
+ for (int i = 0; i < numGameButtons; i++)
+ this->gameButtons[i] = parameters[i];
+
+ this->enabled = true;
+
+ this->pushedValue = false;
+ this->clickedValue = false;
+}
+
+
+GkGameButtonsBinding::~GkGameButtonsBinding(void)
+{
+ delete this->gameButtons;
+}
+
+void GkGameButtonsBinding::SyncPush(int syncButtonIndex)
+{
+ GkGameButton *syncButton = this->gameButtons[syncButtonIndex];
+
+ for (int buttonIndex = 0; buttonIndex < this->numGameButtons; buttonIndex++)
+ {
+ if (buttonIndex != syncButtonIndex)
+ {
+ GkGameButton *button = this->gameButtons[buttonIndex];
+
+ if (button->IsActive())
+ {
+ if (button->pushed != syncButton->pushed)
+ {
+ if (syncButton->pushed)
+ button->Down();
+ else
+ button->Up(true);
+ }
+ }
+ }
+ }
+
+ this->pushedValue = syncButton->pushed;
+}
+
+void GkGameButtonsBinding::SyncClick(int syncButtonIndex)
+{
+ GkGameButton *syncButton = this->gameButtons[syncButtonIndex];
+
+ for (int buttonIndex = 0; buttonIndex < this->numGameButtons; buttonIndex++)
+ {
+ if (buttonIndex != syncButtonIndex)
+ {
+ GkGameButton *button = this->gameButtons[buttonIndex];
+
+ if (button->IsActive())
+ {
+ button->clicked = syncButton->clicked;
+ }
+ }
+ }
+
+ this->clickedValue = syncButton->clicked;
+}
+
+void GkGameButtonsBinding::Process(GkGame *game)
+{
+ if (!enabled)
+ return;
+
+ for (int buttonIndex = 0; buttonIndex < this->numGameButtons; buttonIndex++)
+ {
+ GkGameButton *button = this->gameButtons[buttonIndex];
+ if (button->IsActive())
+ {
+ if (button->pushed != this->pushedValue)
+ {
+ this->SyncPush(buttonIndex);
+ break;
+ }
+ }
+ }
+
+ for (int buttonIndex = 0; buttonIndex < this->numGameButtons; buttonIndex++)
+ {
+ GkGameButton *button = this->gameButtons[buttonIndex];
+ if (button->IsActive())
+ {
+ if (button->clicked != this->clickedValue)
+ {
+ // SyncClick is required beside SyncPush, because mouse events execute separately from the Process sequence and MouseUp usually sets a button pushed to false, which actually prevents SyncPush to execute mouse up (for it checks if the button is pushed)
+ this->SyncClick(buttonIndex);
+ break;
+ }
+ }
+ }
+
+
+}
\ No newline at end of file
diff --git a/COM380/Project5/GambleKit/Engine/Game/Entities/Bindings/GkGameButtonsBinding.h b/COM380/Project5/GambleKit/Engine/Game/Entities/Bindings/GkGameButtonsBinding.h
new file mode 100644
index 0000000..9b909fe
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Game/Entities/Bindings/GkGameButtonsBinding.h
@@ -0,0 +1,27 @@
+#pragma once
+
+#include "..\..\..\GkDefinitions.h"
+
+#include "..\..\GkGameEntity.h"
+#include "..\..\Entities\GkGameButton.h"
+
+class GKDLLCLASS GkGameButtonsBinding :
+ public GkGameEntity
+{
+public:
+ int numGameButtons;
+ GkGameButton **gameButtons;
+
+ bool enabled;
+
+ bool pushedValue, clickedValue;
+
+ GkGameButtonsBinding(int numGameButtons, ...);
+ ~GkGameButtonsBinding(void);
+
+ void SyncPush(int syncButtonIndex);
+ void SyncClick(int syncButtonIndex);
+
+ void Process(GkGame *game);
+};
+
diff --git a/COM380/Project5/GambleKit/Engine/Game/Entities/Bindings/GkGameButtonsSoundBinding.cpp b/COM380/Project5/GambleKit/Engine/Game/Entities/Bindings/GkGameButtonsSoundBinding.cpp
new file mode 100644
index 0000000..f1af4aa
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Game/Entities/Bindings/GkGameButtonsSoundBinding.cpp
@@ -0,0 +1,56 @@
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+// GambleKit Copyright (C) 2014 Ivan Donev
+//
+// This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// contact: gamblekit@gmail.com
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+#include "GkGameButtonsSoundBinding.h"
+
+
+GkGameButtonsSoundBinding::GkGameButtonsSoundBinding(GkSoundSource *soundSource, GkSoundDevice *soundDevice, int numButtons, ...)
+ : GkGameEntity()
+{
+ this->soundSource = soundSource;
+ this->soundDevice = soundDevice;
+
+ this->numButtons = numButtons;
+ GkGameButton **parameters = (GkGameButton **)((int)&numButtons + 4);
+ this->buttons = new GameButtonsSoundBindingButton[numButtons];
+ for (int i = 0; i < numButtons; i++)
+ {
+ this->buttons[i].button = parameters[i];
+ this->buttons[i].played = false;
+ }
+}
+
+
+GkGameButtonsSoundBinding::~GkGameButtonsSoundBinding(void)
+{
+ delete[] this->buttons;
+}
+
+void GkGameButtonsSoundBinding::Process(GkGame *game)
+{
+ for (int i = 0; i < this->numButtons; i++)
+ {
+ if (this->buttons[i].button->pushed)
+ {
+ if (!this->buttons[i].played)
+ {
+ this->soundDevice->PlaySource(this->soundSource);
+
+ this->buttons[i].played = true;
+ }
+ }
+ else
+ {
+ this->buttons[i].played = false;
+ }
+ }
+}
\ No newline at end of file
diff --git a/COM380/Project5/GambleKit/Engine/Game/Entities/Bindings/GkGameButtonsSoundBinding.h b/COM380/Project5/GambleKit/Engine/Game/Entities/Bindings/GkGameButtonsSoundBinding.h
new file mode 100644
index 0000000..3622a8b
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Game/Entities/Bindings/GkGameButtonsSoundBinding.h
@@ -0,0 +1,29 @@
+#pragma once
+
+#include "..\..\..\GkDefinitions.h"
+
+#include "..\GkGameButton.h"
+#include "..\..\..\Sound\GkSoundDevice.h"
+
+struct GameButtonsSoundBindingButton
+{
+ GkGameButton *button;
+ bool played;
+};
+
+class GKDLLCLASS GkGameButtonsSoundBinding :
+ public GkGameEntity
+{
+public:
+ GkSoundDevice *soundDevice;
+ GkSoundSource *soundSource;
+
+ int numButtons;
+ GameButtonsSoundBindingButton *buttons;
+
+ GkGameButtonsSoundBinding(GkSoundSource *soundSource, GkSoundDevice *soundDevice, int numButtons, ...);
+ ~GkGameButtonsSoundBinding(void);
+
+ void Process(GkGame *game);
+};
+
diff --git a/COM380/Project5/GambleKit/Engine/Game/Entities/Bindings/GkGameTextsDateTimeBinding.cpp b/COM380/Project5/GambleKit/Engine/Game/Entities/Bindings/GkGameTextsDateTimeBinding.cpp
new file mode 100644
index 0000000..c6696e4
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Game/Entities/Bindings/GkGameTextsDateTimeBinding.cpp
@@ -0,0 +1,42 @@
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+// GambleKit Copyright (C) 2014 Ivan Donev
+//
+// This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// contact: gamblekit@gmail.com
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+#include "GkGameTextsDateTimeBinding.h"
+
+#include "..\..\..\Utils\GkStrings.h"
+
+GkGameTextsDateTimeBinding::GkGameTextsDateTimeBinding(DateTime* valueAddress, const wchar_t *formatString, int numGameTexts, ...)
+ : GkGameEntity()
+{
+ this->valueAddress = valueAddress;
+ this->formatString = GkStrings::Copy(formatString);
+
+ this->numGameTexts = numGameTexts;
+
+ GkGameText **parameters = (GkGameText **)((int)&numGameTexts + 4);
+ this->gameTexts = new GkGameText*[this->numGameTexts];
+ for (int i = 0; i < this->numGameTexts; i++)
+ this->gameTexts[i] = parameters[i];
+}
+
+
+GkGameTextsDateTimeBinding::~GkGameTextsDateTimeBinding(void)
+{
+ delete[] this->formatString;
+ delete[] this->gameTexts;
+}
+
+void GkGameTextsDateTimeBinding::Process(GkGame *game)
+{
+ for (int i = 0; i < this->numGameTexts; i++)
+ this->gameTexts[i]->SetText(GkStrings::Format(this->formatString, GkStrings::IntToString(this->valueAddress->day, 10, 2).c_str(), GkStrings::IntToString(this->valueAddress->month, 10, 2).c_str(), GkStrings::IntToString(this->valueAddress->year, 10, 4).c_str(), GkStrings::IntToString(this->valueAddress->hour, 10, 2).c_str(), GkStrings::IntToString(this->valueAddress->minute, 10, 2).c_str(), GkStrings::IntToString(this->valueAddress->second, 10, 2).c_str()).c_str());
+}
diff --git a/COM380/Project5/GambleKit/Engine/Game/Entities/Bindings/GkGameTextsDateTimeBinding.h b/COM380/Project5/GambleKit/Engine/Game/Entities/Bindings/GkGameTextsDateTimeBinding.h
new file mode 100644
index 0000000..92b97ef
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Game/Entities/Bindings/GkGameTextsDateTimeBinding.h
@@ -0,0 +1,27 @@
+#pragma once
+
+#include "..\..\..\GkDefinitions.h"
+
+#include "..\..\GkGameEntity.h"
+
+#include "..\GkGameText.h"
+
+#include "..\..\..\OSSpecific\GkOSUtils.h"
+
+class GKDLLCLASS GkGameTextsDateTimeBinding :
+ public GkGameEntity
+{
+public:
+ DateTime * valueAddress;
+
+ int numGameTexts;
+ GkGameText **gameTexts;
+
+ wchar_t *formatString;
+
+ GkGameTextsDateTimeBinding(DateTime* valueAddress, const wchar_t *formatString, int numGameTexts, ...);
+ ~GkGameTextsDateTimeBinding(void);
+
+ void Process(GkGame *game);
+};
+
diff --git a/COM380/Project5/GambleKit/Engine/Game/Entities/Bindings/GkGameTextsFormatBinding.cpp b/COM380/Project5/GambleKit/Engine/Game/Entities/Bindings/GkGameTextsFormatBinding.cpp
new file mode 100644
index 0000000..dd91f21
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Game/Entities/Bindings/GkGameTextsFormatBinding.cpp
@@ -0,0 +1,23 @@
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+// GambleKit Copyright (C) 2014 Ivan Donev
+//
+// This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// contact: gamblekit@gmail.com
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+#include "GkGameTextsFormatBinding.h"
+
+
+GkGameTextsFormatBinding::GkGameTextsFormatBinding(void)
+{
+}
+
+
+GkGameTextsFormatBinding::~GkGameTextsFormatBinding(void)
+{
+}
diff --git a/COM380/Project5/GambleKit/Engine/Game/Entities/Bindings/GkGameTextsFormatBinding.h b/COM380/Project5/GambleKit/Engine/Game/Entities/Bindings/GkGameTextsFormatBinding.h
new file mode 100644
index 0000000..0913727
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Game/Entities/Bindings/GkGameTextsFormatBinding.h
@@ -0,0 +1,14 @@
+#pragma once
+
+#include "..\..\..\GkDefinitions.h"
+
+#include "..\..\GkGameEntity.h"
+
+class GKDLLCLASS GkGameTextsFormatBinding :
+ public GkGameEntity
+{
+public:
+ GkGameTextsFormatBinding(void);
+ ~GkGameTextsFormatBinding(void);
+};
+
diff --git a/COM380/Project5/GambleKit/Engine/Game/Entities/Bindings/GkGameTextsFormatIntBinding.cpp b/COM380/Project5/GambleKit/Engine/Game/Entities/Bindings/GkGameTextsFormatIntBinding.cpp
new file mode 100644
index 0000000..a2f271c
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Game/Entities/Bindings/GkGameTextsFormatIntBinding.cpp
@@ -0,0 +1,59 @@
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+// GambleKit Copyright (C) 2014 Ivan Donev
+//
+// This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// contact: gamblekit@gmail.com
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+#include "GkGameTextsFormatIntBinding.h"
+
+#include "..\..\..\Utils\GkStrings.h"
+
+
+GkGameTextsFormatIntBinding::GkGameTextsFormatIntBinding(const wchar_t *format, int numValues, int numGameTexts, ...)
+{
+ this->numValues = numValues;
+ this->numGameTexts = numGameTexts;
+ this->format = GkStrings::Copy(format);
+
+ int **valueAddressParams = (int**)((int)&numGameTexts + 4);
+ this->valueAddresses = new int*[this->numValues];
+ this->values = new wchar_t*[this->numValues];
+ for (int i = 0; i < this->numValues; i++)
+ this->valueAddresses[i] = valueAddressParams[i];
+
+ GkGameText **gameTextParams = (GkGameText **)((int)&valueAddressParams[this->numValues - 1] + 4);
+ this->gameTexts = new GkGameText*[this->numGameTexts];
+ for (int i = 0; i < this->numGameTexts; i++)
+ this->gameTexts[i] = gameTextParams[i];
+}
+
+
+GkGameTextsFormatIntBinding::~GkGameTextsFormatIntBinding(void)
+{
+ delete[] this->valueAddresses;
+ delete[] this->values;
+
+ delete[] this->gameTexts;
+
+ delete[] this->format;
+}
+
+void GkGameTextsFormatIntBinding::Process(GkGame *game)
+{
+ for (int i = 0; i < this->numValues; i++)
+ this->values[i] = GkStrings::Copy(GkStrings::IntToString(*this->valueAddresses[i]).c_str());
+
+ for (int gameTextIndex = 0; gameTextIndex < this->numGameTexts; gameTextIndex++)
+ {
+ this->gameTexts[gameTextIndex]->SetText(GkStrings::FormatArray(this->format, this->values).c_str());
+ }
+
+ for (int i = 0; i < this->numValues; i++)
+ delete[] this->values[i];
+}
diff --git a/COM380/Project5/GambleKit/Engine/Game/Entities/Bindings/GkGameTextsFormatIntBinding.h b/COM380/Project5/GambleKit/Engine/Game/Entities/Bindings/GkGameTextsFormatIntBinding.h
new file mode 100644
index 0000000..8b07ebc
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Game/Entities/Bindings/GkGameTextsFormatIntBinding.h
@@ -0,0 +1,28 @@
+#pragma once
+
+#include "..\..\..\GkDefinitions.h"
+
+#include "..\..\GkGameEntity.h"
+
+#include "..\GkGameText.h"
+
+
+class GKDLLCLASS GkGameTextsFormatIntBinding :
+ public GkGameEntity
+{
+public:
+ int numValues;
+ int **valueAddresses;
+ wchar_t **values;
+
+ int numGameTexts;
+ GkGameText **gameTexts;
+
+ wchar_t *format;
+
+ GkGameTextsFormatIntBinding(const wchar_t *format, int numValues, int numGameTexts, ...);
+ ~GkGameTextsFormatIntBinding(void);
+
+ void Process(GkGame *game);
+};
+
diff --git a/COM380/Project5/GambleKit/Engine/Game/Entities/Bindings/GkGameTextsIntBinding.cpp b/COM380/Project5/GambleKit/Engine/Game/Entities/Bindings/GkGameTextsIntBinding.cpp
new file mode 100644
index 0000000..bad939c
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Game/Entities/Bindings/GkGameTextsIntBinding.cpp
@@ -0,0 +1,40 @@
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+// GambleKit Copyright (C) 2014 Ivan Donev
+//
+// This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// contact: gamblekit@gmail.com
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+#include "GkGameTextsIntBinding.h"
+
+#include "..\..\..\Utils\GkStrings.h"
+
+GkGameTextsIntBinding::GkGameTextsIntBinding(int* valueAddress, int numGameTexts, ...)
+ : GkGameEntity()
+{
+ this->valueAddress = valueAddress;
+
+ this->numGameTexts = numGameTexts;
+
+ GkGameText **parameters = (GkGameText **)((int)&numGameTexts + 4);
+ this->gameTexts = new GkGameText*[this->numGameTexts];
+ for (int i = 0; i < this->numGameTexts; i++)
+ this->gameTexts[i] = parameters[i];
+}
+
+
+GkGameTextsIntBinding::~GkGameTextsIntBinding(void)
+{
+ delete[] this->gameTexts;
+}
+
+void GkGameTextsIntBinding::Process(GkGame *game)
+{
+ for (int i = 0; i < this->numGameTexts; i++)
+ this->gameTexts[i]->SetText(GkStrings::IntToString(*this->valueAddress).c_str());
+}
diff --git a/COM380/Project5/GambleKit/Engine/Game/Entities/Bindings/GkGameTextsIntBinding.h b/COM380/Project5/GambleKit/Engine/Game/Entities/Bindings/GkGameTextsIntBinding.h
new file mode 100644
index 0000000..19c3295
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Game/Entities/Bindings/GkGameTextsIntBinding.h
@@ -0,0 +1,23 @@
+#pragma once
+
+#include "..\..\..\GkDefinitions.h"
+
+#include "..\..\GkGameEntity.h"
+
+#include "..\GkGameText.h"
+
+class GKDLLCLASS GkGameTextsIntBinding :
+ public GkGameEntity
+{
+public:
+ int * valueAddress;
+
+ int numGameTexts;
+ GkGameText **gameTexts;
+
+ GkGameTextsIntBinding(int* valueAddress, int numGameTexts, ...);
+ ~GkGameTextsIntBinding(void);
+
+ void Process(GkGame *game);
+};
+
diff --git a/COM380/Project5/GambleKit/Engine/Game/Entities/Buttons/GkGameAnimationButton.cpp b/COM380/Project5/GambleKit/Engine/Game/Entities/Buttons/GkGameAnimationButton.cpp
new file mode 100644
index 0000000..78e5231
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Game/Entities/Buttons/GkGameAnimationButton.cpp
@@ -0,0 +1,95 @@
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+// GambleKit Copyright (C) 2014 Ivan Donev
+//
+// This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// contact: gamblekit@gmail.com
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+#include "GkGameAnimationButton.h"
+
+//#include "..\..\Utils\GkMaths.h"
+
+GkGameAnimationButton::GkGameAnimationButton(GkGameEntity *defaultFace, GkGameEntity *selectedFace, GkGameEntity *disabledFace, bool autoEnable, int x, int y, int width, int height)
+ : GkGameButton(defaultFace, selectedFace, disabledFace, autoEnable, x, y, width, height)
+{
+ GkGameAnimation *face = dynamic_cast(this->defaultFace);
+ if (face != 0)
+ face->EndAnimation();
+
+ face = dynamic_cast(this->selectedFace);
+ if (face != 0)
+ face->EndAnimation();
+
+ face = dynamic_cast(this->disabledFace);
+ if (face != 0)
+ face->EndAnimation();
+
+ this->lastFace = this->GetCurrentFace();
+}
+
+
+GkGameAnimationButton::~GkGameAnimationButton(void)
+{
+}
+
+void GkGameAnimationButton::Down()
+{
+ GkGameButton::Down();
+
+ //GkGameAnimation *currentFace = dynamic_cast(this->GetCurrentFace());
+ //if ((currentFace != 0) && (!currentFace->active))
+ //{
+ // currentFace->ResetAnimation();
+ //}
+}
+
+GkGameEntity* GkGameAnimationButton::GetCurrentFace()
+{
+ GkGameAnimation *face = this->GetAnimatingFace();
+ if (face != 0)
+ return face;
+
+ return GkGameButton::GetCurrentFace();
+}
+
+GkGameAnimation* GkGameAnimationButton::GetAnimatingFace()
+{
+ GkGameAnimation *face = dynamic_cast(this->defaultFace);
+ if ((face != 0) && (face->active) && (!face->loop))
+ return face;
+
+ face = dynamic_cast(this->selectedFace);
+ if ((face != 0) && (face->active) && (!face->loop))
+ return face;
+
+ face = dynamic_cast(this->disabledFace);
+ if ((face != 0) && (face->active) && (!face->loop))
+ return face;
+
+ return 0;
+}
+
+void GkGameAnimationButton::Process(GkGame *game)
+{
+ GkGameEntity *currentFace = this->GetCurrentFace();
+
+ if (currentFace != this->lastFace)
+ {
+ GkGameAnimation *lastAnimation = dynamic_cast(this->lastFace);
+ if (lastAnimation != 0)
+ lastAnimation->EndAnimation();
+
+ GkGameAnimation *currentAnimation = dynamic_cast(currentFace);
+ if (currentAnimation != 0)
+ currentAnimation->ResetAnimation();
+
+ this->lastFace = currentFace;
+ }
+
+ GkGameButton::Process(game);
+}
diff --git a/COM380/Project5/GambleKit/Engine/Game/Entities/Buttons/GkGameAnimationButton.h b/COM380/Project5/GambleKit/Engine/Game/Entities/Buttons/GkGameAnimationButton.h
new file mode 100644
index 0000000..5f3e60a
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Game/Entities/Buttons/GkGameAnimationButton.h
@@ -0,0 +1,23 @@
+#pragma once
+
+#include "..\..\..\GkDefinitions.h"
+
+#include "..\GkGameButton.h"
+#include "..\GkGameAnimation.h"
+
+class GKDLLCLASS GkGameAnimationButton :
+ public GkGameButton
+{
+public:
+ GkGameAnimationButton(GkGameEntity *defaultFace, GkGameEntity *selectedFace = 0, GkGameEntity *disabledFace = 0, bool autoEnable = true, int x = 0, int y = 0, int width = 0, int heght = 0);
+ ~GkGameAnimationButton(void);
+
+ GkGameAnimation* GetAnimatingFace();
+ GkGameEntity *lastFace;
+
+ virtual void Down();
+ virtual GkGameEntity* GetCurrentFace();
+
+ void Process(GkGame *game);
+};
+
diff --git a/COM380/Project5/GambleKit/Engine/Game/Entities/Buttons/GkGameCheckButton.cpp b/COM380/Project5/GambleKit/Engine/Game/Entities/Buttons/GkGameCheckButton.cpp
new file mode 100644
index 0000000..7cd6140
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Game/Entities/Buttons/GkGameCheckButton.cpp
@@ -0,0 +1,52 @@
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+// GambleKit Copyright (C) 2014 Ivan Donev
+//
+// This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// contact: gamblekit@gmail.com
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+#include "GkGameCheckButton.h"
+
+GkGameCheckButton::GkGameCheckButton(GkGameEntity *defaultFace, GkGameEntity *selectedFace, GkGameEntity *disabledFace, bool autoEnable, int x, int y, int width, int heght)
+ : GkGameAnimationButton(defaultFace, selectedFace, disabledFace, autoEnable, x, y, width, heght)
+{
+ this->checked = false;
+}
+
+void GkGameCheckButton::Down()
+{
+ GkGameAnimationButton::Down();
+
+ if (!this->IsActive())
+ return;
+
+ this->checked = !this->checked;
+}
+
+GkGameEntity* GkGameCheckButton::GetCurrentFace()
+{
+ GkGameAnimation *face = this->GetAnimatingFace();
+ if (face != 0)
+ return face;
+
+ //if (this->enabled)
+ //{
+ if (this->checked)
+ {
+ return this->selectedFace != 0 ? this->selectedFace : this->defaultFace;
+ }
+ else
+ {
+ return this->defaultFace;
+ }
+ //}
+ //else
+ //{
+ // return this->disabledFace != 0 ? this->disabledFace : this->defaultFace;
+ //}
+}
diff --git a/COM380/Project5/GambleKit/Engine/Game/Entities/Buttons/GkGameCheckButton.h b/COM380/Project5/GambleKit/Engine/Game/Entities/Buttons/GkGameCheckButton.h
new file mode 100644
index 0000000..a74fdfd
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Game/Entities/Buttons/GkGameCheckButton.h
@@ -0,0 +1,20 @@
+#pragma once
+
+#include "..\..\..\GkDefinitions.h"
+
+#include "GkGameAnimationButton.h"
+
+class GKDLLCLASS GkGameCheckButton :
+ public GkGameAnimationButton
+{
+public:
+ bool checked;
+
+ GkGameCheckButton::GkGameCheckButton(GkGameEntity *defaultFace, GkGameEntity *selectedFace = 0, GkGameEntity *disabledFace = 0, bool autoEnable = true, int x = 0, int y = 0, int width = 0, int heght = 0);
+
+ void GkGameCheckButton::Down();
+ GkGameEntity* GkGameCheckButton::GetCurrentFace();
+
+ void GkGameCheckButton::SynchWith(GkGameCheckButton *button);
+};
+
diff --git a/COM380/Project5/GambleKit/Engine/Game/Entities/Buttons/GkGameClickButton.cpp b/COM380/Project5/GambleKit/Engine/Game/Entities/Buttons/GkGameClickButton.cpp
new file mode 100644
index 0000000..9fe8969
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Game/Entities/Buttons/GkGameClickButton.cpp
@@ -0,0 +1,22 @@
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+// GambleKit Copyright (C) 2014 Ivan Donev
+//
+// This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// contact: gamblekit@gmail.com
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+#include "GkGameClickButton.h"
+
+GkGameClickButton::GkGameClickButton(GkGameEntity *defaultFace, GkGameEntity *selectedFace, GkGameEntity *disabledFace, bool autoEnable, int x, int y, int width, int height)
+ : GkGameAnimationButton(defaultFace, selectedFace, disabledFace, autoEnable, x, y, width, height)
+{
+}
+
+GkGameClickButton::~GkGameClickButton()
+{
+}
\ No newline at end of file
diff --git a/COM380/Project5/GambleKit/Engine/Game/Entities/Buttons/GkGameClickButton.h b/COM380/Project5/GambleKit/Engine/Game/Entities/Buttons/GkGameClickButton.h
new file mode 100644
index 0000000..d3d5208
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Game/Entities/Buttons/GkGameClickButton.h
@@ -0,0 +1,15 @@
+#pragma once
+
+#include "..\..\..\GkDefinitions.h"
+
+#include "GkGameAnimationButton.h"
+
+
+class GKDLLCLASS GkGameClickButton :
+ public GkGameAnimationButton
+{
+public:
+ GkGameClickButton(GkGameEntity *defaultFace, GkGameEntity *selectedFace = 0, GkGameEntity *disabledFace = 0, bool autoEnable = true, int x = 0, int y = 0, int width = 0, int height = 0);
+ ~GkGameClickButton();
+};
+
diff --git a/COM380/Project5/GambleKit/Engine/Game/Entities/GkGameAnimation.cpp b/COM380/Project5/GambleKit/Engine/Game/Entities/GkGameAnimation.cpp
new file mode 100644
index 0000000..f7e29e6
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Game/Entities/GkGameAnimation.cpp
@@ -0,0 +1,125 @@
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+// GambleKit Copyright (C) 2014 Ivan Donev
+//
+// This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// contact: gamblekit@gmail.com
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+#include "GkGameAnimation.h"
+
+#include "..\..\Graphics\GkImage.h"
+
+#include "..\GkGame.h"
+
+GkGameAnimation::GkGameAnimation(GkAnimatedTexture *animatedTexture, int x, int y, bool active, bool loop, bool visible, bool flipX, bool flipY, float framesPerSecond, int width, int height)
+{
+ this->SetAnimatedTexture(animatedTexture, framesPerSecond);
+ this->x = x;
+ this->y = y;
+ this->width = width;
+ this->height = height;
+ this->framesPerSecond = framesPerSecond != 0.0f ? framesPerSecond : animatedTexture != 0 ? animatedTexture->framesPerSecond : 0.0f;
+ this->active = active && (animatedTexture != NULL);
+ this->loop = loop && (animatedTexture != NULL);
+ this->visible = visible && (animatedTexture != NULL);
+ this->flipX = flipX;
+ this->flipY = flipY;
+}
+
+GkGameAnimation::~GkGameAnimation(void)
+{
+}
+
+void GkGameAnimation::SetAnimatedTexture(GkAnimatedTexture *animatedTexture, float framesPerSecond)
+{
+ this->animatedTexture = animatedTexture;
+ this->framesPerSecond = framesPerSecond != 0.0f ? framesPerSecond : animatedTexture != 0 ? animatedTexture->framesPerSecond : 0.0f;
+ this->ResetAnimation(this->active);
+}
+
+void GkGameAnimation::Process(GkGame *game)
+{
+ if (!(this->active && this->visible))
+ return;
+
+ if (this->flipX)
+ this->flipX = true;
+
+ this->currentFrame += this->framesPerSecond * game->timer->tickTime;
+
+ if (this->currentFrame > this->animatedTexture->numFrames)
+ {
+ if (this->loop)
+ {
+ int intFrame = (int)this->currentFrame;
+ float fracFrame = this->currentFrame - intFrame;
+ this->currentFrame = intFrame % this->animatedTexture->numFrames + fracFrame;
+ }
+ else
+ {
+ this->EndAnimation();
+ }
+ }
+
+ if (this->currentFrame < 0)
+ {
+ if (this->loop)
+ {
+ int intFrame = (int)this->currentFrame;
+ float fracFrame = this->currentFrame - intFrame;
+ this->currentFrame = (this->animatedTexture->numFrames - 1 - intFrame) % this->animatedTexture->numFrames + fracFrame;
+ }
+ else
+ {
+ this->EndAnimation();
+ }
+ }
+}
+
+void GkGameAnimation::Draw(GkGame *game)
+{
+ if (!this->visible)
+ return;
+
+ GkTexture *frame = this->animatedTexture->frames[(int)this->currentFrame];
+ int width = this->width != 0 ? this->width : frame->width;
+ int height = this->height != 0 ? this->height : frame->height;
+ if (this->flipX)
+ if (this->flipY)
+ game->graphicsDevice->Draw(this->x + width, this->y + height, -width, -height, 0, 0, frame->width,frame->height, frame);
+ else
+ game->graphicsDevice->Draw(this->x + width, this->y, -width, height, 0, 0, frame->width, frame->height, frame);
+ else
+ if (this->flipY)
+ game->graphicsDevice->Draw(this->x, this->y + height, width, -height, 0, 0, frame->width, frame->height, frame);
+ else
+ game->graphicsDevice->Draw(this->x, this->y, width, height, 0, 0, frame->width, frame->height, frame);
+}
+
+bool GkGameAnimation::GetBoundaries(int *x1, int *y1, int *x2, int*y2)
+{
+ *x1 = this->x;
+ *y1 = this->y;
+ *x2 = this->x + this->animatedTexture->frames[0]->width;
+ *y2 = this->y + this->animatedTexture->frames[0]->height;
+
+ return true;
+}
+
+
+void GkGameAnimation::ResetAnimation(bool start)
+{
+ this->currentFrame = this->framesPerSecond < 0 ? this->animatedTexture != 0 ? (float)(this->animatedTexture->numFrames - 1) : 0.0f : 0.0f;
+ this->active = start;
+}
+
+void GkGameAnimation::EndAnimation()
+{
+ this->currentFrame = this->framesPerSecond < 0 ? 0.0f : this->animatedTexture != 0 ? (float)(this->animatedTexture->numFrames - 1) : 0.0f;
+ this->active = false;
+}
diff --git a/COM380/Project5/GambleKit/Engine/Game/Entities/GkGameAnimation.h b/COM380/Project5/GambleKit/Engine/Game/Entities/GkGameAnimation.h
new file mode 100644
index 0000000..b31ac65
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Game/Entities/GkGameAnimation.h
@@ -0,0 +1,31 @@
+#pragma once
+
+#include "..\..\GkDefinitions.h"
+
+#include "..\GkGameEntity.h"
+#include "..\..\Graphics\GkAnimatedTexture.h"
+
+class GKDLLCLASS GkGameAnimation :
+ public GkGameEntity
+{
+public:
+ GkAnimatedTexture *animatedTexture;
+
+ int x, y, width, height;
+ bool visible, active, loop;
+ float framesPerSecond, currentFrame;
+
+ bool flipX, flipY;
+
+
+ GkGameAnimation::GkGameAnimation(GkAnimatedTexture *animatedTexture = 0, int x = 0, int y = 0, bool active = true, bool loop = true, bool visible = true, bool flipX = false, bool flipY = false, float framesPerSecond = 0.0f, int width = 0, int height = 0);
+ GkGameAnimation::~GkGameAnimation(void);
+
+ void GkGameAnimation::SetAnimatedTexture(GkAnimatedTexture *animatedTexture = 0, float framesPerSecond = 0.0f);
+ virtual void GkGameAnimation::Process(GkGame *game);
+ virtual void GkGameAnimation::Draw(GkGame *game);
+ bool GkGameAnimation::GetBoundaries(int *x1, int *y1, int *x2, int*y2);
+ void ResetAnimation(bool start = true);
+ void EndAnimation();
+};
+
diff --git a/COM380/Project5/GambleKit/Engine/Game/Entities/GkGameButton.cpp b/COM380/Project5/GambleKit/Engine/Game/Entities/GkGameButton.cpp
new file mode 100644
index 0000000..50abcb8
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Game/Entities/GkGameButton.cpp
@@ -0,0 +1,176 @@
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+// GambleKit Copyright (C) 2014 Ivan Donev
+//
+// This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// contact: gamblekit@gmail.com
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+#include "GkGameButton.h"
+
+GkGameButton::GkGameButton(GkGameEntity *defaultFace, GkGameEntity *selectedFace, GkGameEntity *disabledFace, bool autoEnable, int x, int y, int width, int height)
+ : GkGameEntity()
+{
+ this->defaultFace = defaultFace;
+ this->selectedFace = selectedFace;
+ this->disabledFace = disabledFace;
+
+ this->x = x;
+ this->y = y;
+
+ if ((width == 0) && (height == 0))
+ {
+ if (defaultFace != 0)
+ {
+ int x1, y1, x2, y2;
+ if (defaultFace->GetBoundaries(&x1, &y1, &x2, &y2))
+ {
+ this->width = x2 - x1;
+ this->height = y2 - y1;
+ }
+ }
+ }
+ else
+ {
+ this->width = width;
+ this->height = height;
+ }
+
+ this->visible = true;
+ this->clicked = false;
+ this->down = false;
+ this->enabled = true;
+ this->autoEnable = autoEnable;
+ this->pushed = false;
+}
+
+
+GkGameButton::~GkGameButton(void)
+{
+ if (this->defaultFace != 0)
+ delete this->defaultFace;
+
+ if (this->selectedFace != 0)
+ delete this->selectedFace;
+
+ if (this->disabledFace != 0)
+ delete this->disabledFace;
+}
+
+
+void GkGameButton::Down()
+{
+ if (!this->IsActive())
+ return;
+
+ this->pushed = true;
+ this->down = true;
+}
+
+void GkGameButton::Up(bool click)
+{
+ if (!this->IsActive())
+ return;
+
+ this->pushed = false;
+ this->clicked = click;
+}
+
+void GkGameButton::MouseDown(int x, int y)
+{
+ if (this->IsMouseOver(x, y))
+ this->Down();
+}
+
+void GkGameButton::MouseUp(int x, int y)
+{
+ this->Up(this->pushed && this->IsMouseOver(x, y));
+}
+
+bool GkGameButton::WasDown()
+{
+ bool result = this->down;
+
+ this->clicked = false;
+ this->down = false;
+ this->read = true;
+
+ return result;
+}
+
+bool GkGameButton::IsClicked()
+{
+ bool result = this->clicked;
+
+ this->clicked = false;
+ this->down = false;
+ this->read = true;
+
+ return result;
+}
+
+bool GkGameButton::IsActive()
+{
+ return this->enabled && this->visible;
+}
+
+GkGameEntity* GkGameButton::GetCurrentFace()
+{
+ if (this->enabled)
+ {
+ if (this->pushed)
+ return this->selectedFace != 0 ? this->selectedFace : this->defaultFace;
+ else
+ return this->defaultFace;
+ }
+ else
+ {
+ return this->disabledFace != 0 ? this->disabledFace : this->defaultFace;
+ }
+}
+
+bool GkGameButton::IsMouseOver(int x, int y)
+{
+ if (this->defaultFace != 0)
+ {
+ // if a defaultFace is given, check a region, relative to it
+ int x1, y1, x2, y2;
+ if (defaultFace->GetBoundaries(&x1, &y1, &x2, &y2))
+ return (x > x1 + this->x) && (x < x1 + this->x + this->width) && (y > y1 + this->y) && (y < y1 + this->y + this->height);
+ }
+ else
+ {
+ // if defaultFace is not given, i.e. the button has no visible part, check its region without relation
+ return (x > this->x) && (x < this->x + this->width) && (y > this->y) && (y < this->y + this->height);
+ }
+
+ return false;
+}
+
+void GkGameButton::Process(GkGame *game)
+{
+ if (this->autoEnable)
+ {
+ this->enabled = this->read;
+ this->read = false;
+ }
+
+ GkGameEntity *face = this->GetCurrentFace();
+ if (face != 0)
+ face->Process(game);
+}
+
+void GkGameButton::Draw(GkGame *game)
+{
+ if (!visible)
+ return;
+
+ GkGameEntity *currentFace = this->GetCurrentFace();
+
+ if (currentFace != 0)
+ currentFace->Draw(game);
+}
diff --git a/COM380/Project5/GambleKit/Engine/Game/Entities/GkGameButton.h b/COM380/Project5/GambleKit/Engine/Game/Entities/GkGameButton.h
new file mode 100644
index 0000000..6d9ed06
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Game/Entities/GkGameButton.h
@@ -0,0 +1,33 @@
+#pragma once
+
+#include "..\..\GkDefinitions.h"
+
+#include "..\GkGameEntity.h"
+
+class GKDLLCLASS GkGameButton :
+ public GkGameEntity
+{
+public:
+ GkGameEntity *defaultFace, *selectedFace, *disabledFace;
+ int x, y, width, height;
+
+ bool visible, enabled, autoEnable, pushed;
+ bool clicked, down, read;
+
+ GkGameButton::GkGameButton(GkGameEntity *defaultFace, GkGameEntity *selectedFace = 0, GkGameEntity *disabledFace = 0, bool autoEnable = true, int x = 0, int y = 0, int width = 0, int heght = 0);
+ virtual GkGameButton::~GkGameButton(void);
+
+ virtual void GkGameButton::Down();
+ virtual void GkGameButton::Up(bool click);
+ virtual void GkGameButton::MouseDown(int x, int y);
+ virtual void GkGameButton::MouseUp(int x, int y);
+ virtual GkGameEntity* GkGameButton::GetCurrentFace();
+
+ bool GkGameButton::WasDown();
+ bool GkGameButton::IsClicked();
+ bool GkGameButton::IsActive();
+ bool GkGameButton::IsMouseOver(int x, int y);
+ void GkGameButton::Process(GkGame *game);
+ void GkGameButton::Draw(GkGame *game);
+};
+
diff --git a/COM380/Project5/GambleKit/Engine/Game/Entities/GkGameReels.cpp b/COM380/Project5/GambleKit/Engine/Game/Entities/GkGameReels.cpp
new file mode 100644
index 0000000..38a1df6
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Game/Entities/GkGameReels.cpp
@@ -0,0 +1,516 @@
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+// GambleKit Copyright (C) 2014 Ivan Donev
+//
+// This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// contact: gamblekit@gmail.com
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+//#include
+
+// Consider reels options:
+// 1. GkGameReel is a class, a fully visual GkGameEntity
+// GkGameReels is a collection of GkGameReel objects and manager for lines, winnings, sequential starting/stopping a reel, etc.
+// Pros. GkGameReels is lighest, GkGameReel is a fully useful GkGameEntity
+// Cons. Many settings, such as the "items" collection of AnimatedTextures, the "reelMap" and etc. must reoccur in all GkGameReel objects and the GkGameReels object, Changing a setting in GkGameReels will not "automatically" take effect until it is changed in all GkGameReel objects also
+// 2. GkGameReel is a class, and is abstract in a sense that it provides only the mechanics of a reel via a spinning position
+// GkGameReels is a collection of GkGameReel objects and aside from all the other things, also does the drawing of the reels
+// Pros. GkGameReels is relatively light, GkGameReel functionality is separated in its own class
+// Cons. GkGameReel is not useful unless used with GkGameReels. GkGameReels holds relatively little (maybe close to irrelevant for a whole class) logic and value
+// 3. GkGameReels has each reel internal and has methods processing a reel. All the logic is inside that class.
+// Pros. No GkGameReel class, no need for different objects to share or have the same information (for settings)
+// Cons. GkGameReels is more heavily loaded with code logic. Does not quite correspond to the architecture model so far.
+
+#include "GkGameReels.h"
+
+#include "..\..\OSSpecific\GkOSUtils.h"
+#include "..\..\Utils\GkMaths.h"
+
+#include "..\GkGame.h"
+#include "..\..\Utils\GkMaths.h"
+
+
+GkGameReels::GkGameReels(int numReels, int numReelItems, int numSymbols, int width, int height)
+ : GkBaseReelMap(numReels, numReelItems)
+{
+ this->width = width;
+ this->height = height;
+ this->numSymbols = numSymbols;
+ this->state = Idle;
+ this->stateOld = Idle;
+ this->stateChange = Undefined;
+
+ this->numReelAnimations = this->numReelItems + 2;
+
+ this->reels = new GkGameReelInfo[numReels];
+ for (int i = 0; i < numReels; i++)
+ {
+ this->reels[i].state = Idle;
+ this->reels[i].stateOld = Idle;
+ this->reels[i].stateChange = Undefined;
+ this->reels[i].position = 0.0f;
+
+ this->reels[i].animations = new GkGameAnimation*[this->numReelAnimations];
+
+ for (int itemIndex = 0; itemIndex < this->numReelAnimations; itemIndex++)
+ {
+ this->reels[i].animations[itemIndex] = new GkGameAnimation();
+ this->reels[i].animations[itemIndex]->visible = true;
+ this->reels[i].animations[itemIndex]->active = false;
+ this->reels[i].animations[itemIndex]->loop = false;
+ }
+ }
+
+ this->symbols = new GkAnimatedTexture*[numSymbols];
+
+ this->speed = 20.0f;
+ this->acceleration = 40.0f;
+ this->stoppingTime = 1.0f;
+
+ this->preStartOffset = 0.15f;
+ this->preStartSpeed = 2.0f;
+ this->postStopOffset = 0.15f;
+ this->postStopSpeed = 2.0f;
+
+ this->itemGenerator = 0;
+}
+
+
+GkGameReels::~GkGameReels(void)
+{
+ for (int i = 0; i < numReels; i++)
+ {
+ for (int j = 0; j < this->numReelAnimations; j++)
+ {
+ delete[] this->reels[i].animations[j];
+ }
+
+ delete[] this->reels[i].animations;
+ }
+
+ delete[] this->symbols;
+ delete[] this->reels;
+}
+
+void GkGameReels::SetItemGenerator(GkGameReelsCombinationGenerator *itemGenerator)
+{
+ this->itemGenerator = itemGenerator;
+}
+
+GkAnimatedTexture *GkGameReels::Reel_GetNewSymbol(int reelIndex)
+{
+ if (this->itemGenerator != 0)
+ {
+ return this->symbols[this->itemGenerator->reels[reelIndex].model->GetSymbol()];
+ }
+ else
+ return this->symbols[GkMaths::Random(this->numSymbols)];
+}
+
+void GkGameReels::Reel_ProcessPosition(int reelIndex, GkGame *game)
+{
+ GkGameReelInfo *reel = &this->reels[reelIndex];
+
+ // Handle position ranging and shifting of symbols when position hops over 1.0
+ reel->position += game->timer->tickTime * reel->speed;
+ if (reel->position >= 1.0f)
+ {
+ int numShifts = (int)reel->position;
+
+ reel->position -= numShifts;
+
+ int reelShifts = GkMaths::Min(numShifts, this->numReelItems - reel->reelMapSetIndex + 1);
+
+ for (int shiftIndex = 0; shiftIndex < reelShifts; shiftIndex++)
+ {
+ GkGameAnimation *rotAnimation = reel->animations[this->numReelAnimations - 1];
+ for (int i = 0; i < this->numReelAnimations; i++)
+ {
+ GkGameAnimation *t = reel->animations[i];
+ reel->animations[i] = rotAnimation;
+ rotAnimation = t;
+ }
+
+ if (reel->state == Stopping)
+ {
+ if (reel->reelMapSetIndex < this->numReelItems)
+ reel->animations[0]->SetAnimatedTexture(this->symbols[this->GetSymbol(reelIndex, this->numReelItems - 1 - reel->reelMapSetIndex)]);
+ else
+ {
+ reel->animations[0]->SetAnimatedTexture(this->Reel_GetNewSymbol(reelIndex));
+ }
+
+ reel->reelMapSetIndex++;
+ }
+ else
+ {
+ reel->animations[0]->SetAnimatedTexture(this->Reel_GetNewSymbol(reelIndex));
+ }
+ }
+ }
+
+ for (int i = 0; i < this->numReelAnimations; i++)
+ {
+ reel->animations[i]->Process(game);
+ }
+}
+
+void GkGameReels::Reel_ProcessState(int reelIndex, GkGameTimer *timer)
+{
+ GkGameReelInfo *reel = &this->reels[reelIndex];
+
+ switch (reel->state)
+ {
+ case Idle:
+ {
+ reel->speed = 0.0f;
+ reel->position = 0.0f;
+
+ // User interaction expected
+ break;
+ }
+
+ case PreStarting:
+ {
+ reel->speed = 0.0f;
+ reel->position -= timer->tickTime * this->preStartSpeed;
+
+ if (reel->position < -this->preStartOffset)
+ {
+ reel->position = -this->preStartOffset;
+ reel->state = Starting;
+ }
+ break;
+ }
+
+ case Starting:
+ {
+ reel->speed += this->acceleration * timer->tickTime;
+
+ if (reel->speed >= this->speed)
+ {
+ reel->speed = this->speed;
+ reel->state = Spinning;
+ }
+ break;
+ }
+
+ case Spinning:
+ {
+ // User interaction expected
+ break;
+ }
+
+ case Stopping:
+ {
+ if ((reel->reelMapSetIndex > this->numReelItems) && (reel->position >= this->postStopOffset))
+ {
+ reel->position = this->postStopOffset;
+
+ reel->state = PostStopping;
+ }
+ break;
+ }
+
+ case PostStopping:
+ {
+ reel->speed = 0.0f;
+ reel->position -= timer->tickTime * this->postStopSpeed;
+
+ if (reel->position < 0.0f)
+ {
+ reel->position = 0.0f;
+ reel->state = Idle;
+ }
+ break;
+ }
+ }
+
+ reel->stateChange = reel->state != reel->stateOld ? reel->state : Undefined;
+ reel->stateOld = reel->state;
+}
+
+bool GkGameReels::Reel_Start(int reelIndex)
+{
+ GkGameReelInfo *reel = &this->reels[reelIndex];
+
+ if (reel->state == Idle)
+ {
+ reel->state = PreStarting;
+ reel->reelMapSetIndex = 0;
+ return true;
+ }
+
+ return false;
+}
+
+bool GkGameReels::Reel_Stop(int reelIndex)
+{
+ GkGameReelInfo *reel = &this->reels[reelIndex];
+
+ if (reel->state == Spinning)
+ {
+ reel->state = Stopping;
+ reel->reelMapSetIndex = 0;
+ return true;
+ }
+
+ return false;
+}
+
+// Gives a summary state. If all reels have the same state, returns that state, otherwise returns Undefined. If a reel has a Blocked state, it's ignored, unless all reels have Blocked state, in which case Blocked is returned.
+GameReelState GkGameReels::GetGeneralState()
+{
+ GameReelState result = Undefined;
+
+ int reelIndex = 0;
+ while (reelIndex < this->numReels)
+ {
+ GameReelState reelState = this->reels[reelIndex].state;
+
+ if (result == Undefined)
+ {
+ result = reelState;
+ }
+ else if (result == Blocked)
+ {
+ if (reelState != Blocked)
+ {
+ result = reelState;
+ }
+ }
+ else
+ {
+ if ((result != reelState) && (reelState != Blocked))
+ {
+ return Undefined;
+ }
+ }
+
+ reelIndex++;
+ }
+
+ return result;
+}
+
+void GkGameReels::ProcessState(GkGameTimer *timer)
+{
+ GameReelState generalState = this->GetGeneralState();
+
+ // Ensure each state is followed by the next for at least one frame
+ switch (this->state)
+ {
+ case Idle:
+ {
+ if ((this->state != generalState) && (generalState != Undefined))
+ this->state = PreStarting;
+
+ break;
+ }
+
+ case PreStarting:
+ {
+ if ((this->state != generalState) && (generalState != Undefined))
+ this->state = Starting;
+
+ break;
+ }
+
+ case Starting:
+ {
+ if ((this->state != generalState) && (generalState != Undefined))
+ this->state = Spinning;
+
+ break;
+ }
+
+ case Spinning:
+ {
+ if ((this->state != generalState) && (generalState != Undefined))
+ this->state = Stopping;
+
+ break;
+ }
+
+ case Stopping:
+ {
+ float fullStopTime = GkMaths::Max(this->stoppingTime - this->numReelItems / this->speed - this->postStopOffset / this->postStopSpeed, 0.0f);
+ float timeSinceStopInitiated = GkGameTimer::GetSampleTime(this->stopInitiatedTime);
+ int reelsStopped = fullStopTime != 0 ? GkMaths::Min((int)(1 + (this->numReels - 1) * timeSinceStopInitiated / fullStopTime), this->numReels) : this->numReels;
+
+ int stopCount = 0;
+ for (int i = 0; i < this->numReels; i++)
+ {
+ this->Reel_Stop(i);
+
+ if ((this->reels[i].state != Blocked) && (this->reels[i].state != Spinning))
+ stopCount++;
+
+ if (stopCount >= reelsStopped)
+ break;
+ }
+
+ if (reelsStopped == this->numReels)
+ this->state = PostStopping;
+
+ break;
+ }
+
+ case PostStopping:
+ {
+ if ((generalState == Idle) | (generalState == Blocked))
+ this->state = Idle;
+ //if ((this->state != generalState) && (generalState != Undefined))
+ // this->state = Idle;
+
+ break;
+ }
+
+ default:
+ {
+ this->state = generalState;
+ }
+ }
+
+ this->stateChange = this->state != this->stateOld ? this->state : Undefined;
+ this->stateOld = this->state;
+}
+
+void GkGameReels::Process(GkGame *game)
+{
+ for (int reelIndex = 0; reelIndex < this->numReels; reelIndex++)
+ {
+ this->Reel_ProcessPosition(reelIndex, game);
+
+ this->Reel_ProcessState(reelIndex, game->timer);
+ }
+
+ this->ProcessState(game->timer);
+}
+
+void GkGameReels::Draw(GkGame *game)
+{
+ int itemWidth = this->symbols[0]->frames[0]->width;
+ int itemHeight = this->symbols[0]->frames[0]->height;
+
+ float horizontalDistance = this->numReels == 1 ? itemWidth : itemWidth + (this->width - this->numReels * itemWidth) / ((float)this->numReels - 1.0f);
+
+ for (int reelIndex = 0; reelIndex < this->numReels; reelIndex++)
+ {
+ int x = (int)(this->x + reelIndex * horizontalDistance);
+
+ for (int itemIndex = 0; itemIndex < this->numReelAnimations; itemIndex++)
+ {
+ int y = (int)(this->y + (this->height - this->numReelAnimations * itemHeight) / 2 + this->reels[reelIndex].position * itemHeight + itemIndex * itemHeight);
+
+ GkGameAnimation *reelItemAnimation = this->reels[reelIndex].animations[itemIndex];
+
+ game->graphicsDevice->DrawClipped(x, y, this->x, this->y, this->width, this->height, reelItemAnimation->animatedTexture->frames[(int)reelItemAnimation->currentFrame]);
+ }
+ }
+}
+
+void GkGameReels::ApplyReelMap(const int *fullItemMap)
+{
+ if (fullItemMap != 0)
+ {
+ this->SetItems(fullItemMap);
+ }
+
+
+ for (int reelIndex = 0; reelIndex < this->numReels; reelIndex++)
+ {
+ this->reels[reelIndex].animations[0]->SetAnimatedTexture(this->symbols[GkMaths::Random(this->numSymbols)]);
+ this->reels[reelIndex].animations[this->numReelAnimations - 1]->SetAnimatedTexture(this->symbols[GkMaths::Random(this->numSymbols)]);
+ }
+
+ for (int reelIndex = 0; reelIndex < this->numReels; reelIndex++)
+ {
+ for (int itemIndex = 0; itemIndex < this->numReelItems; itemIndex++)
+ {
+ this->reels[reelIndex].animations[itemIndex + 1]->SetAnimatedTexture(this->symbols[this->GetSymbol(reelIndex, itemIndex)]);
+ }
+ }
+}
+
+bool GkGameReels::Start()
+{
+ this->reelingTime = GkGameTimer::GetSample();
+
+ bool result = true;
+ if (this->state == Idle)
+ {
+ for (int i = 0; i < this->numReels; i++)
+ result &= this->Reel_Start(i);
+
+ return result;
+ }
+
+ return false;
+}
+
+bool GkGameReels::Stop()
+{
+ if (this->state = Spinning)
+ {
+ this->stopInitiatedTime = GkGameTimer::GetSample();
+
+ this->state = Stopping;
+ return true;
+ }
+
+ return false;
+
+
+
+ bool result = true;
+ if (this->state == Spinning)
+ {
+ for (int i = 0; i < this->numReels; i++)
+ result &= this->Reel_Stop(i);
+
+ return result;
+ }
+
+ return false;
+}
+
+bool GkGameReels::ItemsAnimationsPlaying()
+{
+ for (int reelIndex = 0; reelIndex < this->numReels; reelIndex++)
+ {
+ for (int itemIndex = 0; itemIndex < this->numReelItems; itemIndex++)
+ {
+ if (this->reels[reelIndex].animations[itemIndex + 1]->active)
+ return true;
+ }
+ }
+
+ return false;
+}
+
+void GkGameReels::StopItemsAnimations()
+{
+ for (int reelIndex = 0; reelIndex < this->numReels; reelIndex++)
+ {
+ for (int itemIndex = 0; itemIndex < this->numReelItems; itemIndex++)
+ {
+ this->reels[reelIndex].animations[itemIndex + 1]->active = false;
+ this->reels[reelIndex].animations[itemIndex + 1]->currentFrame = 0.0f;
+ }
+ }
+}
+
+float GkGameReels::GetReelingTime()
+{
+ return GkGameTimer::GetSampleTime(this->reelingTime);
+}
+
+float GkGameReels::GetIdleTime()
+{
+ return GkGameTimer::GetSampleTime(this->idleTime);
+}
diff --git a/COM380/Project5/GambleKit/Engine/Game/Entities/GkGameReels.h b/COM380/Project5/GambleKit/Engine/Game/Entities/GkGameReels.h
new file mode 100644
index 0000000..bf020b0
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Game/Entities/GkGameReels.h
@@ -0,0 +1,86 @@
+#pragma once
+
+#include "..\..\GkDefinitions.h"
+
+#include "..\GkGameEntity.h"
+#include "GkGameAnimation.h"
+#include "..\..\Base\GkBaseReelMap.h"
+#include "..\GkGameReelsCombinationGenerator.h"
+
+class GKDLLCLASS GkGameTimer;
+
+enum GameReelState
+{
+ Idle = 0,
+ PreStarting = 1,
+ Starting = 2,
+ Spinning = 3,
+ Stopping = 4,
+ PostStopping = 5,
+ Blocked = 6,
+ Undefined = 7
+};
+
+struct GkGameReelInfo
+{
+ GameReelState state, stateOld, stateChange;
+ float position, speed;
+ int reelMapSetIndex;
+
+ GkGameAnimation **animations;
+};
+
+class GKDLLCLASS GkGameReels :
+ public GkGameEntity,
+ public GkBaseReelMap
+{
+private:
+ GameReelState stateOld;
+ long long stopInitiatedTime, reelingTime, idleTime;
+
+ // GkGameReel related methods
+ GkAnimatedTexture *GkGameReels::Reel_GetNewSymbol(int reelIndex);
+ void GkGameReels::Reel_ProcessState(int reelIndex, GkGameTimer *gameTimer);
+ void GkGameReels::Reel_ProcessPosition(int reelIndex, GkGame *game);
+ bool GkGameReels::Reel_Start(int reelIndex);
+ bool GkGameReels::Reel_Stop(int reelIndex);
+
+ void GkGameReels::ProcessState(GkGameTimer *gameTimer);
+
+public:
+ GkGameReelInfo *reels;
+
+
+ GameReelState state, // GkGameReels acquires certain state when all of its reels reach that state
+ stateChange; // Gives the state that reels have just obtained in the last frame
+
+ int numSymbols, numReelAnimations;
+
+ int x, y, width, height;
+
+ float speed, // items per second
+ acceleration, // items per second^2
+ stoppingTime, // seconds
+ preStartOffset, postStopOffset, // number of items
+ preStartSpeed, postStopSpeed; // items per second
+
+ GkAnimatedTexture **symbols;
+
+ GkGameReelsCombinationGenerator *itemGenerator;
+
+ GkGameReels::GkGameReels(int numReels, int numReelItems, int numSymbols, int width, int height);
+ GkGameReels::~GkGameReels(void);
+
+ void GkGameReels::SetItemGenerator(GkGameReelsCombinationGenerator *itemGenerator);
+ void GkGameReels::Process(GkGame *game);
+ void GkGameReels::Draw(GkGame *game);
+ void GkGameReels::ApplyReelMap(const int *fullItemMap = 0);
+ bool GkGameReels::Start();
+ bool GkGameReels::Stop();
+ bool GkGameReels::ItemsAnimationsPlaying();
+ void GkGameReels::StopItemsAnimations();
+ float GkGameReels::GetReelingTime();
+ float GkGameReels::GetIdleTime();
+ GameReelState GkGameReels::GetGeneralState();
+};
+
diff --git a/COM380/Project5/GambleKit/Engine/Game/Entities/GkGameStreamingAnimation.cpp b/COM380/Project5/GambleKit/Engine/Game/Entities/GkGameStreamingAnimation.cpp
new file mode 100644
index 0000000..b4cf665
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Game/Entities/GkGameStreamingAnimation.cpp
@@ -0,0 +1,145 @@
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+// GambleKit Copyright (C) 2014 Ivan Donev
+//
+// This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// contact: gamblekit@gmail.com
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+#include "GkGameStreamingAnimation.h"
+
+#include "..\..\Utils\GkStrings.h"
+#include "..\..\OSSpecific\GkFileSystem.h"
+
+GkGameStreamingAnimation::GkGameStreamingAnimation(const wchar_t *fileName, const wchar_t *loadExpression, int x, int y, bool freeAtEnd, float framesPerSecond, int numFrames)
+{
+ this->x = x;
+ this->y = y;
+ this->visible = false;
+ this->active = true;
+ this->loop = false;
+ this->freeAtEnd = freeAtEnd;
+ this->currentFrame = framesPerSecond >= 0.0f ? 0.0f : (float)(numFrames - 1);
+ this->framesPerSecond = framesPerSecond;
+ this->numFrames = numFrames;
+
+ this->loadExpression = GkStrings::Copy(loadExpression);
+ this->fileName = GkStrings::Copy(fileName);
+ this->texture = 0;
+}
+
+
+GkGameStreamingAnimation::~GkGameStreamingAnimation(void)
+{
+ this->Free();
+
+ GkStrings::Dispose(&this->fileName);
+ GkStrings::Dispose(&this->loadExpression);
+}
+
+void GkGameStreamingAnimation::SetSource(const wchar_t *fileName, const wchar_t *loadExpression, float framesPerSecond, int numFrames)
+{
+ this->Free();
+
+ this->active = true;
+ this->loop = false;
+ this->currentFrame = framesPerSecond >= 0.0f ? 0.0f : (float)(numFrames - 1);
+ this->framesPerSecond = framesPerSecond;
+ this->numFrames = numFrames;
+
+ GkStrings::Dispose(&this->fileName);
+ GkStrings::Dispose(&this->loadExpression);
+ this->loadExpression = GkStrings::Copy(loadExpression);
+ this->fileName = GkStrings::Copy(fileName);
+}
+
+void GkGameStreamingAnimation::Free()
+{
+ if (this->texture != 0)
+ {
+ delete this->texture;
+ this->texture = 0;
+ }
+}
+
+bool GkGameStreamingAnimation::Load(int index)
+{
+ void *data;
+ unsigned int dataSize;
+
+ if (GkFileSystem::LoadFile(GkStrings::Format(this->loadExpression, GkStrings::IntToString(index, 10, 5).c_str()).c_str(), &data, &dataSize))
+ {
+ this->Free();
+
+ GkImage image;
+ image.LoadFromMemory(data, dataSize);
+
+ this->texture = new GkTexture();
+ this->texture->LoadFromImage(&image);
+
+ delete data;
+
+ return true;
+ }
+
+ return false;
+}
+
+void GkGameStreamingAnimation::Start()
+{
+ this->currentFrame = framesPerSecond >= 0.0f ? 0.0f : (float)(numFrames - 1);
+ this->lastRenderedFrame = (int)this->currentFrame;
+ this->visible = this->Load(this->lastRenderedFrame);
+ this->active = this->visible;
+}
+
+void GkGameStreamingAnimation::Process(GkGame *game)
+{
+ if (!(this->active && this->visible))
+ return;
+
+ this->currentFrame += this->framesPerSecond * game->timer->tickTime;
+ if ((this->lastRenderedFrame != (int)this->currentFrame) || (this->texture == 0))
+ {
+ bool terminate = false;
+ if (!this->Load((int)this->currentFrame))
+ {
+ if (this->loop)
+ {
+ this->currentFrame = this->framesPerSecond >= 0 ? 0.0f : (float)(this->numFrames - 1);
+ if (!this->Load((int)this->currentFrame))
+ {
+ terminate = true;
+ }
+ }
+ else
+ {
+ terminate = true;
+ }
+ }
+
+ if (terminate)
+ {
+ this->currentFrame = (float)(this->lastRenderedFrame);
+ this->active = false;
+ this->visible = (!this->freeAtEnd) && (this->texture != 0);
+ }
+ }
+
+ this->lastRenderedFrame = (int)this->currentFrame;
+}
+
+void GkGameStreamingAnimation::Draw(GkGame *game)
+{
+ if (!this->visible)
+ {
+ this->Free();
+ return;
+ }
+
+ game->graphicsDevice->Draw(this->x, this->y, this->texture);
+}
diff --git a/COM380/Project5/GambleKit/Engine/Game/Entities/GkGameStreamingAnimation.h b/COM380/Project5/GambleKit/Engine/Game/Entities/GkGameStreamingAnimation.h
new file mode 100644
index 0000000..80df802
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Game/Entities/GkGameStreamingAnimation.h
@@ -0,0 +1,32 @@
+#pragma once
+
+#include "..\..\GkDefinitions.h"
+
+#include "..\GkGame.h"
+#include "..\Entities\GkGameAnimation.h"
+#include "..\..\Graphics\GkTexture.h"
+
+class GKDLLCLASS GkGameStreamingAnimation :
+ public GkGameAnimation
+{
+public:
+ GkTexture *texture;
+
+ wchar_t *fileName, *loadExpression;
+
+ bool freeAtEnd;
+ int lastRenderedFrame;
+ int numFrames; // required only if animation is backwards, i.e. if framesPerSecond is negative
+
+ // Because the animation is streaming and the number of frames is practically unknown, if it is played backwards, i.e. framesPerSecond is negative, then numFrames must be provided
+ GkGameStreamingAnimation::GkGameStreamingAnimation(const wchar_t *fileName, const wchar_t *loadExpression, int x = 0, int y = 0, bool freeAtEnd = true, float framesPerSecond = 25.0f, int numFrames = 0);
+ GkGameStreamingAnimation::~GkGameStreamingAnimation(void);
+
+ void GkGameStreamingAnimation::SetSource(const wchar_t *fileName, const wchar_t *loadExpression, float framesPerSecond = 25.0f, int numFrames = 0);
+ void GkGameStreamingAnimation::Free();
+ bool GkGameStreamingAnimation::Load(int index);
+ void GkGameStreamingAnimation::Start();
+ void GkGameStreamingAnimation::Process(GkGame *game);
+ void GkGameStreamingAnimation::Draw(GkGame *game);
+};
+
diff --git a/COM380/Project5/GambleKit/Engine/Game/Entities/GkGameText.cpp b/COM380/Project5/GambleKit/Engine/Game/Entities/GkGameText.cpp
new file mode 100644
index 0000000..74988fb
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Game/Entities/GkGameText.cpp
@@ -0,0 +1,148 @@
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+// GambleKit Copyright (C) 2014 Ivan Donev
+//
+// This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// contact: gamblekit@gmail.com
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+#include "GkGameText.h"
+
+#include "..\GkGame.h"
+#include "..\..\Utils\GkStrings.h"
+
+GkGameText::GkGameText(GkAnimatedFont *animatedFont, int x, int y, int characterSpacing, int textAlignment, int maxWidth, float framesPerSecond)
+ : GkGameEntity()
+{
+ this->animatedFont = animatedFont;
+
+ this->x = x;
+ this->y = y;
+ this->characterSpacing = characterSpacing;
+ this->maxWidth = maxWidth;
+ this->textAlignment = textAlignment;
+ this->visible = animatedFont != NULL;
+ this->active = animatedFont != NULL;
+ this->loop = animatedFont != NULL;
+
+ this->framesPerSecond = framesPerSecond != 0.0f ? framesPerSecond : animatedFont != 0 ? animatedFont->framesPerSecond : 0.0f;
+ this->currentFrame = 0.0f;
+
+ this->text = 0;
+ this->textTextureIndices = 0;
+ this->textLength = 0;
+}
+
+
+GkGameText::~GkGameText(void)
+{
+ if (this->text != 0)
+ delete[] this->text;
+
+ if (this->textTextureIndices != 0)
+ delete[] this->textTextureIndices;
+}
+
+bool GkGameText::SetText(const wchar_t *text)
+{
+ if ((this->text != 0) && (GkStrings::Compare(this->text, text) == 0))
+ return false;
+
+ if (this->text != 0)
+ delete[] this->text;
+
+ if (this->textTextureIndices != 0)
+ delete[] this->textTextureIndices;
+
+ this->text = GkStrings::Copy(text);
+ this->textLength = GkStrings::GetLength(this->text);
+ this->textTextureIndices = new int[this->textLength];
+
+ this->textWidth = 0;
+ for (int i = 0; i < this->textLength; i++)
+ {
+ this->textTextureIndices[i] = GkStrings::SubChar(this->animatedFont->charMap, this->text[i]);
+
+ if (this->textTextureIndices[i] != -1)
+ {
+ this->textWidth += this->animatedFont->letterTextures[this->textTextureIndices[i]]->frames[0]->width + this->characterSpacing;
+ }
+ }
+
+ this->textWidth -= this->characterSpacing;
+
+ return true;
+}
+
+void GkGameText::Process(GkGame *game)
+{
+ if (!(this->active && this->visible))
+ return;
+
+ this->currentFrame += this->framesPerSecond * game->timer->tickTime;
+ if (this->currentFrame > this->animatedFont->letterTextures[0]->numFrames)
+ {
+ if (this->loop)
+ {
+ int intFrame = (int)this->currentFrame;
+ float fracFrame = this->currentFrame - intFrame;
+ this->currentFrame = intFrame % this->animatedFont->letterTextures[0]->numFrames + fracFrame;
+ }
+ else
+ {
+ this->currentFrame = (float)(this->animatedFont->letterTextures[0]->numFrames - 1);
+ this->active = false;
+ }
+ }
+}
+
+void GkGameText::Draw(GkGame *game)
+{
+ if (!this->visible)
+ return;
+
+ if ((this->maxWidth == 0) || (this->textWidth <= this->maxWidth))
+ {
+ int x = this->textAlignment == GkGameText::GameTextAlignment_Right ? this->x : this->textAlignment == GkGameText::GameTextAlignment_Center ? this->x - this->textWidth / 2 : this->x - this->textWidth;
+
+ for (int i = 0; i < this->textLength; i++)
+ {
+ int letterTextureIndex = this->textTextureIndices[i];
+
+ if (letterTextureIndex != -1)
+ {
+ GkTexture *letterTexture = this->animatedFont->letterTextures[letterTextureIndex]->frames[(int)this->currentFrame];
+
+ game->graphicsDevice->Draw(x, this->y, letterTexture);
+
+ x += letterTexture->width + this->characterSpacing;
+ }
+ }
+ }
+ else
+ {
+ float scalingFactor = (float)this->maxWidth / (float)this->textWidth;
+
+ float x = this->textAlignment == GkGameText::GameTextAlignment_Right ? this->x : this->textAlignment == GkGameText::GameTextAlignment_Center ? this->x - (float)(scalingFactor * (float)this->textWidth / 2.0f) : this->x - (float)(scalingFactor * (float)this->textWidth);
+ int y = this->y + (int)(((1.0f - scalingFactor) * (float)this->animatedFont->letterTextures[0]->frames[0]->height) / 2.0f);
+
+ for (int i = 0; i < this->textLength; i++)
+ {
+ int letterTextureIndex = this->textTextureIndices[i];
+
+ if (letterTextureIndex != -1)
+ {
+ GkTexture *letterTexture = this->animatedFont->letterTextures[letterTextureIndex]->frames[(int)this->currentFrame];
+
+ game->graphicsDevice->Draw((int)x, y, (int)(letterTexture->width * scalingFactor), (int)(letterTexture->height * scalingFactor), 0, 0, letterTexture->width, letterTexture->height, letterTexture);
+
+ x += scalingFactor * (letterTexture->width + this->characterSpacing);
+ }
+ }
+ }
+}
+
diff --git a/COM380/Project5/GambleKit/Engine/Game/Entities/GkGameText.h b/COM380/Project5/GambleKit/Engine/Game/Entities/GkGameText.h
new file mode 100644
index 0000000..3d35e72
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Game/Entities/GkGameText.h
@@ -0,0 +1,36 @@
+#pragma once
+
+#include "..\..\GkDefinitions.h"
+
+#include "..\GkGameEntity.h"
+#include "..\..\Graphics\GkAnimatedFont.h"
+
+class GKDLLCLASS GkGameText :
+ public GkGameEntity
+{
+public:
+ static const int GameTextAlignment_Right = 0,
+ GameTextAlignment_Center = 1,
+ GameTextAlignment_Left = 2;
+
+ GkAnimatedFont *animatedFont;
+ wchar_t *text;
+ int textLength, textWidth;
+ int *textTextureIndices;
+
+ int x, y;
+ bool visible, active, loop;
+ float framesPerSecond, currentFrame;
+ int textAlignment;
+ int characterSpacing;
+ int maxWidth;
+
+
+ GkGameText::GkGameText(GkAnimatedFont *animatedFont, int x = 0, int y = 0, int characterSpacing = 0, int textAlignment = GameTextAlignment_Right, int maxWidth = 0, float framesPerSecond = 0.0f);
+ GkGameText::~GkGameText(void);
+
+ bool GkGameText::SetText(const wchar_t *text);
+ void GkGameText::Process(GkGame *game);
+ void GkGameText::Draw(GkGame *game);
+};
+
diff --git a/COM380/Project5/GambleKit/Engine/Game/Entities/GkGameWinningCounter.cpp b/COM380/Project5/GambleKit/Engine/Game/Entities/GkGameWinningCounter.cpp
new file mode 100644
index 0000000..4356e1a
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Game/Entities/GkGameWinningCounter.cpp
@@ -0,0 +1,85 @@
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+// GambleKit Copyright (C) 2014 Ivan Donev
+//
+// This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// contact: gamblekit@gmail.com
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+#include "GkGameWinningCounter.h"
+
+#include "..\GkGame.h"
+
+GkGameWinningCounter::GkGameWinningCounter(int *actualValue, float minSpeed, float maxTime)
+ : GkGameEntity()
+
+{
+ this->actualValue = actualValue;
+ this->minSpeed = minSpeed;
+ this->maxTime = maxTime;
+
+ this->SetValue((float)*this->actualValue, 0.0f);
+}
+
+
+GkGameWinningCounter::~GkGameWinningCounter(void)
+{
+}
+
+void GkGameWinningCounter::SetValue(float value, float maxTime)
+{
+ float delta = value - this->displayValue;
+ if (maxTime == -1.0f)
+ maxTime = this->maxTime;
+
+ if (maxTime == 0.0f)
+ {
+ this->displayValue = value;
+ }
+ else
+ {
+ float minSpeed = delta / maxTime;
+ this->speed = this->minSpeed > minSpeed ? this->minSpeed : minSpeed;
+ }
+
+ this->oldValue = value;
+}
+
+void GkGameWinningCounter::Reach(float maxTime)
+{
+ this->SetValue((float)*this->actualValue, maxTime);
+}
+
+bool GkGameWinningCounter::IsCounting()
+{
+ return this->intDisplayValue != *this->actualValue;
+}
+
+void GkGameWinningCounter::Process(GkGame *game)
+{
+ float value = (float)*this->actualValue;
+
+ if (value != this->oldValue)
+ this->SetValue(value, this->maxTime);
+
+ this->displayValue += this->speed * game->timer->tickTime;
+
+ if (this->speed > 0.0f)
+ {
+ if (this->displayValue > value)
+ this->displayValue = value;
+ }
+ else
+ {
+ if (this->displayValue < value)
+ this->displayValue = value;
+ }
+
+ this->intDisplayValue = (int)this->displayValue;
+
+ GkGameEntity::Process(game);
+}
diff --git a/COM380/Project5/GambleKit/Engine/Game/Entities/GkGameWinningCounter.h b/COM380/Project5/GambleKit/Engine/Game/Entities/GkGameWinningCounter.h
new file mode 100644
index 0000000..e3d2570
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Game/Entities/GkGameWinningCounter.h
@@ -0,0 +1,32 @@
+#pragma once
+
+#include "..\..\GkDefinitions.h"
+
+#include "..\GkGameEntity.h"
+
+class GKDLLCLASS GkGameWinningCounter :
+ public GkGameEntity
+{
+private:
+ float oldValue;
+
+ void SetValue(float value, float maxTime);
+
+public:
+ int *actualValue;
+
+ float minSpeed, maxTime,
+ displayValue,
+ speed;
+
+ int intDisplayValue;
+
+ GkGameWinningCounter(int *actualValue, float minSpeed = 500.0f, float maxTime = 1.0f);
+ ~GkGameWinningCounter(void);
+
+ void Reach(float maxTime = 0.0f);
+ bool IsCounting();
+
+ void Process(GkGame *game);
+};
+
diff --git a/COM380/Project5/GambleKit/Engine/Game/GkGame.cpp b/COM380/Project5/GambleKit/Engine/Game/GkGame.cpp
new file mode 100644
index 0000000..79e4ce7
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Game/GkGame.cpp
@@ -0,0 +1,304 @@
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+// GambleKit Copyright (C) 2014 Ivan Donev
+//
+// This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// contact: gamblekit@gmail.com
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+#include "GkGame.h"
+
+#include "..\OSSpecific\GkFileSystem.h"
+#include "..\Utils\GkStrings.h"
+
+
+ResourcePoolEntry::ResourcePoolEntry(GkBase *resource, const wchar_t *id)
+{
+ this->resource = resource;
+
+ if (id == NULL)
+ {
+ this->id = NULL;
+ }
+ else
+ {
+ int l = wcslen(id);
+ this->id = new wchar_t[l + 1];
+ wcscpy_s(this->id, l + 1, id);
+ }
+}
+
+GkGame::GkGame(GkGraphicsDevice *graphicsDevice, GkSoundDevice *soundDevice)
+{
+ this->graphicsDevice = graphicsDevice;
+ this->soundDevice = soundDevice;
+
+ this->currentGamePage = 0;
+
+ this->timer = new GkGameTimer();
+}
+
+
+GkGame::~GkGame(void)
+{
+ int numPages = this->gamePages.size();
+ for (int i = 0; i < numPages; i++)
+ {
+ delete this->gamePages[i];
+ }
+
+ int numResources = this->resourcePool.size();
+ for (int i = 0; i < numResources; i++)
+ {
+ delete this->resourcePool[i].resource;
+
+ if (this->resourcePool[i].id != NULL)
+ {
+ delete this->resourcePool[i].id;
+ this->resourcePool[i].id = NULL;
+ }
+ }
+
+ delete this->timer;
+}
+
+void GkGame::SetPage(GkGamePage *page)
+{
+ if (this->currentGamePage != 0)
+ this->currentGamePage->OnHide(page);
+
+ if (page != 0)
+ page->OnShow(this->currentGamePage);
+
+ this->currentGamePage = page;
+}
+
+GkAnimatedTexture* GkGame::AddAnimatedTexture(GkAnimatedTexture *animatedTexture, const wchar_t* id)
+{
+ this->resourcePool.push_back(ResourcePoolEntry(animatedTexture, id));
+ return animatedTexture;
+}
+
+void* GkGame::GetResource(const wchar_t* id)
+{
+ int numResources = this->resourcePool.size();
+ for (int i = 0; i < numResources; i++)
+ {
+ if (wcscmp(this->resourcePool[i].id, id) == 0)
+ return this->resourcePool[i].resource;
+ }
+
+ return NULL;
+}
+
+bool GkGame::ReleaseResource(const wchar_t* id)
+{
+ int numResources = this->resourcePool.size();
+ for (int i = 0; i < numResources; i++)
+ {
+ if (wcscmp(this->resourcePool[i].id, id) == 0)
+ {
+ delete this->resourcePool[i].resource;
+
+ if (this->resourcePool[i].id != NULL)
+ {
+ delete this->resourcePool[i].id;
+ this->resourcePool[i].id = NULL;
+ }
+
+ this->resourcePool[i] = this->resourcePool[numResources - 1];
+ this->resourcePool.pop_back();
+
+ return true;
+ }
+ }
+
+ return false;
+}
+
+GkAnimatedFont* GkGame::AcquireAnimatedFontFromMultipleFiles(const wchar_t* virtualFileName, const wchar_t *charMap, int numFrames)
+{
+ GkAnimatedFont* result = (GkAnimatedFont*)this->GetResource(virtualFileName);
+ if (result != NULL)
+ return result;
+
+
+ result = new GkAnimatedFont(charMap, numFrames);
+
+ void *data;
+ unsigned int dataSize;
+
+ for (int i = 0; i < result->numLetters; i++)
+ {
+ if (GkFileSystem::LoadFile(GkStrings::Format(virtualFileName, GkStrings::IntToString(i, 10, 5).c_str()).c_str(), &data, &dataSize))
+ {
+ result->LoadAnimatedLetter(i, data, dataSize);
+
+ delete[] data;
+ }
+ }
+
+
+ this->resourcePool.push_back(ResourcePoolEntry(result, virtualFileName));
+
+ return result;
+}
+
+GkAnimatedTexture* GkGame::AcquireAnimatedTexture(const wchar_t* virtualFileName, int columnFrames, int rowFrames, int numFrames, float framesPerSecond, int animatedTexture_LoadOrder)
+{
+ GkAnimatedTexture* result = (GkAnimatedTexture*)this->GetResource(virtualFileName);
+ if (result != NULL)
+ return result;
+
+ void *data;
+ unsigned int dataSize;
+
+ if (!GkFileSystem::LoadFile(virtualFileName, &data, &dataSize))
+ return NULL;
+ result = new GkAnimatedTexture(data, dataSize, columnFrames, rowFrames, numFrames, framesPerSecond, animatedTexture_LoadOrder);
+ delete data;
+
+ this->resourcePool.push_back(ResourcePoolEntry(result, virtualFileName));
+
+ return result;
+}
+
+GkAnimatedTexture* GkGame::AcquireAnimatedTextureFromMultipleFiles(const wchar_t* virtualFileName, float framesPerSecond)
+{
+ GkAnimatedTexture *result = (GkAnimatedTexture*)this->GetResource(virtualFileName);
+ if (result != NULL)
+ return result;
+
+
+ std::vector frames;
+
+ void *data;
+ unsigned int dataSize;
+
+ int index = 0;
+ while (GkFileSystem::LoadFile(GkStrings::Format(virtualFileName, GkStrings::IntToString(index, 10, 5).c_str()).c_str(), &data, &dataSize))
+ {
+ GkImage *frameImage = new GkImage();
+ frameImage->LoadFromMemory(data, dataSize);
+
+ GkTexture *frame = new GkTexture();
+ frame->LoadFromImage(frameImage);
+ delete frameImage;
+
+ frames.push_back(frame);
+
+ index++;
+
+ delete[] data;
+ }
+
+
+ int numFrames = frames.size();
+ if (numFrames == 0)
+ return NULL;
+
+ result = new GkAnimatedTexture();
+ result->framesPerSecond = framesPerSecond;
+ result->numFrames = numFrames;
+ result->frames = new GkTexture*[numFrames];
+ for (int i = 0; i < numFrames; i++)
+ {
+ result->frames[i] = frames[i];
+ }
+
+ this->resourcePool.push_back(ResourcePoolEntry(result, virtualFileName));
+
+ return result;
+}
+
+GkSoundSource* GkGame::AcquireSoundSource(const wchar_t* virtualFileName)
+{
+ GkSoundSource* result = (GkSoundSource*)this->GetResource(virtualFileName);
+ if (result != NULL)
+ return result;
+
+ void *data;
+ unsigned int dataSize;
+
+ GkFileSystem::LoadFile(virtualFileName, &data, &dataSize);
+ result = new GkSoundSource();
+ result->LoadFromMemory(data);
+ this->resourcePool.push_back(ResourcePoolEntry(result, virtualFileName));
+ delete data;
+
+ return result;
+}
+
+GkGamePage* GkGame::AddGamePage(GkGamePage *gamePage)
+{
+ this->gamePages.push_back(gamePage);
+
+ if (this->currentGamePage == NULL)
+ this->SetPage(gamePage);
+
+ return gamePage;
+}
+
+void GkGame::RemoveGamePage(GkGamePage *gamePage)
+{
+ int index = -1;
+ for (int i = 0; i < (int)this->gamePages.size(); i++)
+ if (this->gamePages[i] == gamePage)
+ {
+ index = i;
+ break;
+ }
+
+ if (index == -1)
+ return;
+
+ for (int i = index; i < (int)this->gamePages.size() - 1; i++)
+ this->gamePages[i] = this->gamePages[i + 1];
+
+ this->gamePages.pop_back();
+}
+
+void GkGame::MouseDown(int x, int y)
+{
+ int numEntities = this->currentGamePage->entities.size();
+ for (int i = numEntities - 1; i >= 0; i--)
+ {
+ GkGameEntity *entity = this->currentGamePage->entities[i];
+ if (entity->IsMouseOver(x, y))
+ {
+ entity->MouseDown(x, y);
+ break;
+ }
+ }
+}
+
+void GkGame::MouseUp(int x, int y)
+{
+ int numEntities = this->currentGamePage->entities.size();
+ for (int i = numEntities - 1; i >= 0; i--)
+ {
+ GkGameEntity *entity = this->currentGamePage->entities[i];
+ entity->MouseUp(x, y);
+ }
+}
+
+void GkGame::NewFrame()
+{
+ this->timer->Tick();
+}
+
+void GkGame::Process()
+{
+ if (this->currentGamePage != NULL)
+ this->currentGamePage->Process(this);
+}
+
+void GkGame::Render()
+{
+ if (this->currentGamePage != NULL)
+ this->currentGamePage->Render(this);
+}
\ No newline at end of file
diff --git a/COM380/Project5/GambleKit/Engine/Game/GkGame.h b/COM380/Project5/GambleKit/Engine/Game/GkGame.h
new file mode 100644
index 0000000..ae77455
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Game/GkGame.h
@@ -0,0 +1,61 @@
+#pragma once
+
+#include "..\GkDefinitions.h"
+
+#include
+#include
+
+#include "..\Graphics\GkGraphicsDevice.h"
+#include "..\Graphics\GkAnimatedTexture.h"
+#include "..\Graphics\GkAnimatedFont.h"
+#include "..\Sound\GkSoundDevice.h"
+#include "..\Sound\GkSoundSource.h"
+#include "GkGameTimer.h"
+#include "GkGamePage.h"
+#include "..\Base\GkBase.h"
+
+using namespace std;
+
+class GKDLLCLASS GkGamePage;
+
+struct ResourcePoolEntry
+{
+ GkBase* resource;
+ wchar_t* id;
+
+ ResourcePoolEntry::ResourcePoolEntry(GkBase *resource, const wchar_t *id);
+};
+
+class GKDLLCLASS GkGame
+{
+public:
+ GkGraphicsDevice *graphicsDevice;
+ GkSoundDevice *soundDevice;
+
+ GkGameTimer *timer;
+
+ vector gamePages;
+ GkGamePage *currentGamePage;
+
+ vector resourcePool;
+
+ GkGame::GkGame(GkGraphicsDevice *graphicsDevice, GkSoundDevice *soundDevice);
+ virtual GkGame::~GkGame(void);
+
+ void SetPage(GkGamePage *page);
+ GkAnimatedTexture* GkGame::AddAnimatedTexture(GkAnimatedTexture *animatedTexture, const wchar_t* id = 0);
+ void* GkGame::GetResource(const wchar_t* id);
+ bool GkGame::ReleaseResource(const wchar_t* id);
+ GkAnimatedFont* GkGame::AcquireAnimatedFontFromMultipleFiles(const wchar_t* virtualFileName, const wchar_t *charMap, int numFrames = 1);
+ GkAnimatedTexture* GkGame::AcquireAnimatedTexture(const wchar_t* virtualFileName, int columnFrames = 1, int rowFrames = 1, int numFrames = 0, float framesPerSecond = 25.0f, int animatedTexture_LoadOrder = GkAnimatedTexture::LoadOrder_Horizontal);
+ GkAnimatedTexture* GkGame::AcquireAnimatedTextureFromMultipleFiles(const wchar_t* virtualFileName, float framesPerSecond = 25.0f);
+ GkSoundSource* GkGame::AcquireSoundSource(const wchar_t* virtualFileName);
+ GkGamePage* GkGame::AddGamePage(GkGamePage *gamePage);
+ void GkGame::RemoveGamePage(GkGamePage *gamePage);
+ virtual void GkGame::MouseDown(int x, int y);
+ virtual void GkGame::MouseUp(int x, int y);
+ virtual void GkGame::NewFrame();
+ virtual void GkGame::Process();
+ virtual void GkGame::Render();
+};
+
diff --git a/COM380/Project5/GambleKit/Engine/Game/GkGameEntity.cpp b/COM380/Project5/GambleKit/Engine/Game/GkGameEntity.cpp
new file mode 100644
index 0000000..e977058
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Game/GkGameEntity.cpp
@@ -0,0 +1,54 @@
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+// GambleKit Copyright (C) 2014 Ivan Donev
+//
+// This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// contact: gamblekit@gmail.com
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+#include "GkGameEntity.h"
+
+#include "GkGame.h"
+
+GkGameEntity::GkGameEntity()
+{
+}
+
+
+GkGameEntity::~GkGameEntity(void)
+{
+}
+
+void GkGameEntity::MouseDown(int x, int y)
+{
+}
+
+void GkGameEntity::MouseUp(int x, int y)
+{
+}
+
+void GkGameEntity::Process(GkGame *game)
+{
+}
+
+void GkGameEntity::Draw(GkGame *game)
+{
+}
+
+bool GkGameEntity::IsMouseOver(int x, int y)
+{
+ return false;
+}
+
+void GkGameEntity::OnMouseClicked()
+{
+}
+
+bool GkGameEntity::GetBoundaries(int *x1, int *y1, int *x2, int*y2)
+{
+ return false;
+}
diff --git a/COM380/Project5/GambleKit/Engine/Game/GkGameEntity.h b/COM380/Project5/GambleKit/Engine/Game/GkGameEntity.h
new file mode 100644
index 0000000..0c45afd
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Game/GkGameEntity.h
@@ -0,0 +1,20 @@
+#pragma once
+
+#include "..\GkDefinitions.h"
+
+class GKDLLCLASS GkGame;
+
+class GKDLLCLASS GkGameEntity
+{
+public:
+ GkGameEntity::GkGameEntity();
+ virtual GkGameEntity::~GkGameEntity(void);
+
+ virtual void GkGameEntity::MouseDown(int x, int y);
+ virtual void GkGameEntity::MouseUp(int x, int y);
+ virtual void GkGameEntity::Process(GkGame *game);
+ virtual void GkGameEntity::Draw(GkGame *game);
+ virtual bool GkGameEntity::IsMouseOver(int x, int y);
+ virtual void GkGameEntity::OnMouseClicked();
+ virtual bool GkGameEntity::GetBoundaries(int *x1, int *y1, int *x2, int*y2);
+};
\ No newline at end of file
diff --git a/COM380/Project5/GambleKit/Engine/Game/GkGamePage.cpp b/COM380/Project5/GambleKit/Engine/Game/GkGamePage.cpp
new file mode 100644
index 0000000..fda803d
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Game/GkGamePage.cpp
@@ -0,0 +1,93 @@
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+// GambleKit Copyright (C) 2014 Ivan Donev
+//
+// This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// contact: gamblekit@gmail.com
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+#include "GkGamePage.h"
+
+GkGamePage::GkGamePage()
+{
+}
+
+
+GkGamePage::~GkGamePage(void)
+{
+ int numEntities = this->entities.size();
+
+ for (int i = 0; i < numEntities; i++)
+ {
+ delete this->entities[i];
+ }
+}
+
+void GkGamePage::OnShow(GkGamePage *previous)
+{
+}
+
+void GkGamePage::OnHide(GkGamePage *next)
+{
+}
+
+GkGameEntity* GkGamePage::AddEntity(GkGameEntity *entity)
+{
+ this->entities.push_back(entity);
+
+ return entity;
+}
+
+GkGameEntity* GkGamePage::InsertEntity(int position, GkGameEntity *entity)
+{
+ this->entities.push_back(0);
+
+ for (int i = this->entities.size() - 1; i > position; i--)
+ this->entities[i] = this->entities[i - 1];
+
+ this->entities[position] = entity;
+
+ return entity;
+}
+
+bool GkGamePage::RemoveEntity(GkGameEntity *entity)
+{
+ int numEntities = this->entities.size();
+
+ for (int i = 0; i < numEntities; i++)
+ {
+ if (this->entities[i] == entity)
+ {
+ this->entities[i] = this->entities[numEntities - 1];
+ this->entities.pop_back();
+
+ return true;
+ }
+ }
+
+ return false;
+}
+
+void GkGamePage::Process(GkGame *game)
+{
+ int numEntities = this->entities.size();
+
+ for (int i = 0; i < numEntities; i++)
+ {
+ this->entities[i]->Process(game);
+ }
+}
+
+void GkGamePage::Render(GkGame *game)
+{
+ int numEntities = this->entities.size();
+
+ for (int i = 0; i < numEntities; i++)
+ {
+ this->entities[i]->Draw(game);
+ }
+}
diff --git a/COM380/Project5/GambleKit/Engine/Game/GkGamePage.h b/COM380/Project5/GambleKit/Engine/Game/GkGamePage.h
new file mode 100644
index 0000000..5ceca8f
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Game/GkGamePage.h
@@ -0,0 +1,28 @@
+#pragma once
+
+#include "..\GkDefinitions.h"
+
+#include
+
+#include "GkGameEntity.h"
+
+class GKDLLCLASS GkGame;
+
+class GKDLLCLASS GkGamePage
+{
+public:
+ std::vector entities;
+
+ GkGamePage::GkGamePage();
+ virtual GkGamePage::~GkGamePage(void);
+
+ virtual void OnShow(GkGamePage *previous);
+ virtual void OnHide(GkGamePage *next);
+
+ GkGameEntity* GkGamePage::AddEntity(GkGameEntity *entity);
+ GkGameEntity* GkGamePage::InsertEntity(int position, GkGameEntity *entity);
+ bool GkGamePage::RemoveEntity(GkGameEntity *entity);
+ virtual void GkGamePage::Process(GkGame *game);
+ virtual void GkGamePage::Render(GkGame *game);
+};
+
diff --git a/COM380/Project5/GambleKit/Engine/Game/GkGameReelModel.cpp b/COM380/Project5/GambleKit/Engine/Game/GkGameReelModel.cpp
new file mode 100644
index 0000000..9ac035d
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Game/GkGameReelModel.cpp
@@ -0,0 +1,29 @@
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+// GambleKit Copyright (C) 2014 Ivan Donev
+//
+// This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// contact: gamblekit@gmail.com
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+#include "GkGameReelModel.h"
+
+#include "..\OSSpecific\GkOSUtils.h"
+
+GkGameReelModel::GkGameReelModel(int numItems)
+{
+ this->numItems = numItems;
+ this->items = new int[this->numItems];
+
+ GkOSUtils::ZeroMem(this->items, this->numItems * sizeof(int));
+}
+
+
+GkGameReelModel::~GkGameReelModel(void)
+{
+ delete[] this->items;
+}
diff --git a/COM380/Project5/GambleKit/Engine/Game/GkGameReelModel.h b/COM380/Project5/GambleKit/Engine/Game/GkGameReelModel.h
new file mode 100644
index 0000000..6d5094f
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Game/GkGameReelModel.h
@@ -0,0 +1,18 @@
+#pragma once
+
+#include "..\GkDefinitions.h"
+
+class GKDLLCLASS GkGameReelModel
+{
+public:
+ int numItems;
+ int *items;
+
+ GkGameReelModel(int numItems);
+ virtual ~GkGameReelModel(void);
+
+ virtual int GetSymbol() = 0;
+ virtual void GenerateReel() = 0;
+ virtual void GenerateReelZero() = 0;
+};
+
diff --git a/COM380/Project5/GambleKit/Engine/Game/GkGameReelsCombinationGenerator.cpp b/COM380/Project5/GambleKit/Engine/Game/GkGameReelsCombinationGenerator.cpp
new file mode 100644
index 0000000..e47ca0e
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Game/GkGameReelsCombinationGenerator.cpp
@@ -0,0 +1,80 @@
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+// GambleKit Copyright (C) 2014 Ivan Donev
+//
+// This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// contact: gamblekit@gmail.com
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+#include "GkGameReelsCombinationGenerator.h"
+
+#include "..\Utils\GkMaths.h"
+
+GkGameReelsCombinationGenerator::GkGameReelsCombinationGenerator(int numReels, int numReelItems)
+ : GkBaseReelMap(numReels, numReelItems)
+{
+ this->reels = new GameReelsCombinationGeneratorReel[this->numReels];
+ for (int i = 0; i < this->numReels; i++)
+ {
+ this->reels[i].model = 0;
+ this->reels[i].blocked = false;
+ }
+}
+
+
+GkGameReelsCombinationGenerator::~GkGameReelsCombinationGenerator(void)
+{
+ for (int i = 0; i < this->numReels; i++)
+ {
+ if (this->reels[i].model != 0)
+ delete this->reels[i].model;
+ }
+
+ delete[] this->reels;
+}
+
+void GkGameReelsCombinationGenerator::SetReelModel(int reelIndex, GkGameReelModel *reelModel, bool blocked)
+{
+ this->reels[reelIndex].model = reelModel;
+ this->reels[reelIndex].blocked = blocked;
+}
+
+
+void GkGameReelsCombinationGenerator::GenerateReel(int reelIndex)
+{
+ this->reels[reelIndex].model->GenerateReel();
+
+ for (int itemIndex = 0; itemIndex < this->numReelItems; itemIndex++)
+ {
+ this->SetSymbol(reelIndex, itemIndex, this->reels[reelIndex].model->items[itemIndex]);
+ }
+}
+
+void GkGameReelsCombinationGenerator::GenerateCombination()
+{
+ for (int reelIndex = 0; reelIndex < this->numReels; reelIndex++)
+ {
+ if (!this->reels[reelIndex].blocked)
+ this->GenerateReel(reelIndex);
+ }
+}
+
+void GkGameReelsCombinationGenerator::GenerateCombinationZero()
+{
+ for (int reelIndex = 0; reelIndex < this->numReels; reelIndex++)
+ {
+ if (!this->reels[reelIndex].blocked)
+ {
+ this->reels[reelIndex].model->GenerateReelZero();
+
+ for (int itemIndex = 0; itemIndex < this->numReelItems; itemIndex++)
+ {
+ this->SetSymbol(reelIndex, itemIndex, this->reels[reelIndex].model->items[itemIndex]);
+ }
+ }
+ }
+}
diff --git a/COM380/Project5/GambleKit/Engine/Game/GkGameReelsCombinationGenerator.h b/COM380/Project5/GambleKit/Engine/Game/GkGameReelsCombinationGenerator.h
new file mode 100644
index 0000000..34e5093
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Game/GkGameReelsCombinationGenerator.h
@@ -0,0 +1,30 @@
+#pragma once
+
+#include "..\GkDefinitions.h"
+
+#include "..\Base\GkBaseReelMap.h"
+#include "GkGameReelModel.h"
+
+struct GameReelsCombinationGeneratorReel
+{
+ GkGameReelModel *model;
+ bool blocked;
+};
+
+class GKDLLCLASS GkGameReelsCombinationGenerator
+ : public GkBaseReelMap
+{
+public:
+
+ GameReelsCombinationGeneratorReel *reels;
+
+ GkGameReelsCombinationGenerator(int numReels, int numReelItems);
+ ~GkGameReelsCombinationGenerator(void);
+
+ void SetReelModel(int reelIndex, GkGameReelModel *reelModel, bool blocked = false);
+
+ void GenerateReel(int reelIndex);
+ void GenerateCombination();
+ void GenerateCombinationZero();
+};
+
diff --git a/COM380/Project5/GambleKit/Engine/Game/GkGameTimer.cpp b/COM380/Project5/GambleKit/Engine/Game/GkGameTimer.cpp
new file mode 100644
index 0000000..9dfbd14
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Game/GkGameTimer.cpp
@@ -0,0 +1,54 @@
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+// GambleKit Copyright (C) 2014 Ivan Donev
+//
+// This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// contact: gamblekit@gmail.com
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+#include "GkGameTimer.h"
+
+#include "..\OSSpecific\GkOSUtils.h"
+
+GkGameTimer::GkGameTimer(void)
+{
+ this->counterFrequency = GkOSUtils::GetPerformanceCounterFrequency();
+
+ this->Reset();
+}
+
+
+GkGameTimer::~GkGameTimer(void)
+{
+}
+
+void GkGameTimer::Reset()
+{
+ this->counterTime = GkOSUtils::GetPerformanceCounter();
+
+ this->Tick();
+}
+
+float GkGameTimer::Tick()
+{
+ long long newCounterTime = GkOSUtils::GetPerformanceCounter();
+
+ this->tickTime = (float)((double)(newCounterTime - this->counterTime) / (double)this->counterFrequency);
+ this->counterTime = newCounterTime;
+
+ return this->tickTime;
+}
+
+long long GkGameTimer::GetSample()
+{
+ return GkOSUtils::GetPerformanceCounter();
+}
+
+float GkGameTimer::GetSampleTime(long long sample)
+{
+ return (float)(((double)(GkGameTimer::GetSample() - sample)) / ((double)GkOSUtils::GetPerformanceCounterFrequency()));
+}
diff --git a/COM380/Project5/GambleKit/Engine/Game/GkGameTimer.h b/COM380/Project5/GambleKit/Engine/Game/GkGameTimer.h
new file mode 100644
index 0000000..e4b8ae5
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Game/GkGameTimer.h
@@ -0,0 +1,21 @@
+#pragma once
+
+#include "..\GkDefinitions.h"
+
+class GKDLLCLASS GkGameTimer
+{
+public:
+ long long counterTime, counterFrequency;
+
+ float tickTime;
+
+ GkGameTimer(void);
+ ~GkGameTimer(void);
+
+ void GkGameTimer::Reset();
+ float GkGameTimer::Tick();
+
+ static long long GetSample();
+ static float GetSampleTime(long long sample);
+};
+
diff --git a/COM380/Project5/GambleKit/Engine/Game/GkGameWinningPotentialsAnalyzer.cpp b/COM380/Project5/GambleKit/Engine/Game/GkGameWinningPotentialsAnalyzer.cpp
new file mode 100644
index 0000000..f70ac75
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Game/GkGameWinningPotentialsAnalyzer.cpp
@@ -0,0 +1,116 @@
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+// GambleKit Copyright (C) 2014 Ivan Donev
+//
+// This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// contact: gamblekit@gmail.com
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+#include "GkGameWinningPotentialsAnalyzer.h"
+
+GkGameWinningPotentialsAnalyzer::GkGameWinningPotentialsAnalyzer(GkGameWinningsModel *model)
+ : GkGameWinningsAnalyzer(model)
+{
+}
+
+
+GkGameWinningPotentialsAnalyzer::~GkGameWinningPotentialsAnalyzer(void)
+{
+}
+
+GameWinning GkGameWinningPotentialsAnalyzer::GetSymbolWinning(int symbolIndex, int lineIndex)
+{
+ GameWinning reelItem;
+ reelItem.symbolIndex = symbolIndex;
+ reelItem.lineIndex = lineIndex;
+ reelItem.numItems = 0;
+ reelItem.itemsStart = 0;
+
+ GameWinning result = reelItem;
+
+ GameWinningSymbolModel *symbolModel = this->model->GetSymbolModel(symbolIndex);
+
+ bool interrupted = false;
+ for (int reelIndex = 0; reelIndex < this->numReels; reelIndex++)
+ {
+ int reelSymbolIndex = this->GetLineSymbol(reelIndex, lineIndex);
+ GameWinningSymbolModel *reelSymbolModel = this->model->GetSymbolModel(reelSymbolIndex);
+
+ bool match = GkGameWinningsAnalyzer::SymbolsMatch(symbolIndex, reelSymbolIndex);
+ if (match || !interrupted)
+ {
+ if (reelItem.numItems == 0)
+ {
+ reelItem.itemsStart = reelIndex;
+ reelItem.symbolsFlags = GkGameWinningsModel::SymbolFlag_None;
+ }
+
+ reelItem.numItems++;
+ reelItem.symbolsFlags |= reelSymbolModel->flags;
+
+ if (reelItem.numItems > result.numItems)
+ {
+ result = reelItem;
+ }
+
+ if (!match)
+ interrupted = true;
+ }
+ else
+ {
+ if ((symbolModel->flags & GkGameWinningsModel::SymbolFlag_AnyPlace) == 0)
+ break;
+
+ reelItem.numItems = 0;
+
+ interrupted = false;
+ }
+ }
+
+ result.itemsEnd = result.itemsStart + result.numItems - 1;
+ result.winningCoefficient = this->model->GetSymbolCoefficient(result.symbolIndex, result.numItems);
+
+ return result;
+}
+
+GameWinning GkGameWinningPotentialsAnalyzer::GetScatterWinning(int symbolIndex)
+{
+ GameWinning result = GkGameWinningsAnalyzer::GetScatterWinning(symbolIndex);
+
+ if (result.numItems < this->numReels - 1)
+ {
+ result.numItems++;
+ result.winningCoefficient = this->model->GetSymbolCoefficient(result.symbolIndex, result.numItems);
+ }
+
+ return result;
+}
+
+bool GkGameWinningPotentialsAnalyzer::ReelBelongsToWinningAndSymbol(int reelIndex, int winningIndex)
+{
+ if (!GkGameWinningsAnalyzer::ReelBelongsToWinning(reelIndex, winningIndex))
+ return false;
+
+ return this->SymbolsMatch(this->winnings.win[winningIndex].symbolIndex, this->GetLineSymbol(reelIndex, this->winnings.win[winningIndex].lineIndex));
+}
+
+bool GkGameWinningPotentialsAnalyzer::ContainsActualWin(int winningIndex)
+{
+ if ((winningIndex < 0) || (winningIndex >= this->winnings.count))
+ return false;
+
+ int actualSequenceLength = 0;
+ for (int reelIndex = this->winnings.win[winningIndex].itemsStart; reelIndex <= this->winnings.win[winningIndex].itemsEnd; reelIndex++)
+ {
+ if (this->ReelBelongsToWinningAndSymbol(reelIndex, winningIndex))
+ actualSequenceLength++;
+ else
+ break;
+ }
+
+ return this->model->GetSymbolCoefficient(this->winnings.win[winningIndex].symbolIndex, actualSequenceLength) != 0;
+}
diff --git a/COM380/Project5/GambleKit/Engine/Game/GkGameWinningPotentialsAnalyzer.h b/COM380/Project5/GambleKit/Engine/Game/GkGameWinningPotentialsAnalyzer.h
new file mode 100644
index 0000000..35cb9e1
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Game/GkGameWinningPotentialsAnalyzer.h
@@ -0,0 +1,19 @@
+#pragma once
+
+#include "..\GkDefinitions.h"
+
+#include "GkGameWinningsAnalyzer.h"
+
+class GKDLLCLASS GkGameWinningPotentialsAnalyzer :
+ public GkGameWinningsAnalyzer
+{
+public:
+ GkGameWinningPotentialsAnalyzer(GkGameWinningsModel *model);
+ virtual ~GkGameWinningPotentialsAnalyzer(void);
+
+ virtual GameWinning GetSymbolWinning(int symbolIndex, int lineIndex);
+ virtual GameWinning GetScatterWinning(int symbolIndex);
+
+ bool ReelBelongsToWinningAndSymbol(int reelIndex, int winningIndex);
+ bool ContainsActualWin(int winningIndex);
+};
diff --git a/COM380/Project5/GambleKit/Engine/Game/GkGameWinningsAnalyzer.cpp b/COM380/Project5/GambleKit/Engine/Game/GkGameWinningsAnalyzer.cpp
new file mode 100644
index 0000000..9ec90f4
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Game/GkGameWinningsAnalyzer.cpp
@@ -0,0 +1,487 @@
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+// GambleKit Copyright (C) 2014 Ivan Donev
+//
+// This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// contact: gamblekit@gmail.com
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+#include "GkGameWinningsAnalyzer.h"
+
+#include "..\Utils\GkMaths.h"
+#include "..\OSSpecific\GkOSUtils.h"
+
+#include
+
+// Camparison of reel combinations - combinations may have
+// A. Exactly the same symbol wins as the compared - equal
+// B. The same symbol wins from the compared plus more - greater
+// C. Symbol wins from the compared, but not all or with less symbols - lesser
+// D. Not all the symbol wins from the compared plus more - different
+//
+// Rule set
+//
+// Definition: A symbol win is considered a winning of EXACTLY the same symbol and either on EXACTLY the same line OR BEING A SCATTER
+//
+// Signs of comparison:
+// 1.1 Contains all the symbol wins as the compared one
+// 1.2 Contains symbol wins, that are not present in the compared one
+//
+// In addition to that, there might be symbol win(s) with
+// 2.1 The same number of winning items
+// 2.2 Greater number of winning items
+// 2.3 Lesser number of winning items
+//
+// Result
+// Equal - 1.1 and not 1.2 and not 2.2. and not 2.3
+// Greater - 1.1. and (1.2 or 2.2) and not 2.3
+// Lesser - (not 1.1 or 2.3) and not 1.2 and not 2.2
+// Different - otherwise
+
+
+GkGameWinningsAnalyzer::GkGameWinningsAnalyzer(GkGameWinningsModel *model)
+ : GkBaseReelMap(model->numReels, model->numReelItems)
+{
+ this->model = model;
+
+ this->comparisonMode = GameWinningAnalyzerComparisonMode_FullComparison;
+
+ this->InitWinningData(&this->winnings);
+}
+
+GkGameWinningsAnalyzer::~GkGameWinningsAnalyzer(void)
+{
+ this->DisposeWinningData(&this->winnings);
+}
+
+GameWinning GkGameWinningsAnalyzer::GetSymbolWinning(int symbolIndex, int lineIndex)
+{
+ GameWinning reelItem;
+ reelItem.symbolIndex = symbolIndex;
+ reelItem.lineIndex = lineIndex;
+ reelItem.numItems = 0;
+ reelItem.itemsStart = 0;
+
+ GameWinning result = reelItem;
+
+ GameWinningSymbolModel *symbolModel = this->model->GetSymbolModel(symbolIndex);
+
+ bool sequenceValid = false;
+ for (int reelIndex = 0; reelIndex < this->numReels; reelIndex++)
+ {
+ int reelSymbolIndex = this->GetLineSymbol(reelIndex, lineIndex);
+ GameWinningSymbolModel *reelSymbolModel = this->model->GetSymbolModel(reelSymbolIndex);
+
+ if (this->SymbolsMatch(symbolIndex, reelSymbolIndex))
+ {
+ if (symbolIndex == reelSymbolIndex)
+ sequenceValid = true;
+
+ if (reelItem.numItems == 0)
+ {
+ reelItem.itemsStart = reelIndex;
+ reelItem.symbolsFlags = GkGameWinningsModel::SymbolFlag_None;
+ }
+
+ reelItem.numItems++;
+ reelItem.symbolsFlags |= reelSymbolModel->flags;
+
+ if (sequenceValid && (reelItem.numItems > result.numItems))
+ {
+ result = reelItem;
+ }
+ }
+ else
+ {
+ if ((symbolModel->flags & GkGameWinningsModel::SymbolFlag_AnyPlace) == 0)
+ break;
+
+ sequenceValid = false;
+ reelItem.numItems = 0;
+ }
+ }
+
+ result.itemsEnd = result.itemsStart + result.numItems - 1;
+ result.winningCoefficient = this->model->GetSymbolCoefficient(result.symbolIndex, result.numItems);
+
+ return result;
+}
+
+bool GkGameWinningsAnalyzer::SymbolsMatch(int symbolIndex, int testSymbolIndex)
+{
+ GameWinningSymbolModel *symbolModel = this->model->GetSymbolModel(symbolIndex),
+ *testSymbolModel = this->model->GetSymbolModel(testSymbolIndex);
+
+ return ((testSymbolIndex == symbolIndex) || ((testSymbolModel->flags & GkGameWinningsModel::SymbolFlag_Wild) != 0)) &&
+ ((testSymbolModel->flags & symbolModel->exclusionFlags) == 0);
+}
+
+GameWinning GkGameWinningsAnalyzer::GetScatterWinning(int symbolIndex)
+{
+ int scatterNumber = 0;
+ for (int symbolsIndex = 0; symbolsIndex < symbolsIndex; symbolsIndex++)
+ if (this->model->GetSymbolModel(symbolsIndex)->flags & GkGameWinningsModel::SymbolFlag_Scatter)
+ scatterNumber++;
+
+
+ GameWinning result;
+ result.symbolIndex = symbolIndex;
+ result.numItems = 0;
+ result.lineIndex = this->model->numLines + scatterNumber;
+
+ if (scatterNumber >= this->model->numScatters)
+ {
+ result.symbolsFlags = GkGameWinningsModel::SymbolFlag_None;
+ result.winningCoefficient = 0;
+ return result;
+ }
+
+ GameWinningSymbolModel *symbolModel = this->model->GetSymbolModel(symbolIndex);
+
+ for (int reelIndex = 0; reelIndex < this->numReels; reelIndex++)
+ {
+ this->model->lines[result.lineIndex].coordinates[reelIndex] = this->FindFirstSymbol(reelIndex, symbolIndex);
+ if (this->model->lines[result.lineIndex].coordinates[reelIndex] != -1)
+ {
+ if (result.numItems == 0)
+ result.itemsStart = reelIndex;
+
+ result.numItems++;
+ result.itemsEnd = reelIndex;
+ }
+ }
+
+ result.symbolsFlags = symbolModel->flags;
+ result.winningCoefficient = this->model->GetSymbolCoefficient(result.symbolIndex, result.numItems);
+
+ return result;
+}
+
+void GkGameWinningsAnalyzer::AnalyzeWinnings(GkBaseReelMap *reelMap)
+{
+ if (reelMap != 0)
+ this->SetItems(reelMap);
+
+ this->winnings.count = 0;
+
+ // Analyze line winnings
+ for (int lineIndex = 0; lineIndex < this->model->numLines; lineIndex++)
+ {
+ if (this->model->lines[lineIndex].active)
+ {
+ GameWinning maxLineWin;
+ maxLineWin.winningCoefficient = 0;
+
+ for (int symbolIndex = 0; symbolIndex < this->model->numSymbols; symbolIndex++)
+ {
+ if ((this->model->GetSymbolModel(symbolIndex)->flags & GkGameWinningsModel::SymbolFlag_Scatter) == 0)
+ {
+ GameWinning symbolWin = this->GetSymbolWinning(symbolIndex, lineIndex);
+ if (symbolWin.winningCoefficient != 0)
+ {
+ if ((maxLineWin.winningCoefficient == 0) ||
+ (this->model->CompareSymbolWinnning(symbolWin.symbolIndex, symbolWin.numItems, maxLineWin.symbolIndex, maxLineWin.numItems) > 0))
+ {
+ maxLineWin = symbolWin;
+ }
+ }
+ }
+ }
+
+ if (maxLineWin.winningCoefficient != 0)
+ {
+ this->winnings.win[this->winnings.count++] = maxLineWin;
+ }
+ }
+ }
+
+
+ // Analyze scatters
+ for (int symbolIndex = 0; symbolIndex < this->model->numSymbols; symbolIndex++)
+ {
+ if ((this->model->GetSymbolModel(symbolIndex)->flags & GkGameWinningsModel::SymbolFlag_Scatter) != 0)
+ {
+ GameWinning symbolWin = this->GetScatterWinning(symbolIndex);
+ if (symbolWin.winningCoefficient != 0)
+ {
+ this->winnings.win[this->winnings.count++] = symbolWin;
+ }
+ }
+ }
+
+
+ // Calculate total winnigs, total flags and manage items with SymbolFlag_IgnoreWinning
+ this->totalWinning = 0;
+ this->totalFlags = GkGameWinningsModel::SymbolFlag_None;
+ for (int i = 0; i < this->winnings.count; i++)
+ {
+ if (this->winnings.win[i].symbolsFlags & GkGameWinningsModel::SymbolFlag_IgnoreWinning)
+ this->winnings.win[i].winningCoefficient = 0;
+
+ this->totalWinning += this->winnings.win[i].winningCoefficient;
+ this->totalFlags |= this->winnings.win[i].symbolsFlags;
+ }
+
+ this->SortWinnings();
+}
+
+int GkGameWinningsAnalyzer::WinningOrder(int winningIndex1, int winningIndex2)
+{
+ bool win1End = (this->model->GetSymbolModel(this->winnings.win[winningIndex1].symbolIndex)->flags & GkGameWinningsModel::SymbolFlag_AtEnd) != 0;
+ bool win2End = (this->model->GetSymbolModel(this->winnings.win[winningIndex2].symbolIndex)->flags & GkGameWinningsModel::SymbolFlag_AtEnd) != 0;
+ if (win1End && !win2End)
+ return 1;
+
+ if (win2End && !win1End)
+ return -1;
+
+ return GkMaths::Sign(this->winnings.win[winningIndex1].lineIndex - this->winnings.win[winningIndex2].lineIndex);
+}
+
+int GkGameWinningsAnalyzer::CompareWinning(int winningIndex1, int winningIndex2)
+{
+ return GkMaths::Sign(this->winnings.win[winningIndex1].winningCoefficient - this->winnings.win[winningIndex2].winningCoefficient);
+}
+
+void GkGameWinningsAnalyzer::SortWinnings()
+{
+ for (int i = 0; i < this->winnings.count; i++)
+ {
+ int leadingWin = i;
+ for (int j = i + 1; j < this->winnings.count; j++)
+ {
+ if (this->WinningOrder(leadingWin, j) > 0)
+ leadingWin = j;
+ }
+
+ if (leadingWin != i)
+ {
+ GameWinning t = this->winnings.win[i];
+ this->winnings.win[i] = this->winnings.win[leadingWin];
+ this->winnings.win[leadingWin] = t;
+ }
+ }
+}
+
+void GkGameWinningsAnalyzer::MultiplyWinnings(int factor)
+{
+ for (int i = 0; i < this->winnings.count; i++)
+ this->winnings.win[i].winningCoefficient *= factor;
+ this->totalWinning *= factor;
+}
+
+int GkGameWinningsAnalyzer::GetLineSymbol(int reelIndex, int lineIndex)
+{
+ return this->GetSymbol(reelIndex, model->GetLineSymbolCoordinate(reelIndex, lineIndex));
+}
+
+int GkGameWinningsAnalyzer::FindWinning(int symbolIndex, int minSymbols)
+{
+ for (int i = 0; i < this->winnings.count; i++)
+ if ((this->winnings.win[i].symbolIndex == symbolIndex) && (this->winnings.win[i].numItems >= minSymbols))
+ return i;
+
+ return -1;
+}
+
+bool GkGameWinningsAnalyzer::ReelBelongsToWinning(int reelIndex, int winningIndex)
+{
+ if ((winningIndex < 0) || (winningIndex >= this->winnings.count))
+ return false;
+
+ if (this->winnings.win[winningIndex].symbolsFlags & GkGameWinningsModel::SymbolFlag_Scatter)
+ {
+ if (this->model->lines[this->winnings.win[winningIndex].lineIndex].coordinates[reelIndex] == -1)
+ return false;
+ }
+ else
+ {
+ if ((reelIndex < this->winnings.win[winningIndex].itemsStart) || (reelIndex > this->winnings.win[winningIndex].itemsStart + this->winnings.win[winningIndex].numItems - 1))
+ return false;
+ }
+
+ return true;
+}
+
+bool GkGameWinningsAnalyzer::ReelBelongsToAnyWinning(int reelIndex)
+{
+ for (int winningIndex = 0; winningIndex < this->winnings.count; winningIndex++)
+ if (this->ReelBelongsToWinning(reelIndex, winningIndex))
+ return true;
+
+ return false;
+}
+
+bool GkGameWinningsAnalyzer::ReelItemBelongsToWinning(int reelIndex, int itemIndex, int winningIndex)
+{
+ if (!this->ReelBelongsToWinning(reelIndex, winningIndex))
+ return false;
+
+ return this->model->lines[this->winnings.win[winningIndex].lineIndex].coordinates[reelIndex] == itemIndex;
+}
+
+bool GkGameWinningsAnalyzer::ReelItemBelongsToAnyWinning(int reelIndex, int itemIndex)
+{
+ for (int winningIndex = 0; winningIndex < this->winnings.count; winningIndex++)
+ if (this->ReelItemBelongsToWinning(reelIndex, itemIndex, winningIndex))
+ return true;
+
+ return false;
+}
+
+void GkGameWinningsAnalyzer::InitWinningData(GameWinnings *data)
+{
+ data->win = new GameWinning[this->model->numLines + this->model->numScatters];
+ data->count = 0;
+}
+
+void GkGameWinningsAnalyzer::DisposeWinningData(GameWinnings *data)
+{
+ delete[] data->win;
+ data->count = 0;
+}
+
+void GkGameWinningsAnalyzer::SaveWinningData(GameWinnings *destination)
+{
+ destination->count = this->winnings.count;
+ GkOSUtils::CopyMem(destination->win, this->winnings.win, sizeof(GameWinning) * this->winnings.count);
+}
+
+WinningDataComparisonResult GkGameWinningsAnalyzer::FindWinning(GameWinning *gameWinning)
+{
+ for (int i = 0; i < this->winnings.count; i++)
+ {
+ GameWinning *testedWinning = &this->winnings.win[i];
+
+ if ((testedWinning->symbolIndex == gameWinning->symbolIndex) &&
+ ((testedWinning->lineIndex == gameWinning->lineIndex) ||
+ ((testedWinning->symbolsFlags & GkGameWinningsModel::SymbolFlag_Scatter) != 0) ||
+ (this->comparisonMode == GameWinningAnalyzerComparisonMode_IgnoreLineMatching)))
+ {
+ if (testedWinning->numItems == gameWinning->numItems)
+ return WinningDataComparisonResult_Equivalent;
+
+ if (testedWinning->numItems < gameWinning->numItems)
+ return WinningDataComparisonResult_Lesser;
+
+ if (testedWinning->numItems > gameWinning->numItems)
+ return WinningDataComparisonResult_Greater;
+
+ }
+ }
+
+ return WinningDataComparisonResult_Different;
+}
+
+WinningDataComparisonResult GkGameWinningsAnalyzer::CompareWith(GameWinnings *data)
+{
+ bool containsLesserWin = false,
+ containsGreaterWin = false;
+
+ int numMatchingWins = 0;
+
+ for (int winIndex = 0; winIndex < data->count; winIndex++)
+ {
+ GameWinning *winning = &data->win[winIndex];
+
+ WinningDataComparisonResult camparedToData = this->FindWinning(winning);
+
+ if (camparedToData == WinningDataComparisonResult_Lesser)
+ containsLesserWin = true;
+
+ if (camparedToData == WinningDataComparisonResult_Greater)
+ containsGreaterWin = true;
+
+ if (camparedToData != WinningDataComparisonResult_Different)
+ numMatchingWins++;
+ }
+
+ bool containsAllDataWins = numMatchingWins == data->count,
+ containsOtherWins = numMatchingWins < this->winnings.count;
+
+ if (containsAllDataWins && !containsOtherWins && !containsLesserWin && !containsGreaterWin)
+ return WinningDataComparisonResult_Equivalent;
+
+ if (containsAllDataWins && (containsOtherWins || containsGreaterWin) && !containsLesserWin)
+ return WinningDataComparisonResult_Greater;
+
+ if ((!containsAllDataWins || containsLesserWin) && !containsOtherWins && !containsGreaterWin)
+ return WinningDataComparisonResult_Lesser;
+
+
+ return WinningDataComparisonResult_Different;
+}
+
+int GkGameWinningsAnalyzer::GetWinningReelsCount()
+{
+ int result = 0;
+
+ for (int reelIndex = 0; reelIndex < this->model->numReels; reelIndex++)
+ if (this->ReelBelongsToAnyWinning(reelIndex))
+ result++;
+
+ return result;
+}
+
+int GkGameWinningsAnalyzer::GetWinningReelsCount(int winningIndex, int startReel, int numReels)
+{
+ int result = 0;
+
+ if (numReels == -1)
+ numReels = this->model->numReels;
+
+ for (int reelIndex = startReel; reelIndex < startReel + numReels; reelIndex++)
+ if (this->ReelBelongsToWinning(reelIndex, winningIndex))
+ result++;
+
+ return result;
+}
+
+int GkGameWinningsAnalyzer::GetWinningItemReelIndex(int winningItemIndex)
+{
+ for (int reelIndex = 0; reelIndex < this->model->numReels; reelIndex++)
+ {
+ if (this->ReelBelongsToAnyWinning(reelIndex))
+ {
+ if (winningItemIndex == 0)
+ return reelIndex;
+
+ winningItemIndex--;
+ }
+ }
+
+ return -1;
+}
+
+int GkGameWinningsAnalyzer::GetWinningItemReelIndex(int winningItemIndex, int winningIndex)
+{
+ for (int reelIndex = 0; reelIndex < this->model->numReels; reelIndex++)
+ {
+ if (this->ReelBelongsToWinning(reelIndex, winningIndex))
+ {
+ if (winningItemIndex == 0)
+ return reelIndex;
+
+ winningItemIndex--;
+ }
+ }
+
+ return -1;
+}
+
+int GkGameWinningsAnalyzer::GetHighestWinning()
+{
+ if (this->winnings.count == 0)
+ return -1;
+
+ int result = 0;
+ for (int winIndex = 1; winIndex < this->winnings.count; winIndex++)
+ if (this->CompareWinning(winIndex, result) > 0)
+ result = winIndex;
+
+ return result;
+}
\ No newline at end of file
diff --git a/COM380/Project5/GambleKit/Engine/Game/GkGameWinningsAnalyzer.h b/COM380/Project5/GambleKit/Engine/Game/GkGameWinningsAnalyzer.h
new file mode 100644
index 0000000..b134d8d
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Game/GkGameWinningsAnalyzer.h
@@ -0,0 +1,80 @@
+#pragma once
+
+#include "..\GkDefinitions.h"
+
+#include "..\Base\GkBaseReelMap.h"
+#include "GkGameWinningsModel.h"
+
+struct GameWinning
+{
+ int lineIndex, symbolIndex,
+ itemsStart, itemsEnd, numItems,
+ winningCoefficient;
+
+ unsigned int symbolsFlags;
+};
+
+struct GameWinnings
+{
+ int count;
+ GameWinning *win;
+};
+
+enum WinningDataComparisonResult
+{
+ WinningDataComparisonResult_Different,
+ WinningDataComparisonResult_Equivalent,
+ WinningDataComparisonResult_Greater,
+ WinningDataComparisonResult_Lesser
+};
+
+enum GameWinningAnalyzerComparisonMode
+{
+ GameWinningAnalyzerComparisonMode_FullComparison,
+ GameWinningAnalyzerComparisonMode_IgnoreLineMatching,
+};
+
+class GKDLLCLASS GkGameWinningsAnalyzer
+ : public GkBaseReelMap
+{
+public:
+ GkGameWinningsModel *model;
+
+ GameWinnings winnings;
+ int totalWinning, totalFlags;
+
+ GameWinningAnalyzerComparisonMode comparisonMode;
+
+ GkGameWinningsAnalyzer(GkGameWinningsModel *model);
+ virtual ~GkGameWinningsAnalyzer(void);
+
+ virtual GameWinning GetSymbolWinning(int symbolIndex, int lineIndex);
+ virtual GameWinning GetScatterWinning(int symbolIndex);
+ virtual void AnalyzeWinnings(GkBaseReelMap *reelMap = 0);
+ virtual bool SymbolsMatch(int symbol1Index, int testSymbolIndex);
+ virtual int WinningOrder(int winningIndex1, int winningIndex2);
+ virtual int CompareWinning(int winningIndex1, int winningIndex2);
+
+ void SortWinnings();
+ void MultiplyWinnings(int factor);
+ int GetLineSymbol(int reelIndex, int lineIndex);
+
+ int FindWinning(int symbolIndex, int minSymbols = 0);
+ bool ReelBelongsToWinning(int reelIndex, int winningIndex);
+ bool ReelBelongsToAnyWinning(int reelIndex);
+ bool ReelItemBelongsToWinning(int reelIndex, int itemIndex, int winningIndex);
+ bool ReelItemBelongsToAnyWinning(int reelIndex, int itemIndex);
+ int GetWinningReelsCount();
+ int GetWinningReelsCount(int winningIndex, int startReel = 0, int numReels = -1);
+ int GetWinningItemReelIndex(int winningItemIndex);
+ int GetWinningItemReelIndex(int winningItemIndex, int winningIndex);
+ int GetHighestWinning();
+
+ void InitWinningData(GameWinnings *data);
+ void DisposeWinningData(GameWinnings *data);
+ void SaveWinningData(GameWinnings *destination);
+ bool IsLessOrEqualThan(GameWinnings *data);
+ WinningDataComparisonResult FindWinning(GameWinning *gameWinning);
+ WinningDataComparisonResult CompareWith(GameWinnings *data);
+};
+
diff --git a/COM380/Project5/GambleKit/Engine/Game/GkGameWinningsModel.cpp b/COM380/Project5/GambleKit/Engine/Game/GkGameWinningsModel.cpp
new file mode 100644
index 0000000..62c6618
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Game/GkGameWinningsModel.cpp
@@ -0,0 +1,124 @@
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+// GambleKit Copyright (C) 2014 Ivan Donev
+//
+// This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// contact: gamblekit@gmail.com
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+#include "GkGameWinningsModel.h"
+
+#include "..\OSSpecific\GkOSUtils.h"
+#include "..\Utils\GkMaths.h"
+
+GkGameWinningsModel::GkGameWinningsModel(int numReels, int numReelItems, int numLines, int numSymbols, int numScatters, int numChannels)
+{
+ this->numReels = numReels;
+ this->numReelItems = numReelItems;
+ this->numLines = numLines;
+ this->numSymbols = numSymbols;
+ this->numScatters = numScatters;
+ this->numChannels = numChannels;
+ this->selectedChannel = 0;
+
+ this->lines = new GameWinningLineModel[this->numLines + numScatters];
+ for (int i = 0; i < this->numLines + this->numScatters; i++)
+ {
+ this->lines[i].active = true;
+ this->lines[i].coordinates = new int[this->numReels];
+ GkOSUtils::ZeroMem(this->lines[i].coordinates, this->numReels * sizeof(int));
+ }
+
+ this->symbols = new GameWinningSymbolModel*[this->numChannels];
+ for (int channel = 0; channel < this->numChannels; channel++)
+ {
+ this->symbols[channel] = new GameWinningSymbolModel[this->numSymbols];
+ for (int symbol = 0; symbol < this->numSymbols; symbol++)
+ {
+ this->symbols[channel][symbol].coefficients = new int[this->numReels];
+ GkOSUtils::ZeroMem(this->symbols[channel][symbol].coefficients, this->numReels * sizeof(int));
+ }
+ }
+}
+
+GkGameWinningsModel::~GkGameWinningsModel(void)
+{
+ for (int channel = 0; channel < this->numChannels; channel++)
+ {
+ for (int symbol = 0; symbol < this->numSymbols; symbol++)
+ {
+ delete[] this->symbols[channel][symbol].coefficients;
+ }
+ delete[] this->symbols[channel];
+ }
+ delete[] this->symbols;
+
+ for (int i = 0; i < this->numLines + this->numScatters; i++)
+ {
+ delete[] this->lines[i].coordinates;
+ }
+ delete[] this->lines;
+}
+
+void GkGameWinningsModel::SetupLine(int lineIndex, ...)
+{
+ //GkOSUtils::CopyMem(this->lines[lineIndex], (void*)lineCoordinates, this->numReels * sizeof(int));
+
+ va_list lineCoordinates;
+ va_start(lineCoordinates, lineIndex);
+ for(int i = 0; i < this->numReels; ++i )
+ this->lines[lineIndex].coordinates[i] = va_arg(lineCoordinates, int);
+ va_end(lineCoordinates);
+}
+
+void GkGameWinningsModel::SetupSymbol(int symbolIndex, int channelIndex, unsigned int symbolFlags, unsigned int symbolExclusionFlags, ...)
+{
+ va_list winCoefficients;
+ va_start(winCoefficients, symbolExclusionFlags);
+ for(int i = 0; i < this->numReels; ++i )
+ {
+ this->symbols[channelIndex][symbolIndex].coefficients[i] = va_arg(winCoefficients, int);
+ }
+ va_end(winCoefficients);
+
+ this->symbols[channelIndex][symbolIndex].flags = symbolFlags;
+ this->symbols[channelIndex][symbolIndex].exclusionFlags = symbolExclusionFlags;
+}
+
+int GkGameWinningsModel::GetLineSymbolCoordinate(int reelIndex, int lineIndex)
+{
+ return this->lines[lineIndex].coordinates[reelIndex];
+}
+
+GameWinningSymbolModel *GkGameWinningsModel::GetSymbolModel(int symbol)
+{
+ return &this->symbols[this->selectedChannel][symbol];
+}
+
+int GkGameWinningsModel::GetSymbolCoefficient(int symbol, int symbolCount)
+{
+ if (symbolCount == 0)
+ return 0;
+
+ return this->symbols[this->selectedChannel][symbol].coefficients[symbolCount - 1];
+}
+
+int GkGameWinningsModel::CompareSymbolWinnning(int symbol1, int symbol1Count, int symbol2, int symbol2Count)
+{
+ int coefficientDelta = this->GetSymbolCoefficient(symbol1, symbol1Count) - this->GetSymbolCoefficient(symbol2, symbol2Count);
+ if (coefficientDelta != 0)
+ return GkMaths::Sign(coefficientDelta);
+
+ for (int numSymbols = GkMaths::Max(symbol1Count, symbol2Count); numSymbols <= this->numReels; numSymbols++)
+ {
+ coefficientDelta = this->GetSymbolCoefficient(symbol1, numSymbols) - this->GetSymbolCoefficient(symbol2, numSymbols);
+ if (coefficientDelta != 0)
+ return GkMaths::Sign(coefficientDelta);
+ }
+
+ return 0;
+}
diff --git a/COM380/Project5/GambleKit/Engine/Game/GkGameWinningsModel.h b/COM380/Project5/GambleKit/Engine/Game/GkGameWinningsModel.h
new file mode 100644
index 0000000..4c9d432
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Game/GkGameWinningsModel.h
@@ -0,0 +1,48 @@
+#pragma once
+
+#include "..\GkDefinitions.h"
+
+struct GameWinningLineModel
+{
+ bool active;
+ int *coordinates;
+};
+
+struct GameWinningSymbolModel
+{
+ unsigned int flags, exclusionFlags;
+ int *coefficients;
+};
+
+class GKDLLCLASS GkGameWinningsModel
+{
+public:
+ static const unsigned int SymbolFlag_None = 0,
+ SymbolFlag_Default = 1 << 0,
+ SymbolFlag_Wild = 1 << 1,
+ SymbolFlag_AnyPlace = 1 << 2, // Line sequence can start from anywhere, not only from the beginning of a line
+ SymbolFlag_IgnoreWinning = 1 << 3,
+ SymbolFlag_AtEnd = 1 << 4,
+ SymbolFlag_Scatter = 1 << 5, // If a symbol is Scatter, it has a line index of numLines and above, and its line's coordinates are set correspondingly on each CalculateWinnings()
+ SymbolFlag_Custom = 1 << 8; // For user - defined flags. User_Defined_Flag = SymbolFlag_Custom << UserFlag_Index
+
+ int numReels, numReelItems, numChannels, selectedChannel;
+
+ int numLines;
+ GameWinningLineModel *lines;
+
+ int numSymbols, numScatters;
+ GameWinningSymbolModel **symbols;
+
+ GkGameWinningsModel(int numReels, int numReelItems, int numLines, int numSymbols, int numScatters = 0, int numChannels = 1);
+ ~GkGameWinningsModel(void);
+
+ void SetupLine(int lineIndex, ...);
+ void SetupSymbol(int symbolIndex, int channelIndex, unsigned int symbolFlags, unsigned int symbolExclusionFlags, ...);
+
+ int GetLineSymbolCoordinate(int reelIndex, int lineIndex);
+ GameWinningSymbolModel *GetSymbolModel(int symbol);
+ int GetSymbolCoefficient(int symbol, int symbolCount);
+ int CompareSymbolWinnning(int symbol1, int symbol1Count, int symbol2, int symbol2Count);
+};
+
diff --git a/COM380/Project5/GambleKit/Engine/Game/ReelModels/GkGameReelRandomModel.cpp b/COM380/Project5/GambleKit/Engine/Game/ReelModels/GkGameReelRandomModel.cpp
new file mode 100644
index 0000000..9fa8a21
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Game/ReelModels/GkGameReelRandomModel.cpp
@@ -0,0 +1,117 @@
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+// GambleKit Copyright (C) 2014 Ivan Donev
+//
+// This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// contact: gamblekit@gmail.com
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+#include "GkGameReelRandomModel.h"
+
+#include "..\..\Utils\GkMaths.h"
+
+
+GkGameReelRandomModel::GkGameReelRandomModel(int numItems, int numSymbols)
+ :GkGameReelModel(numItems)
+{
+ this->numSymbols = numSymbols;
+ this->symbols = new GameReelRandomModelSymbol[numSymbols];
+
+ for (int i = 0; i < numSymbols; i++)
+ this->SetupSymbol(i, i);
+}
+
+
+GkGameReelRandomModel::~GkGameReelRandomModel(void)
+{
+ delete[] this->symbols;
+}
+
+
+void GkGameReelRandomModel::SetupSymbol(int symbolIndex, int symbolValue, int hitProbability, int maxHits)
+{
+ this->symbols[symbolIndex].value = symbolValue;
+ this->symbols[symbolIndex].hitProbability = hitProbability;
+ this->symbols[symbolIndex].maxHits = maxHits;
+
+ this->overallProbability = 0;
+ for (int i = 0; i < this->numSymbols; i++)
+ this->overallProbability += this->symbols[i].hitProbability;
+}
+
+bool GkGameReelRandomModel::ReplaceReelSymbol(int itemIndex, int symbolIndex, bool forceReplace)
+{
+ bool autoGenerate = symbolIndex == -1;
+
+ do
+ {
+ if (autoGenerate)
+ {
+ symbolIndex = this->GetSymbolIndex();
+ }
+
+ if ((this->symbols[symbolIndex].maxHits == GkGameReelRandomModel::UnlimitedHits) || (this->symbols[symbolIndex].occurances < this->symbols[symbolIndex].maxHits) || forceReplace)
+ {
+ this->symbols[this->items[itemIndex]].occurances--;
+ this->items[itemIndex] = symbolIndex;
+ this->symbols[symbolIndex].occurances++;
+ return true;
+ }
+ } while (autoGenerate);
+
+ return false;
+}
+
+int GkGameReelRandomModel::GetSymbolIndex()
+{
+ int p = GkMaths::Random(this->overallProbability);
+
+ int s = 0;
+ for (int i = 0; i < this->numSymbols; i++)
+ {
+ s += this->symbols[i].hitProbability;
+ if (p < s)
+ return i;
+ }
+
+ return -1;
+}
+
+int GkGameReelRandomModel::GetSymbol()
+{
+ int symbolIndex = this->GetSymbolIndex();
+ if (symbolIndex == -1)
+ return -1;
+ else
+ return this->symbols[symbolIndex].value;
+}
+
+void GkGameReelRandomModel::GenerateReel()
+{
+ for (int symbolIndex = 0; symbolIndex < this->numSymbols; symbolIndex++)
+ this->symbols[symbolIndex].occurances = 0;
+
+
+ for (int itemIndex = 0; itemIndex < this->numItems; itemIndex++)
+ {
+ for (;;)
+ {
+ int symbolIndex = this->GetSymbolIndex();
+ if ((this->symbols[symbolIndex].maxHits == GkGameReelRandomModel::UnlimitedHits) || (this->symbols[symbolIndex].occurances < this->symbols[symbolIndex].maxHits))
+ {
+ this->items[itemIndex] = this->symbols[symbolIndex].value;
+ this->symbols[symbolIndex].occurances++;
+ break;
+ }
+ }
+ }
+}
+
+void GkGameReelRandomModel::GenerateReelZero()
+{
+ this->GenerateReel();
+}
diff --git a/COM380/Project5/GambleKit/Engine/Game/ReelModels/GkGameReelRandomModel.h b/COM380/Project5/GambleKit/Engine/Game/ReelModels/GkGameReelRandomModel.h
new file mode 100644
index 0000000..a8cc951
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Game/ReelModels/GkGameReelRandomModel.h
@@ -0,0 +1,35 @@
+#pragma once
+
+#include "..\..\GkDefinitions.h"
+
+#include "..\GkGameReelModel.h"
+
+struct GameReelRandomModelSymbol
+{
+ int value, hitProbability, maxHits,
+ occurances;
+};
+
+class GKDLLCLASS GkGameReelRandomModel :
+ public GkGameReelModel
+{
+public:
+ static const int UnlimitedHits = -1;
+
+ int numSymbols;
+ GameReelRandomModelSymbol *symbols;
+
+ int overallProbability;
+
+ GkGameReelRandomModel(int numItems, int numSymbols);
+ ~GkGameReelRandomModel(void);
+
+ void SetupSymbol(int symbolIndex, int symbolValue, int hitProbability = 1, int maxHits = GkGameReelRandomModel::UnlimitedHits);
+ bool ReplaceReelSymbol(int itemIndex, int symbolIndex, bool forceReplace);
+ int GetSymbolIndex();
+
+ int GetSymbol();
+ void GenerateReel();
+ void GenerateReelZero();
+};
+
diff --git a/COM380/Project5/GambleKit/Engine/Game/ReelModels/GkGameReelStripModel.cpp b/COM380/Project5/GambleKit/Engine/Game/ReelModels/GkGameReelStripModel.cpp
new file mode 100644
index 0000000..574ce79
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Game/ReelModels/GkGameReelStripModel.cpp
@@ -0,0 +1,61 @@
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+// GambleKit Copyright (C) 2014 Ivan Donev
+//
+// This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// contact: gamblekit@gmail.com
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+#include "GkGameReelStripModel.h"
+
+#include "..\..\OSSpecific\GkOSUtils.h"
+#include "..\..\Utils\GkMaths.h"
+
+GkGameReelStripModel::GkGameReelStripModel(int numItems, int numSymbols, ...)
+ : GkGameReelModel(numItems)
+{
+ this->numSymbols = numSymbols;
+ this->symbolStrip = new int[this->numSymbols];
+
+ int *parameters = (int*)((int)&numSymbols + 4);
+ for (int i = 0; i < this->numSymbols; i++)
+ this->symbolStrip[i] = parameters[i];
+
+ this->stripPosition = GkMaths::Random(this->numSymbols);
+}
+
+
+GkGameReelStripModel::~GkGameReelStripModel(void)
+{
+ delete[] this->symbolStrip;
+}
+
+int GkGameReelStripModel::GetSymbol()
+{
+ this->stripPosition = (this->stripPosition + 1) % this->numSymbols;
+ return this->symbolStrip[this->stripPosition];
+}
+
+void GkGameReelStripModel::GenerateReel()
+{
+ this->stripPosition = GkMaths::Random(this->numSymbols);
+
+ for (int itemIndex = 0; itemIndex < this->numItems; itemIndex++)
+ {
+ this->items[itemIndex] = this->GetSymbol();
+ }
+}
+
+void GkGameReelStripModel::GenerateReelZero()
+{
+ this->stripPosition = this->numSymbols - this->numItems / 2;
+
+ for (int itemIndex = 0; itemIndex < this->numItems; itemIndex++)
+ {
+ this->items[itemIndex] = this->GetSymbol();
+ }
+}
\ No newline at end of file
diff --git a/COM380/Project5/GambleKit/Engine/Game/ReelModels/GkGameReelStripModel.h b/COM380/Project5/GambleKit/Engine/Game/ReelModels/GkGameReelStripModel.h
new file mode 100644
index 0000000..f610854
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Game/ReelModels/GkGameReelStripModel.h
@@ -0,0 +1,21 @@
+#pragma once
+
+#include "..\..\GkDefinitions.h"
+
+#include "..\GkGameReelModel.h"
+
+class GKDLLCLASS GkGameReelStripModel :
+ public GkGameReelModel
+{
+public:
+ int numSymbols;
+ int *symbolStrip;
+ int stripPosition;
+
+ GkGameReelStripModel(int numItems, int numSymbols, ...);
+ ~GkGameReelStripModel(void);
+
+ int GetSymbol();
+ void GenerateReel();
+ void GenerateReelZero();
+};
diff --git a/COM380/Project5/GambleKit/Engine/GkDefinitions.h b/COM380/Project5/GambleKit/Engine/GkDefinitions.h
new file mode 100644
index 0000000..182ea8a
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/GkDefinitions.h
@@ -0,0 +1,12 @@
+#pragma once
+
+//#if defined (GKDLLCOMPILE)
+//# define GKDLLCLASS __declspec(dllexport)
+//# define GKDLLTEMPLATEMEMBER
+//#else
+//# define GKDLLCLASS __declspec(dllimport)
+//# define GKDLLTEMPLATEMEMBER extern
+//#endif
+
+# define GKDLLCLASS
+# define GKDLLTEMPLATEMEMBER
diff --git a/COM380/Project5/GambleKit/Engine/Graphics/GkAnimatedFont.cpp b/COM380/Project5/GambleKit/Engine/Graphics/GkAnimatedFont.cpp
new file mode 100644
index 0000000..35316b4
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Graphics/GkAnimatedFont.cpp
@@ -0,0 +1,50 @@
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+// GambleKit Copyright (C) 2014 Ivan Donev
+//
+// This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// contact: gamblekit@gmail.com
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+#include "GkAnimatedFont.h"
+
+#include "..\Utils\GkStrings.h"
+
+
+GkAnimatedFont::GkAnimatedFont(const wchar_t *charMap, int numFrames, float framesPerSecond)
+{
+ this->charMap = GkStrings::Copy(charMap);
+ this->numFrames = numFrames;
+ this->numLetters = GkStrings::GetLength(charMap);
+ this->framesPerSecond = framesPerSecond;
+
+ this->letterTextures = new GkAnimatedTexture*[this->numLetters];
+ for (int i = 0; i < this->numLetters; i++)
+ {
+ this->letterTextures[i] = 0;
+ }
+}
+
+
+GkAnimatedFont::~GkAnimatedFont(void)
+{
+ delete[] this->charMap;
+
+ for (int i = 0; i < this->numLetters; i++)
+ {
+ delete this->letterTextures[i];
+ }
+ delete[] this->letterTextures;
+}
+
+void GkAnimatedFont::LoadAnimatedLetter(int letterIndex, void *data, int dataSize)
+{
+ if (this->letterTextures[letterIndex] != 0)
+ delete this->letterTextures[letterIndex];
+
+ this->letterTextures[letterIndex] = new GkAnimatedTexture(data, dataSize, 1, this->numFrames, this->numFrames);
+}
diff --git a/COM380/Project5/GambleKit/Engine/Graphics/GkAnimatedFont.h b/COM380/Project5/GambleKit/Engine/Graphics/GkAnimatedFont.h
new file mode 100644
index 0000000..2792df3
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Graphics/GkAnimatedFont.h
@@ -0,0 +1,24 @@
+#pragma once
+
+#include "..\GkDefinitions.h"
+
+#include "..\Base\GkBase.h"
+#include "GkAnimatedTexture.h"
+
+class GKDLLCLASS GkAnimatedFont :
+ public GkBase
+{
+public:
+ wchar_t *charMap;
+ int numLetters, numFrames;
+
+ float framesPerSecond;
+
+ GkAnimatedTexture **letterTextures;
+
+ GkAnimatedFont::GkAnimatedFont(const wchar_t *charMap, int numFrames, float framesPerSecond = 25.0f);
+ GkAnimatedFont::~GkAnimatedFont(void);
+
+ void GkAnimatedFont::LoadAnimatedLetter(int letterIndex, void *data, int dataSize);
+};
+
diff --git a/COM380/Project5/GambleKit/Engine/Graphics/GkAnimatedTexture.cpp b/COM380/Project5/GambleKit/Engine/Graphics/GkAnimatedTexture.cpp
new file mode 100644
index 0000000..bffd7f2
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Graphics/GkAnimatedTexture.cpp
@@ -0,0 +1,123 @@
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+// GambleKit Copyright (C) 2014 Ivan Donev
+//
+// This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// contact: gamblekit@gmail.com
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+#include "GkAnimatedTexture.h"
+
+GkAnimatedTexture::GkAnimatedTexture(void)
+{
+ this->numFrames = 0;
+}
+
+GkAnimatedTexture::GkAnimatedTexture(void* data, unsigned int dataSize, int columnFrames, int rowFrames, int numFrames, float framesPerSecond, int animatedTexture_LoadOrder)
+{
+ this->numFrames = 0;
+
+ this->LoadFromMemory(data, dataSize, columnFrames, rowFrames, numFrames, framesPerSecond, animatedTexture_LoadOrder);
+}
+
+GkAnimatedTexture::GkAnimatedTexture(char *fileName, int columnFrames, int rowFrames, int numFrames, float framesPerSecond, int animatedTexture_LoadOrder)
+{
+ this->numFrames = 0;
+
+ this->LoadFromFile(fileName, columnFrames, rowFrames, numFrames, framesPerSecond, animatedTexture_LoadOrder);
+}
+
+GkAnimatedTexture::~GkAnimatedTexture(void)
+{
+ this->Free();
+}
+
+void GkAnimatedTexture::Free()
+{
+ if (this->numFrames == 0)
+ return;
+
+ for (int i = 0; i < this->numFrames; i++)
+ {
+ delete this->frames[i];
+ }
+
+ delete this->frames;
+
+ this->numFrames = 0;
+}
+
+bool GkAnimatedTexture::LoadFromImage(GkImage *image, int columnFrames, int rowFrames, int numFrames, float framesPerSecond, int animatedTexture_LoadOrder)
+{
+ this->Free();
+
+ this->numFrames = numFrames != 0 ? numFrames : columnFrames * rowFrames;
+ this->framesPerSecond = framesPerSecond;
+
+ this->frames = new GkTexture*[this->numFrames];
+
+ int frameWidth = image->width / columnFrames;
+ int frameHeight = image->height / rowFrames;
+
+ int iMax, jMax;
+ if (animatedTexture_LoadOrder == GkAnimatedTexture::LoadOrder_Vertical)
+ {
+ jMax = columnFrames;
+ iMax = rowFrames;
+ }
+ else
+ {
+ jMax = rowFrames;
+ iMax = columnFrames;
+ }
+
+ int frameIndex = 0;
+ for (int j = 0; j < jMax; j++)
+ {
+ for (int i = 0; i < iMax; i++)
+ {
+ int x, y;
+ if (animatedTexture_LoadOrder == GkAnimatedTexture::LoadOrder_Vertical)
+ {
+ x = j;
+ y = i;
+ }
+ else
+ {
+ x = i;
+ y = j;
+ }
+
+ GkTexture *frame = new GkTexture();
+ frame->LoadFromImage(image, x * frameWidth, y * frameHeight, frameWidth, frameHeight);
+
+ frames[frameIndex++] = frame;
+ }
+ }
+
+ return true;
+}
+
+bool GkAnimatedTexture::LoadFromMemory(void* data, unsigned int dataSize, int columnFrames, int rowFrames, int numFrames, float framesPerSecond, int animatedTexture_LoadOrder)
+{
+ GkImage image;
+ image.LoadFromMemory(data, dataSize);
+
+ this->LoadFromImage(&image, columnFrames, rowFrames, numFrames, framesPerSecond, animatedTexture_LoadOrder);
+
+ return true;
+}
+
+bool GkAnimatedTexture::LoadFromFile(char *fileName, int columnFrames, int rowFrames, int numFrames, float framesPerSecond, int animatedTexture_LoadOrder)
+{
+ GkImage image;
+ image.LoadFromFile(fileName);
+
+ this->LoadFromImage(&image, columnFrames, rowFrames, numFrames, framesPerSecond, animatedTexture_LoadOrder);
+
+ return true;
+}
\ No newline at end of file
diff --git a/COM380/Project5/GambleKit/Engine/Graphics/GkAnimatedTexture.h b/COM380/Project5/GambleKit/Engine/Graphics/GkAnimatedTexture.h
new file mode 100644
index 0000000..ad8f1e4
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Graphics/GkAnimatedTexture.h
@@ -0,0 +1,29 @@
+#pragma once
+
+#include "..\GkDefinitions.h"
+
+#include "..\Base\GkBase.h"
+#include "GkTexture.h"
+
+class GKDLLCLASS GkAnimatedTexture :
+ public GkBase
+{
+public:
+ static const int LoadOrder_Horizontal = 0,
+ LoadOrder_Vertical = 1;
+
+ GkTexture **frames;
+ int numFrames;
+ float framesPerSecond;
+
+ GkAnimatedTexture::GkAnimatedTexture(void);
+ GkAnimatedTexture::GkAnimatedTexture(void* data, unsigned int dataSize, int columnFrames = 1, int rowFrames = 1, int numFrames = 0, float framesPerSecond = 25.0f, int animatedTexture_LoadOrder = GkAnimatedTexture::LoadOrder_Horizontal);
+ GkAnimatedTexture::GkAnimatedTexture(char *fileName, int columnFrames = 1, int rowFrames = 1, int numFrames = 0, float framesPerSecond = 25.0f, int animatedTexture_LoadOrder = GkAnimatedTexture::LoadOrder_Horizontal);
+ GkAnimatedTexture::~GkAnimatedTexture(void);
+
+ void GkAnimatedTexture::Free();
+ bool GkAnimatedTexture::LoadFromImage(GkImage *image, int columnFrames = 1, int rowFrames = 1, int numFrames = 0, float framesPerSecond = 25.0f, int animatedTexture_LoadOrder = GkAnimatedTexture::LoadOrder_Horizontal);
+ bool GkAnimatedTexture::LoadFromMemory(void* data, unsigned int dataSize, int columnFrames = 1, int rowFrames = 1, int numFrames = 0, float framesPerSecond = 25.0f, int animatedTexture_LoadOrder = GkAnimatedTexture::LoadOrder_Horizontal);
+ bool GkAnimatedTexture::LoadFromFile(char *fileName, int columnFrames = 1, int rowFrames = 1, int numFrames = 0, float framesPerSecond = 25.0f, int animatedTexture_LoadOrder = GkAnimatedTexture::LoadOrder_Horizontal);
+};
+
diff --git a/COM380/Project5/GambleKit/Engine/Graphics/GkGraphicsDevice.cpp b/COM380/Project5/GambleKit/Engine/Graphics/GkGraphicsDevice.cpp
new file mode 100644
index 0000000..22082e2
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Graphics/GkGraphicsDevice.cpp
@@ -0,0 +1,197 @@
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+// GambleKit Copyright (C) 2014 Ivan Donev
+//
+// This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// contact: gamblekit@gmail.com
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+#include "GkGraphicsDevice.h"
+
+#include "..\Utils\GkMaths.h"
+
+#include
+
+#include
+#include
+
+void GkGraphicsDevice::Initialize()
+{
+}
+
+GkGraphicsDevice::GkGraphicsDevice(void)
+{
+ this->SetViewport(0, 0, 640, 480);
+
+ glDisable(GL_LIGHTING);
+ glDisable(GL_DEPTH_TEST);
+
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
+ glEnable(GL_TEXTURE_2D);
+
+ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, GL_REPLACE);
+ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
+
+ glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
+
+ glGetIntegerv(GL_MAX_TEXTURE_SIZE, &this->maxTextureSize);
+ this->nonPower2Textures = strstr((char*)glGetString(GL_EXTENSIONS),"GL_ARB_texture_non_power_of_two") != 0;
+
+ GkTexture::powerOfTwo = !this->nonPower2Textures;
+}
+
+
+GkGraphicsDevice::~GkGraphicsDevice(void)
+{
+}
+
+
+void GkGraphicsDevice::Clear()
+{
+ glClear(GL_COLOR_BUFFER_BIT);
+}
+
+void GkGraphicsDevice::Draw(int destX, int destY, int destWidth, int destHeight, int srcX, int srcY, int srcWidth, int srcHeight, GkTexture* texture)
+{
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(0, this->width, this->height, 0, 1, -1);
+
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+ glTranslatef(destX, destY, 0);
+ glScalef(destWidth, destHeight, 1);
+
+ glMatrixMode(GL_TEXTURE);
+ glLoadIdentity();
+ glTranslatef(srcX / (float)texture->textureWidth, srcY / (float)texture->textureHeight, 0.0f);
+ glScalef(srcWidth / (float)texture->textureWidth, srcHeight / (float)texture->textureHeight, 1.0f);
+
+ glBindTexture(GL_TEXTURE_2D, texture->handle);
+
+ GLint filtering = (destWidth != srcWidth) || (destHeight != srcHeight) ? GL_LINEAR : GL_NEAREST;
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filtering);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filtering);
+
+ glBegin(GL_TRIANGLES);
+
+ glTexCoord2f(0.0f, 0.0f);
+ glVertex3f(0.0f, 0.0f, 0.0f);
+
+ glTexCoord2f(0.0f, 1.0f);
+ glVertex3f(0.0f, 1.0f, 0.0f);
+
+ glTexCoord2f(1.0f, 1.0f);
+ glVertex3f(1.0f, 1.0f, 0.0f);
+
+
+ glTexCoord2f(0.0f, 0.0f);
+ glVertex3f(0.0f, 0.0f, 0.0f);
+
+ glTexCoord2f(1.0f, 1.0f);
+ glVertex3f(1.0f, 1.0f, 0.0f);
+
+ glTexCoord2f(1.0f, 0.0f);
+ glVertex3f(1.0f, 0.0f, 0.0f);
+
+ glEnd();
+}
+
+void GkGraphicsDevice::Draw(int x, int y, GkTexture* texture)
+{
+ this->Draw(x, y, texture->width, texture->height, 0, 0, texture->width, texture->height, texture);
+}
+
+void GkGraphicsDevice::DrawClipped(int x, int y, int clipX, int clipY, int clipWidth, int clipHeight, GkTexture* texture)
+{
+ int clipLeft = clipX - x;
+ int clipTop = clipY - y;
+
+ int destX = clipLeft > 0 ? clipX : x;
+ int destY = clipTop > 0 ? clipY : y;
+ int width = GkMaths::Min(texture->width - GkMaths::Max(clipLeft, 0), GkMaths::Min(clipX + clipWidth - destX, texture->width));
+ int height = GkMaths::Min(texture->height - GkMaths::Max(clipTop, 0), GkMaths::Min(clipY + clipHeight - destY, texture->height));
+
+ if ((width <= 0) || (height <= 0))
+ return;
+
+ int srcX = clipLeft > 0 ? clipLeft : 0;
+ int srcY = clipTop > 0 ? clipTop : 0;
+
+ this->Draw(destX, destY, width, height, srcX, srcY, width, height, texture);
+}
+
+void GkGraphicsDevice::DrawString(int x, int y, const char *text)
+{
+
+
+ glLoadIdentity();
+ glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
+ glRasterPos2i(x, y);
+
+ glDisable(GL_TEXTURE_2D);
+
+ for (int i = 0; text[i] != 0; i++)
+ glutBitmapCharacter(GLUT_BITMAP_9_BY_15, text[i]);
+}
+
+void GkGraphicsDevice::DrawString(int x, int y, const wchar_t *text)
+{
+ glLoadIdentity();
+ glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
+ glRasterPos2i(x, y);
+
+ glDisable(GL_TEXTURE_2D);
+
+ for (int i = 0; text[i] != 0; i++)
+ glutBitmapCharacter(GLUT_BITMAP_9_BY_15, text[i]);
+
+ glEnable(GL_TEXTURE_2D);
+}
+
+void GkGraphicsDevice::SetViewport(int x, int y, int width, int height)
+{
+ this->width = width;
+ this->height = height;
+
+ glViewport(x, y, width, height);
+
+ glEnable(GL_TEXTURE_2D);
+}
+
+bool GkGraphicsDevice::CaptureScreen(const wchar_t *fileName, int width, int height)
+{
+ int length = std::wcslen(fileName);
+ char *cFileName = new char[length + 1];
+ std::wcstombs(cFileName, fileName, length);
+ cFileName[length] = 0;
+
+ int dataSize = this->width * this->height * 4;
+ char *data = new char[dataSize];
+
+ glReadPixels(0, 0, this->width, this->height, GL_RGBA, GL_UNSIGNED_BYTE, data);
+
+ ILuint imageId;
+ ilGenImages(1, &imageId);
+ ilBindImage(imageId);
+ ilTexImage(this->width, this->height, 1, 4, IL_RGBA, IL_UNSIGNED_BYTE, data);
+ iluImageParameter(ILU_FILTER, ILU_BILINEAR);
+ iluScale(width, height, 1);
+ ilSetInteger(IL_JPG_QUALITY, 50);
+ ilEnable(IL_FILE_OVERWRITE);
+ bool result = ilSaveImage(cFileName) != 0;
+ ilDeleteImages(1, &imageId);
+
+ delete[] data;
+ delete[] cFileName;
+
+ return result;
+}
diff --git a/COM380/Project5/GambleKit/Engine/Graphics/GkGraphicsDevice.h b/COM380/Project5/GambleKit/Engine/Graphics/GkGraphicsDevice.h
new file mode 100644
index 0000000..1eabfd6
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Graphics/GkGraphicsDevice.h
@@ -0,0 +1,32 @@
+#pragma once
+
+#include "..\GkDefinitions.h"
+
+#include "GkTexture.h"
+
+class GKDLLCLASS GkGraphicsDevice
+{
+public:
+
+ static void Initialize();
+
+ int maxTextureSize;
+ bool nonPower2Textures;
+
+ int width, height;
+
+ GkGraphicsDevice(void);
+ ~GkGraphicsDevice(void);
+
+ void Free();
+ void Clear();
+
+ void Draw(int destX, int destY, int destWidth, int destHeight, int srcX, int srcY, int srcWidth, int srcHeight, GkTexture* texture);
+ void Draw(int x, int y, GkTexture* texture);
+ void DrawClipped(int x, int y, int clipX, int clipY, int clipWidth, int clipHeight, GkTexture* texture);
+ void DrawString(int x, int y, const char *text);
+ void DrawString(int x, int y, const wchar_t *text);
+ void SetViewport(int x, int y, int width, int height);
+
+ bool CaptureScreen(const wchar_t *fileName, int width, int height);
+};
\ No newline at end of file
diff --git a/COM380/Project5/GambleKit/Engine/Graphics/GkImage.cpp b/COM380/Project5/GambleKit/Engine/Graphics/GkImage.cpp
new file mode 100644
index 0000000..1e79a12
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Graphics/GkImage.cpp
@@ -0,0 +1,69 @@
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+// GambleKit Copyright (C) 2014 Ivan Donev
+//
+// This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// contact: gamblekit@gmail.com
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+#include "GkImage.h"
+
+void GkImage::Initialize()
+{
+ ilInit();
+}
+
+GkImage::GkImage(void)
+{
+ ilGenImages(1, &this->handle);
+}
+
+
+GkImage::~GkImage(void)
+{
+ ilDeleteImages(1, &this->handle);
+}
+
+void GkImage::LoadFromMemory(void* data, unsigned int dataSize)
+{
+ ilBindImage(this->handle);
+
+ ilLoadL(IL_TYPE_UNKNOWN, data, dataSize);
+ this->width = ilGetInteger(IL_IMAGE_WIDTH);
+ this->height = ilGetInteger(IL_IMAGE_HEIGHT);
+}
+
+void GkImage::LoadFromFile(char* fileName)
+{
+ ilBindImage(this->handle);
+
+ ilLoadImage(fileName);
+ this->width = ilGetInteger(IL_IMAGE_WIDTH);
+ this->height = ilGetInteger(IL_IMAGE_HEIGHT);
+}
+
+void GkImage::CopyPixels(void* dest)
+{
+ ilBindImage(this->handle);
+ ilCopyPixels(0, 0, 0, this->width, this->height, 1, IL_RGBA, IL_UNSIGNED_BYTE, dest);
+}
+
+void GkImage::CopyPixels(void* dest, int x, int y, int width, int height)
+{
+ ilBindImage(this->handle);
+ ilCopyPixels(x, y, 0, width, height, 1, IL_RGBA, IL_UNSIGNED_BYTE, dest);
+}
+
+void GkImage::CopyPixels(void* dest, int x, int y, int width, int height, int destX, int destY, int destWidth, int destHeight)
+{
+ ilBindImage(this->handle);
+
+ for (int i = 0; i < height; i++)
+ {
+ ilCopyPixels(x, y + i, 0, width, 1, 1, IL_RGBA, IL_UNSIGNED_BYTE, (void*)(&((int*)dest)[(destY + i) * destWidth + destX]));
+ }
+}
diff --git a/COM380/Project5/GambleKit/Engine/Graphics/GkImage.h b/COM380/Project5/GambleKit/Engine/Graphics/GkImage.h
new file mode 100644
index 0000000..08c7018
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Graphics/GkImage.h
@@ -0,0 +1,24 @@
+#pragma once
+
+#include "..\GkDefinitions.h"
+
+#include
+#include
+
+class GKDLLCLASS GkImage
+{
+public:
+ ILuint handle,
+ width, height;
+
+ static void GkImage::Initialize();
+
+ GkImage::GkImage(void);
+ GkImage::~GkImage(void);
+
+ void GkImage::LoadFromMemory(void* data, unsigned int dataSize);
+ void GkImage::LoadFromFile(char* fileName);
+ void GkImage::CopyPixels(void* dest);
+ void GkImage::CopyPixels(void* dest, int x, int y, int width, int height);
+ void GkImage::CopyPixels(void* dest, int x, int y, int width, int height, int destX, int destY, int destWidth, int destHeight);
+};
\ No newline at end of file
diff --git a/COM380/Project5/GambleKit/Engine/Graphics/GkTexture.cpp b/COM380/Project5/GambleKit/Engine/Graphics/GkTexture.cpp
new file mode 100644
index 0000000..63530a9
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Graphics/GkTexture.cpp
@@ -0,0 +1,87 @@
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+// GambleKit Copyright (C) 2014 Ivan Donev
+//
+// This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// contact: gamblekit@gmail.com
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+#include "GkTexture.h"
+
+#include
+
+bool GkTexture::powerOfTwo = false;
+
+GkTexture::GkTexture(void)
+{
+ glGenTextures(1, &handle);
+
+ glBindTexture(GL_TEXTURE_2D, this->handle);
+
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
+}
+
+GkTexture::~GkTexture(void)
+{
+ glDeleteTextures(1, &handle);
+}
+
+void GkTexture::LoadFromImage(GkImage* image)
+{
+ this->LoadFromImage(image, 0, 0, image->width, image->height);
+}
+
+void GkTexture::LoadFromImage(GkImage* image, int x, int y, int width, int height)
+{
+ if (GkTexture::powerOfTwo)
+ {
+ this->textureWidth = GkTexture::GetPowerOfTwo(width);
+ this->textureHeight = GkTexture::GetPowerOfTwo(height);
+ }
+ else
+ {
+ this->textureWidth = width;
+ this->textureHeight = height;
+ }
+
+ this->width = width;
+ this->height = height;
+
+ void *imageData = new char[this->textureWidth * this->textureHeight * 4];
+
+ if (this->width != this->textureWidth)
+ image->CopyPixels(imageData, x, y, width, height, 0, 0, this->textureWidth, this->textureHeight);
+ else
+ image->CopyPixels(imageData, x, y, width, height);
+
+ glBindTexture(GL_TEXTURE_2D, this->handle);
+ //glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, this->textureWidth, this->textureHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, imageData);
+
+ delete imageData;
+}
+
+void GkTexture::LoadFromFile(char* fileName)
+{
+ GkImage* image = new GkImage();
+ image->LoadFromFile(fileName);
+ this->LoadFromImage(image);
+ delete image;
+}
+
+int GkTexture::GetPowerOfTwo(int value)
+{
+ int result = 1;
+ while (result < value)
+ result *= 2;
+
+ return result;
+}
\ No newline at end of file
diff --git a/COM380/Project5/GambleKit/Engine/Graphics/GkTexture.h b/COM380/Project5/GambleKit/Engine/Graphics/GkTexture.h
new file mode 100644
index 0000000..de21089
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Graphics/GkTexture.h
@@ -0,0 +1,27 @@
+#pragma once
+
+#include "..\GkDefinitions.h"
+
+#include "GkImage.h"
+#include "..\Base\GkBase.h"
+
+class GKDLLCLASS GkTexture :
+ public GkBase
+{
+public:
+ static bool powerOfTwo;
+
+ unsigned int handle;
+
+ int width, height,
+ textureWidth, textureHeight;
+
+ GkTexture::GkTexture(void);
+ GkTexture::~GkTexture(void);
+
+ void GkTexture::LoadFromImage(GkImage* image);
+ void GkTexture::LoadFromImage(GkImage* image, int x, int y, int width, int height);
+ void GkTexture::LoadFromFile(char* fileName);
+
+ static int GkTexture::GetPowerOfTwo(int value);
+};
\ No newline at end of file
diff --git a/COM380/Project5/GambleKit/Engine/OSSpecific/GkFileSystem.cpp b/COM380/Project5/GambleKit/Engine/OSSpecific/GkFileSystem.cpp
new file mode 100644
index 0000000..7e1472e
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/OSSpecific/GkFileSystem.cpp
@@ -0,0 +1,285 @@
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+// GambleKit Copyright (C) 2014 Ivan Donev
+//
+// This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// contact: gamblekit@gmail.com
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+#include "GkFileSystem.h"
+
+#include
+#include
+#include
+#include "..\Utils\GkStrings.h"
+
+std::wstring GkFileSystem::source;
+//wchar_t *GkFileSystem::source;
+FileSystemMode GkFileSystem::mode;
+GkFileSystem::Init GkFileSystem::init;
+
+GkFileSystem::Init::Init(void)
+{
+ //GkFileSystem::source = GkStrings::Copy(L"\0");
+}
+
+GkFileSystem::Init::~Init(void)
+{
+ //delete[] GkFileSystem::source;
+}
+
+GkFileSystem::GkFileSystem(void)
+{
+}
+
+
+GkFileSystem::~GkFileSystem(void)
+{
+}
+
+
+void GkFileSystem::SetSource(const wchar_t *source, FileSystemMode mode)
+{
+ //delete[] GkFileSystem::source;
+
+ //if (source == 0)
+ // GkFileSystem::source = GkStrings::Copy(L"\0");
+ //else
+ // GkFileSystem::source = GkStrings::Copy(source);
+
+ if (source == 0)
+ GkFileSystem::source = std::wstring(L"\0");
+ else
+ GkFileSystem::source = std::wstring(source);
+
+
+
+ GkFileSystem::mode = mode;
+}
+
+bool GkFileSystem::LoadFile(const wchar_t *fileName, void **fileData, unsigned int *fileSize)
+{
+ if (GkFileSystem::mode == FileSystemMode_Physical)
+ return GkFileSystem::LoadPhysicalFile(fileName, fileData, fileSize);
+
+ if (GkFileSystem::mode == FileSystemMode_Virtual)
+ return GkFileSystem::LoadVirtualFile(fileName, fileData, fileSize);
+
+ return false;
+}
+
+void GkFileSystem::CreateVirtualFileSystem(const wchar_t* directory, const wchar_t* fileName)
+{
+ std::ofstream fileStream(fileName, std::ios::out | std::ios::binary);
+
+ GkFileSystem::WriteVirtualFileSystem(directory, &fileStream);
+
+ fileStream.close();
+}
+
+bool GkFileSystem::LoadVirtualFile(const wchar_t *fileName, void **fileData, unsigned int *fileSize)
+{
+ std::vector pathElements;
+
+ int elementStart = 0;
+ int i = 0;
+ bool done;
+ do
+ {
+ done = *((char*)&fileName[i]) == 0;
+
+ if ((fileName[i] == L'\\') || done)
+ {
+ int l = i - elementStart;
+ wchar_t *element = new wchar_t[l + 1];
+ CopyMemory(element, &fileName[elementStart], l * sizeof(wchar_t));
+ element[l] = 0;
+ pathElements.push_back(element);
+ elementStart = i + 1;
+ }
+
+ i++;
+ } while (!done);
+
+
+ std::ifstream file(GkFileSystem::source, std::ios::in | std::ios::binary | std::ios::ate);
+ int pathElementIndex = 0;
+
+ int dirLimit = (int)file.tellg();
+ file.seekg(0);
+
+ done = false;
+ while (file && !done)
+ {
+ wchar_t *vfn = GkFileSystem::ReadString(&file);
+ int size;
+ file.read((char*)&size, sizeof(int));
+
+ if (wcscmp(vfn, pathElements[pathElementIndex]) == 0)
+ {
+ pathElementIndex++;
+ dirLimit = (int)file.tellg() + size;
+
+ if (pathElementIndex == pathElements.size())
+ {
+ *fileSize = size;
+ *fileData = new char[size];
+ file.read((char*)*fileData, size);
+
+ done = true;
+ }
+ }
+ else
+ {
+ file.seekg((int)file.tellg() + size);
+ }
+
+ delete vfn;
+
+ if (file.tellg() >= dirLimit)
+ break;
+ }
+
+ file.close();
+
+
+ for (int i = 0; i < (int)pathElements.size(); i++)
+ {
+ delete pathElements[i];
+ }
+
+ return done;
+}
+
+bool GkFileSystem::LoadPhysicalFile(const wchar_t *fileName, void **fileData, unsigned int *fileSize)
+{
+ // TODO: fix this static string
+ std::wstring fn(GkFileSystem::source);
+ fn.append(fileName);
+
+ std::ifstream file(fn.c_str(), std::ios::in | std::ios::binary | std::ios::ate);
+
+ if (!file)
+ return false;
+
+ *fileSize = (unsigned int)file.tellg();
+ *fileData = new char[*fileSize];
+
+ file.seekg(0);
+ file.read((char*)*fileData, *fileSize);
+
+ file.close();
+
+ return true;
+}
+
+wchar_t* GkFileSystem::ReadString(std::ifstream* fileStream)
+{
+ int l;
+ fileStream->read((char*)&l, sizeof(int));
+
+ wchar_t *result = new wchar_t[l + 1];
+ fileStream->read((char*)result, l * sizeof(wchar_t));
+ result[l] = 0;
+
+ return result;
+}
+
+void GkFileSystem::WriteVirtualFileSystem(const wchar_t* directory, std::ofstream* fileStream)
+{
+ std::wstring fullSearchDir(directory);
+ fullSearchDir.append(L"\\*");
+
+ WIN32_FIND_DATAW findData;
+
+ HANDLE findHandle = INVALID_HANDLE_VALUE;
+ findHandle = FindFirstFileW(fullSearchDir.c_str(), &findData);
+
+ if (findHandle == INVALID_HANDLE_VALUE)
+ {
+ return;
+ }
+
+ int chunkSize, chunkSizePos;
+ do
+ {
+ if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+ {
+ if ((wcscmp(findData.cFileName, L".") != 0) && (wcscmp(findData.cFileName, L"..") != 0))
+ {
+ std::wstring fullSearchSubDir(directory);
+ fullSearchSubDir.append(L"\\");
+ fullSearchSubDir.append(findData.cFileName);
+
+ GkFileSystem::WriteString(findData.cFileName, fileStream);
+
+ chunkSizePos = (int)fileStream->tellp();
+ fileStream->write((char*)&chunkSize, sizeof(int));
+
+ GkFileSystem::WriteVirtualFileSystem(fullSearchSubDir.c_str(), fileStream);
+
+ int endPos = (int)fileStream->tellp();
+ chunkSize = endPos - chunkSizePos - 4;
+ fileStream->seekp(chunkSizePos);
+ fileStream->write((char*)&chunkSize, sizeof(int));
+ fileStream->seekp(endPos);
+ }
+ }
+ else
+ {
+ std::wstring fullFileName(directory);
+ fullFileName.append(L"\\");
+ fullFileName.append(findData.cFileName);
+
+ GkFileSystem::WriteString(findData.cFileName, fileStream);
+
+ chunkSizePos = (int)fileStream->tellp();
+ fileStream->write((char*)&chunkSize, sizeof(int));
+
+ GkFileSystem::WriteFile(fullFileName.c_str(), fileStream);
+
+ int endPos = (int)fileStream->tellp();
+ chunkSize = endPos - chunkSizePos - 4;
+ fileStream->seekp(chunkSizePos);
+ fileStream->write((char*)&chunkSize, sizeof(int));
+ fileStream->seekp(endPos);
+ }
+
+ }
+ while (FindNextFileW(findHandle, &findData) != 0);
+
+ FindClose(findHandle);
+}
+
+void GkFileSystem::WriteString(const wchar_t* s, std::ofstream* fileStream)
+{
+ int l = 0;
+ while (s[l] != 0)
+ l++;
+
+ fileStream->write((char*)&l, sizeof(int));
+ fileStream->write((char*)s, l * sizeof(wchar_t));
+}
+
+void GkFileSystem::WriteFile(const wchar_t* fileName, std::ofstream* fileStream)
+{
+ std::ifstream file(fileName, std::ios::in | std::ios::binary);
+
+ const int bufferSize = 2048;
+ char buffer[bufferSize];
+
+ for (;;)
+ {
+ file.read(buffer, bufferSize);
+ fileStream->write(buffer, file.gcount());
+
+ if (!file)
+ break;
+ }
+
+ file.close();
+}
\ No newline at end of file
diff --git a/COM380/Project5/GambleKit/Engine/OSSpecific/GkFileSystem.h b/COM380/Project5/GambleKit/Engine/OSSpecific/GkFileSystem.h
new file mode 100644
index 0000000..8aa7fb6
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/OSSpecific/GkFileSystem.h
@@ -0,0 +1,53 @@
+#pragma once
+
+#include "..\GkDefinitions.h"
+
+#include
+#include
+
+enum FileSystemMode
+{
+ FileSystemMode_Physical,
+ FileSystemMode_Virtual
+};
+
+class GKDLLCLASS GkFileSystem
+{
+private:
+ static class GKDLLCLASS Init
+ {
+ public:
+ Init(void);
+ ~Init(void);
+ } init;
+
+ static std::wstring source;
+ //static wchar_t *source;
+ static FileSystemMode mode;
+
+ static wchar_t* ReadString(std::ifstream* fileStream);
+
+ static void WriteVirtualFileSystem(const wchar_t* directory, std::ofstream* fileStream);
+
+ static void WriteString(const wchar_t* s, std::ofstream* fileStream);
+ static void WriteFile(const wchar_t* fileName, std::ofstream* fileStream);
+
+ static bool LoadPhysicalFile(const wchar_t *fileName, void **fileData, unsigned int *fileSize);
+ static bool LoadVirtualFile(const wchar_t *fileName, void **fileData, unsigned int *fileSize);
+
+public:
+ GkFileSystem(void);
+ ~GkFileSystem(void);
+
+ // Sets the source and mode of the virtual file system.
+ // If mode is FileSystemMode_Virtual, the source should be the name of the file, containing the virtual file system. Such file can be produced by the CreateVirtualFileSystem method.
+ // If mode is FileSystemMode_Physical, the source can be a root directory for the game's resources. Usually, this root directory is used to create a virtual file system from.
+ static void SetSource(const wchar_t *source, FileSystemMode mode);
+
+ // Allocates memory in fileData and loads the requested file in it, returning the size of the file in fileSize
+ static bool LoadFile(const wchar_t *fileName, void **fileData, unsigned int *fileSize);
+
+ // Writes the contents of a directory and all its subdirectories into a virtual file with the given name. The file can then be used as a virtual file system file.
+ static void CreateVirtualFileSystem(const wchar_t* directory, const wchar_t* fileName);
+};
+
diff --git a/COM380/Project5/GambleKit/Engine/OSSpecific/GkOSUtils.cpp b/COM380/Project5/GambleKit/Engine/OSSpecific/GkOSUtils.cpp
new file mode 100644
index 0000000..8e7df9a
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/OSSpecific/GkOSUtils.cpp
@@ -0,0 +1,201 @@
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+// GambleKit Copyright (C) 2014 Ivan Donev
+//
+// This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// contact: gamblekit@gmail.com
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+#include "GkOSUtils.h"
+
+#include
+#include
+
+GkOSUtils::GkOSUtils(void)
+{
+}
+
+
+GkOSUtils::~GkOSUtils(void)
+{
+}
+
+
+void* GkOSUtils::GetMem(int size)
+{
+ return malloc(size);
+}
+
+void GkOSUtils::FreeMem(void* data)
+{
+ free(data);
+}
+
+void GkOSUtils::ZeroMem(void* data, int size)
+{
+ memset(data, 0, size);
+}
+
+void GkOSUtils::CopyMem(void* destination, void* source, int size)
+{
+ memcpy(destination, source, size);
+}
+
+int GkOSUtils::CompareMem(void* block1, void* block2, int size)
+{
+ return memcmp(block1, block2, size);
+}
+
+long long GkOSUtils::GetPerformanceCounter()
+{
+ LARGE_INTEGER result;
+
+ if (QueryPerformanceCounter(&result))
+ return result.QuadPart;
+ else
+ return -1;
+}
+
+long long GkOSUtils::GetPerformanceCounterFrequency()
+{
+ LARGE_INTEGER result;
+
+ if (QueryPerformanceFrequency(&result))
+ return result.QuadPart;
+ else
+ return -1;
+}
+
+void GkOSUtils::ShowMessage(const char *text, HWND windowHandle)
+{
+ MessageBox(windowHandle, text, "Message", MB_OK);
+}
+
+int GkOSUtils::GetScreenWidth()
+{
+ return GetSystemMetrics(SM_CXSCREEN);
+}
+
+int GkOSUtils::GetScreenHeight()
+{
+ return GetSystemMetrics(SM_CYSCREEN);
+}
+
+
+BOOL CALLBACK MonitorEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData)
+{
+ int *Count = (int*)dwData;
+ (*Count)++;
+ return TRUE;
+}
+
+int GkOSUtils::GetNumberOfScreens()
+{
+ int Count = 0;
+ if (EnumDisplayMonitors(NULL, NULL, MonitorEnumProc, (LPARAM)&Count))
+ return Count;
+ return -1;//signals an error
+}
+
+DateTime GkOSUtils::GetDateTime()
+{
+ time_t currentTime;
+ time(¤tTime);
+
+ tm localTime;
+ localtime_s(&localTime, ¤tTime);
+
+ DateTime result;
+ result.day = localTime.tm_mday;
+ result.month = 1 + localTime.tm_mon;
+ result.year = 1900 + localTime.tm_year;
+ result.hour = localTime.tm_hour;
+ result.minute = localTime.tm_min;
+ result.second = localTime.tm_sec;
+
+ return result;
+}
+
+bool GkOSUtils::SetDateTime(DateTime &dateTime)
+{
+ SYSTEMTIME sysTime;
+ sysTime.wDay = dateTime.day;
+ sysTime.wMonth = dateTime.month;
+ sysTime.wYear = dateTime.year;
+ sysTime.wHour = dateTime.hour;
+ sysTime.wMinute = dateTime.minute;
+ sysTime.wSecond = dateTime.second;
+ sysTime.wMilliseconds = 0;
+
+ return SetLocalTime(&sysTime) != 0;
+}
+
+int GkOSUtils::GetSecondsElapsed(DateTime &since)
+{
+ //TODO
+
+ DateTime now = GkOSUtils::GetDateTime();
+ return ((now.hour - since.hour) * 60 + (now.minute - since.minute)) * 60 + (now.second - since.second);
+}
+
+DateTime GkOSUtils::GetFileModificationDateTime(const wchar_t *fileName)
+{
+ DateTime result;
+
+ HANDLE handle = CreateFileW(fileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
+ if (handle != INVALID_HANDLE_VALUE)
+ {
+ FILETIME created, accessed, modified;
+
+ GetFileTime(handle, &created, &accessed, &modified);
+
+ FILETIME localFileTime;
+ FileTimeToLocalFileTime(&modified, &localFileTime);
+
+ SYSTEMTIME localTime;
+ FileTimeToSystemTime(&localFileTime, &localTime);
+
+ result.day = localTime.wDay;
+ result.month = localTime.wMonth;
+ result.year = localTime.wYear;
+ result.hour = localTime.wHour;
+ result.minute = localTime.wMinute;
+ result.second = localTime.wSecond;
+ }
+ CloseHandle(handle);
+
+ return result;
+}
+
+std::string GkOSUtils::GetApplicationName()
+{
+ TCHAR buffer[MAX_PATH]={0};
+ GetModuleFileName(NULL, buffer, MAX_PATH);
+ return std::string(buffer);
+}
+
+std::string GkOSUtils::GetApplicationPath()
+{
+ std::string applicationName = GkOSUtils::GetApplicationName();
+ int nameLength = applicationName.length();
+ char path[MAX_PATH];
+ int pathLast = 0;
+ for (int i = 0; i < nameLength; i++)
+ {
+ path[i] = applicationName[i];
+ if (path[i] == '\\')
+ pathLast = i;
+ }
+ path[pathLast + 1] = 0;
+
+ return std::string(path);
+}
+
+void GkOSUtils::Execute(const char *command)
+{
+ ShellExecuteA(GetDesktopWindow(), "open", command, NULL, NULL, SW_SHOWNORMAL);
+}
\ No newline at end of file
diff --git a/COM380/Project5/GambleKit/Engine/OSSpecific/GkOSUtils.h b/COM380/Project5/GambleKit/Engine/OSSpecific/GkOSUtils.h
new file mode 100644
index 0000000..274265c
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/OSSpecific/GkOSUtils.h
@@ -0,0 +1,47 @@
+#pragma once
+
+#include "..\GkDefinitions.h"
+
+#include
+#include
+
+struct DateTime
+{
+ int day, month, year,
+ hour, minute, second;
+};
+
+class GKDLLCLASS GkOSUtils
+{
+public:
+ GkOSUtils(void);
+ ~GkOSUtils(void);
+
+ static void* GkOSUtils::GetMem(int size);
+ static void GkOSUtils::FreeMem(void* data);
+ static void GkOSUtils::ZeroMem(void* data, int size);
+ static void GkOSUtils::CopyMem(void* destination, void* source, int size);
+ static int GkOSUtils::CompareMem(void* block1, void* block2, int size);
+
+ static long long GkOSUtils::GetPerformanceCounter();
+ static long long GkOSUtils::GetPerformanceCounterFrequency();
+
+ static void GkOSUtils::ShowMessage(const char *text, HWND windowHandle = 0);
+
+ static int GetScreenWidth();
+ static int GetScreenHeight();
+
+ static int GetNumberOfScreens();
+
+ static DateTime GetDateTime();
+ static bool SetDateTime(DateTime &dateTime);
+ static int GetSecondsElapsed(DateTime &since);
+
+ static DateTime GetFileModificationDateTime(const wchar_t *fileName);
+
+ static std::string GetApplicationName();
+ static std::string GetApplicationPath();
+
+ static void Execute(const char *command);
+};
+
diff --git a/COM380/Project5/GambleKit/Engine/OSSpecific/GkOpenGLWindowsForm.cpp b/COM380/Project5/GambleKit/Engine/OSSpecific/GkOpenGLWindowsForm.cpp
new file mode 100644
index 0000000..a8ffe66
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/OSSpecific/GkOpenGLWindowsForm.cpp
@@ -0,0 +1,87 @@
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+// GambleKit Copyright (C) 2014 Ivan Donev
+//
+// This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// contact: gamblekit@gmail.com
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+#include "GkOpenGLWindowsForm.h"
+
+
+GkOpenGLWindowsForm::GkOpenGLWindowsForm(HGLRC renderContext)
+{
+ PIXELFORMATDESCRIPTOR d =
+ {
+ 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
+ 32, // 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
+ };
+ this->pixelFormatDescriptor = d;
+
+ this->CreateContext(renderContext);
+}
+
+
+GkOpenGLWindowsForm::~GkOpenGLWindowsForm(void)
+{
+}
+
+bool GkOpenGLWindowsForm::CreateContext(HGLRC renderContext)
+{
+ this->deviceContext = GetDC(this->handle);
+ if (this->deviceContext == 0)
+ return false;
+
+ this->pixelFormat = ChoosePixelFormat(this->deviceContext, &this->pixelFormatDescriptor);
+ if (this->pixelFormat == 0)
+ return false;
+
+ if(!SetPixelFormat(this->deviceContext, this->pixelFormat, &this->pixelFormatDescriptor))
+ return false;
+
+ if (renderContext == 0)
+ {
+ this->renderContext = wglCreateContext(this->deviceContext);
+ if (this->renderContext == 0)
+ return false;
+ }
+ else
+ {
+ this->renderContext = renderContext;
+ }
+
+ if (!this->MakeCurrent())
+ return false;
+
+ return true;
+}
+
+bool GkOpenGLWindowsForm::Present()
+{
+ return SwapBuffers(this->deviceContext) != 0;
+}
+
+bool GkOpenGLWindowsForm::MakeCurrent()
+{
+ return wglMakeCurrent(this->deviceContext, this->renderContext) != 0;
+}
\ No newline at end of file
diff --git a/COM380/Project5/GambleKit/Engine/OSSpecific/GkOpenGLWindowsForm.h b/COM380/Project5/GambleKit/Engine/OSSpecific/GkOpenGLWindowsForm.h
new file mode 100644
index 0000000..2ef5efd
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/OSSpecific/GkOpenGLWindowsForm.h
@@ -0,0 +1,24 @@
+#pragma once
+
+#include "..\GkDefinitions.h"
+
+#include "GkWindowsForm.h"
+
+class GKDLLCLASS GkOpenGLWindowsForm :
+ public GkWindowsForm
+{
+public:
+ HDC deviceContext;
+ HGLRC renderContext;
+
+ PIXELFORMATDESCRIPTOR pixelFormatDescriptor;
+ unsigned int pixelFormat;
+
+ GkOpenGLWindowsForm(HGLRC renderContext = 0);
+ virtual ~GkOpenGLWindowsForm(void);
+
+ bool GkOpenGLWindowsForm::CreateContext(HGLRC renderContext = 0);
+ bool GkOpenGLWindowsForm::Present();
+ bool GkOpenGLWindowsForm::MakeCurrent();
+};
+
diff --git a/COM380/Project5/GambleKit/Engine/OSSpecific/GkWindowsForm.cpp b/COM380/Project5/GambleKit/Engine/OSSpecific/GkWindowsForm.cpp
new file mode 100644
index 0000000..18717cf
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/OSSpecific/GkWindowsForm.cpp
@@ -0,0 +1,397 @@
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+// GambleKit Copyright (C) 2014 Ivan Donev
+//
+// This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// contact: gamblekit@gmail.com
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+#include "GkWindowsForm.h"
+
+#include
+
+const char* GkWindowsForm::FormClassName = "MyWindowsForm";
+
+//std::vector GkWindowsForm::instances;
+GkList GkWindowsForm::instances;
+
+LRESULT CALLBACK GkWindowsForm::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ GkWindowsForm* instance = GkWindowsForm::GetInstance(hWnd);
+
+ if (instance != NULL)
+ {
+ switch (uMsg)
+ {
+ case WM_SYSCOMMAND:
+ {
+ switch (wParam)
+ {
+ case SC_SCREENSAVE:
+ {
+ if (instance->suppressScreenSaver)
+ return 0;
+ }
+ case SC_MONITORPOWER:
+ {
+ if (instance->suppressMonitorPowerSave)
+ return 0;
+ }
+ }
+ break;
+ }
+
+ case WM_ACTIVATE:
+ {
+ // Minimization state
+ if (!HIWORD(wParam))
+ {
+ instance->active=TRUE;
+ }
+ else
+ {
+ instance->active=FALSE;
+ }
+
+ return 0;
+ }
+
+ case WM_DESTROY:
+ {
+ if (instance->Close())
+ {
+ GkWindowsForm::instances.Remove(instance);
+
+ if (GkWindowsForm::instances.size == 0)
+ PostQuitMessage(0);
+ }
+ return 0;
+ }
+
+ case WM_SIZE:
+ {
+ int width = LOWORD(lParam);
+ int height = HIWORD(lParam);
+
+ instance->Resize(width, height);
+
+ return 0;
+ }
+
+ case WM_PAINT:
+ {
+ if (instance->Paint())
+ {
+ ValidateRect(instance->handle, NULL);
+ }
+
+ return 0;
+ }
+
+ case WM_KEYDOWN:
+ {
+ int key = wParam;
+
+ instance->KeyDown(key);
+
+ if ((key >=0 ) && (key < 256))
+ instance->keys[key] = TRUE;
+ return 0;
+ }
+
+ case WM_KEYUP:
+ {
+ int key = wParam;
+
+ instance->KeyUp(key);
+
+ if ((key >=0 ) && (key < 256))
+ instance->keys[key] = FALSE;
+ return 0;
+ }
+
+ case WM_LBUTTONDOWN:
+ {
+ int x = GET_X_LPARAM(lParam);
+ int y = GET_Y_LPARAM(lParam);
+
+ instance->MouseDown(x, y, GkWindowsForm::MouseButton_Left);
+ instance->mouseButtons |= GkWindowsForm::MouseButton_Left;
+
+ return 0;
+ }
+
+ case WM_LBUTTONUP:
+ {
+ int x = GET_X_LPARAM(lParam);
+ int y = GET_Y_LPARAM(lParam);
+
+ instance->MouseUp(x, y, GkWindowsForm::MouseButton_Left);
+ instance->mouseButtons &= !GkWindowsForm::MouseButton_Left;
+
+ return 0;
+ }
+
+ case WM_RBUTTONDOWN:
+ {
+ int x = GET_X_LPARAM(lParam);
+ int y = GET_Y_LPARAM(lParam);
+
+ instance->MouseDown(x, y, GkWindowsForm::MouseButton_Right);
+ instance->mouseButtons |= GkWindowsForm::MouseButton_Right;
+
+ return 0;
+ }
+
+ case WM_RBUTTONUP:
+ {
+ int x = GET_X_LPARAM(lParam);
+ int y = GET_Y_LPARAM(lParam);
+
+ instance->MouseUp(x, y, GkWindowsForm::MouseButton_Right);
+ instance->mouseButtons &= !GkWindowsForm::MouseButton_Right;
+
+ return 0;
+ }
+
+ case WM_MBUTTONDOWN:
+ {
+ int x = GET_X_LPARAM(lParam);
+ int y = GET_Y_LPARAM(lParam);
+
+ instance->MouseDown(x, y, GkWindowsForm::MouseButton_Middle);
+ instance->mouseButtons |= GkWindowsForm::MouseButton_Middle;
+
+ return 0;
+ }
+
+ case WM_MBUTTONUP:
+ {
+ int x = GET_X_LPARAM(lParam);
+ int y = GET_Y_LPARAM(lParam);
+
+ instance->MouseUp(x, y, GkWindowsForm::MouseButton_Middle);
+ instance->mouseButtons &= !GkWindowsForm::MouseButton_Middle;
+
+ return 0;
+ }
+
+ case WM_MOUSEMOVE:
+ {
+ int x = GET_X_LPARAM(lParam);
+ int y = GET_Y_LPARAM(lParam);
+
+ instance->MouseMove(x, y);
+
+ instance->mouseX = x;
+ instance->mouseY = y;
+
+ return 0;
+ }
+
+ case WM_MOUSEHWHEEL:
+ {
+ int x = GET_X_LPARAM(lParam);
+ int y = GET_Y_LPARAM(lParam);
+ int deltaFactor = GET_WHEEL_DELTA_WPARAM(wParam);
+
+ instance->MouseWheel(x, y, deltaFactor, WHEEL_DELTA);
+
+ return 0;
+ }
+ }
+
+ int result;
+ if (instance->HandleMessage(uMsg, wParam, lParam, &result))
+ return result;
+ }
+
+ return DefWindowProc(hWnd,uMsg,wParam,lParam);
+}
+
+GkWindowsForm* GkWindowsForm::GetInstance(HWND instanceHandle)
+{
+ for (int i = 0; i < GkWindowsForm::instances.size; i++)
+ {
+ if (GkWindowsForm::instances[i]->handle == instanceHandle)
+ {
+ return GkWindowsForm::instances[i];
+ }
+ }
+
+ return NULL;
+}
+
+bool GkWindowsForm::ProcessMessages()
+{
+ MSG msg;
+
+ bool result = false;
+
+ while (PeekMessage(&msg,NULL,0,0,PM_REMOVE))
+ {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+
+ result = true;
+ }
+
+ return result;
+}
+
+int GkWindowsForm::PerformFormLoop()
+{
+ MSG msg;
+
+ bool done = false;
+ 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
+ }
+ }
+
+ if (!done)
+ {
+ for (int i = 0; i < GkWindowsForm::instances.size; i++)
+ {
+ GkWindowsForm::instances[i]->MainLoop();
+ }
+ }
+ }
+
+ return (int)msg.wParam;
+
+ //while (GetMessage(&msg, NULL, 0, 0))
+ // {
+ // TranslateMessage(&msg);
+ // DispatchMessage(&msg);
+ // }
+
+ // return (int)msg.wParam;
+}
+
+GkWindowsForm::GkWindowsForm(void)
+{
+ this->applicationInstance = GetModuleHandle(NULL);
+ ZeroMemory(keys, 256);
+
+ this->left = 0;
+ this->top = 0;
+ this->width = 640;
+ this->height = 480;
+ this->caption = "Window Title";
+ //this->windowMode = GkWindowsForm::WindowMode_Windowed;
+ this->windowMode = GkWindowsForm::WindowMode_FullScreen;
+
+ GkWindowsForm::instances.Add(this);
+ //GkWindowsForm::instances.push_back(this);
+
+ this->RegisterWindowClass();
+ this->CreateFormWindow();
+ this->ShowFormWindow();
+}
+
+
+GkWindowsForm::~GkWindowsForm(void)
+{
+ this->DestroyFormWindow();
+ //GkWindowsForm::instances.Remove(this);
+ //if (GkWindowsForm::instances.size == 0)
+ // PostMessage(this->handle, WM_CLOSE, 0, 0);
+}
+
+bool GkWindowsForm::RegisterWindowClass()
+{
+ //LRESULT (CALLBACK GkWindowsForm::*memfun)(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
+ //memfun = &GkWindowsForm::WndProc;
+ //this->ex.lpfnWndProc = *((WNDPROC*) (&memfun));
+
+ this->windowClass.cbSize = sizeof(WNDCLASSEX);
+ this->windowClass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
+ this->windowClass.lpfnWndProc = (WNDPROC)GkWindowsForm::WndProc;
+ this->windowClass.cbClsExtra = 0;
+ this->windowClass.cbWndExtra = 0;
+ this->windowClass.hInstance = this->applicationInstance;
+ this->windowClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
+ this->windowClass.hCursor = LoadCursor(NULL, IDC_ARROW);
+ this->windowClass.hbrBackground = NULL;
+ this->windowClass.lpszMenuName = NULL;
+ this->windowClass.hIconSm = NULL;
+ this->windowClass.lpszClassName = GkWindowsForm::FormClassName;
+
+ return RegisterClassEx(&this->windowClass) != 0;
+}
+
+bool GkWindowsForm::CreateFormWindow()
+{
+ long wndStyle = this->windowMode == GkWindowsForm::WindowMode_FullScreen ? WS_POPUP : WS_OVERLAPPEDWINDOW;
+ wndStyle |= WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
+
+ // Translate from client rect to window rect
+ RECT wRect = { this->left, this->top, this->left + this->width, this->top + this->height };
+ AdjustWindowRect(&wRect, wndStyle, false);
+
+ this->handle = CreateWindow(GkWindowsForm::FormClassName, this->caption,
+ wndStyle,
+ this->left, this->top, wRect.right - wRect.left, wRect.bottom - wRect.top,
+ NULL, NULL,
+ this->applicationInstance,
+ NULL);
+
+ return this->handle != 0;
+}
+
+void GkWindowsForm::ShowFormWindow()
+{
+ ShowWindow(this->handle,SW_SHOW);
+ //UpdateWindow(this->handle);
+ SetForegroundWindow(this->handle); // Slightly Higher Priority
+ SetFocus(this->handle); // Sets Keyboard Focus To The Window
+}
+
+void GkWindowsForm::DestroyFormWindow()
+{
+ PostMessage(this->handle, WM_DESTROY, 0, 0);
+}
+
+void GkWindowsForm::SetPosition(int left, int top)
+{
+ this->left = left;
+ this->top = top;
+
+ SetWindowPos(this->handle, HWND_TOP, this->left, this->top, this->width, this->height, SWP_NOSIZE);
+}
+
+void GkWindowsForm::SetSize(int width, int height)
+{
+ this->width = width;
+ this->height = height;
+
+ SetWindowPos(this->handle, HWND_TOP, this->left, this->top, this->width, this->height, SWP_NOMOVE);
+}
+
+void GkWindowsForm::SetStyle()
+{
+ SetWindowLong(this->handle, GWL_STYLE, WS_POPUP | WS_MINIMIZEBOX);
+ SetWindowLong(this->handle, GWL_EXSTYLE, 0);
+ //SetWindowLong(this->handle, GWL_STYLE, WS_POPUP);
+ //SetWindowLong(this->handle, GWL_EXSTYLE, WS_EX_APPWINDOW);
+}
+
+void GkWindowsForm::SetActive()
+{
+ SetActiveWindow(this->handle);
+}
diff --git a/COM380/Project5/GambleKit/Engine/OSSpecific/GkWindowsForm.h b/COM380/Project5/GambleKit/Engine/OSSpecific/GkWindowsForm.h
new file mode 100644
index 0000000..b969865
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/OSSpecific/GkWindowsForm.h
@@ -0,0 +1,71 @@
+#pragma once
+
+#include "..\GkDefinitions.h"
+
+#include "..\Utils\GkList.h"
+//#include
+
+#include
+
+class GKDLLCLASS GkWindowsForm
+{
+public:
+ static const int WindowMode_Windowed = 0,
+ WindowMode_FullScreen = 1,
+
+ MouseButton_None = 0,
+ MouseButton_Left = 1,
+ MouseButton_Right = 2,
+ MouseButton_Middle = 4;
+
+ static const char* FormClassName;
+
+ static GkList instances;
+ //static std::vector instances;
+
+
+ HINSTANCE applicationInstance;
+ WNDCLASSEX windowClass;
+ HWND handle;
+
+ bool keys[256];
+ int mouseX, mouseY, mouseButtons;
+ bool suppressScreenSaver, suppressMonitorPowerSave;
+
+ bool active;
+ int windowMode;
+ int left, top, width, height;
+ char *caption;
+
+
+ GkWindowsForm(void);
+ virtual ~GkWindowsForm(void);
+
+ bool GkWindowsForm::RegisterWindowClass();
+ bool GkWindowsForm::CreateFormWindow();
+ void GkWindowsForm::ShowFormWindow();
+ void GkWindowsForm::DestroyFormWindow();
+ void GkWindowsForm::SetPosition(int left, int top);
+ void GkWindowsForm::SetSize(int width, int height);
+ void GkWindowsForm::SetStyle();
+ void GkWindowsForm::SetActive();
+
+ virtual bool GkWindowsForm::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, int *result) { return false; };
+ virtual void GkWindowsForm::MainLoop() { };
+ virtual void GkWindowsForm::Created() { };
+ virtual bool GkWindowsForm::Close() { return true; };
+ virtual bool GkWindowsForm::Paint() { return true; };
+ virtual void GkWindowsForm::KeyDown(int keyCode) { };
+ virtual void GkWindowsForm::KeyUp(int keyCode) { };
+ virtual void GkWindowsForm::Resize(int width, int height) { };
+ virtual void GkWindowsForm::MouseMove(int x, int y) { };
+ virtual void GkWindowsForm::MouseDown(int x, int y, int mouseButton) { };
+ virtual void GkWindowsForm::MouseUp(int x, int y, int mouseButton) { };
+ virtual void GkWindowsForm::MouseWheel(int x, int y, int deltaFactor, int delta) { };
+
+ static LRESULT CALLBACK GkWindowsForm::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
+ static GkWindowsForm* GkWindowsForm::GetInstance(HWND instanceHandle);
+ static bool GkWindowsForm::ProcessMessages();
+ static int GkWindowsForm::PerformFormLoop();
+};
+
diff --git a/COM380/Project5/GambleKit/Engine/OSSpecific/GkWindowsMutex.cpp b/COM380/Project5/GambleKit/Engine/OSSpecific/GkWindowsMutex.cpp
new file mode 100644
index 0000000..915145b
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/OSSpecific/GkWindowsMutex.cpp
@@ -0,0 +1,36 @@
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+// GambleKit Copyright (C) 2014 Ivan Donev
+//
+// This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// contact: gamblekit@gmail.com
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+#include "GkWindowsMutex.h"
+
+
+GkWindowsMutex::GkWindowsMutex(void)
+{
+ this->handle = CreateMutex(NULL, FALSE, NULL);
+}
+
+
+GkWindowsMutex::~GkWindowsMutex(void)
+{
+ if(this->handle != NULL)
+ CloseHandle(this->handle);
+}
+
+bool GkWindowsMutex::Lock()
+{
+ return WaitForSingleObject(this->handle, INFINITE) == WAIT_OBJECT_0;
+}
+
+void GkWindowsMutex::Unlock()
+{
+ ReleaseMutex(this->handle);
+}
\ No newline at end of file
diff --git a/COM380/Project5/GambleKit/Engine/OSSpecific/GkWindowsMutex.h b/COM380/Project5/GambleKit/Engine/OSSpecific/GkWindowsMutex.h
new file mode 100644
index 0000000..3df6e3e
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/OSSpecific/GkWindowsMutex.h
@@ -0,0 +1,18 @@
+#pragma once
+
+#include "..\GkDefinitions.h"
+
+#include
+
+class GKDLLCLASS GkWindowsMutex
+{
+public:
+ HANDLE handle;
+
+ GkWindowsMutex(void);
+ ~GkWindowsMutex(void);
+
+ bool Lock();
+ void Unlock();
+};
+
diff --git a/COM380/Project5/GambleKit/Engine/OSSpecific/GkWindowsThread.cpp b/COM380/Project5/GambleKit/Engine/OSSpecific/GkWindowsThread.cpp
new file mode 100644
index 0000000..6a5e83b
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/OSSpecific/GkWindowsThread.cpp
@@ -0,0 +1,50 @@
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+// GambleKit Copyright (C) 2014 Ivan Donev
+//
+// This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// contact: gamblekit@gmail.com
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+#include "GkWindowsThread.h"
+
+
+DWORD WINAPI GkWindowsThread::ExecuteThread(LPVOID lpParam)
+{
+ GkWindowsThread *instance = (GkWindowsThread*)lpParam;
+
+ int result = instance->Execute();
+ instance->exited = true;
+
+ return result;
+}
+
+void GkWindowsThread::SleepX(int milliseconds)
+{
+ Sleep(milliseconds);
+}
+
+GkWindowsThread::GkWindowsThread(void)
+{
+ this->handle = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) GkWindowsThread::ExecuteThread, this, 0, &this->id);
+ this->terminated = this->handle == NULL;
+ this->exited = terminated;
+}
+
+
+GkWindowsThread::~GkWindowsThread(void)
+{
+ if(this->handle == NULL)
+ return;
+
+ this->terminated = true;
+
+ while (!this->exited)
+ Sleep(0);
+
+ CloseHandle(this->handle);
+}
\ No newline at end of file
diff --git a/COM380/Project5/GambleKit/Engine/OSSpecific/GkWindowsThread.h b/COM380/Project5/GambleKit/Engine/OSSpecific/GkWindowsThread.h
new file mode 100644
index 0000000..8c8b932
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/OSSpecific/GkWindowsThread.h
@@ -0,0 +1,26 @@
+#pragma once
+
+#include "..\GkDefinitions.h"
+
+#include
+
+class GKDLLCLASS GkWindowsThread
+{
+public:
+ HANDLE handle;
+ DWORD id;
+
+ bool terminated, exited;
+
+ GkWindowsThread(void);
+ virtual ~GkWindowsThread(void);
+
+ virtual int Execute() = 0;
+
+ void Lock();
+ void Unlock();
+
+ static void SleepX(int milliseconds);
+ static DWORD WINAPI ExecuteThread(LPVOID lpParam);
+};
+
diff --git a/COM380/Project5/GambleKit/Engine/Sound/GkSoundDevice.cpp b/COM380/Project5/GambleKit/Engine/Sound/GkSoundDevice.cpp
new file mode 100644
index 0000000..8260963
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Sound/GkSoundDevice.cpp
@@ -0,0 +1,67 @@
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+// GambleKit Copyright (C) 2014 Ivan Donev
+//
+// This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// contact: gamblekit@gmail.com
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+#include "GkSoundDevice.h"
+
+#include
+#include
+
+void GkSoundDevice::Initialize()
+{
+ alutInit(0, 0);
+}
+
+void GkSoundDevice::Close()
+{
+ alutExit();
+}
+
+GkSoundDevice::GkSoundDevice(int volume)
+{
+ this->volume = volume;
+}
+
+
+GkSoundDevice::~GkSoundDevice(void)
+{
+}
+
+bool GkSoundDevice::IsPlaying(GkSoundSource *soundSource)
+{
+ ALenum state;
+ alGetSourcei(soundSource->handle, AL_SOURCE_STATE, &state);
+
+ return (state == AL_PLAYING);
+}
+
+void GkSoundDevice::PlaySource(GkSoundSource *soundSource)
+{
+ alSourcei (soundSource->handle, AL_LOOPING, AL_FALSE);
+ alSourcef (soundSource->handle, AL_GAIN, this->volume / 10.0f);
+ alSourcePlay(soundSource->handle);
+}
+
+void GkSoundDevice::PlaySourceLooping(GkSoundSource *soundSource)
+{
+ alSourcei (soundSource->handle, AL_LOOPING, AL_TRUE);
+ alSourcePlay(soundSource->handle);
+}
+
+void GkSoundDevice::PauseSource(GkSoundSource *soundSource)
+{
+ alSourcePause(soundSource->handle);
+}
+
+void GkSoundDevice::StopSource(GkSoundSource *soundSource)
+{
+ alSourceStop(soundSource->handle);
+}
diff --git a/COM380/Project5/GambleKit/Engine/Sound/GkSoundDevice.h b/COM380/Project5/GambleKit/Engine/Sound/GkSoundDevice.h
new file mode 100644
index 0000000..7904450
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Sound/GkSoundDevice.h
@@ -0,0 +1,23 @@
+#pragma once
+
+#include "..\GkDefinitions.h"
+
+#include "GkSoundSource.h"
+
+class GKDLLCLASS GkSoundDevice
+{
+public:
+ int volume;
+
+ static void Initialize();
+ static void Close();
+
+ GkSoundDevice(int volume = 100);
+ ~GkSoundDevice(void);
+
+ bool IsPlaying(GkSoundSource *soundSource);
+ void PlaySource(GkSoundSource *soundSource);
+ void PlaySourceLooping(GkSoundSource *soundSource);
+ void PauseSource(GkSoundSource *soundSource);
+ void StopSource(GkSoundSource *soundSource);
+};
\ No newline at end of file
diff --git a/COM380/Project5/GambleKit/Engine/Sound/GkSoundSource.cpp b/COM380/Project5/GambleKit/Engine/Sound/GkSoundSource.cpp
new file mode 100644
index 0000000..1390ae5
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Sound/GkSoundSource.cpp
@@ -0,0 +1,87 @@
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+// GambleKit Copyright (C) 2014 Ivan Donev
+//
+// This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// contact: gamblekit@gmail.com
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+#include "GkSoundSource.h"
+
+#include
+#include
+
+#pragma pack(1)
+struct WAVFileHeader
+{
+ char chunkID[4]; // "RIFF"
+ unsigned int chunkSize;
+ char format[4]; // "WAVE"
+
+ char subchunk1Id[4]; // "fmt "
+ unsigned int subchunk1Size;
+ unsigned short audioFormat; // 1 - PCM
+ unsigned short numChannels; // 1 - mono, 2 - stereo
+ unsigned int sampleRate; // 22050, 44100, etc.
+ unsigned int byteRate; // == SampleRate * NumChannels * BitsPerSample / 8
+ unsigned short blockAlign; // == NumChannels * BitsPerSample / 8. The number of bytes for one sample including
+ unsigned short bitsPerSample; // 8, 16, etc.
+ //unsigned short extraParamsSize; //if PCM does not exist
+ //extraParams; //variable format
+
+ //char subchunk2Id[4]; // "data"
+ //unsigned int subchunk2Size;
+};
+
+GkSoundSource::GkSoundSource(void)
+{
+ alGenSources(1, &this->handle);
+
+ this->buffer = 0;
+}
+
+
+GkSoundSource::~GkSoundSource(void)
+{
+ this->UnloadBuffer();
+
+ alDeleteSources(1, &this->handle);
+}
+
+void GkSoundSource::LoadFromMemory(void *wavData)
+{
+ ALenum format;
+ ALvoid *data;
+ ALsizei size, frequency;
+
+ WAVFileHeader *header = (WAVFileHeader*)wavData;
+ int dataOffset = 20 + header->subchunk1Size;
+ while (memcmp((char*)&((char*)wavData)[dataOffset], &"data", 4) != 0)
+ {
+ dataOffset += *((int*)&(((char*)wavData)[dataOffset + 4])) + 8;
+ }
+ size = *((int*)&(((char*)wavData)[dataOffset + 4]));
+ data = (ALvoid*)&(((char*)wavData)[dataOffset + 8]);
+ format = header->numChannels == 1 ? header->bitsPerSample == 8 ? AL_FORMAT_MONO8 : AL_FORMAT_MONO16 : header->bitsPerSample == 8 ? AL_FORMAT_STEREO8 : AL_FORMAT_STEREO16;
+ frequency = header->sampleRate;
+
+ this->UnloadBuffer();
+
+ alGenBuffers(1, &this->buffer);
+ alBufferData(this->buffer, format, data, size, frequency);
+
+ alSourcei(this->handle, AL_BUFFER, this->buffer);
+}
+
+void GkSoundSource::UnloadBuffer()
+{
+ if (this->buffer == 0)
+ return;
+
+ alDeleteBuffers(1, &this->buffer);
+ this->buffer = 0;
+}
diff --git a/COM380/Project5/GambleKit/Engine/Sound/GkSoundSource.h b/COM380/Project5/GambleKit/Engine/Sound/GkSoundSource.h
new file mode 100644
index 0000000..59e2444
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Sound/GkSoundSource.h
@@ -0,0 +1,20 @@
+#pragma once
+
+#include "..\GkDefinitions.h"
+
+#include
+
+#include "..\Base\GkBase.h"
+
+class GKDLLCLASS GkSoundSource
+ : public GkBase
+{
+public:
+ ALuint handle, buffer;
+
+ GkSoundSource::GkSoundSource(void);
+ GkSoundSource::~GkSoundSource(void);
+
+ void GkSoundSource::LoadFromMemory(void *data);
+ void GkSoundSource::UnloadBuffer();
+};
\ No newline at end of file
diff --git a/COM380/Project5/GambleKit/Engine/Utils/GkList.h b/COM380/Project5/GambleKit/Engine/Utils/GkList.h
new file mode 100644
index 0000000..b40a96c
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Utils/GkList.h
@@ -0,0 +1,110 @@
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+// GambleKit Copyright (C) 2014 Ivan Donev
+//
+// This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// contact: gamblekit@gmail.com
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+#pragma once
+
+#include "..\GkDefinitions.h"
+
+#include "..\OSSpecific\GkOSUtils.h"
+
+template class GKDLLCLASS GkList
+{
+public:
+ static const int ListIndex_NotFound = -1;
+
+ int size, capacity;
+ T *values;
+
+ T& operator [](int index)
+ {
+ return this->values[index];
+ };
+
+ GkList::GkList(int capacity = 8)
+ {
+ this->capacity = 0;
+ this->size = 0;
+ this->values = 0;
+
+ this->Resize(capacity);
+ };
+
+ GkList::~GkList(void)
+ {
+ delete this->values;
+ };
+
+ void GkList::Resize(int newCapacity)
+ {
+ T *newValues = new T[newCapacity];
+
+ if (this->size > 0)
+ GkOSUtils::CopyMem(newValues, values, this->size * sizeof(T));
+ if (this->values != 0)
+ delete this->values;
+
+ this->values = newValues;
+ this->capacity = newCapacity;
+ };
+
+ T GkList::Add(T value)
+ {
+ if (this->size >= this->capacity)
+ this->Resize(this->capacity * 2);
+
+ this->values[this->size++] = value;
+
+ return value;
+ };
+
+ T GkList::Insert(T value, int index)
+ {
+ if (this->size >= this->capacity)
+ this->Resize(this->capacity * 2);
+
+ for (int i = this->size; i > index; i--)
+ this->values[i] = this->values[i - 1];
+
+ this->values[index] = value;
+
+ this->size++;
+ };
+
+ bool GkList::Remove(T value)
+ {
+ int index = this->IndexOf(value);
+ if (index != GkList::ListIndex_NotFound)
+ {
+ this->RemoveIndex(index);
+ return true;
+ }
+
+ return false;
+ };
+
+ void GkList::RemoveIndex(int index)
+ {
+ for (int i = index; i < this->size -1; i++)
+ this[i] = this[i + 1];
+ this->size--;
+ };
+
+ int GkList::IndexOf(T value)
+ {
+ for (int i = 0; i < this->size; i++)
+ if (this->values[i] == value)
+ return i;
+
+ return GkList::ListIndex_NotFound;
+ };
+};
+
diff --git a/COM380/Project5/GambleKit/Engine/Utils/GkLogFile.h b/COM380/Project5/GambleKit/Engine/Utils/GkLogFile.h
new file mode 100644
index 0000000..4d3bb9c
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Utils/GkLogFile.h
@@ -0,0 +1,71 @@
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+// GambleKit Copyright (C) 2014 Ivan Donev
+//
+// This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// contact: gamblekit@gmail.com
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+#pragma once
+
+#include "..\GkDefinitions.h"
+
+#include "GkStrings.h"
+
+#include
+
+template class GKDLLCLASS GkLogFile
+{
+public:
+ wchar_t *fileName;
+ int numRecords;
+
+ GkLogFile(const wchar_t *fileName)
+ {
+ this->fileName = GkStrings::Copy(fileName);
+
+ std::fstream file(this->fileName, std::ios::in | std::ios::out | std::ios::binary | std::ios::ate);
+ this->numRecords = (int)file.tellp() / (int)sizeof(T);
+ file.close();
+ };
+
+ ~GkLogFile(void)
+ {
+ if (this->fileName != 0)
+ delete[] this->fileName;
+ };
+
+ void Write(T &record)
+ {
+ std::fstream file(this->fileName, std::ios::in | std::ios::out | std::ios::binary | std::ios::ate);
+ file.write((char*)&record, sizeof(T));
+ file.close();
+
+ this->numRecords++;
+ };
+
+ bool Read(int recordIndex, T &record)
+ {
+ if (recordIndex >= this->numRecords)
+ return false;
+
+ std::fstream file(this->fileName, std::ios::in | std::ios::binary);
+ file.seekg(recordIndex * sizeof(T));
+ file.read((char*)&record, sizeof(T));
+ file.close();
+
+ return true;
+ };
+
+ void Clear()
+ {
+ std::fstream file(this->fileName, std::ios::out | std::ios::trunc);
+ file.close();
+
+ this->numRecords = 0;
+ };
+};
diff --git a/COM380/Project5/GambleKit/Engine/Utils/GkMaths.cpp b/COM380/Project5/GambleKit/Engine/Utils/GkMaths.cpp
new file mode 100644
index 0000000..878bbc8
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Utils/GkMaths.cpp
@@ -0,0 +1,92 @@
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+// GambleKit Copyright (C) 2014 Ivan Donev
+//
+// This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// contact: gamblekit@gmail.com
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+#include "GkMaths.h"
+
+#include
+#include
+#include
+
+GkMaths::GkMaths(void)
+{
+}
+
+
+GkMaths::~GkMaths(void)
+{
+}
+
+int GkMaths::Min(int a, int b)
+{
+ if (a < b)
+ return a;
+
+ return b;
+}
+
+int GkMaths::Max(int a, int b)
+{
+ if (a > b)
+ return a;
+
+ return b;
+}
+
+float GkMaths::Max(float a, float b)
+{
+ if (a > b)
+ return a;
+
+ return b;
+}
+
+int GkMaths::Trim(int x, int min, int max)
+{
+ if (x < min)
+ return min;
+
+ if (x > max)
+ return max;
+
+ return x;
+}
+
+int GkMaths::Sign(int x)
+{
+ return x > 0 ? 1 : x < 0 ? -1 : 0;
+}
+
+float GkMaths::Sign(float x)
+{
+ return x > 0 ? 1.0f : x < 0 ? -1.0f : 0.0f;
+}
+
+float GkMaths::Abs(float x)
+{
+ return x >= 0 ? x : -x;
+}
+
+int GkMaths::Abs(int x)
+{
+ return x >= 0 ? x : -x;
+}
+
+int GkMaths::Random(int range)
+{
+ return rand() % range;
+}
+
+
+void GkMaths::Randomize()
+{
+ srand((unsigned int)time(NULL));
+}
\ No newline at end of file
diff --git a/COM380/Project5/GambleKit/Engine/Utils/GkMaths.h b/COM380/Project5/GambleKit/Engine/Utils/GkMaths.h
new file mode 100644
index 0000000..56f6599
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Utils/GkMaths.h
@@ -0,0 +1,23 @@
+#pragma once
+
+#include "..\GkDefinitions.h"
+
+class GKDLLCLASS GkMaths
+{
+public:
+ GkMaths(void);
+ ~GkMaths(void);
+
+ static int GkMaths::Trim(int x, int min, int max);
+ static int GkMaths::Min(int a, int b);
+ static int GkMaths::Max(int a, int b);
+ static float GkMaths::Max(float a, float b);
+ static int GkMaths::Sign(int x);
+ static float GkMaths::Sign(float x);
+ static float GkMaths::Abs(float x);
+ static int GkMaths::Abs(int x);
+
+ static int GkMaths::Random(int n);
+ static void GkMaths::Randomize();
+};
+
diff --git a/COM380/Project5/GambleKit/Engine/Utils/GkStrings.cpp b/COM380/Project5/GambleKit/Engine/Utils/GkStrings.cpp
new file mode 100644
index 0000000..78a5080
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Utils/GkStrings.cpp
@@ -0,0 +1,283 @@
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+// GambleKit Copyright (C) 2014 Ivan Donev
+//
+// This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// contact: gamblekit@gmail.com
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+#include "GkStrings.h"
+
+#include
+#include "..\OSSpecific\GkOSUtils.h"
+
+GkStrings::GkStrings(void)
+{
+}
+
+
+GkStrings::~GkStrings(void)
+{
+}
+
+struct FormatStringChunk
+{
+ bool isFormatter;
+ int start, length;
+};
+
+struct FormatStringChunks
+{
+ std::vector chunks;
+ int numFormatterChunks;
+};
+
+FormatStringChunks GetFormatStringChunks(const wchar_t *formatString)
+{
+ FormatStringChunks result;
+ result.numFormatterChunks = 0;
+
+ FormatStringChunk chunk;
+ chunk.isFormatter = false;
+ chunk.start = 0;
+
+ for (int i = 0; ; i++)
+ {
+ if (formatString[i] == L'{')
+ {
+ chunk.length = i - chunk.start;
+
+ if (chunk.length > 0)
+ result.chunks.push_back(chunk);
+
+ chunk.isFormatter = true;
+ chunk.start = i + 1;
+ }
+ else if (formatString[i] == L'}')
+ {
+ chunk.length = i - chunk.start;
+
+ if (chunk.length > 0)
+ {
+ result.chunks.push_back(chunk);
+
+ if (chunk.isFormatter)
+ result.numFormatterChunks++;
+ }
+
+ chunk.isFormatter = false;
+ chunk.start = i + 1;
+ }
+ else if (formatString[i] == 0)
+ {
+ chunk.length = i - chunk.start;
+
+ if (chunk.length > 0)
+ result.chunks.push_back(chunk);
+
+ break;
+ }
+ }
+
+ return result;
+}
+
+std::wstring GkStrings::Format(const wchar_t *formatString, ...)
+{
+ wchar_t **parameters = (wchar_t**)((int)&formatString + 4);
+
+ return GkStrings::FormatArray(formatString, parameters);
+}
+
+std::wstring GkStrings::FormatArray(const wchar_t *formatString, wchar_t **parameters)
+{
+ FormatStringChunks chunks = GetFormatStringChunks(formatString);
+
+ std::wstring result;
+
+ int numChunks = chunks.chunks.size();
+ for (int i = 0; i < numChunks; i++)
+ {
+ FormatStringChunk chunk = chunks.chunks[i];
+
+ if (chunk.isFormatter)
+ {
+ result.append(parameters[GkStrings::StringToInt(std::wstring(&formatString[chunk.start], chunk.length).c_str())]);
+ }
+ else
+ {
+ result.append(std::wstring(&formatString[chunk.start], chunk.length));
+ }
+ }
+
+ return result;
+}
+
+std::wstring GkStrings::IntToString(int value, int base, int digits, const wchar_t defaultDigit)
+{
+ wchar_t s[256], result[256];
+ _itow_s(value, s, base);
+ int intLength = wcslen(s);
+ int extraDigits = digits > intLength ? digits - intLength : 0;
+ int resultLength = extraDigits > 0 ? digits : intLength;
+
+ for (int i = 0; i < resultLength; i++)
+ {
+ if (i < extraDigits)
+ result[i] = defaultDigit;
+ else
+ result[i] = s[i - extraDigits];
+ }
+
+ result[resultLength] = L'\0';
+
+ return std::wstring(result);
+}
+
+std::wstring GkStrings::FloatToString(float value, int fracDigits, int intDigits, const wchar_t defaultDigit)
+{
+ int intPart = (int)value;
+ int fracPart = (int)((value - intPart) * pow(10.0f, fracDigits));
+
+ return GkStrings::Format(L"{0}.{1}", GkStrings::IntToString(intPart, 10, intDigits, defaultDigit).c_str(), GkStrings::IntToString(fracPart, 10, fracDigits, L'0').c_str());
+}
+
+int GkStrings::StringToInt(const wchar_t *string)
+{
+ return _wtoi(string);
+}
+
+wchar_t *GkStrings::Copy(const wchar_t *string)
+{
+ if (string == 0)
+ return 0;
+
+ int length = wcslen(string);
+
+ wchar_t *result = new wchar_t[length + 1];
+ memcpy(result, string, (length + 1) * 2);
+
+ return result;
+}
+
+char *GkStrings::Copy(const char *string)
+{
+ if (string == 0)
+ return 0;
+
+ int length = strlen(string);
+
+ char *result = new char[length + 1];
+ memcpy(result, string, (length + 1));
+
+ return result;
+}
+
+void GkStrings::Dispose(wchar_t **string)
+{
+ if (*string != 0)
+ {
+ delete[] *string;
+ string = 0;
+ }
+}
+
+int GkStrings::GetLength(const wchar_t *string)
+{
+ return wcslen(string);
+}
+
+int GkStrings::GetLength(const char *string)
+{
+ return strlen(string);
+}
+
+int GkStrings::SubChar(const wchar_t *string, const wchar_t subChar)
+{
+ if (string == 0)
+ return -1;
+
+ for (int i = 0; *string != 0; i++)
+ {
+ if (*string++ == subChar)
+ {
+ return i;
+ }
+ }
+
+ return -1;
+}
+
+int GkStrings::Compare(const char *string1, const char *string2)
+{
+ return strcmp(string1, string2);
+}
+
+int GkStrings::Compare(const wchar_t *string1, const wchar_t *string2)
+{
+ return wcscmp(string1, string2);
+}
+
+std::wstring GkStrings::FormatDateTime(const wchar_t *formatString, DateTime &dateTime)
+{
+ return std::wstring(GkStrings::Format(formatString, GkStrings::IntToString(dateTime.day, 10, 2).c_str(), GkStrings::IntToString(dateTime.month, 10, 2).c_str(), GkStrings::IntToString(dateTime.year, 10, 4).c_str(), GkStrings::IntToString(dateTime.hour, 10, 2).c_str(), GkStrings::IntToString(dateTime.minute, 10, 2).c_str(), GkStrings::IntToString(dateTime.second, 10, 2).c_str()));
+}
+
+std::wstring GkStrings::IntToDecimalString(int value, int numFractionDigits)
+{
+ int fractionalFactor = 1;
+ for (int i = 0; i < numFractionDigits; i++)
+ fractionalFactor *= 10;
+
+ return GkStrings::Format(L"{0}.{1}", GkStrings::IntToString(value / fractionalFactor).c_str(), GkStrings::IntToString(value % fractionalFactor, 10, numFractionDigits).c_str());
+}
+
+std::wstring GkStrings::FromShort(const char *chars)
+{
+ int length = GkStrings::GetLength(chars);
+
+ wchar_t *wide = new wchar_t[length + 1];
+ for (int i = 0; i < length; i++)
+ wide[i] = chars[i];
+ wide[length] = 0;
+
+ std::wstring result(wide);
+
+ delete[] wide;
+
+ return result;
+}
+
+std::wstring GkStrings::FromShort(const char *chars, int start, int length)
+{
+ wchar_t *wide = new wchar_t[length + 1];
+ for (int i = 0; i < length; i++)
+ wide[i] = chars[start + i];
+ wide[length] = 0;
+
+ std::wstring result(wide);
+
+ delete[] wide;
+
+ return result;
+}
+
+std::string GkStrings::ToShort(const wchar_t *string)
+{
+ int length = GkStrings::GetLength(string);
+
+ char *shortString = new char[length + 1];
+ for (int i = 0; i < length; i++)
+ shortString[i] = (char)string[i];
+ shortString[length] = 0;
+
+ std::string result(shortString);
+
+ delete[] shortString;
+
+ return result;
+}
diff --git a/COM380/Project5/GambleKit/Engine/Utils/GkStrings.h b/COM380/Project5/GambleKit/Engine/Utils/GkStrings.h
new file mode 100644
index 0000000..a3b91b5
--- /dev/null
+++ b/COM380/Project5/GambleKit/Engine/Utils/GkStrings.h
@@ -0,0 +1,35 @@
+#pragma once
+
+#include "..\GkDefinitions.h"
+
+#include
+
+struct DateTime;
+
+class GKDLLCLASS GkStrings
+{
+public:
+ GkStrings::GkStrings(void);
+ GkStrings::~GkStrings(void);
+
+ static std::wstring GkStrings::FromShort(const char *chars);
+ static std::wstring GkStrings::FromShort(const char *chars, int start, int length);
+ static std::string GkStrings::ToShort(const wchar_t *string);
+ static std::wstring GkStrings::Format(const wchar_t *formatString, ...);
+ static std::wstring GkStrings::FormatArray(const wchar_t *formatString, wchar_t **parameters);
+ static std::wstring GkStrings::IntToString(int value, int base = 10, int digits = 0, const wchar_t defaultDigit = L'0');
+ static int GkStrings::StringToInt(const wchar_t *string);
+ static std::wstring GkStrings::FloatToString(float value, int fracDigits, int intDigits = 0, const wchar_t defaultDigit = L'0');
+ static wchar_t *GkStrings::Copy(const wchar_t *string);
+ static char *GkStrings::Copy(const char *string);
+ static void GkStrings::Dispose(wchar_t **string);
+ static int GkStrings::GetLength(const wchar_t *string);
+ static int GkStrings::GetLength(const char *string);
+ static int GkStrings::SubChar(const wchar_t *string, const wchar_t subChar);
+ static int GkStrings::Compare(const char *string1, const char *string2);
+ static int GkStrings::Compare(const wchar_t *string1, const wchar_t *string2);
+
+ static std::wstring GkStrings::FormatDateTime(const wchar_t *formatString, DateTime &dateTime);
+ static std::wstring GkStrings::IntToDecimalString(int value, int numFractionDigits = 2);
+};
+
diff --git a/COM380/Project5/GambleKit/GambleKit.vcxproj b/COM380/Project5/GambleKit/GambleKit.vcxproj
new file mode 100644
index 0000000..59cc250
--- /dev/null
+++ b/COM380/Project5/GambleKit/GambleKit.vcxproj
@@ -0,0 +1,196 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Release
+ Win32
+
+
+
+ {E6093060-EA31-4FF3-9230-2E9CDF34C694}
+ Win32Proj
+ GambleKit
+
+
+
+ Application
+ true
+ MultiByte
+ v110
+
+
+ Application
+ false
+ true
+ MultiByte
+ v110
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ $(SolutionDir)lib\DevIL;$(SolutionDir)lib\AL;$(SolutionDir)lib\GL;$(SolutionDir)lib\vld\Win32;$(LibraryPath)
+ $(SolutionDir)include;$(SolutionDir)\include\AL;$(IncludePath)
+
+
+ false
+ $(SolutionDir)include;$(SolutionDir)\include\AL;$(IncludePath)
+ $(SolutionDir)lib\DevIL;$(SolutionDir)lib\AL;$(SolutionDir)lib\GL;$(LibraryPath)
+
+
+
+
+
+ Level3
+ Disabled
+ WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+
+
+ NotSet
+ true
+ glut32.lib;DevIL.lib;ILU.lib;ILUT.lib;OpenAL32.lib;alut.lib;vld.lib;%(AdditionalDependencies)
+
+
+
+
+ Level3
+
+
+ MaxSpeed
+ true
+ true
+ WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
+
+
+ NotSet
+ true
+ true
+ true
+ glut32.lib;DevIL.lib;ILU.lib;ILUT.lib;OpenAL32.lib;alut.lib;vld.lib;%(AdditionalDependencies)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/COM380/Project5/GambleKit/GambleKit.vcxproj.filters b/COM380/Project5/GambleKit/GambleKit.vcxproj.filters
new file mode 100644
index 0000000..81c7764
--- /dev/null
+++ b/COM380/Project5/GambleKit/GambleKit.vcxproj.filters
@@ -0,0 +1,349 @@
+
+
+
+
+ {3f4469b0-7c4f-4209-8d86-c635a412f491}
+
+
+ {abe5ace2-6fa2-49f8-a75c-7bdd1cb2d702}
+
+
+ {29a2bff4-0ad9-4ebd-9ab0-421c1bc47fd8}
+
+
+ {69d9be45-fad1-4dcc-8ae6-be36db0824c4}
+
+
+ {4a352382-1872-44d4-b20b-6c87fc2a960e}
+
+
+ {c231860d-988c-4cc2-a671-2ec8edac93d1}
+
+
+ {afe7aa3e-baf9-4e45-a55c-e4ca52abcc94}
+
+
+ {e661e87d-850a-490c-a3d2-24a5be94b765}
+
+
+ {82d32f9e-c1f2-4642-8d53-c23c76e52fc9}
+
+
+ {39edfe35-394e-49b3-a13c-efebc50f322e}
+
+
+ {490b83e7-4287-4fc8-a4e4-6095eb0b8fc0}
+
+
+ {9f15391c-49db-4601-8f29-c24eb9bf0ea4}
+
+
+ {f42eacd7-d7ed-4ef6-9543-605970a76838}
+
+
+
+
+ CustomGameLogic\Pages
+
+
+ CustomGameLogic
+
+
+ CustomGameLogic
+
+
+ CustomGameLogic
+
+
+ Engine\Utils
+
+
+ Engine\Utils
+
+
+ Engine\Sound
+
+
+ Engine\Sound
+
+
+ Engine\OSSpecific
+
+
+ Engine\OSSpecific
+
+
+ Engine\OSSpecific
+
+
+ Engine\OSSpecific
+
+
+ Engine\Graphics
+
+
+ Engine\OSSpecific
+
+
+ Engine\OSSpecific
+
+
+ Engine\Graphics
+
+
+ Engine\Graphics
+
+
+ Engine\Graphics
+
+
+ Engine\Graphics
+
+
+ Engine\Game
+
+
+ Engine\Game
+
+
+ Engine\Game
+
+
+ Engine\Game
+
+
+ Engine\Game
+
+
+ Engine\Game
+
+
+ Engine\Game
+
+
+ Engine\Game
+
+
+ Engine\Game\ReelModels
+
+
+ Engine\Game\ReelModels
+
+
+ Engine\Game\Entities
+
+
+ Engine\Game\Entities
+
+
+ Engine\Game\Entities
+
+
+ Engine\Game\Entities
+
+
+ Engine\Game\Entities
+
+
+ Engine\Game\Entities
+
+
+ Engine\Game\Entities\Buttons
+
+
+ Engine\Game\Entities\Buttons
+
+
+ Engine\Game\Entities\Buttons
+
+
+ Engine\Game\Entities\Bindings
+
+
+ Engine\Game\Entities\Bindings
+
+
+ Engine\Game\Entities\Bindings
+
+
+ Engine\Game\Entities\Bindings
+
+
+ Engine\Game\Entities\Bindings
+
+
+ Engine\Game\Entities\Bindings
+
+
+ Engine\Game\Entities\Bindings
+
+
+ Engine\Base
+
+
+ Engine\Base
+
+
+ Engine\Game
+
+
+
+
+ CustomGameLogic\Pages
+
+
+ CustomGameLogic
+
+
+ CustomGameLogic
+
+
+ Engine\Utils
+
+
+ Engine\Utils
+
+
+ Engine\Utils
+
+
+ Engine\Utils
+
+
+ Engine\Sound
+
+
+ Engine\Sound
+
+
+ Engine\OSSpecific
+
+
+ Engine\OSSpecific
+
+
+ Engine\OSSpecific
+
+
+ Engine\OSSpecific
+
+
+ Engine\OSSpecific
+
+
+ Engine\OSSpecific
+
+
+ Engine\Graphics
+
+
+ Engine\Graphics
+
+
+ Engine\Graphics
+
+
+ Engine\Graphics
+
+
+ Engine\Graphics
+
+
+ Engine\Game
+
+
+ Engine\Game
+
+
+ Engine\Game
+
+
+ Engine\Game
+
+
+ Engine\Game
+
+
+ Engine\Game
+
+
+ Engine\Game
+
+
+ Engine\Game
+
+
+ Engine\Game
+
+
+ Engine\Game\ReelModels
+
+
+ Engine\Game\ReelModels
+
+
+ Engine\Game\Entities
+
+
+ Engine\Game\Entities
+
+
+ Engine\Game\Entities
+
+
+ Engine\Game\Entities
+
+
+ Engine\Game\Entities
+
+
+ Engine\Game\Entities
+
+
+ Engine\Game\Entities\Buttons
+
+
+ Engine\Game\Entities\Buttons
+
+
+ Engine\Game\Entities\Buttons
+
+
+ Engine\Game\Entities\Bindings
+
+
+ Engine\Game\Entities\Bindings
+
+
+ Engine\Game\Entities\Bindings
+
+
+ Engine\Game\Entities\Bindings
+
+
+ Engine\Game\Entities\Bindings
+
+
+ Engine\Game\Entities\Bindings
+
+
+ Engine\Game\Entities\Bindings
+
+
+ Engine\Base
+
+
+ Engine\Base
+
+
+ Engine
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/COM380/Project5/GambleKit/Intruduction.txt b/COM380/Project5/GambleKit/Intruduction.txt
new file mode 100644
index 0000000..66a076a
--- /dev/null
+++ b/COM380/Project5/GambleKit/Intruduction.txt
@@ -0,0 +1,33 @@
+This is the first publicly released version of the Kit and its documentation is still scarcely written.
+
+1. GambleKit's ideology
+
+ GambleKit aims at a declarative style of programming gambling games, and especially slot machine simulations.
+ The basic idea and guiding point is to emphasize on the declarative nature of the api, so that much coding and tedious work is saved by declaring the entities and models of the game, most often at its initialization, on game pages' creation.
+ As at creation time the environment is still relatively static, logic should be more plainly covered and readable after time, plus this greatly reduces the per-frame code, leaving mostly the higher level operations.
+ Because resources for woring on the kit are scarce, access to most, if not all parts of the entities is also provided. This leaves the ability to make custom changes at runtime and modify the parts of the game if required.
+ Just as any real-time rendering application, a game which uses GambleKit will need to process its entities at every frame. Aside from the declarations, the per-frame code is the second half of the general programing of a game with the kit.
+
+
+2. Organization
+ The object, which is highest in a game's logic is an instance of the "GkGame" class. It manages all the game's screens, or "pages", and handles loading of resources. Normally, there would be one such object.
+ GambleKit is organized into "pages". That is because a game may have different screens, each with separate logic - for example a main screen with reels, or one with a bonus, or a menu, or whatever. These screens are represented by pages - instances of the GkGamePage class. Each page has its own visual and logical layout, and how one page is built does not affect another. Only one page can be rendered at a time.
+ Each page is constructed out of Entities. Entities are, in most part, visual objects like animated images, texts, buttons, reels. An entity can also be not visible - one such are the bindings. Basically, the entities are what constructs most, if not all of a page. The whole game might be constructed entirely of them by adding them to their page in the correct manner. A game page automatically handles the behaviour of its entities and they might run fairly well without any intervention from the programmer, aside from declaring them.
+
+ Loading of resources is handled by the GkGame object. Each page of the game can and should separately load whatever resources it needs, regardless of other pages. The resources manager of GkGame handles the loading and prevents for doubling resources in memory. This way, a page is added or removed from GkGame and the exactly the right resources will be loaded with no overweight and no resource misses. Simply load in every page exactly and only what it requires. Releasing of the resources is automatically done when the GkGame object is destroyed.
+ There are a few methods for loading resources. Among their parameters, two can always be found: a "fileName" and a "virtualFileName". Because GambleKit can load its resources from a virtual file system contained in a single file, "fileName" is the name of the file containing the virtual file system. "virtualFileName" is the name to the actual file resource - either in the virtual file system, or in the real one, depending on how the file system management is set.
+ "AcquireAnimatedTexture" method loads a single image file and depending on the given parameters, may split it into pieces to form an animation
+ "AcquireAnimatedTextureFromMultipleFiles" method loads a number of image files, making animation out of each of them. The name of the files should be formatted with a five-digit index, giving the frame number, say "image_00000.png", "image_00001.png", "image_00002.png" and so on. With the latter example, the "virtualFileName" parameter should be given as "image_{0}.png", where the {0} denotes where the index is.
+ "AcquireAnimatedFontFromMultipleFiles" method loads an animated font. Like "AcquireAnimatedTextureFromMultipleFiles", it loads multiple images in the same manner, but it uses each image as a letter for the font, while the "numFrames" parameter determines in how many pieces, or frames, to split each image to animate it.
+ "AcquireSoundSource" method loads a single sound file in the raw PCM wav format and creates a sound source, which can be played.
+
+3. Entities
+ Entities will be described in a later release. I am lone, tired and hungry, so please forgive my lack of will for now.
+
+4. Demonstration code
+ Starting with "main.cpp" we have a standart entry point for the application. Some debug memory leak detection enabling, some initializers and then the mainWindow and the loop processing it.
+ Looking at the "MainWindow" class, there is its constructor, where a GkGraphicsDevice, a GkSoundDevice and a CustomGame objects are created. There is the MainLoop, where every frame is processed and rendered. There are the MouseDown and MouseUp method, where mouse events are fetched to the game object. And there are some other minor routines. The GkWindowsForm class GKDLLCLASS have a couple of methods which can be overridden when appropriate. The most interesting part here is the creation of CustomGame, which is, after all, the game.
+ In "CustomGame" class GKDLLCLASS there is not much code to behold - creation of a log and then the addition of a new GkGamePage - the "MainPage" to the game.
+ Finally, having a grasp of some real-deal code in the "MainPage" class, there's the actual difinition of the entities of the page in its constructor and some actual per-frame custom processing in its "Process" method.
+ In the constructor, the page is build through its "AddEntity" method which, just as its name promises, adds a GkGameEntity object to the page, and returns it so that it can eventually comfortably be assigned to a variable if needed. Most of the entities' constructors have many parameters with default values in order be easier to declare and add in one line. The buttons for example may not have only one or two animations for faces, while a GkGameAnimation's constructor may be given paramters such that flip the image, stretch it, override the animation framerate, make it inactive of invisible.
+ The page's "Process" method is called before the rendering of every frame. It is a convenient place to perform real-time routines, implement custom logic and program some additional dynamic to the game page. Here, the buttons are handled in regard to the motional state of the reels. Buttons are created with such parameters, that automatically renders them inactive, if their state was not asked for, which is why no logic has to be implemented for this task. Even though the "credits" member variable is changed instantly, the text for credits changes smoothly, because it was bound to a GkGameWinningCounter counter entity.
\ No newline at end of file
diff --git a/COM380/Project5/GambleKit/ReadMe.txt b/COM380/Project5/GambleKit/ReadMe.txt
new file mode 100644
index 0000000..2c1fe7c
--- /dev/null
+++ b/COM380/Project5/GambleKit/ReadMe.txt
@@ -0,0 +1,19 @@
+IMPORTANT: To run applications built with GambleKit, you'll need to have installed OpenAL and MSVS Redistributables, which are included in the "Prerequisites" folder
+
+GambleKit is a free open-source engine for easy building of slot machine gambling games with reels and GUI management.
+
+It relyes basically on declarative programming style, so the programmer needs simply to declare, for example at creation time, the basic layout and behaviour of the game, and then leave the game flow, requiring as little additional intervention as possible.
+Of course, a game can hardly go without any need of customizing the designed behaviours and it can be customized at will, having direct access to all its elements.
+The goal of GambleKit is to provide the base for this kind of games, the ability to handle common tasks declaratively with one or just a few lines of code, to leave only the very custom part of code for implementation by the programmer.
+The basic idea being to code the very game logic and visuals immediately from the start and do it with as few lines of code as possible.
+Even currently being implemented only for windows, GambleKit has little coupling with the OS and uses cross-platform tools with the prospect of easily increasing the number of supported platforms.
+
+For technical info and guide, please refer to the "Introduction" file.
+For a brief demonstration of the api, look at the "CustomGameLogic" directory in the solution.
+
+GambleKit uses the following software products:
+-OpenGL for its graphics http://www.opengl.org/
+-OpenAL for its sound http://openal-soft.org/
+-DevIL for image files decoding http://openil.sourceforge.net/
+
+You can contact me at gamblekit@gmail.com
\ No newline at end of file
diff --git a/COM380/Project5/GambleKit/version.txt b/COM380/Project5/GambleKit/version.txt
new file mode 100644
index 0000000..a838ebb
--- /dev/null
+++ b/COM380/Project5/GambleKit/version.txt
@@ -0,0 +1,12 @@
+v 0.891
+Added a "Gk" prefix to all GambleKit class names. Still considering using namespece instead.
+Added methods for creating a file containing a virtual file system. Changed the VirtualFileSystem class to GkFileSystem. Added functionality to dynamically change the file system mode to physical or virtual and to respectively set a root dir or a virtual file system file.
+Removed the first parameter from the four Acquire methods of Game (now GkGame)
+Made preparations for making the project as a library.
+
+For the next version:
+Make GambleKit as a dll. After that, It will still be available to use directly from the source.
+New examples
+Settings manager
+
+v 0.89 - First release
\ No newline at end of file
diff --git a/COM380/Project5/GameData/Background.png b/COM380/Project5/GameData/Background.png
new file mode 100644
index 0000000..bd0a252
Binary files /dev/null and b/COM380/Project5/GameData/Background.png differ
diff --git a/COM380/Project5/GameData/Thumbs.db b/COM380/Project5/GameData/Thumbs.db
new file mode 100644
index 0000000..ed103de
Binary files /dev/null and b/COM380/Project5/GameData/Thumbs.db differ
diff --git a/COM380/Project5/GameData/btn_bet_default.png b/COM380/Project5/GameData/btn_bet_default.png
new file mode 100644
index 0000000..77d4cff
Binary files /dev/null and b/COM380/Project5/GameData/btn_bet_default.png differ
diff --git a/COM380/Project5/GameData/btn_bet_disabled.png b/COM380/Project5/GameData/btn_bet_disabled.png
new file mode 100644
index 0000000..8b8e279
Binary files /dev/null and b/COM380/Project5/GameData/btn_bet_disabled.png differ
diff --git a/COM380/Project5/GameData/btn_bet_down.png b/COM380/Project5/GameData/btn_bet_down.png
new file mode 100644
index 0000000..7f9c5e1
Binary files /dev/null and b/COM380/Project5/GameData/btn_bet_down.png differ
diff --git a/COM380/Project5/GameData/btn_lines_default.png b/COM380/Project5/GameData/btn_lines_default.png
new file mode 100644
index 0000000..7d99f95
Binary files /dev/null and b/COM380/Project5/GameData/btn_lines_default.png differ
diff --git a/COM380/Project5/GameData/btn_lines_disabled.png b/COM380/Project5/GameData/btn_lines_disabled.png
new file mode 100644
index 0000000..89f71a8
Binary files /dev/null and b/COM380/Project5/GameData/btn_lines_disabled.png differ
diff --git a/COM380/Project5/GameData/btn_lines_down.png b/COM380/Project5/GameData/btn_lines_down.png
new file mode 100644
index 0000000..4ca904d
Binary files /dev/null and b/COM380/Project5/GameData/btn_lines_down.png differ
diff --git a/COM380/Project5/GameData/btn_start_default.png b/COM380/Project5/GameData/btn_start_default.png
new file mode 100644
index 0000000..c0e53c3
Binary files /dev/null and b/COM380/Project5/GameData/btn_start_default.png differ
diff --git a/COM380/Project5/GameData/btn_start_disabled.png b/COM380/Project5/GameData/btn_start_disabled.png
new file mode 100644
index 0000000..93bbb35
Binary files /dev/null and b/COM380/Project5/GameData/btn_start_disabled.png differ
diff --git a/COM380/Project5/GameData/btn_start_down.png b/COM380/Project5/GameData/btn_start_down.png
new file mode 100644
index 0000000..2a8c433
Binary files /dev/null and b/COM380/Project5/GameData/btn_start_down.png differ
diff --git a/COM380/Project5/GameData/font_main_00000.png b/COM380/Project5/GameData/font_main_00000.png
new file mode 100644
index 0000000..0cc6bfb
Binary files /dev/null and b/COM380/Project5/GameData/font_main_00000.png differ
diff --git a/COM380/Project5/GameData/font_main_00001.png b/COM380/Project5/GameData/font_main_00001.png
new file mode 100644
index 0000000..2dc4746
Binary files /dev/null and b/COM380/Project5/GameData/font_main_00001.png differ
diff --git a/COM380/Project5/GameData/font_main_00002.png b/COM380/Project5/GameData/font_main_00002.png
new file mode 100644
index 0000000..511e41c
Binary files /dev/null and b/COM380/Project5/GameData/font_main_00002.png differ
diff --git a/COM380/Project5/GameData/font_main_00003.png b/COM380/Project5/GameData/font_main_00003.png
new file mode 100644
index 0000000..10efad3
Binary files /dev/null and b/COM380/Project5/GameData/font_main_00003.png differ
diff --git a/COM380/Project5/GameData/font_main_00004.png b/COM380/Project5/GameData/font_main_00004.png
new file mode 100644
index 0000000..c3c5361
Binary files /dev/null and b/COM380/Project5/GameData/font_main_00004.png differ
diff --git a/COM380/Project5/GameData/font_main_00005.png b/COM380/Project5/GameData/font_main_00005.png
new file mode 100644
index 0000000..77705fa
Binary files /dev/null and b/COM380/Project5/GameData/font_main_00005.png differ
diff --git a/COM380/Project5/GameData/font_main_00006.png b/COM380/Project5/GameData/font_main_00006.png
new file mode 100644
index 0000000..455cc87
Binary files /dev/null and b/COM380/Project5/GameData/font_main_00006.png differ
diff --git a/COM380/Project5/GameData/font_main_00007.png b/COM380/Project5/GameData/font_main_00007.png
new file mode 100644
index 0000000..f2928e1
Binary files /dev/null and b/COM380/Project5/GameData/font_main_00007.png differ
diff --git a/COM380/Project5/GameData/font_main_00008.png b/COM380/Project5/GameData/font_main_00008.png
new file mode 100644
index 0000000..fc85f2c
Binary files /dev/null and b/COM380/Project5/GameData/font_main_00008.png differ
diff --git a/COM380/Project5/GameData/font_main_00009.png b/COM380/Project5/GameData/font_main_00009.png
new file mode 100644
index 0000000..aed86cd
Binary files /dev/null and b/COM380/Project5/GameData/font_main_00009.png differ
diff --git a/COM380/Project5/GameData/font_main_00010.png b/COM380/Project5/GameData/font_main_00010.png
new file mode 100644
index 0000000..b18966b
Binary files /dev/null and b/COM380/Project5/GameData/font_main_00010.png differ
diff --git a/COM380/Project5/GameData/font_main_00011.png b/COM380/Project5/GameData/font_main_00011.png
new file mode 100644
index 0000000..84a153a
Binary files /dev/null and b/COM380/Project5/GameData/font_main_00011.png differ
diff --git a/COM380/Project5/GameData/font_main_00012.png b/COM380/Project5/GameData/font_main_00012.png
new file mode 100644
index 0000000..96a7dc3
Binary files /dev/null and b/COM380/Project5/GameData/font_main_00012.png differ
diff --git a/COM380/Project5/GameData/line123.png b/COM380/Project5/GameData/line123.png
new file mode 100644
index 0000000..60f01ca
Binary files /dev/null and b/COM380/Project5/GameData/line123.png differ
diff --git a/COM380/Project5/GameData/line45.png b/COM380/Project5/GameData/line45.png
new file mode 100644
index 0000000..79b4479
Binary files /dev/null and b/COM380/Project5/GameData/line45.png differ
diff --git a/COM380/Project5/GameData/reel.wav b/COM380/Project5/GameData/reel.wav
new file mode 100644
index 0000000..3589bb4
Binary files /dev/null and b/COM380/Project5/GameData/reel.wav differ
diff --git a/COM380/Project5/GameData/reels.wav b/COM380/Project5/GameData/reels.wav
new file mode 100644
index 0000000..26dce8d
Binary files /dev/null and b/COM380/Project5/GameData/reels.wav differ
diff --git a/COM380/Project5/GameData/symbol_7.png b/COM380/Project5/GameData/symbol_7.png
new file mode 100644
index 0000000..1fdf442
Binary files /dev/null and b/COM380/Project5/GameData/symbol_7.png differ
diff --git a/COM380/Project5/GameData/symbol_bell.png b/COM380/Project5/GameData/symbol_bell.png
new file mode 100644
index 0000000..196fb3d
Binary files /dev/null and b/COM380/Project5/GameData/symbol_bell.png differ
diff --git a/COM380/Project5/GameData/symbol_cherry.png b/COM380/Project5/GameData/symbol_cherry.png
new file mode 100644
index 0000000..c4afef2
Binary files /dev/null and b/COM380/Project5/GameData/symbol_cherry.png differ
diff --git a/COM380/Project5/GameData/symbol_melon.png b/COM380/Project5/GameData/symbol_melon.png
new file mode 100644
index 0000000..3a7dbcb
Binary files /dev/null and b/COM380/Project5/GameData/symbol_melon.png differ
diff --git a/COM380/Project5/License.txt b/COM380/Project5/License.txt
new file mode 100644
index 0000000..04d7be2
--- /dev/null
+++ b/COM380/Project5/License.txt
@@ -0,0 +1,144 @@
+GNU Lesser General Public License
+
+Version 2.1, February 1999
+
+Copyright (C) 1991, 1999 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.]
+Preamble
+
+ The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users.
+
+This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things.
+
+To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights.
+
+We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library.
+
+To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others.
+
+ Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license.
+
+Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs.
+
+When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library.
+
+We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances.
+
+For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License.
+
+In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system.
+
+ Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library.
+
+The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run.
+TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library.
+
+Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does.
+
+1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library.
+
+ You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.
+
+2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:
+
+a) The modified work must itself be a software library.
+
+b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change.
+
+c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License.
+
+d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.)
+
+ These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library.
+
+ In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.
+
+3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices.
+
+Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of the Library into a program that is not a library.
+
+4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange.
+
+If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code.
+
+5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.)
+
+Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself.
+
+6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things:
+
+a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.)
+
+b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution.
+
+d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place.
+
+e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy.
+
+For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.
+
+ It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute.
+
+7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things:
+
+a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above.
+
+b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work.
+
+8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.
+
+9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it.
+
+10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License.
+
+11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library.
+
+ If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.
+
+This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.
+
+12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.
+
+13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation.
+
+14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+END OF TERMS AND CONDITIONS
\ No newline at end of file
diff --git a/COM380/Project5/include/AL/al.h b/COM380/Project5/include/AL/al.h
new file mode 100644
index 0000000..1c2f95b
--- /dev/null
+++ b/COM380/Project5/include/AL/al.h
@@ -0,0 +1,732 @@
+#ifndef AL_AL_H
+#define AL_AL_H
+
+
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+#if defined(_WIN32) && !defined(_XBOX)
+ /* _OPENAL32LIB is deprecated */
+ #if defined(AL_BUILD_LIBRARY) || defined (_OPENAL32LIB)
+ #define AL_API __declspec(dllexport)
+ #else
+ #define AL_API __declspec(dllimport)
+ #endif
+#else
+ #define AL_API extern
+#endif
+
+#if defined(_WIN32)
+ #define AL_APIENTRY __cdecl
+#else
+ #define AL_APIENTRY
+#endif
+
+#if TARGET_OS_MAC
+ #pragma export on
+#endif
+
+/* The OPENAL, ALAPI, and ALAPIENTRY macros are deprecated, but are included for applications porting code
+ from AL 1.0 */
+#define OPENAL
+#define ALAPI AL_API
+#define ALAPIENTRY AL_APIENTRY
+
+#define AL_VERSION_1_0
+#define AL_VERSION_1_1
+
+
+/** 8-bit boolean */
+typedef char ALboolean;
+
+/** character */
+typedef char ALchar;
+
+/** signed 8-bit 2's complement integer */
+typedef char ALbyte;
+
+/** unsigned 8-bit integer */
+typedef unsigned char ALubyte;
+
+/** signed 16-bit 2's complement integer */
+typedef short ALshort;
+
+/** unsigned 16-bit integer */
+typedef unsigned short ALushort;
+
+/** signed 32-bit 2's complement integer */
+typedef int ALint;
+
+/** unsigned 32-bit integer */
+typedef unsigned int ALuint;
+
+/** non-negative 32-bit binary integer size */
+typedef int ALsizei;
+
+/** enumerated 32-bit value */
+typedef int ALenum;
+
+/** 32-bit IEEE754 floating-point */
+typedef float ALfloat;
+
+/** 64-bit IEEE754 floating-point */
+typedef double ALdouble;
+
+/** void type (for opaque pointers only) */
+typedef void ALvoid;
+
+
+/* Enumerant values begin at column 50. No tabs. */
+
+/* bad value */
+#define AL_INVALID -1
+
+#define AL_NONE 0
+
+/* Boolean False. */
+#define AL_FALSE 0
+
+/** Boolean True. */
+#define AL_TRUE 1
+
+/** Indicate Source has relative coordinates. */
+#define AL_SOURCE_RELATIVE 0x202
+
+
+
+/**
+ * Directional source, inner cone angle, in degrees.
+ * Range: [0-360]
+ * Default: 360
+ */
+#define AL_CONE_INNER_ANGLE 0x1001
+
+/**
+ * Directional source, outer cone angle, in degrees.
+ * Range: [0-360]
+ * Default: 360
+ */
+#define AL_CONE_OUTER_ANGLE 0x1002
+
+/**
+ * Specify the pitch to be applied, either at source,
+ * or on mixer results, at listener.
+ * Range: [0.5-2.0]
+ * Default: 1.0
+ */
+#define AL_PITCH 0x1003
+
+/**
+ * Specify the current location in three dimensional space.
+ * OpenAL, like OpenGL, uses a right handed coordinate system,
+ * where in a frontal default view X (thumb) points right,
+ * Y points up (index finger), and Z points towards the
+ * viewer/camera (middle finger).
+ * To switch from a left handed coordinate system, flip the
+ * sign on the Z coordinate.
+ * Listener position is always in the world coordinate system.
+ */
+#define AL_POSITION 0x1004
+
+/** Specify the current direction. */
+#define AL_DIRECTION 0x1005
+
+/** Specify the current velocity in three dimensional space. */
+#define AL_VELOCITY 0x1006
+
+/**
+ * Indicate whether source is looping.
+ * Type: ALboolean?
+ * Range: [AL_TRUE, AL_FALSE]
+ * Default: FALSE.
+ */
+#define AL_LOOPING 0x1007
+
+/**
+ * Indicate the buffer to provide sound samples.
+ * Type: ALuint.
+ * Range: any valid Buffer id.
+ */
+#define AL_BUFFER 0x1009
+
+/**
+ * Indicate the gain (volume amplification) applied.
+ * Type: ALfloat.
+ * Range: ]0.0- ]
+ * A value of 1.0 means un-attenuated/unchanged.
+ * Each division by 2 equals an attenuation of -6dB.
+ * Each multiplicaton with 2 equals an amplification of +6dB.
+ * A value of 0.0 is meaningless with respect to a logarithmic
+ * scale; it is interpreted as zero volume - the channel
+ * is effectively disabled.
+ */
+#define AL_GAIN 0x100A
+
+/*
+ * Indicate minimum source attenuation
+ * Type: ALfloat
+ * Range: [0.0 - 1.0]
+ *
+ * Logarthmic
+ */
+#define AL_MIN_GAIN 0x100D
+
+/**
+ * Indicate maximum source attenuation
+ * Type: ALfloat
+ * Range: [0.0 - 1.0]
+ *
+ * Logarthmic
+ */
+#define AL_MAX_GAIN 0x100E
+
+/**
+ * Indicate listener orientation.
+ *
+ * at/up
+ */
+#define AL_ORIENTATION 0x100F
+
+/**
+ * Specify the channel mask. (Creative)
+ * Type: ALuint
+ * Range: [0 - 255]
+ */
+#define AL_CHANNEL_MASK 0x3000
+
+
+/**
+ * Source state information.
+ */
+#define AL_SOURCE_STATE 0x1010
+#define AL_INITIAL 0x1011
+#define AL_PLAYING 0x1012
+#define AL_PAUSED 0x1013
+#define AL_STOPPED 0x1014
+
+/**
+ * Buffer Queue params
+ */
+#define AL_BUFFERS_QUEUED 0x1015
+#define AL_BUFFERS_PROCESSED 0x1016
+
+/**
+ * Source buffer position information
+ */
+#define AL_SEC_OFFSET 0x1024
+#define AL_SAMPLE_OFFSET 0x1025
+#define AL_BYTE_OFFSET 0x1026
+
+/*
+ * Source type (Static, Streaming or undetermined)
+ * Source is Static if a Buffer has been attached using AL_BUFFER
+ * Source is Streaming if one or more Buffers have been attached using alSourceQueueBuffers
+ * Source is undetermined when it has the NULL buffer attached
+ */
+#define AL_SOURCE_TYPE 0x1027
+#define AL_STATIC 0x1028
+#define AL_STREAMING 0x1029
+#define AL_UNDETERMINED 0x1030
+
+/** Sound samples: format specifier. */
+#define AL_FORMAT_MONO8 0x1100
+#define AL_FORMAT_MONO16 0x1101
+#define AL_FORMAT_STEREO8 0x1102
+#define AL_FORMAT_STEREO16 0x1103
+
+/**
+ * source specific reference distance
+ * Type: ALfloat
+ * Range: 0.0 - +inf
+ *
+ * At 0.0, no distance attenuation occurs. Default is
+ * 1.0.
+ */
+#define AL_REFERENCE_DISTANCE 0x1020
+
+/**
+ * source specific rolloff factor
+ * Type: ALfloat
+ * Range: 0.0 - +inf
+ *
+ */
+#define AL_ROLLOFF_FACTOR 0x1021
+
+/**
+ * Directional source, outer cone gain.
+ *
+ * Default: 0.0
+ * Range: [0.0 - 1.0]
+ * Logarithmic
+ */
+#define AL_CONE_OUTER_GAIN 0x1022
+
+/**
+ * Indicate distance above which sources are not
+ * attenuated using the inverse clamped distance model.
+ *
+ * Default: +inf
+ * Type: ALfloat
+ * Range: 0.0 - +inf
+ */
+#define AL_MAX_DISTANCE 0x1023
+
+/**
+ * Sound samples: frequency, in units of Hertz [Hz].
+ * This is the number of samples per second. Half of the
+ * sample frequency marks the maximum significant
+ * frequency component.
+ */
+#define AL_FREQUENCY 0x2001
+#define AL_BITS 0x2002
+#define AL_CHANNELS 0x2003
+#define AL_SIZE 0x2004
+
+/**
+ * Buffer state.
+ *
+ * Not supported for public use (yet).
+ */
+#define AL_UNUSED 0x2010
+#define AL_PENDING 0x2011
+#define AL_PROCESSED 0x2012
+
+
+/** Errors: No Error. */
+#define AL_NO_ERROR AL_FALSE
+
+/**
+ * Invalid Name paramater passed to AL call.
+ */
+#define AL_INVALID_NAME 0xA001
+
+/**
+ * Invalid parameter passed to AL call.
+ */
+#define AL_ILLEGAL_ENUM 0xA002
+#define AL_INVALID_ENUM 0xA002
+
+/**
+ * Invalid enum parameter value.
+ */
+#define AL_INVALID_VALUE 0xA003
+
+/**
+ * Illegal call.
+ */
+#define AL_ILLEGAL_COMMAND 0xA004
+#define AL_INVALID_OPERATION 0xA004
+
+
+/**
+ * No mojo.
+ */
+#define AL_OUT_OF_MEMORY 0xA005
+
+
+/** Context strings: Vendor Name. */
+#define AL_VENDOR 0xB001
+#define AL_VERSION 0xB002
+#define AL_RENDERER 0xB003
+#define AL_EXTENSIONS 0xB004
+
+/** Global tweakage. */
+
+/**
+ * Doppler scale. Default 1.0
+ */
+#define AL_DOPPLER_FACTOR 0xC000
+
+/**
+ * Tweaks speed of propagation.
+ */
+#define AL_DOPPLER_VELOCITY 0xC001
+
+/**
+ * Speed of Sound in units per second
+ */
+#define AL_SPEED_OF_SOUND 0xC003
+
+/**
+ * Distance models
+ *
+ * used in conjunction with DistanceModel
+ *
+ * implicit: NONE, which disances distance attenuation.
+ */
+#define AL_DISTANCE_MODEL 0xD000
+#define AL_INVERSE_DISTANCE 0xD001
+#define AL_INVERSE_DISTANCE_CLAMPED 0xD002
+#define AL_LINEAR_DISTANCE 0xD003
+#define AL_LINEAR_DISTANCE_CLAMPED 0xD004
+#define AL_EXPONENT_DISTANCE 0xD005
+#define AL_EXPONENT_DISTANCE_CLAMPED 0xD006
+
+
+#if !defined(AL_NO_PROTOTYPES)
+
+/*
+ * Renderer State management
+ */
+AL_API void AL_APIENTRY alEnable( ALenum capability );
+
+AL_API void AL_APIENTRY alDisable( ALenum capability );
+
+AL_API ALboolean AL_APIENTRY alIsEnabled( ALenum capability );
+
+
+/*
+ * State retrieval
+ */
+AL_API const ALchar* AL_APIENTRY alGetString( ALenum param );
+
+AL_API void AL_APIENTRY alGetBooleanv( ALenum param, ALboolean* data );
+
+AL_API void AL_APIENTRY alGetIntegerv( ALenum param, ALint* data );
+
+AL_API void AL_APIENTRY alGetFloatv( ALenum param, ALfloat* data );
+
+AL_API void AL_APIENTRY alGetDoublev( ALenum param, ALdouble* data );
+
+AL_API ALboolean AL_APIENTRY alGetBoolean( ALenum param );
+
+AL_API ALint AL_APIENTRY alGetInteger( ALenum param );
+
+AL_API ALfloat AL_APIENTRY alGetFloat( ALenum param );
+
+AL_API ALdouble AL_APIENTRY alGetDouble( ALenum param );
+
+
+/*
+ * Error support.
+ * Obtain the most recent error generated in the AL state machine.
+ */
+AL_API ALenum AL_APIENTRY alGetError( void );
+
+
+/*
+ * Extension support.
+ * Query for the presence of an extension, and obtain any appropriate
+ * function pointers and enum values.
+ */
+AL_API ALboolean AL_APIENTRY alIsExtensionPresent( const ALchar* extname );
+
+AL_API void* AL_APIENTRY alGetProcAddress( const ALchar* fname );
+
+AL_API ALenum AL_APIENTRY alGetEnumValue( const ALchar* ename );
+
+
+/*
+ * LISTENER
+ * Listener represents the location and orientation of the
+ * 'user' in 3D-space.
+ *
+ * Properties include: -
+ *
+ * Gain AL_GAIN ALfloat
+ * Position AL_POSITION ALfloat[3]
+ * Velocity AL_VELOCITY ALfloat[3]
+ * Orientation AL_ORIENTATION ALfloat[6] (Forward then Up vectors)
+*/
+
+/*
+ * Set Listener parameters
+ */
+AL_API void AL_APIENTRY alListenerf( ALenum param, ALfloat value );
+
+AL_API void AL_APIENTRY alListener3f( ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 );
+
+AL_API void AL_APIENTRY alListenerfv( ALenum param, const ALfloat* values );
+
+AL_API void AL_APIENTRY alListeneri( ALenum param, ALint value );
+
+AL_API void AL_APIENTRY alListener3i( ALenum param, ALint value1, ALint value2, ALint value3 );
+
+AL_API void AL_APIENTRY alListeneriv( ALenum param, const ALint* values );
+
+/*
+ * Get Listener parameters
+ */
+AL_API void AL_APIENTRY alGetListenerf( ALenum param, ALfloat* value );
+
+AL_API void AL_APIENTRY alGetListener3f( ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3 );
+
+AL_API void AL_APIENTRY alGetListenerfv( ALenum param, ALfloat* values );
+
+AL_API void AL_APIENTRY alGetListeneri( ALenum param, ALint* value );
+
+AL_API void AL_APIENTRY alGetListener3i( ALenum param, ALint *value1, ALint *value2, ALint *value3 );
+
+AL_API void AL_APIENTRY alGetListeneriv( ALenum param, ALint* values );
+
+
+/**
+ * SOURCE
+ * Sources represent individual sound objects in 3D-space.
+ * Sources take the PCM data provided in the specified Buffer,
+ * apply Source-specific modifications, and then
+ * submit them to be mixed according to spatial arrangement etc.
+ *
+ * Properties include: -
+ *
+ * Gain AL_GAIN ALfloat
+ * Min Gain AL_MIN_GAIN ALfloat
+ * Max Gain AL_MAX_GAIN ALfloat
+ * Position AL_POSITION ALfloat[3]
+ * Velocity AL_VELOCITY ALfloat[3]
+ * Direction AL_DIRECTION ALfloat[3]
+ * Head Relative Mode AL_SOURCE_RELATIVE ALint (AL_TRUE or AL_FALSE)
+ * Reference Distance AL_REFERENCE_DISTANCE ALfloat
+ * Max Distance AL_MAX_DISTANCE ALfloat
+ * RollOff Factor AL_ROLLOFF_FACTOR ALfloat
+ * Inner Angle AL_CONE_INNER_ANGLE ALint or ALfloat
+ * Outer Angle AL_CONE_OUTER_ANGLE ALint or ALfloat
+ * Cone Outer Gain AL_CONE_OUTER_GAIN ALint or ALfloat
+ * Pitch AL_PITCH ALfloat
+ * Looping AL_LOOPING ALint (AL_TRUE or AL_FALSE)
+ * MS Offset AL_MSEC_OFFSET ALint or ALfloat
+ * Byte Offset AL_BYTE_OFFSET ALint or ALfloat
+ * Sample Offset AL_SAMPLE_OFFSET ALint or ALfloat
+ * Attached Buffer AL_BUFFER ALint
+ * State (Query only) AL_SOURCE_STATE ALint
+ * Buffers Queued (Query only) AL_BUFFERS_QUEUED ALint
+ * Buffers Processed (Query only) AL_BUFFERS_PROCESSED ALint
+ */
+
+/* Create Source objects */
+AL_API void AL_APIENTRY alGenSources( ALsizei n, ALuint* sources );
+
+/* Delete Source objects */
+AL_API void AL_APIENTRY alDeleteSources( ALsizei n, const ALuint* sources );
+
+/* Verify a handle is a valid Source */
+AL_API ALboolean AL_APIENTRY alIsSource( ALuint sid );
+
+/*
+ * Set Source parameters
+ */
+AL_API void AL_APIENTRY alSourcef( ALuint sid, ALenum param, ALfloat value );
+
+AL_API void AL_APIENTRY alSource3f( ALuint sid, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 );
+
+AL_API void AL_APIENTRY alSourcefv( ALuint sid, ALenum param, const ALfloat* values );
+
+AL_API void AL_APIENTRY alSourcei( ALuint sid, ALenum param, ALint value );
+
+AL_API void AL_APIENTRY alSource3i( ALuint sid, ALenum param, ALint value1, ALint value2, ALint value3 );
+
+AL_API void AL_APIENTRY alSourceiv( ALuint sid, ALenum param, const ALint* values );
+
+/*
+ * Get Source parameters
+ */
+AL_API void AL_APIENTRY alGetSourcef( ALuint sid, ALenum param, ALfloat* value );
+
+AL_API void AL_APIENTRY alGetSource3f( ALuint sid, ALenum param, ALfloat* value1, ALfloat* value2, ALfloat* value3);
+
+AL_API void AL_APIENTRY alGetSourcefv( ALuint sid, ALenum param, ALfloat* values );
+
+AL_API void AL_APIENTRY alGetSourcei( ALuint sid, ALenum param, ALint* value );
+
+AL_API void AL_APIENTRY alGetSource3i( ALuint sid, ALenum param, ALint* value1, ALint* value2, ALint* value3);
+
+AL_API void AL_APIENTRY alGetSourceiv( ALuint sid, ALenum param, ALint* values );
+
+
+/*
+ * Source vector based playback calls
+ */
+
+/* Play, replay, or resume (if paused) a list of Sources */
+AL_API void AL_APIENTRY alSourcePlayv( ALsizei ns, const ALuint *sids );
+
+/* Stop a list of Sources */
+AL_API void AL_APIENTRY alSourceStopv( ALsizei ns, const ALuint *sids );
+
+/* Rewind a list of Sources */
+AL_API void AL_APIENTRY alSourceRewindv( ALsizei ns, const ALuint *sids );
+
+/* Pause a list of Sources */
+AL_API void AL_APIENTRY alSourcePausev( ALsizei ns, const ALuint *sids );
+
+/*
+ * Source based playback calls
+ */
+
+/* Play, replay, or resume a Source */
+AL_API void AL_APIENTRY alSourcePlay( ALuint sid );
+
+/* Stop a Source */
+AL_API void AL_APIENTRY alSourceStop( ALuint sid );
+
+/* Rewind a Source (set playback postiton to beginning) */
+AL_API void AL_APIENTRY alSourceRewind( ALuint sid );
+
+/* Pause a Source */
+AL_API void AL_APIENTRY alSourcePause( ALuint sid );
+
+/*
+ * Source Queuing
+ */
+AL_API void AL_APIENTRY alSourceQueueBuffers( ALuint sid, ALsizei numEntries, const ALuint *bids );
+
+AL_API void AL_APIENTRY alSourceUnqueueBuffers( ALuint sid, ALsizei numEntries, ALuint *bids );
+
+
+/**
+ * BUFFER
+ * Buffer objects are storage space for sample data.
+ * Buffers are referred to by Sources. One Buffer can be used
+ * by multiple Sources.
+ *
+ * Properties include: -
+ *
+ * Frequency (Query only) AL_FREQUENCY ALint
+ * Size (Query only) AL_SIZE ALint
+ * Bits (Query only) AL_BITS ALint
+ * Channels (Query only) AL_CHANNELS ALint
+ */
+
+/* Create Buffer objects */
+AL_API void AL_APIENTRY alGenBuffers( ALsizei n, ALuint* buffers );
+
+/* Delete Buffer objects */
+AL_API void AL_APIENTRY alDeleteBuffers( ALsizei n, const ALuint* buffers );
+
+/* Verify a handle is a valid Buffer */
+AL_API ALboolean AL_APIENTRY alIsBuffer( ALuint bid );
+
+/* Specify the data to be copied into a buffer */
+AL_API void AL_APIENTRY alBufferData( ALuint bid, ALenum format, const ALvoid* data, ALsizei size, ALsizei freq );
+
+/*
+ * Set Buffer parameters
+ */
+AL_API void AL_APIENTRY alBufferf( ALuint bid, ALenum param, ALfloat value );
+
+AL_API void AL_APIENTRY alBuffer3f( ALuint bid, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 );
+
+AL_API void AL_APIENTRY alBufferfv( ALuint bid, ALenum param, const ALfloat* values );
+
+AL_API void AL_APIENTRY alBufferi( ALuint bid, ALenum param, ALint value );
+
+AL_API void AL_APIENTRY alBuffer3i( ALuint bid, ALenum param, ALint value1, ALint value2, ALint value3 );
+
+AL_API void AL_APIENTRY alBufferiv( ALuint bid, ALenum param, const ALint* values );
+
+/*
+ * Get Buffer parameters
+ */
+AL_API void AL_APIENTRY alGetBufferf( ALuint bid, ALenum param, ALfloat* value );
+
+AL_API void AL_APIENTRY alGetBuffer3f( ALuint bid, ALenum param, ALfloat* value1, ALfloat* value2, ALfloat* value3);
+
+AL_API void AL_APIENTRY alGetBufferfv( ALuint bid, ALenum param, ALfloat* values );
+
+AL_API void AL_APIENTRY alGetBufferi( ALuint bid, ALenum param, ALint* value );
+
+AL_API void AL_APIENTRY alGetBuffer3i( ALuint bid, ALenum param, ALint* value1, ALint* value2, ALint* value3);
+
+AL_API void AL_APIENTRY alGetBufferiv( ALuint bid, ALenum param, ALint* values );
+
+
+/*
+ * Global Parameters
+ */
+AL_API void AL_APIENTRY alDopplerFactor( ALfloat value );
+
+AL_API void AL_APIENTRY alDopplerVelocity( ALfloat value );
+
+AL_API void AL_APIENTRY alSpeedOfSound( ALfloat value );
+
+AL_API void AL_APIENTRY alDistanceModel( ALenum distanceModel );
+
+#else /* AL_NO_PROTOTYPES */
+
+typedef void (AL_APIENTRY *LPALENABLE)( ALenum capability );
+typedef void (AL_APIENTRY *LPALDISABLE)( ALenum capability );
+typedef ALboolean (AL_APIENTRY *LPALISENABLED)( ALenum capability );
+typedef const ALchar* (AL_APIENTRY *LPALGETSTRING)( ALenum param );
+typedef void (AL_APIENTRY *LPALGETBOOLEANV)( ALenum param, ALboolean* data );
+typedef void (AL_APIENTRY *LPALGETINTEGERV)( ALenum param, ALint* data );
+typedef void (AL_APIENTRY *LPALGETFLOATV)( ALenum param, ALfloat* data );
+typedef void (AL_APIENTRY *LPALGETDOUBLEV)( ALenum param, ALdouble* data );
+typedef ALboolean (AL_APIENTRY *LPALGETBOOLEAN)( ALenum param );
+typedef ALint (AL_APIENTRY *LPALGETINTEGER)( ALenum param );
+typedef ALfloat (AL_APIENTRY *LPALGETFLOAT)( ALenum param );
+typedef ALdouble (AL_APIENTRY *LPALGETDOUBLE)( ALenum param );
+typedef ALenum (AL_APIENTRY *LPALGETERROR)( void );
+typedef ALboolean (AL_APIENTRY *LPALISEXTENSIONPRESENT)(const ALchar* extname );
+typedef void* (AL_APIENTRY *LPALGETPROCADDRESS)( const ALchar* fname );
+typedef ALenum (AL_APIENTRY *LPALGETENUMVALUE)( const ALchar* ename );
+typedef void (AL_APIENTRY *LPALLISTENERF)( ALenum param, ALfloat value );
+typedef void (AL_APIENTRY *LPALLISTENER3F)( ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 );
+typedef void (AL_APIENTRY *LPALLISTENERFV)( ALenum param, const ALfloat* values );
+typedef void (AL_APIENTRY *LPALLISTENERI)( ALenum param, ALint value );
+typedef void (AL_APIENTRY *LPALLISTENER3I)( ALenum param, ALint value1, ALint value2, ALint value3 );
+typedef void (AL_APIENTRY *LPALLISTENERIV)( ALenum param, const ALint* values );
+typedef void (AL_APIENTRY *LPALGETLISTENERF)( ALenum param, ALfloat* value );
+typedef void (AL_APIENTRY *LPALGETLISTENER3F)( ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3 );
+typedef void (AL_APIENTRY *LPALGETLISTENERFV)( ALenum param, ALfloat* values );
+typedef void (AL_APIENTRY *LPALGETLISTENERI)( ALenum param, ALint* value );
+typedef void (AL_APIENTRY *LPALGETLISTENER3I)( ALenum param, ALint *value1, ALint *value2, ALint *value3 );
+typedef void (AL_APIENTRY *LPALGETLISTENERIV)( ALenum param, ALint* values );
+typedef void (AL_APIENTRY *LPALGENSOURCES)( ALsizei n, ALuint* sources );
+typedef void (AL_APIENTRY *LPALDELETESOURCES)( ALsizei n, const ALuint* sources );
+typedef ALboolean (AL_APIENTRY *LPALISSOURCE)( ALuint sid );
+typedef void (AL_APIENTRY *LPALSOURCEF)( ALuint sid, ALenum param, ALfloat value);
+typedef void (AL_APIENTRY *LPALSOURCE3F)( ALuint sid, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 );
+typedef void (AL_APIENTRY *LPALSOURCEFV)( ALuint sid, ALenum param, const ALfloat* values );
+typedef void (AL_APIENTRY *LPALSOURCEI)( ALuint sid, ALenum param, ALint value);
+typedef void (AL_APIENTRY *LPALSOURCE3I)( ALuint sid, ALenum param, ALint value1, ALint value2, ALint value3 );
+typedef void (AL_APIENTRY *LPALSOURCEIV)( ALuint sid, ALenum param, const ALint* values );
+typedef void (AL_APIENTRY *LPALGETSOURCEF)( ALuint sid, ALenum param, ALfloat* value );
+typedef void (AL_APIENTRY *LPALGETSOURCE3F)( ALuint sid, ALenum param, ALfloat* value1, ALfloat* value2, ALfloat* value3);
+typedef void (AL_APIENTRY *LPALGETSOURCEFV)( ALuint sid, ALenum param, ALfloat* values );
+typedef void (AL_APIENTRY *LPALGETSOURCEI)( ALuint sid, ALenum param, ALint* value );
+typedef void (AL_APIENTRY *LPALGETSOURCE3I)( ALuint sid, ALenum param, ALint* value1, ALint* value2, ALint* value3);
+typedef void (AL_APIENTRY *LPALGETSOURCEIV)( ALuint sid, ALenum param, ALint* values );
+typedef void (AL_APIENTRY *LPALSOURCEPLAYV)( ALsizei ns, const ALuint *sids );
+typedef void (AL_APIENTRY *LPALSOURCESTOPV)( ALsizei ns, const ALuint *sids );
+typedef void (AL_APIENTRY *LPALSOURCEREWINDV)( ALsizei ns, const ALuint *sids );
+typedef void (AL_APIENTRY *LPALSOURCEPAUSEV)( ALsizei ns, const ALuint *sids );
+typedef void (AL_APIENTRY *LPALSOURCEPLAY)( ALuint sid );
+typedef void (AL_APIENTRY *LPALSOURCESTOP)( ALuint sid );
+typedef void (AL_APIENTRY *LPALSOURCEREWIND)( ALuint sid );
+typedef void (AL_APIENTRY *LPALSOURCEPAUSE)( ALuint sid );
+typedef void (AL_APIENTRY *LPALSOURCEQUEUEBUFFERS)(ALuint sid, ALsizei numEntries, const ALuint *bids );
+typedef void (AL_APIENTRY *LPALSOURCEUNQUEUEBUFFERS)(ALuint sid, ALsizei numEntries, ALuint *bids );
+typedef void (AL_APIENTRY *LPALGENBUFFERS)( ALsizei n, ALuint* buffers );
+typedef void (AL_APIENTRY *LPALDELETEBUFFERS)( ALsizei n, const ALuint* buffers );
+typedef ALboolean (AL_APIENTRY *LPALISBUFFER)( ALuint bid );
+typedef void (AL_APIENTRY *LPALBUFFERDATA)( ALuint bid, ALenum format, const ALvoid* data, ALsizei size, ALsizei freq );
+typedef void (AL_APIENTRY *LPALBUFFERF)( ALuint bid, ALenum param, ALfloat value);
+typedef void (AL_APIENTRY *LPALBUFFER3F)( ALuint bid, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 );
+typedef void (AL_APIENTRY *LPALBUFFERFV)( ALuint bid, ALenum param, const ALfloat* values );
+typedef void (AL_APIENTRY *LPALBUFFERI)( ALuint bid, ALenum param, ALint value);
+typedef void (AL_APIENTRY *LPALBUFFER3I)( ALuint bid, ALenum param, ALint value1, ALint value2, ALint value3 );
+typedef void (AL_APIENTRY *LPALBUFFERIV)( ALuint bid, ALenum param, const ALint* values );
+typedef void (AL_APIENTRY *LPALGETBUFFERF)( ALuint bid, ALenum param, ALfloat* value );
+typedef void (AL_APIENTRY *LPALGETBUFFER3F)( ALuint bid, ALenum param, ALfloat* value1, ALfloat* value2, ALfloat* value3);
+typedef void (AL_APIENTRY *LPALGETBUFFERFV)( ALuint bid, ALenum param, ALfloat* values );
+typedef void (AL_APIENTRY *LPALGETBUFFERI)( ALuint bid, ALenum param, ALint* value );
+typedef void (AL_APIENTRY *LPALGETBUFFER3I)( ALuint bid, ALenum param, ALint* value1, ALint* value2, ALint* value3);
+typedef void (AL_APIENTRY *LPALGETBUFFERIV)( ALuint bid, ALenum param, ALint* values );
+typedef void (AL_APIENTRY *LPALDOPPLERFACTOR)( ALfloat value );
+typedef void (AL_APIENTRY *LPALDOPPLERVELOCITY)( ALfloat value );
+typedef void (AL_APIENTRY *LPALSPEEDOFSOUND)( ALfloat value );
+typedef void (AL_APIENTRY *LPALDISTANCEMODEL)( ALenum distanceModel );
+
+#endif /* AL_NO_PROTOTYPES */
+
+#if TARGET_OS_MAC
+ #pragma export off
+#endif
+
+#if defined(__cplusplus)
+} /* extern "C" */
+#endif
+
+#endif /* AL_AL_H */
diff --git a/COM380/Project5/include/AL/alc.h b/COM380/Project5/include/AL/alc.h
new file mode 100644
index 0000000..b0bbfbe
--- /dev/null
+++ b/COM380/Project5/include/AL/alc.h
@@ -0,0 +1,281 @@
+#ifndef AL_ALC_H
+#define AL_ALC_H
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+#if defined(_WIN32) && !defined(_XBOX)
+ /* _OPENAL32LIB is deprecated */
+ #if defined(AL_BUILD_LIBRARY) || defined (_OPENAL32LIB)
+ #define ALC_API __declspec(dllexport)
+ #else
+ #define ALC_API __declspec(dllimport)
+ #endif
+#else
+ #if defined(AL_BUILD_LIBRARY) && defined(HAVE_GCC_VISIBILITY)
+ #define ALC_API __attribute__((visibility("default")))
+ #else
+ #define ALC_API extern
+ #endif
+#endif
+
+#if defined(_WIN32)
+ #define ALC_APIENTRY __cdecl
+#else
+ #define ALC_APIENTRY
+#endif
+
+#if defined(TARGET_OS_MAC) && TARGET_OS_MAC
+ #pragma export on
+#endif
+
+/*
+ * The ALCAPI, ALCAPIENTRY, and ALC_INVALID macros are deprecated, but are
+ * included for applications porting code from AL 1.0
+ */
+#define ALCAPI ALC_API
+#define ALCAPIENTRY ALC_APIENTRY
+#define ALC_INVALID 0
+
+
+#define ALC_VERSION_0_1 1
+
+typedef struct ALCdevice_struct ALCdevice;
+typedef struct ALCcontext_struct ALCcontext;
+
+
+/** 8-bit boolean */
+typedef char ALCboolean;
+
+/** character */
+typedef char ALCchar;
+
+/** signed 8-bit 2's complement integer */
+typedef char ALCbyte;
+
+/** unsigned 8-bit integer */
+typedef unsigned char ALCubyte;
+
+/** signed 16-bit 2's complement integer */
+typedef short ALCshort;
+
+/** unsigned 16-bit integer */
+typedef unsigned short ALCushort;
+
+/** signed 32-bit 2's complement integer */
+typedef int ALCint;
+
+/** unsigned 32-bit integer */
+typedef unsigned int ALCuint;
+
+/** non-negative 32-bit binary integer size */
+typedef int ALCsizei;
+
+/** enumerated 32-bit value */
+typedef int ALCenum;
+
+/** 32-bit IEEE754 floating-point */
+typedef float ALCfloat;
+
+/** 64-bit IEEE754 floating-point */
+typedef double ALCdouble;
+
+/** void type (for opaque pointers only) */
+typedef void ALCvoid;
+
+
+/* Enumerant values begin at column 50. No tabs. */
+
+/* Boolean False. */
+#define ALC_FALSE 0
+
+/* Boolean True. */
+#define ALC_TRUE 1
+
+/**
+ * followed by Hz
+ */
+#define ALC_FREQUENCY 0x1007
+
+/**
+ * followed by Hz
+ */
+#define ALC_REFRESH 0x1008
+
+/**
+ * followed by AL_TRUE, AL_FALSE
+ */
+#define ALC_SYNC 0x1009
+
+/**
+ * followed by Num of requested Mono (3D) Sources
+ */
+#define ALC_MONO_SOURCES 0x1010
+
+/**
+ * followed by Num of requested Stereo Sources
+ */
+#define ALC_STEREO_SOURCES 0x1011
+
+/**
+ * errors
+ */
+
+/**
+ * No error
+ */
+#define ALC_NO_ERROR ALC_FALSE
+
+/**
+ * No device
+ */
+#define ALC_INVALID_DEVICE 0xA001
+
+/**
+ * invalid context ID
+ */
+#define ALC_INVALID_CONTEXT 0xA002
+
+/**
+ * bad enum
+ */
+#define ALC_INVALID_ENUM 0xA003
+
+/**
+ * bad value
+ */
+#define ALC_INVALID_VALUE 0xA004
+
+/**
+ * Out of memory.
+ */
+#define ALC_OUT_OF_MEMORY 0xA005
+
+
+/**
+ * The Specifier string for default device
+ */
+#define ALC_DEFAULT_DEVICE_SPECIFIER 0x1004
+#define ALC_DEVICE_SPECIFIER 0x1005
+#define ALC_EXTENSIONS 0x1006
+
+#define ALC_MAJOR_VERSION 0x1000
+#define ALC_MINOR_VERSION 0x1001
+
+#define ALC_ATTRIBUTES_SIZE 0x1002
+#define ALC_ALL_ATTRIBUTES 0x1003
+
+/**
+ * ALC_ENUMERATE_ALL_EXT enums
+ */
+#define ALC_DEFAULT_ALL_DEVICES_SPECIFIER 0x1012
+#define ALC_ALL_DEVICES_SPECIFIER 0x1013
+
+/**
+ * Capture extension
+ */
+#define ALC_CAPTURE_DEVICE_SPECIFIER 0x310
+#define ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER 0x311
+#define ALC_CAPTURE_SAMPLES 0x312
+
+
+/*
+ * Context Management
+ */
+ALC_API ALCcontext * ALC_APIENTRY alcCreateContext( ALCdevice *device, const ALCint* attrlist );
+
+ALC_API ALCboolean ALC_APIENTRY alcMakeContextCurrent( ALCcontext *context );
+
+ALC_API void ALC_APIENTRY alcProcessContext( ALCcontext *context );
+
+ALC_API void ALC_APIENTRY alcSuspendContext( ALCcontext *context );
+
+ALC_API void ALC_APIENTRY alcDestroyContext( ALCcontext *context );
+
+ALC_API ALCcontext * ALC_APIENTRY alcGetCurrentContext( void );
+
+ALC_API ALCdevice* ALC_APIENTRY alcGetContextsDevice( ALCcontext *context );
+
+
+/*
+ * Device Management
+ */
+ALC_API ALCdevice * ALC_APIENTRY alcOpenDevice( const ALCchar *devicename );
+
+ALC_API ALCboolean ALC_APIENTRY alcCloseDevice( ALCdevice *device );
+
+
+/*
+ * Error support.
+ * Obtain the most recent Context error
+ */
+ALC_API ALCenum ALC_APIENTRY alcGetError( ALCdevice *device );
+
+
+/*
+ * Extension support.
+ * Query for the presence of an extension, and obtain any appropriate
+ * function pointers and enum values.
+ */
+ALC_API ALCboolean ALC_APIENTRY alcIsExtensionPresent( ALCdevice *device, const ALCchar *extname );
+
+ALC_API void * ALC_APIENTRY alcGetProcAddress( ALCdevice *device, const ALCchar *funcname );
+
+ALC_API ALCenum ALC_APIENTRY alcGetEnumValue( ALCdevice *device, const ALCchar *enumname );
+
+
+/*
+ * Query functions
+ */
+ALC_API const ALCchar * ALC_APIENTRY alcGetString( ALCdevice *device, ALCenum param );
+
+ALC_API void ALC_APIENTRY alcGetIntegerv( ALCdevice *device, ALCenum param, ALCsizei size, ALCint *data );
+
+
+/*
+ * Capture functions
+ */
+ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice( const ALCchar *devicename, ALCuint frequency, ALCenum format, ALCsizei buffersize );
+
+ALC_API ALCboolean ALC_APIENTRY alcCaptureCloseDevice( ALCdevice *device );
+
+ALC_API void ALC_APIENTRY alcCaptureStart( ALCdevice *device );
+
+ALC_API void ALC_APIENTRY alcCaptureStop( ALCdevice *device );
+
+ALC_API void ALC_APIENTRY alcCaptureSamples( ALCdevice *device, ALCvoid *buffer, ALCsizei samples );
+
+/*
+ * Pointer-to-function types, useful for dynamically getting ALC entry points.
+ */
+typedef ALCcontext * (ALC_APIENTRY *LPALCCREATECONTEXT) (ALCdevice *device, const ALCint *attrlist);
+typedef ALCboolean (ALC_APIENTRY *LPALCMAKECONTEXTCURRENT)( ALCcontext *context );
+typedef void (ALC_APIENTRY *LPALCPROCESSCONTEXT)( ALCcontext *context );
+typedef void (ALC_APIENTRY *LPALCSUSPENDCONTEXT)( ALCcontext *context );
+typedef void (ALC_APIENTRY *LPALCDESTROYCONTEXT)( ALCcontext *context );
+typedef ALCcontext * (ALC_APIENTRY *LPALCGETCURRENTCONTEXT)( void );
+typedef ALCdevice * (ALC_APIENTRY *LPALCGETCONTEXTSDEVICE)( ALCcontext *context );
+typedef ALCdevice * (ALC_APIENTRY *LPALCOPENDEVICE)( const ALCchar *devicename );
+typedef ALCboolean (ALC_APIENTRY *LPALCCLOSEDEVICE)( ALCdevice *device );
+typedef ALCenum (ALC_APIENTRY *LPALCGETERROR)( ALCdevice *device );
+typedef ALCboolean (ALC_APIENTRY *LPALCISEXTENSIONPRESENT)( ALCdevice *device, const ALCchar *extname );
+typedef void * (ALC_APIENTRY *LPALCGETPROCADDRESS)(ALCdevice *device, const ALCchar *funcname );
+typedef ALCenum (ALC_APIENTRY *LPALCGETENUMVALUE)(ALCdevice *device, const ALCchar *enumname );
+typedef const ALCchar* (ALC_APIENTRY *LPALCGETSTRING)( ALCdevice *device, ALCenum param );
+typedef void (ALC_APIENTRY *LPALCGETINTEGERV)( ALCdevice *device, ALCenum param, ALCsizei size, ALCint *dest );
+typedef ALCdevice * (ALC_APIENTRY *LPALCCAPTUREOPENDEVICE)( const ALCchar *devicename, ALCuint frequency, ALCenum format, ALCsizei buffersize );
+typedef ALCboolean (ALC_APIENTRY *LPALCCAPTURECLOSEDEVICE)( ALCdevice *device );
+typedef void (ALC_APIENTRY *LPALCCAPTURESTART)( ALCdevice *device );
+typedef void (ALC_APIENTRY *LPALCCAPTURESTOP)( ALCdevice *device );
+typedef void (ALC_APIENTRY *LPALCCAPTURESAMPLES)( ALCdevice *device, ALCvoid *buffer, ALCsizei samples );
+
+#if defined(TARGET_OS_MAC) && TARGET_OS_MAC
+ #pragma export off
+#endif
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif /* AL_ALC_H */
diff --git a/COM380/Project5/include/AL/alut.h b/COM380/Project5/include/AL/alut.h
new file mode 100644
index 0000000..4b05a3c
--- /dev/null
+++ b/COM380/Project5/include/AL/alut.h
@@ -0,0 +1,126 @@
+#if !defined(AL_ALUT_H)
+#define AL_ALUT_H
+
+#if defined(_MSC_VER)
+#include
+#include
+#elif defined(__APPLE__)
+#include
+#include
+#else
+#include
+#include
+#endif
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+#if defined(_WIN32) && !defined(_XBOX)
+ #if defined (ALUT_BUILD_LIBRARY)
+ #define ALUT_API __declspec(dllexport)
+ #else
+ #define ALUT_API __declspec(dllimport)
+ #endif
+#else
+ #if defined(ALUT_BUILD_LIBRARY) && defined(HAVE_GCC_VISIBILITY)
+ #define ALUT_API __attribute__((visibility("default")))
+ #else
+ #define ALUT_API extern
+ #endif
+#endif
+
+#if defined(_WIN32)
+ #define ALUT_APIENTRY __cdecl
+#else
+ #define ALUT_APIENTRY
+#endif
+
+#if defined(__MWERKS_)
+ #pragma export on
+#endif
+
+/* Flag deprecated functions if possible (VisualC++ .NET and GCC >= 3.1.1). */
+#if defined(_MSC_VER) && _MSC_VER >= 1300 && !defined(MIDL_PASS)
+#define ALUT_ATTRIBUTE_DEPRECATED __declspec(deprecated)
+#elif defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && (__GNUC_MINOR__ > 1 || (__GNUC_MINOR__ == 1 && __GNUC_PATCHLEVEL__ >= 1))))
+#define ALUT_ATTRIBUTE_DEPRECATED __attribute__((deprecated))
+#else
+#define ALUT_ATTRIBUTE_DEPRECATED
+#endif
+
+#define ALUT_API_MAJOR_VERSION 1
+#define ALUT_API_MINOR_VERSION 1
+
+#define ALUT_ERROR_NO_ERROR 0
+#define ALUT_ERROR_OUT_OF_MEMORY 0x200
+#define ALUT_ERROR_INVALID_ENUM 0x201
+#define ALUT_ERROR_INVALID_VALUE 0x202
+#define ALUT_ERROR_INVALID_OPERATION 0x203
+#define ALUT_ERROR_NO_CURRENT_CONTEXT 0x204
+#define ALUT_ERROR_AL_ERROR_ON_ENTRY 0x205
+#define ALUT_ERROR_ALC_ERROR_ON_ENTRY 0x206
+#define ALUT_ERROR_OPEN_DEVICE 0x207
+#define ALUT_ERROR_CLOSE_DEVICE 0x208
+#define ALUT_ERROR_CREATE_CONTEXT 0x209
+#define ALUT_ERROR_MAKE_CONTEXT_CURRENT 0x20A
+#define ALUT_ERROR_DESTROY_CONTEXT 0x20B
+#define ALUT_ERROR_GEN_BUFFERS 0x20C
+#define ALUT_ERROR_BUFFER_DATA 0x20D
+#define ALUT_ERROR_IO_ERROR 0x20E
+#define ALUT_ERROR_UNSUPPORTED_FILE_TYPE 0x20F
+#define ALUT_ERROR_UNSUPPORTED_FILE_SUBTYPE 0x210
+#define ALUT_ERROR_CORRUPT_OR_TRUNCATED_DATA 0x211
+
+#define ALUT_WAVEFORM_SINE 0x100
+#define ALUT_WAVEFORM_SQUARE 0x101
+#define ALUT_WAVEFORM_SAWTOOTH 0x102
+#define ALUT_WAVEFORM_WHITENOISE 0x103
+#define ALUT_WAVEFORM_IMPULSE 0x104
+
+#define ALUT_LOADER_BUFFER 0x300
+#define ALUT_LOADER_MEMORY 0x301
+
+ALUT_API ALboolean ALUT_APIENTRY alutInit (int *argcp, char **argv);
+ALUT_API ALboolean ALUT_APIENTRY alutInitWithoutContext (int *argcp, char **argv);
+ALUT_API ALboolean ALUT_APIENTRY alutExit (void);
+
+ALUT_API ALenum ALUT_APIENTRY alutGetError (void);
+ALUT_API const char *ALUT_APIENTRY alutGetErrorString (ALenum error);
+
+ALUT_API ALuint ALUT_APIENTRY alutCreateBufferFromFile (const char *fileName);
+ALUT_API ALuint ALUT_APIENTRY alutCreateBufferFromFileImage (const ALvoid *data, ALsizei length);
+ALUT_API ALuint ALUT_APIENTRY alutCreateBufferHelloWorld (void);
+ALUT_API ALuint ALUT_APIENTRY alutCreateBufferWaveform (ALenum waveshape, ALfloat frequency, ALfloat phase, ALfloat duration);
+
+ALUT_API ALvoid *ALUT_APIENTRY alutLoadMemoryFromFile (const char *fileName, ALenum *format, ALsizei *size, ALfloat *frequency);
+ALUT_API ALvoid *ALUT_APIENTRY alutLoadMemoryFromFileImage (const ALvoid *data, ALsizei length, ALenum *format, ALsizei *size, ALfloat *frequency);
+ALUT_API ALvoid *ALUT_APIENTRY alutLoadMemoryHelloWorld (ALenum *format, ALsizei *size, ALfloat *frequency);
+ALUT_API ALvoid *ALUT_APIENTRY alutLoadMemoryWaveform (ALenum waveshape, ALfloat frequency, ALfloat phase, ALfloat duration, ALenum *format, ALsizei *size, ALfloat *freq);
+
+ALUT_API const char *ALUT_APIENTRY alutGetMIMETypes (ALenum loader);
+
+ALUT_API ALint ALUT_APIENTRY alutGetMajorVersion (void);
+ALUT_API ALint ALUT_APIENTRY alutGetMinorVersion (void);
+
+ALUT_API ALboolean ALUT_APIENTRY alutSleep (ALfloat duration);
+
+/* Nasty Compatibility stuff, WARNING: THESE FUNCTIONS ARE STRONGLY DEPRECATED */
+#if defined(__APPLE__)
+ALUT_API ALUT_ATTRIBUTE_DEPRECATED void ALUT_APIENTRY alutLoadWAVFile (ALbyte *fileName, ALenum *format, void **data, ALsizei *size, ALsizei *frequency);
+ALUT_API ALUT_ATTRIBUTE_DEPRECATED void ALUT_APIENTRY alutLoadWAVMemory (ALbyte *buffer, ALenum *format, void **data, ALsizei *size, ALsizei *frequency);
+#else
+ALUT_API ALUT_ATTRIBUTE_DEPRECATED void ALUT_APIENTRY alutLoadWAVFile (ALbyte *fileName, ALenum *format, void **data, ALsizei *size, ALsizei *frequency, ALboolean *loop);
+ALUT_API ALUT_ATTRIBUTE_DEPRECATED void ALUT_APIENTRY alutLoadWAVMemory (ALbyte *buffer, ALenum *format, void **data, ALsizei *size, ALsizei *frequency, ALboolean *loop);
+#endif
+ALUT_API ALUT_ATTRIBUTE_DEPRECATED void ALUT_APIENTRY alutUnloadWAV (ALenum format, ALvoid *data, ALsizei size, ALsizei frequency);
+
+#if defined(__MWERKS_)
+ #pragma export off
+#endif
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
diff --git a/COM380/Project5/include/DevIL/config.h b/COM380/Project5/include/DevIL/config.h
new file mode 100644
index 0000000..b9fe5dc
--- /dev/null
+++ b/COM380/Project5/include/DevIL/config.h
@@ -0,0 +1,140 @@
+/* include/IL/config.h. Generated by configure. */
+/* include/IL/config.h.in. Generated from configure.in by autoheader. */
+#ifndef __CONFIG_H__
+#define __CONFIG_H__
+
+#define IL_USE_PRAGMA_LIBS
+
+// Supported image formats (IL)
+
+// #define IL_NO_BLP
+// #define IL_NO_BMP
+// #define IL_NO_CUT
+// #define IL_NO_CHEAD
+// #define IL_NO_DCX
+// #define IL_NO_DDS
+// #define IL_NO_DICOM
+// #define IL_NO_DOOM
+// #define IL_NO_EXR
+// #define IL_NO_FITS
+// #define IL_NO_FTX
+// #define IL_NO_GIF
+// #define IL_NO_HDR
+// #define IL_NO_ICO
+// #define IL_NO_ICNS
+// #define IL_NO_IWI
+// #define IL_NO_JP2
+// #define IL_NO_JPG
+// #define IL_NO_LCMS
+// #define IL_NO_LIF
+// #define IL_NO_MDL
+// #define IL_NO_MNG
+// #define IL_NO_PCD
+// #define IL_NO_PCX
+// #define IL_NO_PIC
+// #define IL_NO_PIX
+// #define IL_NO_PNG
+// #define IL_NO_PNM
+// #define IL_NO_PSD
+// #define IL_NO_PSP
+// #define IL_NO_PXR
+// #define IL_NO_RAW
+// #define IL_NO_ROT
+// #define IL_NO_SGI
+// #define IL_NO_SUN
+// #define IL_NO_TGA
+// #define IL_NO_TIF
+// #define IL_NO_TPL
+// #define IL_NO_WAL
+// #define IL_NO_WDP
+// #define IL_NO_XPM
+#define IL_USE_JPEGLIB_UNMODIFIED 1
+//#define IL_USE_DXTC_NVIDIA
+#define IL_USE_DXTC_SQUISH
+
+/* Supported api (ilut) */
+
+
+//
+// sorry just
+// cant get this one to work under windows
+// have disabled for the now
+//
+// will look at it some more later
+//
+// Kriss
+//
+#undef ILUT_USE_ALLEGRO
+
+#undef ILUT_USE_DIRECTX8
+//#define ILUT_USE_DIRECTX9
+//#define ILUT_USE_DIRECTX10
+//#define ILUT_USE_OPENGL
+//#define ILUT_USE_SDL
+//#define ILUT_USE_WIN32
+
+
+/* Define to 1 if you have the header file. */
+//#define HAVE_DLFCN_H 1
+
+/* Define to 1 if you have the header file. */
+//#define HAVE_INTTYPES_H 1
+
+/* Define to 1 if you have the header file. */
+//#define HAVE_MEMORY_H 1
+
+/* Define to 1 if you have the header file. */
+//#define HAVE_STDINT_H 1
+
+/* Define to 1 if you have the header file. */
+//#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the header file. */
+//#define HAVE_STRINGS_H 1
+
+/* Define to 1 if you have the header file. */
+//#define HAVE_STRING_H 1
+
+/* Define to 1 if you have the header file. */
+//#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the header file. */
+//#define HAVE_SYS_TYPES_H 1
+
+/* Define to 1 if you have the header file. */
+//#define HAVE_UNISTD_H 1
+
+/* Name of package */
+#define IL_PACKAGE "DevIL"
+
+/* Define to the address where bug reports for this package should be sent. */
+#define PACKAGE_BUGREPORT ""
+
+/* Define to the full name of this package. */
+#define IL_PACKAGE_NAME ""
+
+/* Define to the full name and version of this package. */
+#define IL_PACKAGE_STRING ""
+
+/* Define to the one symbol short name of this package. */
+#define IL_PACKAGE_TARNAME ""
+
+/* Define to the version of this package. */
+#define IL_PACKAGE_VERSION ""
+
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* Version number of package */
+//#define IL_VERSION "1.7.3"
+
+/* Define to 1 if your processor stores words with the most significant byte
+ first (like Motorola and SPARC, unlike Intel and VAX). */
+/* #undef WORDS_BIGENDIAN */
+
+/* If using Mac OS X uncomment this line */
+/* #include "macconfig.h" */
+
+/* Define to 1 if the X Window System is missing or not being used. */
+/* #undef X_DISPLAY_MISSING */
+#endif /* __CONFIG_H__ */
diff --git a/COM380/Project5/include/DevIL/config.h.win b/COM380/Project5/include/DevIL/config.h.win
new file mode 100644
index 0000000..659f4ca
--- /dev/null
+++ b/COM380/Project5/include/DevIL/config.h.win
@@ -0,0 +1,79 @@
+#ifndef __CONFIG_H__
+#define __CONFIG_H__
+
+#define IL_USE_PRAGMA_LIBS // Links to only the libraries that are requested.
+#define IL_INLINE_ASM 1 // Define if you can support at least some ASM
+
+// Supported images formats (IL)
+
+// #define IL_NO_BLP
+// #define IL_NO_BMP
+// #define IL_NO_CUT
+// #define IL_NO_CHEAD
+// #define IL_NO_DCX
+// #define IL_NO_DDS
+// #define IL_NO_DICOM
+// #define IL_NO_DOOM
+// #define IL_NO_EXR
+// #define IL_NO_FITS
+// #define IL_NO_FTX
+// #define IL_NO_GIF
+// #define IL_NO_HDR
+// #define IL_NO_ICO
+// #define IL_NO_ICNS
+// #define IL_NO_IWI
+// #define IL_NO_JP2
+// #define IL_NO_JPG
+// #define IL_NO_LCMS
+// #define IL_NO_LIF
+// #define IL_NO_MDL
+// #define IL_NO_MNG
+// #define IL_NO_PCD
+// #define IL_NO_PCX
+// #define IL_NO_PIC
+// #define IL_NO_PIX
+// #define IL_NO_PNG
+// #define IL_NO_PNM
+// #define IL_NO_PSD
+// #define IL_NO_PSP
+// #define IL_NO_PXR
+// #define IL_NO_RAW
+// #define IL_NO_ROT
+// #define IL_NO_SGI
+// #define IL_NO_SUN
+// #define IL_NO_TGA
+// #define IL_NO_TIF
+// #define IL_NO_TPL
+// #define IL_NO_WAL
+// #define IL_NO_WDP
+// #define IL_NO_XPM
+
+#define IL_USE_JPEGLIB_UNMODIFIED 1
+#define IL_USE_DXTC_NVIDIA
+#define IL_USE_DXTC_SQUISH
+
+//#define IL_NO_GAMES
+
+/* Supported api (ilut) */
+
+
+//
+// sorry just
+// cant get this one to work under windows
+// have disabled for the now
+//
+// will look at it some more later
+//
+// Kriss
+//
+#undef ILUT_USE_ALLEGRO
+
+#undef ILUT_USE_DIRECTX8
+#define ILUT_USE_DIRECTX9
+#define ILUT_USE_DIRECTX10
+#define ILUT_USE_OPENGL
+#define ILUT_USE_SDL
+#define ILUT_USE_WIN32
+
+
+#endif /* __CONFIG_H__ */
diff --git a/COM380/Project5/include/DevIL/devil_internal_exports.h b/COM380/Project5/include/DevIL/devil_internal_exports.h
new file mode 100644
index 0000000..30b7aaa
--- /dev/null
+++ b/COM380/Project5/include/DevIL/devil_internal_exports.h
@@ -0,0 +1,161 @@
+//-----------------------------------------------------------------------------
+//
+// ImageLib Sources
+// Copyright (C) 2000-2009 by Denton Woods
+// Last modified: 01/06/2009
+//
+// Filename: IL/devil_internal_exports.h
+//
+// Description: Internal stuff for DevIL (IL, ILU and ILUT)
+//
+//-----------------------------------------------------------------------------
+
+#ifndef IL_EXPORTS_H
+#define IL_EXPORTS_H
+
+#include "IL/il.h"
+
+#ifdef DEBUG
+ #include
+#else
+ #define assert(x)
+#endif
+
+//#ifndef NOINLINE
+#ifndef INLINE
+#if defined(__GNUC__)
+ #define INLINE extern inline
+#elif defined(_MSC_VER) //@TODO: Get this working in MSVC++.
+ // http://www.greenend.org.uk/rjk/2003/03/inline.html
+ #define NOINLINE
+ //#define INLINE
+ /*#ifndef _WIN64 // Cannot use inline assembly in x64 target platform.
+ #define USE_WIN32_ASM
+ #endif//_WIN64*/
+ #define INLINE __inline
+#else
+ #define INLINE inline
+#endif
+#endif
+//#else
+//#define INLINE
+//#endif //NOINLINE
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define IL_MAX(a,b) (((a) > (b)) ? (a) : (b))
+#define IL_MIN(a,b) (((a) < (b)) ? (a) : (b))
+
+
+//! Basic Palette struct
+typedef struct ILpal
+{
+ ILubyte* Palette; //!< the image palette (if any)
+ ILuint PalSize; //!< size of the palette (in bytes)
+ ILenum PalType; //!< the palette types in il.h (0x0500 range)
+} ILpal;
+
+
+//! The Fundamental Image structure
+/*! Every bit of information about an image is stored in this internal structure.*/
+typedef struct ILimage
+{
+ ILuint Width; //!< the image's width
+ ILuint Height; //!< the image's height
+ ILuint Depth; //!< the image's depth
+ ILubyte Bpp; //!< bytes per pixel (now number of channels)
+ ILubyte Bpc; //!< bytes per channel
+ ILuint Bps; //!< bytes per scanline (components for IL)
+ ILubyte* Data; //!< the image data
+ ILuint SizeOfData; //!< the total size of the data (in bytes)
+ ILuint SizeOfPlane; //!< SizeOfData in a 2d image, size of each plane slice in a 3d image (in bytes)
+ ILenum Format; //!< image format (in IL enum style)
+ ILenum Type; //!< image type (in IL enum style)
+ ILenum Origin; //!< origin of the image
+ ILpal Pal; //!< palette details
+ ILuint Duration; //!< length of the time to display this "frame"
+ ILenum CubeFlags; //!< cube map flags for sides present in chain
+ struct ILimage* Mipmaps; //!< mipmapped versions of this image terminated by a NULL - usu. NULL
+ struct ILimage* Next; //!< next image in the chain - usu. NULL
+ struct ILimage* Faces; //!< next cubemap face in the chain - usu. NULL
+ struct ILimage* Layers; //!< subsequent layers in the chain - usu. NULL
+ ILuint* AnimList; //!< animation list
+ ILuint AnimSize; //!< animation list size
+ void* Profile; //!< colour profile
+ ILuint ProfileSize; //!< colour profile size
+ ILuint OffX; //!< x-offset of the image
+ ILuint OffY; //!< y-offset of the image
+ ILubyte* DxtcData; //!< compressed data
+ ILenum DxtcFormat; //!< compressed data format
+ ILuint DxtcSize; //!< compressed data size
+} ILimage;
+
+
+// Memory functions
+ILAPI void* ILAPIENTRY ialloc(const ILsizei Size);
+ILAPI void ILAPIENTRY ifree(const void *Ptr);
+ILAPI void* ILAPIENTRY icalloc(const ILsizei Size, const ILsizei Num);
+#ifdef ALTIVEC_GCC
+ILAPI void* ILAPIENTRY ivec_align_buffer(void *buffer, const ILuint size);
+#endif
+
+// Internal library functions in IL
+ILAPI ILimage* ILAPIENTRY ilGetCurImage(void);
+ILAPI void ILAPIENTRY ilSetCurImage(ILimage *Image);
+ILAPI void ILAPIENTRY ilSetError(ILenum Error);
+ILAPI void ILAPIENTRY ilSetPal(ILpal *Pal);
+
+//
+// Utility functions
+//
+ILAPI ILubyte ILAPIENTRY ilGetBppFormat(ILenum Format);
+ILAPI ILenum ILAPIENTRY ilGetFormatBpp(ILubyte Bpp);
+ILAPI ILubyte ILAPIENTRY ilGetBpcType(ILenum Type);
+ILAPI ILenum ILAPIENTRY ilGetTypeBpc(ILubyte Bpc);
+ILAPI ILubyte ILAPIENTRY ilGetBppPal(ILenum PalType);
+ILAPI ILenum ILAPIENTRY ilGetPalBaseType(ILenum PalType);
+ILAPI ILuint ILAPIENTRY ilNextPower2(ILuint Num);
+ILAPI ILenum ILAPIENTRY ilTypeFromExt(ILconst_string FileName);
+ILAPI void ILAPIENTRY ilReplaceCurImage(ILimage *Image);
+ILAPI void ILAPIENTRY iMemSwap(ILubyte *, ILubyte *, const ILuint);
+
+//
+// Image functions
+//
+ILAPI void ILAPIENTRY iBindImageTemp (void);
+ILAPI ILboolean ILAPIENTRY ilClearImage_ (ILimage *Image);
+ILAPI void ILAPIENTRY ilCloseImage (ILimage *Image);
+ILAPI void ILAPIENTRY ilClosePal (ILpal *Palette);
+ILAPI ILpal* ILAPIENTRY iCopyPal (void);
+ILAPI ILboolean ILAPIENTRY ilCopyImageAttr (ILimage *Dest, ILimage *Src);
+ILAPI ILimage* ILAPIENTRY ilCopyImage_ (ILimage *Src);
+ILAPI void ILAPIENTRY ilGetClear (void *Colours, ILenum Format, ILenum Type);
+ILAPI ILuint ILAPIENTRY ilGetCurName (void);
+ILAPI ILboolean ILAPIENTRY ilIsValidPal (ILpal *Palette);
+ILAPI ILimage* ILAPIENTRY ilNewImage (ILuint Width, ILuint Height, ILuint Depth, ILubyte Bpp, ILubyte Bpc);
+ILAPI ILimage* ILAPIENTRY ilNewImageFull (ILuint Width, ILuint Height, ILuint Depth, ILubyte Bpp, ILenum Format, ILenum Type, void *Data);
+ILAPI ILboolean ILAPIENTRY ilInitImage (ILimage *Image, ILuint Width, ILuint Height, ILuint Depth, ILubyte Bpp, ILenum Format, ILenum Type, void *Data);
+ILAPI ILboolean ILAPIENTRY ilResizeImage (ILimage *Image, ILuint Width, ILuint Height, ILuint Depth, ILubyte Bpp, ILubyte Bpc);
+ILAPI ILboolean ILAPIENTRY ilTexImage_ (ILimage *Image, ILuint Width, ILuint Height, ILuint Depth, ILubyte Bpp, ILenum Format, ILenum Type, void *Data);
+ILAPI ILboolean ILAPIENTRY ilTexSubImage_ (ILimage *Image, void *Data);
+ILAPI void* ILAPIENTRY ilConvertBuffer (ILuint SizeOfData, ILenum SrcFormat, ILenum DestFormat, ILenum SrcType, ILenum DestType, ILpal *SrcPal, void *Buffer);
+ILAPI ILimage* ILAPIENTRY iConvertImage (ILimage *Image, ILenum DestFormat, ILenum DestType);
+ILAPI ILpal* ILAPIENTRY iConvertPal (ILpal *Pal, ILenum DestFormat);
+ILAPI ILubyte* ILAPIENTRY iGetFlipped (ILimage *Image);
+ILAPI ILboolean ILAPIENTRY iMirror();
+ILAPI void ILAPIENTRY iFlipBuffer(ILubyte *buff, ILuint depth, ILuint line_size, ILuint line_num);
+ILubyte* iFlipNewBuffer(ILubyte *buff, ILuint depth, ILuint line_size, ILuint line_num);
+ILAPI void ILAPIENTRY iGetIntegervImage(ILimage *Image, ILenum Mode, ILint *Param);
+
+// Internal library functions in ILU
+ILAPI ILimage* ILAPIENTRY iluRotate_(ILimage *Image, ILfloat Angle);
+ILAPI ILimage* ILAPIENTRY iluRotate3D_(ILimage *Image, ILfloat x, ILfloat y, ILfloat z, ILfloat Angle);
+ILAPI ILimage* ILAPIENTRY iluScale_(ILimage *Image, ILuint Width, ILuint Height, ILuint Depth);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif//IL_EXPORTS_H
diff --git a/COM380/Project5/include/DevIL/il.h b/COM380/Project5/include/DevIL/il.h
new file mode 100644
index 0000000..540a56e
--- /dev/null
+++ b/COM380/Project5/include/DevIL/il.h
@@ -0,0 +1,644 @@
+//-----------------------------------------------------------------------------
+//
+// ImageLib Sources
+// Copyright (C) 2000-2009 by Denton Woods
+// Last modified: 03/07/2009
+//
+// Filename: IL/il.h
+//
+// Description: The main include file for DevIL
+//
+//-----------------------------------------------------------------------------
+
+// Doxygen comment
+/*! \file il.h
+ The main include file for DevIL
+*/
+
+#ifndef __il_h_
+#ifndef __IL_H__
+
+#define __il_h_
+#define __IL_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+//this define controls if floats and doubles are clampled to [0..1]
+//during conversion. It takes a little more time, but it is the correct
+//way of doing this. If you are sure your floats are always valid,
+//you can undefine this value...
+#define CLAMP_HALF 1
+#define CLAMP_FLOATS 1
+#define CLAMP_DOUBLES 1
+
+/*#ifdef _WIN32_WCE
+ #define IL_NO_EXR
+ #define IL_NO_GIF
+ #define IL_NO_JP2
+ #define IL_NO_JPG
+ #define IL_NO_MNG
+ #define IL_NO_PNG
+ #define IL_NO_TIF
+ #define IL_NO_LCMS
+#endif //_WIN32_WCE
+
+#ifdef DJGPP
+ #define IL_NO_EXR
+ #define IL_NO_GIF
+ #define IL_NO_JP2
+ #define IL_NO_JPG
+ #define IL_NO_MNG
+ #define IL_NO_PNG
+ #define IL_NO_TIF
+ #define IL_NO_LCMS
+#endif //DJGPP*/
+
+#ifdef _WIN32
+ #if (defined(IL_USE_PRAGMA_LIBS)) && (!defined(_IL_BUILD_LIBRARY))
+ #if defined(_MSC_VER) || defined(__BORLANDC__)
+ #pragma comment(lib, "DevIL.lib")
+ #endif
+ #endif
+#endif
+
+#ifdef RESTRICT_KEYWORD
+#define RESTRICT restrict
+#define CONST_RESTRICT const restrict
+#else
+#define RESTRICT
+#define CONST_RESTRICT const
+#endif
+
+#include
+
+typedef unsigned int ILenum;
+typedef unsigned char ILboolean;
+typedef unsigned int ILbitfield;
+typedef signed char ILbyte;
+typedef signed short ILshort;
+typedef int ILint;
+typedef size_t ILsizei;
+typedef unsigned char ILubyte;
+typedef unsigned short ILushort;
+typedef unsigned int ILuint;
+typedef float ILfloat;
+typedef float ILclampf;
+typedef double ILdouble;
+typedef double ILclampd;
+
+#ifdef _MSC_VER
+typedef __int64 ILint64;
+typedef unsigned __int64 ILuint64;
+#else
+typedef long long int ILint64;
+typedef long long unsigned int ILuint64;
+#endif
+
+
+#include
+#ifdef _UNICODE
+ #ifndef _WIN32_WCE
+ #include
+ #endif
+ //if we use a define instead of a typedef,
+ //ILconst_string works as intended
+ #define ILchar wchar_t
+ #define ILstring wchar_t*
+ #define ILconst_string wchar_t const *
+#else
+ //if we use a define instead of a typedef,
+ //ILconst_string works as intended
+ #define ILchar char
+ #define ILstring char*
+ #define ILconst_string char const *
+#endif //_UNICODE
+
+#define IL_FALSE 0
+#define IL_TRUE 1
+
+// Matches OpenGL's right now.
+//! Data formats \link Formats Formats\endlink
+#define IL_COLOUR_INDEX 0x1900
+#define IL_COLOR_INDEX 0x1900
+#define IL_ALPHA 0x1906
+#define IL_RGB 0x1907
+#define IL_RGBA 0x1908
+#define IL_BGR 0x80E0
+#define IL_BGRA 0x80E1
+#define IL_LUMINANCE 0x1909
+#define IL_LUMINANCE_ALPHA 0x190A
+
+//! Data types \link Types Types\endlink
+#define IL_BYTE 0x1400
+#define IL_UNSIGNED_BYTE 0x1401
+#define IL_SHORT 0x1402
+#define IL_UNSIGNED_SHORT 0x1403
+#define IL_INT 0x1404
+#define IL_UNSIGNED_INT 0x1405
+#define IL_FLOAT 0x1406
+#define IL_DOUBLE 0x140A
+#define IL_HALF 0x140B
+
+
+#define IL_MAX_BYTE SCHAR_MAX
+#define IL_MAX_UNSIGNED_BYTE UCHAR_MAX
+#define IL_MAX_SHORT SHRT_MAX
+#define IL_MAX_UNSIGNED_SHORT USHRT_MAX
+#define IL_MAX_INT INT_MAX
+#define IL_MAX_UNSIGNED_INT UINT_MAX
+
+#define IL_LIMIT(x,m,M) (xM?M:x))
+#define IL_CLAMP(x) IL_LIMIT(x,0,1)
+
+#define IL_VENDOR 0x1F00
+#define IL_LOAD_EXT 0x1F01
+#define IL_SAVE_EXT 0x1F02
+
+
+//
+// IL-specific #define's
+//
+
+#define IL_VERSION_1_7_8 1
+#define IL_VERSION 178
+
+
+// Attribute Bits
+#define IL_ORIGIN_BIT 0x00000001
+#define IL_FILE_BIT 0x00000002
+#define IL_PAL_BIT 0x00000004
+#define IL_FORMAT_BIT 0x00000008
+#define IL_TYPE_BIT 0x00000010
+#define IL_COMPRESS_BIT 0x00000020
+#define IL_LOADFAIL_BIT 0x00000040
+#define IL_FORMAT_SPECIFIC_BIT 0x00000080
+#define IL_ALL_ATTRIB_BITS 0x000FFFFF
+
+
+// Palette types
+#define IL_PAL_NONE 0x0400
+#define IL_PAL_RGB24 0x0401
+#define IL_PAL_RGB32 0x0402
+#define IL_PAL_RGBA32 0x0403
+#define IL_PAL_BGR24 0x0404
+#define IL_PAL_BGR32 0x0405
+#define IL_PAL_BGRA32 0x0406
+
+
+// Image types
+#define IL_TYPE_UNKNOWN 0x0000
+#define IL_BMP 0x0420 //!< Microsoft Windows Bitmap - .bmp extension
+#define IL_CUT 0x0421 //!< Dr. Halo - .cut extension
+#define IL_DOOM 0x0422 //!< DooM walls - no specific extension
+#define IL_DOOM_FLAT 0x0423 //!< DooM flats - no specific extension
+#define IL_ICO 0x0424 //!< Microsoft Windows Icons and Cursors - .ico and .cur extensions
+#define IL_JPG 0x0425 //!< JPEG - .jpg, .jpe and .jpeg extensions
+#define IL_JFIF 0x0425 //!<
+#define IL_ILBM 0x0426 //!< Amiga IFF (FORM ILBM) - .iff, .ilbm, .lbm extensions
+#define IL_PCD 0x0427 //!< Kodak PhotoCD - .pcd extension
+#define IL_PCX 0x0428 //!< ZSoft PCX - .pcx extension
+#define IL_PIC 0x0429 //!< PIC - .pic extension
+#define IL_PNG 0x042A //!< Portable Network Graphics - .png extension
+#define IL_PNM 0x042B //!< Portable Any Map - .pbm, .pgm, .ppm and .pnm extensions
+#define IL_SGI 0x042C //!< Silicon Graphics - .sgi, .bw, .rgb and .rgba extensions
+#define IL_TGA 0x042D //!< TrueVision Targa File - .tga, .vda, .icb and .vst extensions
+#define IL_TIF 0x042E //!< Tagged Image File Format - .tif and .tiff extensions
+#define IL_CHEAD 0x042F //!< C-Style Header - .h extension
+#define IL_RAW 0x0430 //!< Raw Image Data - any extension
+#define IL_MDL 0x0431 //!< Half-Life Model Texture - .mdl extension
+#define IL_WAL 0x0432 //!< Quake 2 Texture - .wal extension
+#define IL_LIF 0x0434 //!< Homeworld Texture - .lif extension
+#define IL_MNG 0x0435 //!< Multiple-image Network Graphics - .mng extension
+#define IL_JNG 0x0435 //!<
+#define IL_GIF 0x0436 //!< Graphics Interchange Format - .gif extension
+#define IL_DDS 0x0437 //!< DirectDraw Surface - .dds extension
+#define IL_DCX 0x0438 //!< ZSoft Multi-PCX - .dcx extension
+#define IL_PSD 0x0439 //!< Adobe PhotoShop - .psd extension
+#define IL_EXIF 0x043A //!<
+#define IL_PSP 0x043B //!< PaintShop Pro - .psp extension
+#define IL_PIX 0x043C //!< PIX - .pix extension
+#define IL_PXR 0x043D //!< Pixar - .pxr extension
+#define IL_XPM 0x043E //!< X Pixel Map - .xpm extension
+#define IL_HDR 0x043F //!< Radiance High Dynamic Range - .hdr extension
+#define IL_ICNS 0x0440 //!< Macintosh Icon - .icns extension
+#define IL_JP2 0x0441 //!< Jpeg 2000 - .jp2 extension
+#define IL_EXR 0x0442 //!< OpenEXR - .exr extension
+#define IL_WDP 0x0443 //!< Microsoft HD Photo - .wdp and .hdp extension
+#define IL_VTF 0x0444 //!< Valve Texture Format - .vtf extension
+#define IL_WBMP 0x0445 //!< Wireless Bitmap - .wbmp extension
+#define IL_SUN 0x0446 //!< Sun Raster - .sun, .ras, .rs, .im1, .im8, .im24 and .im32 extensions
+#define IL_IFF 0x0447 //!< Interchange File Format - .iff extension
+#define IL_TPL 0x0448 //!< Gamecube Texture - .tpl extension
+#define IL_FITS 0x0449 //!< Flexible Image Transport System - .fit and .fits extensions
+#define IL_DICOM 0x044A //!< Digital Imaging and Communications in Medicine (DICOM) - .dcm and .dicom extensions
+#define IL_IWI 0x044B //!< Call of Duty Infinity Ward Image - .iwi extension
+#define IL_BLP 0x044C //!< Blizzard Texture Format - .blp extension
+#define IL_FTX 0x044D //!< Heavy Metal: FAKK2 Texture - .ftx extension
+#define IL_ROT 0x044E //!< Homeworld 2 - Relic Texture - .rot extension
+#define IL_TEXTURE 0x044F //!< Medieval II: Total War Texture - .texture extension
+#define IL_DPX 0x0450 //!< Digital Picture Exchange - .dpx extension
+#define IL_UTX 0x0451 //!< Unreal (and Unreal Tournament) Texture - .utx extension
+#define IL_MP3 0x0452 //!< MPEG-1 Audio Layer 3 - .mp3 extension
+
+
+#define IL_JASC_PAL 0x0475 //!< PaintShop Pro Palette
+
+
+// Error Types
+#define IL_NO_ERROR 0x0000
+#define IL_INVALID_ENUM 0x0501
+#define IL_OUT_OF_MEMORY 0x0502
+#define IL_FORMAT_NOT_SUPPORTED 0x0503
+#define IL_INTERNAL_ERROR 0x0504
+#define IL_INVALID_VALUE 0x0505
+#define IL_ILLEGAL_OPERATION 0x0506
+#define IL_ILLEGAL_FILE_VALUE 0x0507
+#define IL_INVALID_FILE_HEADER 0x0508
+#define IL_INVALID_PARAM 0x0509
+#define IL_COULD_NOT_OPEN_FILE 0x050A
+#define IL_INVALID_EXTENSION 0x050B
+#define IL_FILE_ALREADY_EXISTS 0x050C
+#define IL_OUT_FORMAT_SAME 0x050D
+#define IL_STACK_OVERFLOW 0x050E
+#define IL_STACK_UNDERFLOW 0x050F
+#define IL_INVALID_CONVERSION 0x0510
+#define IL_BAD_DIMENSIONS 0x0511
+#define IL_FILE_READ_ERROR 0x0512 // 05/12/2002: Addition by Sam.
+#define IL_FILE_WRITE_ERROR 0x0512
+
+#define IL_LIB_GIF_ERROR 0x05E1
+#define IL_LIB_JPEG_ERROR 0x05E2
+#define IL_LIB_PNG_ERROR 0x05E3
+#define IL_LIB_TIFF_ERROR 0x05E4
+#define IL_LIB_MNG_ERROR 0x05E5
+#define IL_LIB_JP2_ERROR 0x05E6
+#define IL_LIB_EXR_ERROR 0x05E7
+#define IL_UNKNOWN_ERROR 0x05FF
+
+
+// Origin Definitions
+#define IL_ORIGIN_SET 0x0600
+#define IL_ORIGIN_LOWER_LEFT 0x0601
+#define IL_ORIGIN_UPPER_LEFT 0x0602
+#define IL_ORIGIN_MODE 0x0603
+
+
+// Format and Type Mode Definitions
+#define IL_FORMAT_SET 0x0610
+#define IL_FORMAT_MODE 0x0611
+#define IL_TYPE_SET 0x0612
+#define IL_TYPE_MODE 0x0613
+
+
+// File definitions
+#define IL_FILE_OVERWRITE 0x0620
+#define IL_FILE_MODE 0x0621
+
+
+// Palette definitions
+#define IL_CONV_PAL 0x0630
+
+
+// Load fail definitions
+#define IL_DEFAULT_ON_FAIL 0x0632
+
+
+// Key colour and alpha definitions
+#define IL_USE_KEY_COLOUR 0x0635
+#define IL_USE_KEY_COLOR 0x0635
+#define IL_BLIT_BLEND 0x0636
+
+
+// Interlace definitions
+#define IL_SAVE_INTERLACED 0x0639
+#define IL_INTERLACE_MODE 0x063A
+
+
+// Quantization definitions
+#define IL_QUANTIZATION_MODE 0x0640
+#define IL_WU_QUANT 0x0641
+#define IL_NEU_QUANT 0x0642
+#define IL_NEU_QUANT_SAMPLE 0x0643
+#define IL_MAX_QUANT_INDEXS 0x0644 //XIX : ILint : Maximum number of colors to reduce to, default of 256. and has a range of 2-256
+#define IL_MAX_QUANT_INDICES 0x0644 // Redefined, since the above #define is misspelled
+
+
+// Hints
+#define IL_FASTEST 0x0660
+#define IL_LESS_MEM 0x0661
+#define IL_DONT_CARE 0x0662
+#define IL_MEM_SPEED_HINT 0x0665
+#define IL_USE_COMPRESSION 0x0666
+#define IL_NO_COMPRESSION 0x0667
+#define IL_COMPRESSION_HINT 0x0668
+
+
+// Compression
+#define IL_NVIDIA_COMPRESS 0x0670
+#define IL_SQUISH_COMPRESS 0x0671
+
+
+// Subimage types
+#define IL_SUB_NEXT 0x0680
+#define IL_SUB_MIPMAP 0x0681
+#define IL_SUB_LAYER 0x0682
+
+
+// Compression definitions
+#define IL_COMPRESS_MODE 0x0700
+#define IL_COMPRESS_NONE 0x0701
+#define IL_COMPRESS_RLE 0x0702
+#define IL_COMPRESS_LZO 0x0703
+#define IL_COMPRESS_ZLIB 0x0704
+
+
+// File format-specific values
+#define IL_TGA_CREATE_STAMP 0x0710
+#define IL_JPG_QUALITY 0x0711
+#define IL_PNG_INTERLACE 0x0712
+#define IL_TGA_RLE 0x0713
+#define IL_BMP_RLE 0x0714
+#define IL_SGI_RLE 0x0715
+#define IL_TGA_ID_STRING 0x0717
+#define IL_TGA_AUTHNAME_STRING 0x0718
+#define IL_TGA_AUTHCOMMENT_STRING 0x0719
+#define IL_PNG_AUTHNAME_STRING 0x071A
+#define IL_PNG_TITLE_STRING 0x071B
+#define IL_PNG_DESCRIPTION_STRING 0x071C
+#define IL_TIF_DESCRIPTION_STRING 0x071D
+#define IL_TIF_HOSTCOMPUTER_STRING 0x071E
+#define IL_TIF_DOCUMENTNAME_STRING 0x071F
+#define IL_TIF_AUTHNAME_STRING 0x0720
+#define IL_JPG_SAVE_FORMAT 0x0721
+#define IL_CHEAD_HEADER_STRING 0x0722
+#define IL_PCD_PICNUM 0x0723
+#define IL_PNG_ALPHA_INDEX 0x0724 //XIX : ILint : the color in the palette at this index value (0-255) is considered transparent, -1 for no trasparent color
+#define IL_JPG_PROGRESSIVE 0x0725
+#define IL_VTF_COMP 0x0726
+
+
+// DXTC definitions
+#define IL_DXTC_FORMAT 0x0705
+#define IL_DXT1 0x0706
+#define IL_DXT2 0x0707
+#define IL_DXT3 0x0708
+#define IL_DXT4 0x0709
+#define IL_DXT5 0x070A
+#define IL_DXT_NO_COMP 0x070B
+#define IL_KEEP_DXTC_DATA 0x070C
+#define IL_DXTC_DATA_FORMAT 0x070D
+#define IL_3DC 0x070E
+#define IL_RXGB 0x070F
+#define IL_ATI1N 0x0710
+#define IL_DXT1A 0x0711 // Normally the same as IL_DXT1, except for nVidia Texture Tools.
+
+// Environment map definitions
+#define IL_CUBEMAP_POSITIVEX 0x00000400
+#define IL_CUBEMAP_NEGATIVEX 0x00000800
+#define IL_CUBEMAP_POSITIVEY 0x00001000
+#define IL_CUBEMAP_NEGATIVEY 0x00002000
+#define IL_CUBEMAP_POSITIVEZ 0x00004000
+#define IL_CUBEMAP_NEGATIVEZ 0x00008000
+#define IL_SPHEREMAP 0x00010000
+
+
+// Values
+#define IL_VERSION_NUM 0x0DE2
+#define IL_IMAGE_WIDTH 0x0DE4
+#define IL_IMAGE_HEIGHT 0x0DE5
+#define IL_IMAGE_DEPTH 0x0DE6
+#define IL_IMAGE_SIZE_OF_DATA 0x0DE7
+#define IL_IMAGE_BPP 0x0DE8
+#define IL_IMAGE_BYTES_PER_PIXEL 0x0DE8
+#define IL_IMAGE_BPP 0x0DE8
+#define IL_IMAGE_BITS_PER_PIXEL 0x0DE9
+#define IL_IMAGE_FORMAT 0x0DEA
+#define IL_IMAGE_TYPE 0x0DEB
+#define IL_PALETTE_TYPE 0x0DEC
+#define IL_PALETTE_SIZE 0x0DED
+#define IL_PALETTE_BPP 0x0DEE
+#define IL_PALETTE_NUM_COLS 0x0DEF
+#define IL_PALETTE_BASE_TYPE 0x0DF0
+#define IL_NUM_FACES 0x0DE1
+#define IL_NUM_IMAGES 0x0DF1
+#define IL_NUM_MIPMAPS 0x0DF2
+#define IL_NUM_LAYERS 0x0DF3
+#define IL_ACTIVE_IMAGE 0x0DF4
+#define IL_ACTIVE_MIPMAP 0x0DF5
+#define IL_ACTIVE_LAYER 0x0DF6
+#define IL_ACTIVE_FACE 0x0E00
+#define IL_CUR_IMAGE 0x0DF7
+#define IL_IMAGE_DURATION 0x0DF8
+#define IL_IMAGE_PLANESIZE 0x0DF9
+#define IL_IMAGE_BPC 0x0DFA
+#define IL_IMAGE_OFFX 0x0DFB
+#define IL_IMAGE_OFFY 0x0DFC
+#define IL_IMAGE_CUBEFLAGS 0x0DFD
+#define IL_IMAGE_ORIGIN 0x0DFE
+#define IL_IMAGE_CHANNELS 0x0DFF
+
+# if defined __GNUC__ && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 0))
+// __attribute__((deprecated)) is supported by GCC 3.1 and later.
+# define DEPRECATED(D) D __attribute__((deprecated))
+# elif defined _MSC_VER && _MSC_VER >= 1300
+// __declspec(deprecated) is supported by MSVC 7.0 and later.
+# define DEPRECATED(D) __declspec(deprecated) D
+# else
+# define DEPRECATED (D) D
+# endif
+
+//
+// Section shamelessly modified from the glut header.
+//
+
+// This is from Win32's
+#if (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED) || defined(__BORLANDC__) || defined(__LCC__)
+ #define ILAPIENTRY __stdcall
+ #define IL_PACKSTRUCT
+//#elif defined(linux) || defined(MACOSX) || defined(__CYGWIN__) //fix bug 840364
+#elif defined( __GNUC__ )
+ // this should work for any of the above commented platforms
+ // plus any platform using GCC
+ #ifdef __MINGW32__
+ #define ILAPIENTRY __stdcall
+ #else
+ #define ILAPIENTRY
+ #endif
+ #define IL_PACKSTRUCT __attribute__ ((packed))
+#else
+ #define ILAPIENTRY
+ #define IL_PACKSTRUCT
+#endif
+
+// This is from Win32's and
+#if defined(__LCC__)
+ #define ILAPI __stdcall
+#elif defined(_WIN32) //changed 20031221 to fix bug 840421
+ #ifdef IL_STATIC_LIB
+ #define ILAPI
+ #else
+ #ifdef _IL_BUILD_LIBRARY
+ #define ILAPI __declspec(dllexport)
+ #else
+ #define ILAPI __declspec(dllimport)
+ #endif
+ #endif
+#elif __APPLE__
+ #define ILAPI extern
+#else
+ #define ILAPI
+#endif
+
+
+#define IL_SEEK_SET 0
+#define IL_SEEK_CUR 1
+#define IL_SEEK_END 2
+#define IL_EOF -1
+
+
+// Callback functions for file reading
+typedef void* ILHANDLE;
+typedef void (ILAPIENTRY *fCloseRProc)(ILHANDLE);
+typedef ILboolean (ILAPIENTRY *fEofProc) (ILHANDLE);
+typedef ILint (ILAPIENTRY *fGetcProc) (ILHANDLE);
+typedef ILHANDLE (ILAPIENTRY *fOpenRProc) (ILconst_string);
+typedef ILint (ILAPIENTRY *fReadProc) (void*, ILuint, ILuint, ILHANDLE);
+typedef ILint (ILAPIENTRY *fSeekRProc) (ILHANDLE, ILint, ILint);
+typedef ILint (ILAPIENTRY *fTellRProc) (ILHANDLE);
+
+// Callback functions for file writing
+typedef void (ILAPIENTRY *fCloseWProc)(ILHANDLE);
+typedef ILHANDLE (ILAPIENTRY *fOpenWProc) (ILconst_string);
+typedef ILint (ILAPIENTRY *fPutcProc) (ILubyte, ILHANDLE);
+typedef ILint (ILAPIENTRY *fSeekWProc) (ILHANDLE, ILint, ILint);
+typedef ILint (ILAPIENTRY *fTellWProc) (ILHANDLE);
+typedef ILint (ILAPIENTRY *fWriteProc) (const void*, ILuint, ILuint, ILHANDLE);
+
+// Callback functions for allocation and deallocation
+typedef void* (ILAPIENTRY *mAlloc)(const ILsizei);
+typedef void (ILAPIENTRY *mFree) (const void* CONST_RESTRICT);
+
+// Registered format procedures
+typedef ILenum (ILAPIENTRY *IL_LOADPROC)(ILconst_string);
+typedef ILenum (ILAPIENTRY *IL_SAVEPROC)(ILconst_string);
+
+
+// ImageLib Functions
+ILAPI ILboolean ILAPIENTRY ilActiveFace(ILuint Number);
+ILAPI ILboolean ILAPIENTRY ilActiveImage(ILuint Number);
+ILAPI ILboolean ILAPIENTRY ilActiveLayer(ILuint Number);
+ILAPI ILboolean ILAPIENTRY ilActiveMipmap(ILuint Number);
+ILAPI ILboolean ILAPIENTRY ilApplyPal(ILconst_string FileName);
+ILAPI ILboolean ILAPIENTRY ilApplyProfile(ILstring InProfile, ILstring OutProfile);
+ILAPI void ILAPIENTRY ilBindImage(ILuint Image);
+ILAPI ILboolean ILAPIENTRY ilBlit(ILuint Source, ILint DestX, ILint DestY, ILint DestZ, ILuint SrcX, ILuint SrcY, ILuint SrcZ, ILuint Width, ILuint Height, ILuint Depth);
+ILAPI ILboolean ILAPIENTRY ilClampNTSC(void);
+ILAPI void ILAPIENTRY ilClearColour(ILclampf Red, ILclampf Green, ILclampf Blue, ILclampf Alpha);
+ILAPI ILboolean ILAPIENTRY ilClearImage(void);
+ILAPI ILuint ILAPIENTRY ilCloneCurImage(void);
+ILAPI ILubyte* ILAPIENTRY ilCompressDXT(ILubyte *Data, ILuint Width, ILuint Height, ILuint Depth, ILenum DXTCFormat, ILuint *DXTCSize);
+ILAPI ILboolean ILAPIENTRY ilCompressFunc(ILenum Mode);
+ILAPI ILboolean ILAPIENTRY ilConvertImage(ILenum DestFormat, ILenum DestType);
+ILAPI ILboolean ILAPIENTRY ilConvertPal(ILenum DestFormat);
+ILAPI ILboolean ILAPIENTRY ilCopyImage(ILuint Src);
+ILAPI ILuint ILAPIENTRY ilCopyPixels(ILuint XOff, ILuint YOff, ILuint ZOff, ILuint Width, ILuint Height, ILuint Depth, ILenum Format, ILenum Type, void *Data);
+ILAPI ILuint ILAPIENTRY ilCreateSubImage(ILenum Type, ILuint Num);
+ILAPI ILboolean ILAPIENTRY ilDefaultImage(void);
+ILAPI void ILAPIENTRY ilDeleteImage(const ILuint Num);
+ILAPI void ILAPIENTRY ilDeleteImages(ILsizei Num, const ILuint *Images);
+ILAPI ILenum ILAPIENTRY ilDetermineType(ILconst_string FileName);
+ILAPI ILenum ILAPIENTRY ilDetermineTypeF(ILHANDLE File);
+ILAPI ILenum ILAPIENTRY ilDetermineTypeL(const void *Lump, ILuint Size);
+ILAPI ILboolean ILAPIENTRY ilDisable(ILenum Mode);
+ILAPI ILboolean ILAPIENTRY ilDxtcDataToImage(void);
+ILAPI ILboolean ILAPIENTRY ilDxtcDataToSurface(void);
+ILAPI ILboolean ILAPIENTRY ilEnable(ILenum Mode);
+ILAPI void ILAPIENTRY ilFlipSurfaceDxtcData(void);
+ILAPI ILboolean ILAPIENTRY ilFormatFunc(ILenum Mode);
+ILAPI void ILAPIENTRY ilGenImages(ILsizei Num, ILuint *Images);
+ILAPI ILuint ILAPIENTRY ilGenImage(void);
+ILAPI ILubyte* ILAPIENTRY ilGetAlpha(ILenum Type);
+ILAPI ILboolean ILAPIENTRY ilGetBoolean(ILenum Mode);
+ILAPI void ILAPIENTRY ilGetBooleanv(ILenum Mode, ILboolean *Param);
+ILAPI ILubyte* ILAPIENTRY ilGetData(void);
+ILAPI ILuint ILAPIENTRY ilGetDXTCData(void *Buffer, ILuint BufferSize, ILenum DXTCFormat);
+ILAPI ILenum ILAPIENTRY ilGetError(void);
+ILAPI ILint ILAPIENTRY ilGetInteger(ILenum Mode);
+ILAPI void ILAPIENTRY ilGetIntegerv(ILenum Mode, ILint *Param);
+ILAPI ILuint ILAPIENTRY ilGetLumpPos(void);
+ILAPI ILubyte* ILAPIENTRY ilGetPalette(void);
+ILAPI ILconst_string ILAPIENTRY ilGetString(ILenum StringName);
+ILAPI void ILAPIENTRY ilHint(ILenum Target, ILenum Mode);
+ILAPI ILboolean ILAPIENTRY ilInvertSurfaceDxtcDataAlpha(void);
+ILAPI void ILAPIENTRY ilInit(void);
+ILAPI ILboolean ILAPIENTRY ilImageToDxtcData(ILenum Format);
+ILAPI ILboolean ILAPIENTRY ilIsDisabled(ILenum Mode);
+ILAPI ILboolean ILAPIENTRY ilIsEnabled(ILenum Mode);
+ILAPI ILboolean ILAPIENTRY ilIsImage(ILuint Image);
+ILAPI ILboolean ILAPIENTRY ilIsValid(ILenum Type, ILconst_string FileName);
+ILAPI ILboolean ILAPIENTRY ilIsValidF(ILenum Type, ILHANDLE File);
+ILAPI ILboolean ILAPIENTRY ilIsValidL(ILenum Type, void *Lump, ILuint Size);
+ILAPI void ILAPIENTRY ilKeyColour(ILclampf Red, ILclampf Green, ILclampf Blue, ILclampf Alpha);
+ILAPI ILboolean ILAPIENTRY ilLoad(ILenum Type, ILconst_string FileName);
+ILAPI ILboolean ILAPIENTRY ilLoadF(ILenum Type, ILHANDLE File);
+ILAPI ILboolean ILAPIENTRY ilLoadImage(ILconst_string FileName);
+ILAPI ILboolean ILAPIENTRY ilLoadL(ILenum Type, const void *Lump, ILuint Size);
+ILAPI ILboolean ILAPIENTRY ilLoadPal(ILconst_string FileName);
+ILAPI void ILAPIENTRY ilModAlpha(ILdouble AlphaValue);
+ILAPI ILboolean ILAPIENTRY ilOriginFunc(ILenum Mode);
+ILAPI ILboolean ILAPIENTRY ilOverlayImage(ILuint Source, ILint XCoord, ILint YCoord, ILint ZCoord);
+ILAPI void ILAPIENTRY ilPopAttrib(void);
+ILAPI void ILAPIENTRY ilPushAttrib(ILuint Bits);
+ILAPI void ILAPIENTRY ilRegisterFormat(ILenum Format);
+ILAPI ILboolean ILAPIENTRY ilRegisterLoad(ILconst_string Ext, IL_LOADPROC Load);
+ILAPI ILboolean ILAPIENTRY ilRegisterMipNum(ILuint Num);
+ILAPI ILboolean ILAPIENTRY ilRegisterNumFaces(ILuint Num);
+ILAPI ILboolean ILAPIENTRY ilRegisterNumImages(ILuint Num);
+ILAPI void ILAPIENTRY ilRegisterOrigin(ILenum Origin);
+ILAPI void ILAPIENTRY ilRegisterPal(void *Pal, ILuint Size, ILenum Type);
+ILAPI ILboolean ILAPIENTRY ilRegisterSave(ILconst_string Ext, IL_SAVEPROC Save);
+ILAPI void ILAPIENTRY ilRegisterType(ILenum Type);
+ILAPI ILboolean ILAPIENTRY ilRemoveLoad(ILconst_string Ext);
+ILAPI ILboolean ILAPIENTRY ilRemoveSave(ILconst_string Ext);
+ILAPI void ILAPIENTRY ilResetMemory(void); // Deprecated
+ILAPI void ILAPIENTRY ilResetRead(void);
+ILAPI void ILAPIENTRY ilResetWrite(void);
+ILAPI ILboolean ILAPIENTRY ilSave(ILenum Type, ILconst_string FileName);
+ILAPI ILuint ILAPIENTRY ilSaveF(ILenum Type, ILHANDLE File);
+ILAPI ILboolean ILAPIENTRY ilSaveImage(ILconst_string FileName);
+ILAPI ILuint ILAPIENTRY ilSaveL(ILenum Type, void *Lump, ILuint Size);
+ILAPI ILboolean ILAPIENTRY ilSavePal(ILconst_string FileName);
+ILAPI ILboolean ILAPIENTRY ilSetAlpha(ILdouble AlphaValue);
+ILAPI ILboolean ILAPIENTRY ilSetData(void *Data);
+ILAPI ILboolean ILAPIENTRY ilSetDuration(ILuint Duration);
+ILAPI void ILAPIENTRY ilSetInteger(ILenum Mode, ILint Param);
+ILAPI void ILAPIENTRY ilSetMemory(mAlloc, mFree);
+ILAPI void ILAPIENTRY ilSetPixels(ILint XOff, ILint YOff, ILint ZOff, ILuint Width, ILuint Height, ILuint Depth, ILenum Format, ILenum Type, void *Data);
+ILAPI void ILAPIENTRY ilSetRead(fOpenRProc, fCloseRProc, fEofProc, fGetcProc, fReadProc, fSeekRProc, fTellRProc);
+ILAPI void ILAPIENTRY ilSetString(ILenum Mode, const char *String);
+ILAPI void ILAPIENTRY ilSetWrite(fOpenWProc, fCloseWProc, fPutcProc, fSeekWProc, fTellWProc, fWriteProc);
+ILAPI void ILAPIENTRY ilShutDown(void);
+ILAPI ILboolean ILAPIENTRY ilSurfaceToDxtcData(ILenum Format);
+ILAPI ILboolean ILAPIENTRY ilTexImage(ILuint Width, ILuint Height, ILuint Depth, ILubyte NumChannels, ILenum Format, ILenum Type, void *Data);
+ILAPI ILboolean ILAPIENTRY ilTexImageDxtc(ILint w, ILint h, ILint d, ILenum DxtFormat, const ILubyte* data);
+ILAPI ILenum ILAPIENTRY ilTypeFromExt(ILconst_string FileName);
+ILAPI ILboolean ILAPIENTRY ilTypeFunc(ILenum Mode);
+ILAPI ILboolean ILAPIENTRY ilLoadData(ILconst_string FileName, ILuint Width, ILuint Height, ILuint Depth, ILubyte Bpp);
+ILAPI ILboolean ILAPIENTRY ilLoadDataF(ILHANDLE File, ILuint Width, ILuint Height, ILuint Depth, ILubyte Bpp);
+ILAPI ILboolean ILAPIENTRY ilLoadDataL(void *Lump, ILuint Size, ILuint Width, ILuint Height, ILuint Depth, ILubyte Bpp);
+ILAPI ILboolean ILAPIENTRY ilSaveData(ILconst_string FileName);
+
+// For all those weirdos that spell "colour" without the 'u'.
+#define ilClearColor ilClearColour
+#define ilKeyColor ilKeyColour
+
+#define imemclear(x,y) memset(x,0,y);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // __IL_H__
+#endif // __il_h__
diff --git a/COM380/Project5/include/DevIL/il_wrap.h b/COM380/Project5/include/DevIL/il_wrap.h
new file mode 100644
index 0000000..5cf9b0e
--- /dev/null
+++ b/COM380/Project5/include/DevIL/il_wrap.h
@@ -0,0 +1,205 @@
+#ifndef WRAPPER_H
+#define WRAPPER_H
+
+/*#include
+#include */
+#include // Probably only have to #include this one
+
+#ifdef _MSC_VER
+ #ifndef _IL_WRAP_BUILD_LIB
+ #pragma comment(lib, "il_wrap.lib")
+ #endif
+#endif
+
+class ilImage
+{
+public:
+ ilImage();
+ ilImage(char *);
+ ilImage(const ilImage &);
+ virtual ~ilImage();
+
+ ILboolean Load(char *);
+ ILboolean Load(char *, ILenum);
+ ILboolean Save(char *);
+ ILboolean Save(char *, ILenum);
+
+
+ // ImageLib functions
+ ILboolean ActiveImage(ILuint);
+ ILboolean ActiveLayer(ILuint);
+ ILboolean ActiveMipmap(ILuint);
+ ILboolean Clear(void);
+ ILvoid ClearColour(ILclampf, ILclampf, ILclampf, ILclampf);
+ ILboolean Convert(ILenum);
+ ILboolean Copy(ILuint);
+ ILboolean Default(void);
+ ILboolean Flip(void);
+ ILboolean SwapColours(void);
+ ILboolean Resize(ILuint, ILuint, ILuint);
+ ILboolean TexImage(ILuint, ILuint, ILuint, ILubyte, ILenum, ILenum, ILvoid*);
+
+
+ // Image handling
+ ILvoid Bind(void) const;
+ ILvoid Bind(ILuint);
+ ILvoid Close(void) { this->Delete(); }
+ ILvoid Delete(void);
+ ILvoid iGenBind();
+ ILenum PaletteAlphaIndex();
+
+ // Image characteristics
+ ILuint Width(void);
+ ILuint Height(void);
+ ILuint Depth(void);
+ ILubyte Bpp(void);
+ ILubyte Bitpp(void);
+ ILenum PaletteType(void);
+ ILenum Format(void);
+ ILenum Type(void);
+ ILuint NumImages(void);
+ ILuint NumMipmaps(void);
+ ILuint GetId(void) const;
+ ILenum GetOrigin(void);
+ ILubyte *GetData(void);
+ ILubyte *GetPalette(void);
+
+
+ // Rendering
+ ILuint BindImage(void);
+ ILuint BindImage(ILenum);
+
+
+ // Operators
+ ilImage& operator = (ILuint);
+ ilImage& operator = (const ilImage &);
+
+
+protected:
+ ILuint Id;
+
+private:
+ ILvoid iStartUp();
+
+
+};
+
+
+class ilFilters
+{
+public:
+ static ILboolean Alienify(ilImage &);
+ static ILboolean BlurAvg(ilImage &, ILuint Iter);
+ static ILboolean BlurGaussian(ilImage &, ILuint Iter);
+ static ILboolean Contrast(ilImage &, ILfloat Contrast);
+ static ILboolean EdgeDetectE(ilImage &);
+ static ILboolean EdgeDetectP(ilImage &);
+ static ILboolean EdgeDetectS(ilImage &);
+ static ILboolean Emboss(ilImage &);
+ static ILboolean Gamma(ilImage &, ILfloat Gamma);
+ static ILboolean Negative(ilImage &);
+ static ILboolean Noisify(ilImage &, ILubyte Factor);
+ static ILboolean Pixelize(ilImage &, ILuint PixSize);
+ static ILboolean Saturate(ilImage &, ILfloat Saturation);
+ static ILboolean Saturate(ilImage &, ILfloat r, ILfloat g, ILfloat b, ILfloat Saturation);
+ static ILboolean ScaleColours(ilImage &, ILfloat r, ILfloat g, ILfloat b);
+ static ILboolean Sharpen(ilImage &, ILfloat Factor, ILuint Iter);
+};
+
+
+#ifdef ILUT_USE_OPENGL
+class ilOgl
+{
+public:
+ static ILvoid Init(void);
+ static GLuint BindTex(ilImage &);
+ static ILboolean Upload(ilImage &, ILuint);
+ static GLuint Mipmap(ilImage &);
+ static ILboolean Screen(void);
+ static ILboolean Screenie(void);
+};
+#endif//ILUT_USE_OPENGL
+
+
+#ifdef ILUT_USE_ALLEGRO
+class ilAlleg
+{
+public:
+ static ILvoid Init(void);
+ static BITMAP *Convert(ilImage &);
+};
+#endif//ILUT_USE_ALLEGRO
+
+
+#ifdef ILUT_USE_WIN32
+class ilWin32
+{
+public:
+ static ILvoid Init(void);
+ static HBITMAP Convert(ilImage &);
+ static ILboolean GetClipboard(ilImage &);
+ static ILvoid GetInfo(ilImage &, BITMAPINFO *Info);
+ static ILubyte *GetPadData(ilImage &);
+ static HPALETTE GetPal(ilImage &);
+ static ILboolean GetResource(ilImage &, HINSTANCE hInst, ILint ID, char *ResourceType);
+ static ILboolean GetResource(ilImage &, HINSTANCE hInst, ILint ID, char *ResourceType, ILenum Type);
+ static ILboolean SetClipboard(ilImage &);
+};
+#endif//ILUT_USE_WIN32
+
+
+class ilValidate
+{
+public:
+ static ILboolean Valid(ILenum, char *);
+ static ILboolean Valid(ILenum, FILE *);
+ static ILboolean Valid(ILenum, ILvoid *, ILuint);
+
+protected:
+
+private:
+
+};
+
+
+class ilState
+{
+public:
+ static ILboolean Disable(ILenum);
+ static ILboolean Enable(ILenum);
+ static ILvoid Get(ILenum, ILboolean &);
+ static ILvoid Get(ILenum, ILint &);
+ static ILboolean GetBool(ILenum);
+ static ILint GetInt(ILenum);
+ static const char *GetString(ILenum);
+ static ILboolean IsDisabled(ILenum);
+ static ILboolean IsEnabled(ILenum);
+ static ILboolean Origin(ILenum);
+ static ILvoid Pop(void);
+ static ILvoid Push(ILuint);
+
+
+protected:
+
+private:
+
+};
+
+
+class ilError
+{
+public:
+ static ILvoid Check(ILvoid (*Callback)(const char*));
+ static ILvoid Check(ILvoid (*Callback)(ILenum));
+ static ILenum Get(void);
+ static const char *String(void);
+ static const char *String(ILenum);
+
+protected:
+
+private:
+
+};
+
+
+#endif//WRAPPER_H
diff --git a/COM380/Project5/include/DevIL/ilu.h b/COM380/Project5/include/DevIL/ilu.h
new file mode 100644
index 0000000..0a07a97
--- /dev/null
+++ b/COM380/Project5/include/DevIL/ilu.h
@@ -0,0 +1,195 @@
+//-----------------------------------------------------------------------------
+//
+// ImageLib Utility Sources
+// Copyright (C) 2000-2009 by Denton Woods
+// Last modified: 03/07/2009
+//
+// Filename: IL/ilu.h
+//
+// Description: The main include file for ILU
+//
+//-----------------------------------------------------------------------------
+
+// Doxygen comment
+/*! \file ilu.h
+ The main include file for ILU
+*/
+
+#ifndef __ilu_h_
+#ifndef __ILU_H__
+
+#define __ilu_h_
+#define __ILU_H__
+
+#include
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#ifdef _WIN32
+ #if (defined(IL_USE_PRAGMA_LIBS)) && (!defined(_IL_BUILD_LIBRARY))
+ #if defined(_MSC_VER) || defined(__BORLANDC__)
+ #pragma comment(lib, "ILU.lib")
+ #endif
+ #endif
+#endif
+
+
+#define ILU_VERSION_1_7_8 1
+#define ILU_VERSION 178
+
+
+#define ILU_FILTER 0x2600
+#define ILU_NEAREST 0x2601
+#define ILU_LINEAR 0x2602
+#define ILU_BILINEAR 0x2603
+#define ILU_SCALE_BOX 0x2604
+#define ILU_SCALE_TRIANGLE 0x2605
+#define ILU_SCALE_BELL 0x2606
+#define ILU_SCALE_BSPLINE 0x2607
+#define ILU_SCALE_LANCZOS3 0x2608
+#define ILU_SCALE_MITCHELL 0x2609
+
+
+// Error types
+#define ILU_INVALID_ENUM 0x0501
+#define ILU_OUT_OF_MEMORY 0x0502
+#define ILU_INTERNAL_ERROR 0x0504
+#define ILU_INVALID_VALUE 0x0505
+#define ILU_ILLEGAL_OPERATION 0x0506
+#define ILU_INVALID_PARAM 0x0509
+
+
+// Values
+#define ILU_PLACEMENT 0x0700
+#define ILU_LOWER_LEFT 0x0701
+#define ILU_LOWER_RIGHT 0x0702
+#define ILU_UPPER_LEFT 0x0703
+#define ILU_UPPER_RIGHT 0x0704
+#define ILU_CENTER 0x0705
+#define ILU_CONVOLUTION_MATRIX 0x0710
+
+#define ILU_VERSION_NUM IL_VERSION_NUM
+#define ILU_VENDOR IL_VENDOR
+
+
+// Languages
+#define ILU_ENGLISH 0x0800
+#define ILU_ARABIC 0x0801
+#define ILU_DUTCH 0x0802
+#define ILU_JAPANESE 0x0803
+#define ILU_SPANISH 0x0804
+#define ILU_GERMAN 0x0805
+#define ILU_FRENCH 0x0806
+
+
+// Filters
+/*
+#define ILU_FILTER_BLUR 0x0803
+#define ILU_FILTER_GAUSSIAN_3x3 0x0804
+#define ILU_FILTER_GAUSSIAN_5X5 0x0805
+#define ILU_FILTER_EMBOSS1 0x0807
+#define ILU_FILTER_EMBOSS2 0x0808
+#define ILU_FILTER_LAPLACIAN1 0x080A
+#define ILU_FILTER_LAPLACIAN2 0x080B
+#define ILU_FILTER_LAPLACIAN3 0x080C
+#define ILU_FILTER_LAPLACIAN4 0x080D
+#define ILU_FILTER_SHARPEN1 0x080E
+#define ILU_FILTER_SHARPEN2 0x080F
+#define ILU_FILTER_SHARPEN3 0x0810
+*/
+
+
+typedef struct ILinfo
+{
+ ILuint Id; // the image's id
+ ILubyte *Data; // the image's data
+ ILuint Width; // the image's width
+ ILuint Height; // the image's height
+ ILuint Depth; // the image's depth
+ ILubyte Bpp; // bytes per pixel (not bits) of the image
+ ILuint SizeOfData; // the total size of the data (in bytes)
+ ILenum Format; // image format (in IL enum style)
+ ILenum Type; // image type (in IL enum style)
+ ILenum Origin; // origin of the image
+ ILubyte *Palette; // the image's palette
+ ILenum PalType; // palette type
+ ILuint PalSize; // palette size
+ ILenum CubeFlags; // flags for what cube map sides are present
+ ILuint NumNext; // number of images following
+ ILuint NumMips; // number of mipmaps
+ ILuint NumLayers; // number of layers
+} ILinfo;
+
+
+typedef struct ILpointf {
+ ILfloat x;
+ ILfloat y;
+} ILpointf;
+
+typedef struct ILpointi {
+ ILint x;
+ ILint y;
+} ILpointi;
+
+ILAPI ILboolean ILAPIENTRY iluAlienify(void);
+ILAPI ILboolean ILAPIENTRY iluBlurAvg(ILuint Iter);
+ILAPI ILboolean ILAPIENTRY iluBlurGaussian(ILuint Iter);
+ILAPI ILboolean ILAPIENTRY iluBuildMipmaps(void);
+ILAPI ILuint ILAPIENTRY iluColoursUsed(void);
+ILAPI ILboolean ILAPIENTRY iluCompareImage(ILuint Comp);
+ILAPI ILboolean ILAPIENTRY iluContrast(ILfloat Contrast);
+ILAPI ILboolean ILAPIENTRY iluCrop(ILuint XOff, ILuint YOff, ILuint ZOff, ILuint Width, ILuint Height, ILuint Depth);
+ILAPI void ILAPIENTRY iluDeleteImage(ILuint Id); // Deprecated
+ILAPI ILboolean ILAPIENTRY iluEdgeDetectE(void);
+ILAPI ILboolean ILAPIENTRY iluEdgeDetectP(void);
+ILAPI ILboolean ILAPIENTRY iluEdgeDetectS(void);
+ILAPI ILboolean ILAPIENTRY iluEmboss(void);
+ILAPI ILboolean ILAPIENTRY iluEnlargeCanvas(ILuint Width, ILuint Height, ILuint Depth);
+ILAPI ILboolean ILAPIENTRY iluEnlargeImage(ILfloat XDim, ILfloat YDim, ILfloat ZDim);
+ILAPI ILboolean ILAPIENTRY iluEqualize(void);
+ILAPI ILconst_string ILAPIENTRY iluErrorString(ILenum Error);
+ILAPI ILboolean ILAPIENTRY iluConvolution(ILint *matrix, ILint scale, ILint bias);
+ILAPI ILboolean ILAPIENTRY iluFlipImage(void);
+ILAPI ILboolean ILAPIENTRY iluGammaCorrect(ILfloat Gamma);
+ILAPI ILuint ILAPIENTRY iluGenImage(void); // Deprecated
+ILAPI void ILAPIENTRY iluGetImageInfo(ILinfo *Info);
+ILAPI ILint ILAPIENTRY iluGetInteger(ILenum Mode);
+ILAPI void ILAPIENTRY iluGetIntegerv(ILenum Mode, ILint *Param);
+ILAPI ILstring ILAPIENTRY iluGetString(ILenum StringName);
+ILAPI void ILAPIENTRY iluImageParameter(ILenum PName, ILenum Param);
+ILAPI void ILAPIENTRY iluInit(void);
+ILAPI ILboolean ILAPIENTRY iluInvertAlpha(void);
+ILAPI ILuint ILAPIENTRY iluLoadImage(ILconst_string FileName);
+ILAPI ILboolean ILAPIENTRY iluMirror(void);
+ILAPI ILboolean ILAPIENTRY iluNegative(void);
+ILAPI ILboolean ILAPIENTRY iluNoisify(ILclampf Tolerance);
+ILAPI ILboolean ILAPIENTRY iluPixelize(ILuint PixSize);
+ILAPI void ILAPIENTRY iluRegionfv(ILpointf *Points, ILuint n);
+ILAPI void ILAPIENTRY iluRegioniv(ILpointi *Points, ILuint n);
+ILAPI ILboolean ILAPIENTRY iluReplaceColour(ILubyte Red, ILubyte Green, ILubyte Blue, ILfloat Tolerance);
+ILAPI ILboolean ILAPIENTRY iluRotate(ILfloat Angle);
+ILAPI ILboolean ILAPIENTRY iluRotate3D(ILfloat x, ILfloat y, ILfloat z, ILfloat Angle);
+ILAPI ILboolean ILAPIENTRY iluSaturate1f(ILfloat Saturation);
+ILAPI ILboolean ILAPIENTRY iluSaturate4f(ILfloat r, ILfloat g, ILfloat b, ILfloat Saturation);
+ILAPI ILboolean ILAPIENTRY iluScale(ILuint Width, ILuint Height, ILuint Depth);
+ILAPI ILboolean ILAPIENTRY iluScaleAlpha(ILfloat scale);
+ILAPI ILboolean ILAPIENTRY iluScaleColours(ILfloat r, ILfloat g, ILfloat b);
+ILAPI ILboolean ILAPIENTRY iluSetLanguage(ILenum Language);
+ILAPI ILboolean ILAPIENTRY iluSharpen(ILfloat Factor, ILuint Iter);
+ILAPI ILboolean ILAPIENTRY iluSwapColours(void);
+ILAPI ILboolean ILAPIENTRY iluWave(ILfloat Angle);
+
+#define iluColorsUsed iluColoursUsed
+#define iluSwapColors iluSwapColours
+#define iluReplaceColor iluReplaceColour
+#define iluScaleColor iluScaleColour
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // __ILU_H__
+#endif // __ilu_h_
diff --git a/COM380/Project5/include/DevIL/ilu_region.h b/COM380/Project5/include/DevIL/ilu_region.h
new file mode 100644
index 0000000..b5b3adc
--- /dev/null
+++ b/COM380/Project5/include/DevIL/ilu_region.h
@@ -0,0 +1,25 @@
+//-----------------------------------------------------------------------------
+//
+// ImageLib Utility Sources
+// Copyright (C) 2000-2002 by Denton Woods
+// Last modified: 07/09/2002 <--Y2K Compliant! =]
+//
+// Filename: src-ILU/src/ilu_region.h
+//
+// Description: Creates an image region.
+//
+//-----------------------------------------------------------------------------
+
+#ifndef ILU_REGION_H
+#define ILU_REGION_H
+
+typedef struct Edge
+{
+ ILint yUpper;
+ ILfloat xIntersect, dxPerScan;
+ struct Edge *next;
+} Edge;
+
+
+#endif//ILU_REGION_H
+
diff --git a/COM380/Project5/include/DevIL/ilut.h b/COM380/Project5/include/DevIL/ilut.h
new file mode 100644
index 0000000..4a84b84
--- /dev/null
+++ b/COM380/Project5/include/DevIL/ilut.h
@@ -0,0 +1,390 @@
+//-----------------------------------------------------------------------------
+//
+// ImageLib Utility Toolkit Sources
+// Copyright (C) 2000-2009 by Denton Woods
+// Last modified: 03/07/2009
+//
+// Filename: IL/ilut.h
+//
+// Description: The main include file for ILUT
+//
+//-----------------------------------------------------------------------------
+
+// Doxygen comment
+/*! \file ilut.h
+ The main include file for ILUT
+*/
+
+#ifndef __ilut_h_
+#ifndef __ILUT_H__
+
+#define __ilut_h_
+#define __ILUT_H__
+
+#include
+#include
+
+
+//-----------------------------------------------------------------------------
+// Defines
+//-----------------------------------------------------------------------------
+
+#define ILUT_VERSION_1_7_8 1
+#define ILUT_VERSION 178
+
+
+// Attribute Bits
+#define ILUT_OPENGL_BIT 0x00000001
+#define ILUT_D3D_BIT 0x00000002
+#define ILUT_ALL_ATTRIB_BITS 0x000FFFFF
+
+
+// Error Types
+#define ILUT_INVALID_ENUM 0x0501
+#define ILUT_OUT_OF_MEMORY 0x0502
+#define ILUT_INVALID_VALUE 0x0505
+#define ILUT_ILLEGAL_OPERATION 0x0506
+#define ILUT_INVALID_PARAM 0x0509
+#define ILUT_COULD_NOT_OPEN_FILE 0x050A
+#define ILUT_STACK_OVERFLOW 0x050E
+#define ILUT_STACK_UNDERFLOW 0x050F
+#define ILUT_BAD_DIMENSIONS 0x0511
+#define ILUT_NOT_SUPPORTED 0x0550
+
+
+// State Definitions
+#define ILUT_PALETTE_MODE 0x0600
+#define ILUT_OPENGL_CONV 0x0610
+#define ILUT_D3D_MIPLEVELS 0x0620
+#define ILUT_MAXTEX_WIDTH 0x0630
+#define ILUT_MAXTEX_HEIGHT 0x0631
+#define ILUT_MAXTEX_DEPTH 0x0632
+#define ILUT_GL_USE_S3TC 0x0634
+#define ILUT_D3D_USE_DXTC 0x0634
+#define ILUT_GL_GEN_S3TC 0x0635
+#define ILUT_D3D_GEN_DXTC 0x0635
+#define ILUT_S3TC_FORMAT 0x0705
+#define ILUT_DXTC_FORMAT 0x0705
+#define ILUT_D3D_POOL 0x0706
+#define ILUT_D3D_ALPHA_KEY_COLOR 0x0707
+#define ILUT_D3D_ALPHA_KEY_COLOUR 0x0707
+#define ILUT_FORCE_INTEGER_FORMAT 0x0636
+
+//This new state does automatic texture target detection
+//if enabled. Currently, only cubemap detection is supported.
+//if the current image is no cubemap, the 2d texture is chosen.
+#define ILUT_GL_AUTODETECT_TEXTURE_TARGET 0x0807
+
+
+// Values
+#define ILUT_VERSION_NUM IL_VERSION_NUM
+#define ILUT_VENDOR IL_VENDOR
+
+// The different rendering api's...more to be added later?
+#define ILUT_OPENGL 0
+#define ILUT_ALLEGRO 1
+#define ILUT_WIN32 2
+#define ILUT_DIRECT3D8 3
+#define ILUT_DIRECT3D9 4
+#define ILUT_X11 5
+#define ILUT_DIRECT3D10 6
+
+/*
+// Includes specific config
+#ifdef DJGPP
+ #define ILUT_USE_ALLEGRO
+#elif _WIN32_WCE
+ #define ILUT_USE_WIN32
+#elif _WIN32
+ //#ifdef __GNUC__ //__CYGWIN32__ (Cygwin seems to not define this with DevIL builds)
+ #define ILUT_USE_WIN32
+ #include "IL/config.h"
+
+ // Temporary fix for the SDL main() linker bug.
+ //#ifdef ILUT_USE_SDL
+ //#undef ILUT_USE_SDL
+ //#endif//ILUT_USE_SDL
+
+ //#else
+ // #define ILUT_USE_WIN32
+ // #define ILUT_USE_OPENGL
+ // #define ILUT_USE_SDL
+ // #define ILUT_USE_DIRECTX8
+ //#endif
+#elif BEOS // Don't know the #define
+ #define ILUT_USE_BEOS
+ #define ILUT_USE_OPENGL
+#elif MACOSX
+ #define ILUT_USE_OPENGL
+#else
+
+ // We are surely using a *nix so the configure script
+ // may have written the configured config.h header
+ #include "IL/config.h"
+#endif
+*/
+
+#if (defined(_WIN32) || defined(_WIN64))
+ #if (defined(IL_USE_PRAGMA_LIBS)) && (!defined(_IL_BUILD_LIBRARY))
+ #if defined(_MSC_VER) || defined(__BORLANDC__)
+ #pragma comment(lib, "ILUT.lib")
+ #endif
+ #endif
+
+ #include
+#endif
+
+
+
+//this should remain private and hidden
+//#include "IL/config.h"
+
+//////////////
+// OpenGL
+//////////////
+
+#ifdef ILUT_USE_OPENGL
+ #if defined(_MSC_VER) || defined(_WIN32)
+ //#define WIN32_LEAN_AND_MEAN
+ #include
+ #endif//_MSC_VER
+
+ #ifdef __APPLE__
+ #include
+ #include
+ #else
+ #include
+ #include
+ #endif//__APPLE__
+#endif
+
+
+#ifdef ILUT_USE_WIN32
+ //#define WIN32_LEAN_AND_MEAN
+ #ifdef _DEBUG
+ #define _CRTDBG_MAP_ALLOC
+ #include
+ #ifndef _WIN32_WCE
+ #include
+ #endif
+ #endif
+ #include
+#endif
+
+
+//
+// If we can avoid including these in all cases thing tend to break less
+// and we can keep all of them defined as available
+//
+// Kriss
+//
+
+// ImageLib Utility Toolkit's Allegro Functions
+#ifdef ILUT_USE_ALLEGRO
+// #include
+#endif//ILUT_USE_ALLEGRO
+
+#ifdef ILUT_USE_SDL
+// #include
+#endif
+
+#ifdef ILUT_USE_DIRECTX8
+ #include
+#endif//ILUT_USE_DIRECTX9
+
+#ifdef ILUT_USE_DIRECTX9
+ #include
+#endif//ILUT_USE_DIRECTX9
+
+#ifdef ILUT_USE_DIRECTX10
+ #pragma warning(push)
+ #pragma warning(disable : 4201) // Disables 'nonstandard extension used : nameless struct/union' warning
+ #include
+ #include
+ #include
+ #pragma warning(pop)
+#endif//ILUT_USE_DIRECTX10
+
+#ifdef ILUT_USE_X11
+ #include
+ #include
+#ifdef ILUT_USE_XSHM
+ #include
+ #include
+ #include
+#endif//ILUT_USE_XSHM
+#endif//ILUT_USE_X11
+
+
+
+//-----------------------------------------------------------------------------
+// Functions
+//-----------------------------------------------------------------------------
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// ImageLib Utility Toolkit Functions
+ILAPI ILboolean ILAPIENTRY ilutDisable(ILenum Mode);
+ILAPI ILboolean ILAPIENTRY ilutEnable(ILenum Mode);
+ILAPI ILboolean ILAPIENTRY ilutGetBoolean(ILenum Mode);
+ILAPI void ILAPIENTRY ilutGetBooleanv(ILenum Mode, ILboolean *Param);
+ILAPI ILint ILAPIENTRY ilutGetInteger(ILenum Mode);
+ILAPI void ILAPIENTRY ilutGetIntegerv(ILenum Mode, ILint *Param);
+ILAPI ILstring ILAPIENTRY ilutGetString(ILenum StringName);
+ILAPI void ILAPIENTRY ilutInit(void);
+ILAPI ILboolean ILAPIENTRY ilutIsDisabled(ILenum Mode);
+ILAPI ILboolean ILAPIENTRY ilutIsEnabled(ILenum Mode);
+ILAPI void ILAPIENTRY ilutPopAttrib(void);
+ILAPI void ILAPIENTRY ilutPushAttrib(ILuint Bits);
+ILAPI void ILAPIENTRY ilutSetInteger(ILenum Mode, ILint Param);
+
+ILAPI ILboolean ILAPIENTRY ilutRenderer(ILenum Renderer);
+
+
+// ImageLib Utility Toolkit's OpenGL Functions
+#ifdef ILUT_USE_OPENGL
+ ILAPI GLuint ILAPIENTRY ilutGLBindTexImage();
+ ILAPI GLuint ILAPIENTRY ilutGLBindMipmaps(void);
+ ILAPI ILboolean ILAPIENTRY ilutGLBuildMipmaps(void);
+ ILAPI GLuint ILAPIENTRY ilutGLLoadImage(ILstring FileName);
+ ILAPI ILboolean ILAPIENTRY ilutGLScreen(void);
+ ILAPI ILboolean ILAPIENTRY ilutGLScreenie(void);
+ ILAPI ILboolean ILAPIENTRY ilutGLSaveImage(ILstring FileName, GLuint TexID);
+ ILAPI ILboolean ILAPIENTRY ilutGLSubTex2D(GLuint TexID, ILuint XOff, ILuint YOff);
+ ILAPI ILboolean ILAPIENTRY ilutGLSubTex3D(GLuint TexID, ILuint XOff, ILuint YOff, ILuint ZOff);
+ ILAPI ILboolean ILAPIENTRY ilutGLSetTex2D(GLuint TexID);
+ ILAPI ILboolean ILAPIENTRY ilutGLSetTex3D(GLuint TexID);
+ ILAPI ILboolean ILAPIENTRY ilutGLTexImage(GLuint Level);
+ ILAPI ILboolean ILAPIENTRY ilutGLSubTex(GLuint TexID, ILuint XOff, ILuint YOff);
+
+ ILAPI ILboolean ILAPIENTRY ilutGLSetTex(GLuint TexID); // Deprecated - use ilutGLSetTex2D.
+ ILAPI ILboolean ILAPIENTRY ilutGLSubTex(GLuint TexID, ILuint XOff, ILuint YOff); // Use ilutGLSubTex2D.
+#endif//ILUT_USE_OPENGL
+
+
+// ImageLib Utility Toolkit's Allegro Functions
+#ifdef ILUT_USE_ALLEGRO
+ #ifdef __cplusplus
+ extern "C" {
+ #endif
+ #include
+ #ifdef __cplusplus
+ }
+ #endif
+
+ ILAPI BITMAP* ILAPIENTRY ilutAllegLoadImage(ILstring FileName);
+ ILAPI BITMAP* ILAPIENTRY ilutConvertToAlleg(PALETTE Pal);
+#endif//ILUT_USE_ALLEGRO
+
+
+// ImageLib Utility Toolkit's SDL Functions
+#ifdef ILUT_USE_SDL
+ ILAPI struct SDL_Surface* ILAPIENTRY ilutConvertToSDLSurface(unsigned int flags);
+ ILAPI struct SDL_Surface* ILAPIENTRY ilutSDLSurfaceLoadImage(ILstring FileName);
+ ILAPI ILboolean ILAPIENTRY ilutSDLSurfaceFromBitmap(struct SDL_Surface *Bitmap);
+#endif//ILUT_USE_SDL
+
+
+// ImageLib Utility Toolkit's BeOS Functions
+#ifdef ILUT_USE_BEOS
+ ILAPI BBitmap ILAPIENTRY ilutConvertToBBitmap(void);
+#endif//ILUT_USE_BEOS
+
+
+// ImageLib Utility Toolkit's Win32 GDI Functions
+#ifdef ILUT_USE_WIN32
+ ILAPI HBITMAP ILAPIENTRY ilutConvertToHBitmap(HDC hDC);
+ ILAPI HBITMAP ILAPIENTRY ilutConvertSliceToHBitmap(HDC hDC, ILuint slice);
+ ILAPI void ILAPIENTRY ilutFreePaddedData(ILubyte *Data);
+ ILAPI void ILAPIENTRY ilutGetBmpInfo(BITMAPINFO *Info);
+ ILAPI HPALETTE ILAPIENTRY ilutGetHPal(void);
+ ILAPI ILubyte* ILAPIENTRY ilutGetPaddedData(void);
+ ILAPI ILboolean ILAPIENTRY ilutGetWinClipboard(void);
+ ILAPI ILboolean ILAPIENTRY ilutLoadResource(HINSTANCE hInst, ILint ID, ILstring ResourceType, ILenum Type);
+ ILAPI ILboolean ILAPIENTRY ilutSetHBitmap(HBITMAP Bitmap);
+ ILAPI ILboolean ILAPIENTRY ilutSetHPal(HPALETTE Pal);
+ ILAPI ILboolean ILAPIENTRY ilutSetWinClipboard(void);
+ ILAPI HBITMAP ILAPIENTRY ilutWinLoadImage(ILstring FileName, HDC hDC);
+ ILAPI ILboolean ILAPIENTRY ilutWinLoadUrl(ILstring Url);
+ ILAPI ILboolean ILAPIENTRY ilutWinPrint(ILuint XPos, ILuint YPos, ILuint Width, ILuint Height, HDC hDC);
+ ILAPI ILboolean ILAPIENTRY ilutWinSaveImage(ILstring FileName, HBITMAP Bitmap);
+#endif//ILUT_USE_WIN32
+
+// ImageLib Utility Toolkit's DirectX 8 Functions
+#ifdef ILUT_USE_DIRECTX8
+// ILAPI void ILAPIENTRY ilutD3D8MipFunc(ILuint NumLevels);
+ ILAPI struct IDirect3DTexture8* ILAPIENTRY ilutD3D8Texture(struct IDirect3DDevice8 *Device);
+ ILAPI struct IDirect3DVolumeTexture8* ILAPIENTRY ilutD3D8VolumeTexture(struct IDirect3DDevice8 *Device);
+ ILAPI ILboolean ILAPIENTRY ilutD3D8TexFromFile(struct IDirect3DDevice8 *Device, char *FileName, struct IDirect3DTexture8 **Texture);
+ ILAPI ILboolean ILAPIENTRY ilutD3D8VolTexFromFile(struct IDirect3DDevice8 *Device, char *FileName, struct IDirect3DVolumeTexture8 **Texture);
+ ILAPI ILboolean ILAPIENTRY ilutD3D8TexFromFileInMemory(struct IDirect3DDevice8 *Device, void *Lump, ILuint Size, struct IDirect3DTexture8 **Texture);
+ ILAPI ILboolean ILAPIENTRY ilutD3D8VolTexFromFileInMemory(struct IDirect3DDevice8 *Device, void *Lump, ILuint Size, struct IDirect3DVolumeTexture8 **Texture);
+ ILAPI ILboolean ILAPIENTRY ilutD3D8TexFromFileHandle(struct IDirect3DDevice8 *Device, ILHANDLE File, struct IDirect3DTexture8 **Texture);
+ ILAPI ILboolean ILAPIENTRY ilutD3D8VolTexFromFileHandle(struct IDirect3DDevice8 *Device, ILHANDLE File, struct IDirect3DVolumeTexture8 **Texture);
+ // These two are not tested yet.
+ ILAPI ILboolean ILAPIENTRY ilutD3D8TexFromResource(struct IDirect3DDevice8 *Device, HMODULE SrcModule, char *SrcResource, struct IDirect3DTexture8 **Texture);
+ ILAPI ILboolean ILAPIENTRY ilutD3D8VolTexFromResource(struct IDirect3DDevice8 *Device, HMODULE SrcModule, char *SrcResource, struct IDirect3DVolumeTexture8 **Texture);
+ ILAPI ILboolean ILAPIENTRY ilutD3D8LoadSurface(struct IDirect3DDevice8 *Device, struct IDirect3DSurface8 *Surface);
+#endif//ILUT_USE_DIRECTX8
+
+#ifdef ILUT_USE_DIRECTX9
+ #pragma warning(push)
+ #pragma warning(disable : 4115) // Disables 'named type definition in parentheses' warning
+// ILAPI void ILAPIENTRY ilutD3D9MipFunc(ILuint NumLevels);
+ ILAPI struct IDirect3DTexture9* ILAPIENTRY ilutD3D9Texture (struct IDirect3DDevice9* Device);
+ ILAPI struct IDirect3DVolumeTexture9* ILAPIENTRY ilutD3D9VolumeTexture (struct IDirect3DDevice9* Device);
+ ILAPI struct IDirect3DCubeTexture9* ILAPIENTRY ilutD3D9CubeTexture (struct IDirect3DDevice9* Device);
+
+ ILAPI ILboolean ILAPIENTRY ilutD3D9CubeTexFromFile(struct IDirect3DDevice9 *Device, ILconst_string FileName, struct IDirect3DCubeTexture9 **Texture);
+ ILAPI ILboolean ILAPIENTRY ilutD3D9CubeTexFromFileInMemory(struct IDirect3DDevice9 *Device, void *Lump, ILuint Size, struct IDirect3DCubeTexture9 **Texture);
+ ILAPI ILboolean ILAPIENTRY ilutD3D9CubeTexFromFileHandle(struct IDirect3DDevice9 *Device, ILHANDLE File, struct IDirect3DCubeTexture9 **Texture);
+ ILAPI ILboolean ILAPIENTRY ilutD3D9CubeTexFromResource(struct IDirect3DDevice9 *Device, HMODULE SrcModule, ILconst_string SrcResource, struct IDirect3DCubeTexture9 **Texture);
+
+ ILAPI ILboolean ILAPIENTRY ilutD3D9TexFromFile(struct IDirect3DDevice9 *Device, ILconst_string FileName, struct IDirect3DTexture9 **Texture);
+ ILAPI ILboolean ILAPIENTRY ilutD3D9VolTexFromFile(struct IDirect3DDevice9 *Device, ILconst_string FileName, struct IDirect3DVolumeTexture9 **Texture);
+ ILAPI ILboolean ILAPIENTRY ilutD3D9TexFromFileInMemory(struct IDirect3DDevice9 *Device, void *Lump, ILuint Size, struct IDirect3DTexture9 **Texture);
+ ILAPI ILboolean ILAPIENTRY ilutD3D9VolTexFromFileInMemory(struct IDirect3DDevice9 *Device, void *Lump, ILuint Size, struct IDirect3DVolumeTexture9 **Texture);
+ ILAPI ILboolean ILAPIENTRY ilutD3D9TexFromFileHandle(struct IDirect3DDevice9 *Device, ILHANDLE File, struct IDirect3DTexture9 **Texture);
+ ILAPI ILboolean ILAPIENTRY ilutD3D9VolTexFromFileHandle(struct IDirect3DDevice9 *Device, ILHANDLE File, struct IDirect3DVolumeTexture9 **Texture);
+
+ // These three are not tested yet.
+ ILAPI ILboolean ILAPIENTRY ilutD3D9TexFromResource(struct IDirect3DDevice9 *Device, HMODULE SrcModule, ILconst_string SrcResource, struct IDirect3DTexture9 **Texture);
+ ILAPI ILboolean ILAPIENTRY ilutD3D9VolTexFromResource(struct IDirect3DDevice9 *Device, HMODULE SrcModule, ILconst_string SrcResource, struct IDirect3DVolumeTexture9 **Texture);
+ ILAPI ILboolean ILAPIENTRY ilutD3D9LoadSurface(struct IDirect3DDevice9 *Device, struct IDirect3DSurface9 *Surface);
+ #pragma warning(pop)
+#endif//ILUT_USE_DIRECTX9
+
+#ifdef ILUT_USE_DIRECTX10
+ ILAPI ID3D10Texture2D* ILAPIENTRY ilutD3D10Texture(ID3D10Device *Device);
+ ILAPI ILboolean ILAPIENTRY ilutD3D10TexFromFile(ID3D10Device *Device, ILconst_string FileName, ID3D10Texture2D **Texture);
+ ILAPI ILboolean ILAPIENTRY ilutD3D10TexFromFileInMemory(ID3D10Device *Device, void *Lump, ILuint Size, ID3D10Texture2D **Texture);
+ ILAPI ILboolean ILAPIENTRY ilutD3D10TexFromResource(ID3D10Device *Device, HMODULE SrcModule, ILconst_string SrcResource, ID3D10Texture2D **Texture);
+ ILAPI ILboolean ILAPIENTRY ilutD3D10TexFromFileHandle(ID3D10Device *Device, ILHANDLE File, ID3D10Texture2D **Texture);
+#endif//ILUT_USE_DIRECTX10
+
+
+
+#ifdef ILUT_USE_X11
+ ILAPI XImage * ILAPIENTRY ilutXCreateImage( Display* );
+ ILAPI Pixmap ILAPIENTRY ilutXCreatePixmap( Display*,Drawable );
+ ILAPI XImage * ILAPIENTRY ilutXLoadImage( Display*,char* );
+ ILAPI Pixmap ILAPIENTRY ilutXLoadPixmap( Display*,Drawable,char* );
+#ifdef ILUT_USE_XSHM
+ ILAPI XImage * ILAPIENTRY ilutXShmCreateImage( Display*,XShmSegmentInfo* );
+ ILAPI void ILAPIENTRY ilutXShmDestroyImage( Display*,XImage*,XShmSegmentInfo* );
+ ILAPI Pixmap ILAPIENTRY ilutXShmCreatePixmap( Display*,Drawable,XShmSegmentInfo* );
+ ILAPI void ILAPIENTRY ilutXShmFreePixmap( Display*,Pixmap,XShmSegmentInfo* );
+ ILAPI XImage * ILAPIENTRY ilutXShmLoadImage( Display*,char*,XShmSegmentInfo* );
+ ILAPI Pixmap ILAPIENTRY ilutXShmLoadPixmap( Display*,Drawable,char*,XShmSegmentInfo* );
+#endif//ILUT_USE_XSHM
+#endif//ILUT_USE_X11
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // __ILUT_H__
+#endif // __ilut_h_
diff --git a/COM380/Project5/include/DevIL/ilut_config.h b/COM380/Project5/include/DevIL/ilut_config.h
new file mode 100644
index 0000000..2b3625b
--- /dev/null
+++ b/COM380/Project5/include/DevIL/ilut_config.h
@@ -0,0 +1,26 @@
+#ifndef __ILUT_CONFIG_H__
+#define __ILUT_CONFIG_H__
+
+#define IL_USE_PRAGMA_LIBS
+
+// Supported APIs (ILUT)
+
+//
+// sorry just
+// cant get this one to work under windows
+// have disabled for the now
+//
+// will look at it some more later
+//
+// Kriss
+//
+#undef ILUT_USE_ALLEGRO
+
+#undef ILUT_USE_DIRECTX8
+//#define ILUT_USE_DIRECTX9
+//#define ILUT_USE_DIRECTX10
+#define ILUT_USE_OPENGL
+//#define ILUT_USE_SDL
+#define ILUT_USE_WIN32
+
+#endif//__ILUT_CONFIG_H__
diff --git a/COM380/Project5/include/GL/GLUt.h b/COM380/Project5/include/GL/GLUt.h
new file mode 100644
index 0000000..0e6ddfb
--- /dev/null
+++ b/COM380/Project5/include/GL/GLUt.h
@@ -0,0 +1,716 @@
+#ifndef __glut_h__
+#define __glut_h__
+
+/* Copyright (c) Mark J. Kilgard, 1994, 1995, 1996, 1998. */
+
+/* This program is freely distributable without licensing fees and is
+ provided without guarantee or warrantee expressed or implied. This
+ program is -not- in the public domain. */
+
+#if defined(_WIN32)
+
+/* GLUT 3.7 now tries to avoid including
+ to avoid name space pollution, but Win32's
+ needs APIENTRY and WINGDIAPI defined properly. */
+# if 0
+ /* This would put tons of macros and crap in our clean name space. */
+# define WIN32_LEAN_AND_MEAN
+# include
+# else
+ /* XXX This is from Win32's */
+# ifndef APIENTRY
+# define GLUT_APIENTRY_DEFINED
+# if (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED) || defined(__BORLANDC__) || defined(__LCC__)
+# define APIENTRY __stdcall
+# else
+# define APIENTRY
+# endif
+# endif
+ /* XXX This is from Win32's */
+# ifndef CALLBACK
+# if (defined(_M_MRX000) || defined(_M_IX86) || defined(_M_ALPHA) || defined(_M_PPC)) && !defined(MIDL_PASS) || defined(__LCC__)
+# define CALLBACK __stdcall
+# else
+# define CALLBACK
+# endif
+# endif
+ /* XXX Hack for lcc compiler. It doesn't support __declspec(dllimport), just __stdcall. */
+# if defined( __LCC__ )
+# undef WINGDIAPI
+# define WINGDIAPI __stdcall
+# else
+ /* XXX This is from Win32's and */
+# ifndef WINGDIAPI
+# define GLUT_WINGDIAPI_DEFINED
+# define WINGDIAPI __declspec(dllimport)
+# endif
+# endif
+ /* XXX This is from Win32's */
+# ifndef _WCHAR_T_DEFINED
+typedef unsigned short wchar_t;
+# define _WCHAR_T_DEFINED
+# endif
+# endif
+
+/* To disable automatic library usage for GLUT, define GLUT_NO_LIB_PRAGMA
+ in your compile preprocessor options. */
+# if !defined(GLUT_BUILDING_LIB) && !defined(GLUT_NO_LIB_PRAGMA)
+# pragma comment (lib, "winmm.lib") /* link with Windows MultiMedia lib */
+/* To enable automatic SGI OpenGL for Windows library usage for GLUT,
+ define GLUT_USE_SGI_OPENGL in your compile preprocessor options. */
+# ifdef GLUT_USE_SGI_OPENGL
+# pragma comment (lib, "opengl.lib") /* link with SGI OpenGL for Windows lib */
+# pragma comment (lib, "glu.lib") /* link with SGI OpenGL Utility lib */
+# pragma comment (lib, "glut.lib") /* link with Win32 GLUT for SGI OpenGL lib */
+# else
+# pragma comment (lib, "opengl32.lib") /* link with Microsoft OpenGL lib */
+# pragma comment (lib, "glu32.lib") /* link with Microsoft OpenGL Utility lib */
+# pragma comment (lib, "glut32.lib") /* link with Win32 GLUT lib */
+# endif
+# endif
+
+/* To disable supression of annoying warnings about floats being promoted
+ to doubles, define GLUT_NO_WARNING_DISABLE in your compile preprocessor
+ options. */
+# ifndef GLUT_NO_WARNING_DISABLE
+# pragma warning (disable:4244) /* Disable bogus VC++ 4.2 conversion warnings. */
+# pragma warning (disable:4305) /* VC++ 5.0 version of above warning. */
+# endif
+
+/* Win32 has an annoying issue where there are multiple C run-time
+ libraries (CRTs). If the executable is linked with a different CRT
+ from the GLUT DLL, the GLUT DLL will not share the same CRT static
+ data seen by the executable. In particular, atexit callbacks registered
+ in the executable will not be called if GLUT calls its (different)
+ exit routine). GLUT is typically built with the
+ "/MD" option (the CRT with multithreading DLL support), but the Visual
+ C++ linker default is "/ML" (the single threaded CRT).
+
+ One workaround to this issue is requiring users to always link with
+ the same CRT as GLUT is compiled with. That requires users supply a
+ non-standard option. GLUT 3.7 has its own built-in workaround where
+ the executable's "exit" function pointer is covertly passed to GLUT.
+ GLUT then calls the executable's exit function pointer to ensure that
+ any "atexit" calls registered by the application are called if GLUT
+ needs to exit.
+
+ Note that the __glut*WithExit routines should NEVER be called directly.
+ To avoid the atexit workaround, #define GLUT_DISABLE_ATEXIT_HACK. */
+
+/* XXX This is from Win32's */
+# if !defined(_MSC_VER) && !defined(__cdecl)
+ /* Define __cdecl for non-Microsoft compilers. */
+# define __cdecl
+# define GLUT_DEFINED___CDECL
+# endif
+# ifndef _CRTIMP
+# ifdef _NTSDK
+ /* Definition compatible with NT SDK */
+# define _CRTIMP
+# else
+ /* Current definition */
+# ifdef _DLL
+# define _CRTIMP __declspec(dllimport)
+# else
+# define _CRTIMP
+# endif
+# endif
+# define GLUT_DEFINED__CRTIMP
+# endif
+
+/* GLUT API entry point declarations for Win32. */
+# ifdef GLUT_BUILDING_LIB
+# define GLUTAPI __declspec(dllexport)
+# else
+# ifdef _DLL
+# define GLUTAPI __declspec(dllimport)
+# else
+# define GLUTAPI extern
+# endif
+# endif
+
+/* GLUT callback calling convention for Win32. */
+# define GLUTCALLBACK __cdecl
+
+#endif /* _WIN32 */
+
+#include
+#include
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if defined(_WIN32)
+# ifndef GLUT_BUILDING_LIB
+extern _CRTIMP void __cdecl exit(int);
+# endif
+#else
+/* non-Win32 case. */
+/* Define APIENTRY and CALLBACK to nothing if we aren't on Win32. */
+# define APIENTRY
+# define GLUT_APIENTRY_DEFINED
+# define CALLBACK
+/* Define GLUTAPI and GLUTCALLBACK as below if we aren't on Win32. */
+# define GLUTAPI extern
+# define GLUTCALLBACK
+/* Prototype exit for the non-Win32 case (see above). */
+extern void exit(int);
+#endif
+
+/**
+ GLUT API revision history:
+
+ GLUT_API_VERSION is updated to reflect incompatible GLUT
+ API changes (interface changes, semantic changes, deletions,
+ or additions).
+
+ GLUT_API_VERSION=1 First public release of GLUT. 11/29/94
+
+ GLUT_API_VERSION=2 Added support for OpenGL/GLX multisampling,
+ extension. Supports new input devices like tablet, dial and button
+ box, and Spaceball. Easy to query OpenGL extensions.
+
+ GLUT_API_VERSION=3 glutMenuStatus added.
+
+ GLUT_API_VERSION=4 glutInitDisplayString, glutWarpPointer,
+ glutBitmapLength, glutStrokeLength, glutWindowStatusFunc, dynamic
+ video resize subAPI, glutPostWindowRedisplay, glutKeyboardUpFunc,
+ glutSpecialUpFunc, glutIgnoreKeyRepeat, glutSetKeyRepeat,
+ glutJoystickFunc, glutForceJoystickFunc (NOT FINALIZED!).
+**/
+#ifndef GLUT_API_VERSION /* allow this to be overriden */
+#define GLUT_API_VERSION 3
+#endif
+
+/**
+ GLUT implementation revision history:
+
+ GLUT_XLIB_IMPLEMENTATION is updated to reflect both GLUT
+ API revisions and implementation revisions (ie, bug fixes).
+
+ GLUT_XLIB_IMPLEMENTATION=1 mjk's first public release of
+ GLUT Xlib-based implementation. 11/29/94
+
+ GLUT_XLIB_IMPLEMENTATION=2 mjk's second public release of
+ GLUT Xlib-based implementation providing GLUT version 2
+ interfaces.
+
+ GLUT_XLIB_IMPLEMENTATION=3 mjk's GLUT 2.2 images. 4/17/95
+
+ GLUT_XLIB_IMPLEMENTATION=4 mjk's GLUT 2.3 images. 6/?/95
+
+ GLUT_XLIB_IMPLEMENTATION=5 mjk's GLUT 3.0 images. 10/?/95
+
+ GLUT_XLIB_IMPLEMENTATION=7 mjk's GLUT 3.1+ with glutWarpPoitner. 7/24/96
+
+ GLUT_XLIB_IMPLEMENTATION=8 mjk's GLUT 3.1+ with glutWarpPoitner
+ and video resize. 1/3/97
+
+ GLUT_XLIB_IMPLEMENTATION=9 mjk's GLUT 3.4 release with early GLUT 4 routines.
+
+ GLUT_XLIB_IMPLEMENTATION=11 Mesa 2.5's GLUT 3.6 release.
+
+ GLUT_XLIB_IMPLEMENTATION=12 mjk's GLUT 3.6 release with early GLUT 4 routines + signal handling.
+
+ GLUT_XLIB_IMPLEMENTATION=13 mjk's GLUT 3.7 beta with GameGLUT support.
+
+ GLUT_XLIB_IMPLEMENTATION=14 mjk's GLUT 3.7 beta with f90gl friend interface.
+
+ GLUT_XLIB_IMPLEMENTATION=15 mjk's GLUT 3.7 beta sync'ed with Mesa
+**/
+#ifndef GLUT_XLIB_IMPLEMENTATION /* Allow this to be overriden. */
+#define GLUT_XLIB_IMPLEMENTATION 15
+#endif
+
+/* Display mode bit masks. */
+#define GLUT_RGB 0
+#define GLUT_RGBA GLUT_RGB
+#define GLUT_INDEX 1
+#define GLUT_SINGLE 0
+#define GLUT_DOUBLE 2
+#define GLUT_ACCUM 4
+#define GLUT_ALPHA 8
+#define GLUT_DEPTH 16
+#define GLUT_STENCIL 32
+#if (GLUT_API_VERSION >= 2)
+#define GLUT_MULTISAMPLE 128
+#define GLUT_STEREO 256
+#endif
+#if (GLUT_API_VERSION >= 3)
+#define GLUT_LUMINANCE 512
+#endif
+
+/* Mouse buttons. */
+#define GLUT_LEFT_BUTTON 0
+#define GLUT_MIDDLE_BUTTON 1
+#define GLUT_RIGHT_BUTTON 2
+
+/* Mouse button state. */
+#define GLUT_DOWN 0
+#define GLUT_UP 1
+
+#if (GLUT_API_VERSION >= 2)
+/* function keys */
+#define GLUT_KEY_F1 1
+#define GLUT_KEY_F2 2
+#define GLUT_KEY_F3 3
+#define GLUT_KEY_F4 4
+#define GLUT_KEY_F5 5
+#define GLUT_KEY_F6 6
+#define GLUT_KEY_F7 7
+#define GLUT_KEY_F8 8
+#define GLUT_KEY_F9 9
+#define GLUT_KEY_F10 10
+#define GLUT_KEY_F11 11
+#define GLUT_KEY_F12 12
+/* directional keys */
+#define GLUT_KEY_LEFT 100
+#define GLUT_KEY_UP 101
+#define GLUT_KEY_RIGHT 102
+#define GLUT_KEY_DOWN 103
+#define GLUT_KEY_PAGE_UP 104
+#define GLUT_KEY_PAGE_DOWN 105
+#define GLUT_KEY_HOME 106
+#define GLUT_KEY_END 107
+#define GLUT_KEY_INSERT 108
+#endif
+
+/* Entry/exit state. */
+#define GLUT_LEFT 0
+#define GLUT_ENTERED 1
+
+/* Menu usage state. */
+#define GLUT_MENU_NOT_IN_USE 0
+#define GLUT_MENU_IN_USE 1
+
+/* Visibility state. */
+#define GLUT_NOT_VISIBLE 0
+#define GLUT_VISIBLE 1
+
+/* Window status state. */
+#define GLUT_HIDDEN 0
+#define GLUT_FULLY_RETAINED 1
+#define GLUT_PARTIALLY_RETAINED 2
+#define GLUT_FULLY_COVERED 3
+
+/* Color index component selection values. */
+#define GLUT_RED 0
+#define GLUT_GREEN 1
+#define GLUT_BLUE 2
+
+#if defined(_WIN32)
+/* Stroke font constants (use these in GLUT program). */
+#define GLUT_STROKE_ROMAN ((void*)0)
+#define GLUT_STROKE_MONO_ROMAN ((void*)1)
+
+/* Bitmap font constants (use these in GLUT program). */
+#define GLUT_BITMAP_9_BY_15 ((void*)2)
+#define GLUT_BITMAP_8_BY_13 ((void*)3)
+#define GLUT_BITMAP_TIMES_ROMAN_10 ((void*)4)
+#define GLUT_BITMAP_TIMES_ROMAN_24 ((void*)5)
+#if (GLUT_API_VERSION >= 3)
+#define GLUT_BITMAP_HELVETICA_10 ((void*)6)
+#define GLUT_BITMAP_HELVETICA_12 ((void*)7)
+#define GLUT_BITMAP_HELVETICA_18 ((void*)8)
+#endif
+#else
+/* Stroke font opaque addresses (use constants instead in source code). */
+GLUTAPI void *glutStrokeRoman;
+GLUTAPI void *glutStrokeMonoRoman;
+
+/* Stroke font constants (use these in GLUT program). */
+#define GLUT_STROKE_ROMAN (&glutStrokeRoman)
+#define GLUT_STROKE_MONO_ROMAN (&glutStrokeMonoRoman)
+
+/* Bitmap font opaque addresses (use constants instead in source code). */
+GLUTAPI void *glutBitmap9By15;
+GLUTAPI void *glutBitmap8By13;
+GLUTAPI void *glutBitmapTimesRoman10;
+GLUTAPI void *glutBitmapTimesRoman24;
+GLUTAPI void *glutBitmapHelvetica10;
+GLUTAPI void *glutBitmapHelvetica12;
+GLUTAPI void *glutBitmapHelvetica18;
+
+/* Bitmap font constants (use these in GLUT program). */
+#define GLUT_BITMAP_9_BY_15 (&glutBitmap9By15)
+#define GLUT_BITMAP_8_BY_13 (&glutBitmap8By13)
+#define GLUT_BITMAP_TIMES_ROMAN_10 (&glutBitmapTimesRoman10)
+#define GLUT_BITMAP_TIMES_ROMAN_24 (&glutBitmapTimesRoman24)
+#if (GLUT_API_VERSION >= 3)
+#define GLUT_BITMAP_HELVETICA_10 (&glutBitmapHelvetica10)
+#define GLUT_BITMAP_HELVETICA_12 (&glutBitmapHelvetica12)
+#define GLUT_BITMAP_HELVETICA_18 (&glutBitmapHelvetica18)
+#endif
+#endif
+
+/* glutGet parameters. */
+#define GLUT_WINDOW_X ((GLenum) 100)
+#define GLUT_WINDOW_Y ((GLenum) 101)
+#define GLUT_WINDOW_WIDTH ((GLenum) 102)
+#define GLUT_WINDOW_HEIGHT ((GLenum) 103)
+#define GLUT_WINDOW_BUFFER_SIZE ((GLenum) 104)
+#define GLUT_WINDOW_STENCIL_SIZE ((GLenum) 105)
+#define GLUT_WINDOW_DEPTH_SIZE ((GLenum) 106)
+#define GLUT_WINDOW_RED_SIZE ((GLenum) 107)
+#define GLUT_WINDOW_GREEN_SIZE ((GLenum) 108)
+#define GLUT_WINDOW_BLUE_SIZE ((GLenum) 109)
+#define GLUT_WINDOW_ALPHA_SIZE ((GLenum) 110)
+#define GLUT_WINDOW_ACCUM_RED_SIZE ((GLenum) 111)
+#define GLUT_WINDOW_ACCUM_GREEN_SIZE ((GLenum) 112)
+#define GLUT_WINDOW_ACCUM_BLUE_SIZE ((GLenum) 113)
+#define GLUT_WINDOW_ACCUM_ALPHA_SIZE ((GLenum) 114)
+#define GLUT_WINDOW_DOUBLEBUFFER ((GLenum) 115)
+#define GLUT_WINDOW_RGBA ((GLenum) 116)
+#define GLUT_WINDOW_PARENT ((GLenum) 117)
+#define GLUT_WINDOW_NUM_CHILDREN ((GLenum) 118)
+#define GLUT_WINDOW_COLORMAP_SIZE ((GLenum) 119)
+#if (GLUT_API_VERSION >= 2)
+#define GLUT_WINDOW_NUM_SAMPLES ((GLenum) 120)
+#define GLUT_WINDOW_STEREO ((GLenum) 121)
+#endif
+#if (GLUT_API_VERSION >= 3)
+#define GLUT_WINDOW_CURSOR ((GLenum) 122)
+#endif
+#define GLUT_SCREEN_WIDTH ((GLenum) 200)
+#define GLUT_SCREEN_HEIGHT ((GLenum) 201)
+#define GLUT_SCREEN_WIDTH_MM ((GLenum) 202)
+#define GLUT_SCREEN_HEIGHT_MM ((GLenum) 203)
+#define GLUT_MENU_NUM_ITEMS ((GLenum) 300)
+#define GLUT_DISPLAY_MODE_POSSIBLE ((GLenum) 400)
+#define GLUT_INIT_WINDOW_X ((GLenum) 500)
+#define GLUT_INIT_WINDOW_Y ((GLenum) 501)
+#define GLUT_INIT_WINDOW_WIDTH ((GLenum) 502)
+#define GLUT_INIT_WINDOW_HEIGHT ((GLenum) 503)
+#define GLUT_INIT_DISPLAY_MODE ((GLenum) 504)
+#if (GLUT_API_VERSION >= 2)
+#define GLUT_ELAPSED_TIME ((GLenum) 700)
+#endif
+#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 13)
+#define GLUT_WINDOW_FORMAT_ID ((GLenum) 123)
+#endif
+
+#if (GLUT_API_VERSION >= 2)
+/* glutDeviceGet parameters. */
+#define GLUT_HAS_KEYBOARD ((GLenum) 600)
+#define GLUT_HAS_MOUSE ((GLenum) 601)
+#define GLUT_HAS_SPACEBALL ((GLenum) 602)
+#define GLUT_HAS_DIAL_AND_BUTTON_BOX ((GLenum) 603)
+#define GLUT_HAS_TABLET ((GLenum) 604)
+#define GLUT_NUM_MOUSE_BUTTONS ((GLenum) 605)
+#define GLUT_NUM_SPACEBALL_BUTTONS ((GLenum) 606)
+#define GLUT_NUM_BUTTON_BOX_BUTTONS ((GLenum) 607)
+#define GLUT_NUM_DIALS ((GLenum) 608)
+#define GLUT_NUM_TABLET_BUTTONS ((GLenum) 609)
+#endif
+#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 13)
+#define GLUT_DEVICE_IGNORE_KEY_REPEAT ((GLenum) 610)
+#define GLUT_DEVICE_KEY_REPEAT ((GLenum) 611)
+#define GLUT_HAS_JOYSTICK ((GLenum) 612)
+#define GLUT_OWNS_JOYSTICK ((GLenum) 613)
+#define GLUT_JOYSTICK_BUTTONS ((GLenum) 614)
+#define GLUT_JOYSTICK_AXES ((GLenum) 615)
+#define GLUT_JOYSTICK_POLL_RATE ((GLenum) 616)
+#endif
+
+#if (GLUT_API_VERSION >= 3)
+/* glutLayerGet parameters. */
+#define GLUT_OVERLAY_POSSIBLE ((GLenum) 800)
+#define GLUT_LAYER_IN_USE ((GLenum) 801)
+#define GLUT_HAS_OVERLAY ((GLenum) 802)
+#define GLUT_TRANSPARENT_INDEX ((GLenum) 803)
+#define GLUT_NORMAL_DAMAGED ((GLenum) 804)
+#define GLUT_OVERLAY_DAMAGED ((GLenum) 805)
+
+#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9)
+/* glutVideoResizeGet parameters. */
+#define GLUT_VIDEO_RESIZE_POSSIBLE ((GLenum) 900)
+#define GLUT_VIDEO_RESIZE_IN_USE ((GLenum) 901)
+#define GLUT_VIDEO_RESIZE_X_DELTA ((GLenum) 902)
+#define GLUT_VIDEO_RESIZE_Y_DELTA ((GLenum) 903)
+#define GLUT_VIDEO_RESIZE_WIDTH_DELTA ((GLenum) 904)
+#define GLUT_VIDEO_RESIZE_HEIGHT_DELTA ((GLenum) 905)
+#define GLUT_VIDEO_RESIZE_X ((GLenum) 906)
+#define GLUT_VIDEO_RESIZE_Y ((GLenum) 907)
+#define GLUT_VIDEO_RESIZE_WIDTH ((GLenum) 908)
+#define GLUT_VIDEO_RESIZE_HEIGHT ((GLenum) 909)
+#endif
+
+/* glutUseLayer parameters. */
+#define GLUT_NORMAL ((GLenum) 0)
+#define GLUT_OVERLAY ((GLenum) 1)
+
+/* glutGetModifiers return mask. */
+#define GLUT_ACTIVE_SHIFT 1
+#define GLUT_ACTIVE_CTRL 2
+#define GLUT_ACTIVE_ALT 4
+
+/* glutSetCursor parameters. */
+/* Basic arrows. */
+#define GLUT_CURSOR_RIGHT_ARROW 0
+#define GLUT_CURSOR_LEFT_ARROW 1
+/* Symbolic cursor shapes. */
+#define GLUT_CURSOR_INFO 2
+#define GLUT_CURSOR_DESTROY 3
+#define GLUT_CURSOR_HELP 4
+#define GLUT_CURSOR_CYCLE 5
+#define GLUT_CURSOR_SPRAY 6
+#define GLUT_CURSOR_WAIT 7
+#define GLUT_CURSOR_TEXT 8
+#define GLUT_CURSOR_CROSSHAIR 9
+/* Directional cursors. */
+#define GLUT_CURSOR_UP_DOWN 10
+#define GLUT_CURSOR_LEFT_RIGHT 11
+/* Sizing cursors. */
+#define GLUT_CURSOR_TOP_SIDE 12
+#define GLUT_CURSOR_BOTTOM_SIDE 13
+#define GLUT_CURSOR_LEFT_SIDE 14
+#define GLUT_CURSOR_RIGHT_SIDE 15
+#define GLUT_CURSOR_TOP_LEFT_CORNER 16
+#define GLUT_CURSOR_TOP_RIGHT_CORNER 17
+#define GLUT_CURSOR_BOTTOM_RIGHT_CORNER 18
+#define GLUT_CURSOR_BOTTOM_LEFT_CORNER 19
+/* Inherit from parent window. */
+#define GLUT_CURSOR_INHERIT 100
+/* Blank cursor. */
+#define GLUT_CURSOR_NONE 101
+/* Fullscreen crosshair (if available). */
+#define GLUT_CURSOR_FULL_CROSSHAIR 102
+#endif
+
+/* GLUT initialization sub-API. */
+GLUTAPI void APIENTRY glutInit(int *argcp, char **argv);
+#if defined(_WIN32) && !defined(GLUT_DISABLE_ATEXIT_HACK)
+GLUTAPI void APIENTRY __glutInitWithExit(int *argcp, char **argv, void (__cdecl *exitfunc)(int));
+#ifndef GLUT_BUILDING_LIB
+static void APIENTRY glutInit_ATEXIT_HACK(int *argcp, char **argv) { __glutInitWithExit(argcp, argv, exit); }
+#define glutInit glutInit_ATEXIT_HACK
+#endif
+#endif
+GLUTAPI void APIENTRY glutInitDisplayMode(unsigned int mode);
+#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9)
+GLUTAPI void APIENTRY glutInitDisplayString(const char *string);
+#endif
+GLUTAPI void APIENTRY glutInitWindowPosition(int x, int y);
+GLUTAPI void APIENTRY glutInitWindowSize(int width, int height);
+GLUTAPI void APIENTRY glutMainLoop(void);
+
+/* GLUT window sub-API. */
+GLUTAPI int APIENTRY glutCreateWindow(const char *title);
+#if defined(_WIN32) && !defined(GLUT_DISABLE_ATEXIT_HACK)
+GLUTAPI int APIENTRY __glutCreateWindowWithExit(const char *title, void (__cdecl *exitfunc)(int));
+#ifndef GLUT_BUILDING_LIB
+static int APIENTRY glutCreateWindow_ATEXIT_HACK(const char *title) { return __glutCreateWindowWithExit(title, exit); }
+#define glutCreateWindow glutCreateWindow_ATEXIT_HACK
+#endif
+#endif
+GLUTAPI int APIENTRY glutCreateSubWindow(int win, int x, int y, int width, int height);
+GLUTAPI void APIENTRY glutDestroyWindow(int win);
+GLUTAPI void APIENTRY glutPostRedisplay(void);
+#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 11)
+GLUTAPI void APIENTRY glutPostWindowRedisplay(int win);
+#endif
+GLUTAPI void APIENTRY glutSwapBuffers(void);
+GLUTAPI int APIENTRY glutGetWindow(void);
+GLUTAPI void APIENTRY glutSetWindow(int win);
+GLUTAPI void APIENTRY glutSetWindowTitle(const char *title);
+GLUTAPI void APIENTRY glutSetIconTitle(const char *title);
+GLUTAPI void APIENTRY glutPositionWindow(int x, int y);
+GLUTAPI void APIENTRY glutReshapeWindow(int width, int height);
+GLUTAPI void APIENTRY glutPopWindow(void);
+GLUTAPI void APIENTRY glutPushWindow(void);
+GLUTAPI void APIENTRY glutIconifyWindow(void);
+GLUTAPI void APIENTRY glutShowWindow(void);
+GLUTAPI void APIENTRY glutHideWindow(void);
+#if (GLUT_API_VERSION >= 3)
+GLUTAPI void APIENTRY glutFullScreen(void);
+GLUTAPI void APIENTRY glutSetCursor(int cursor);
+#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9)
+GLUTAPI void APIENTRY glutWarpPointer(int x, int y);
+#endif
+
+/* GLUT overlay sub-API. */
+GLUTAPI void APIENTRY glutEstablishOverlay(void);
+GLUTAPI void APIENTRY glutRemoveOverlay(void);
+GLUTAPI void APIENTRY glutUseLayer(GLenum layer);
+GLUTAPI void APIENTRY glutPostOverlayRedisplay(void);
+#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 11)
+GLUTAPI void APIENTRY glutPostWindowOverlayRedisplay(int win);
+#endif
+GLUTAPI void APIENTRY glutShowOverlay(void);
+GLUTAPI void APIENTRY glutHideOverlay(void);
+#endif
+
+/* GLUT menu sub-API. */
+GLUTAPI int APIENTRY glutCreateMenu(void (GLUTCALLBACK *func)(int));
+#if defined(_WIN32) && !defined(GLUT_DISABLE_ATEXIT_HACK)
+GLUTAPI int APIENTRY __glutCreateMenuWithExit(void (GLUTCALLBACK *func)(int), void (__cdecl *exitfunc)(int));
+#ifndef GLUT_BUILDING_LIB
+static int APIENTRY glutCreateMenu_ATEXIT_HACK(void (GLUTCALLBACK *func)(int)) { return __glutCreateMenuWithExit(func, exit); }
+#define glutCreateMenu glutCreateMenu_ATEXIT_HACK
+#endif
+#endif
+GLUTAPI void APIENTRY glutDestroyMenu(int menu);
+GLUTAPI int APIENTRY glutGetMenu(void);
+GLUTAPI void APIENTRY glutSetMenu(int menu);
+GLUTAPI void APIENTRY glutAddMenuEntry(const char *label, int value);
+GLUTAPI void APIENTRY glutAddSubMenu(const char *label, int submenu);
+GLUTAPI void APIENTRY glutChangeToMenuEntry(int item, const char *label, int value);
+GLUTAPI void APIENTRY glutChangeToSubMenu(int item, const char *label, int submenu);
+GLUTAPI void APIENTRY glutRemoveMenuItem(int item);
+GLUTAPI void APIENTRY glutAttachMenu(int button);
+GLUTAPI void APIENTRY glutDetachMenu(int button);
+
+/* GLUT window callback sub-API. */
+GLUTAPI void APIENTRY glutDisplayFunc(void (GLUTCALLBACK *func)(void));
+GLUTAPI void APIENTRY glutReshapeFunc(void (GLUTCALLBACK *func)(int width, int height));
+GLUTAPI void APIENTRY glutKeyboardFunc(void (GLUTCALLBACK *func)(unsigned char key, int x, int y));
+GLUTAPI void APIENTRY glutMouseFunc(void (GLUTCALLBACK *func)(int button, int state, int x, int y));
+GLUTAPI void APIENTRY glutMotionFunc(void (GLUTCALLBACK *func)(int x, int y));
+GLUTAPI void APIENTRY glutPassiveMotionFunc(void (GLUTCALLBACK *func)(int x, int y));
+GLUTAPI void APIENTRY glutEntryFunc(void (GLUTCALLBACK *func)(int state));
+GLUTAPI void APIENTRY glutVisibilityFunc(void (GLUTCALLBACK *func)(int state));
+GLUTAPI void APIENTRY glutIdleFunc(void (GLUTCALLBACK *func)(void));
+GLUTAPI void APIENTRY glutTimerFunc(unsigned int millis, void (GLUTCALLBACK *func)(int value), int value);
+GLUTAPI void APIENTRY glutMenuStateFunc(void (GLUTCALLBACK *func)(int state));
+#if (GLUT_API_VERSION >= 2)
+GLUTAPI void APIENTRY glutSpecialFunc(void (GLUTCALLBACK *func)(int key, int x, int y));
+GLUTAPI void APIENTRY glutSpaceballMotionFunc(void (GLUTCALLBACK *func)(int x, int y, int z));
+GLUTAPI void APIENTRY glutSpaceballRotateFunc(void (GLUTCALLBACK *func)(int x, int y, int z));
+GLUTAPI void APIENTRY glutSpaceballButtonFunc(void (GLUTCALLBACK *func)(int button, int state));
+GLUTAPI void APIENTRY glutButtonBoxFunc(void (GLUTCALLBACK *func)(int button, int state));
+GLUTAPI void APIENTRY glutDialsFunc(void (GLUTCALLBACK *func)(int dial, int value));
+GLUTAPI void APIENTRY glutTabletMotionFunc(void (GLUTCALLBACK *func)(int x, int y));
+GLUTAPI void APIENTRY glutTabletButtonFunc(void (GLUTCALLBACK *func)(int button, int state, int x, int y));
+#if (GLUT_API_VERSION >= 3)
+GLUTAPI void APIENTRY glutMenuStatusFunc(void (GLUTCALLBACK *func)(int status, int x, int y));
+GLUTAPI void APIENTRY glutOverlayDisplayFunc(void (GLUTCALLBACK *func)(void));
+#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9)
+GLUTAPI void APIENTRY glutWindowStatusFunc(void (GLUTCALLBACK *func)(int state));
+#endif
+#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 13)
+GLUTAPI void APIENTRY glutKeyboardUpFunc(void (GLUTCALLBACK *func)(unsigned char key, int x, int y));
+GLUTAPI void APIENTRY glutSpecialUpFunc(void (GLUTCALLBACK *func)(int key, int x, int y));
+GLUTAPI void APIENTRY glutJoystickFunc(void (GLUTCALLBACK *func)(unsigned int buttonMask, int x, int y, int z), int pollInterval);
+#endif
+#endif
+#endif
+
+/* GLUT color index sub-API. */
+GLUTAPI void APIENTRY glutSetColor(int, GLfloat red, GLfloat green, GLfloat blue);
+GLUTAPI GLfloat APIENTRY glutGetColor(int ndx, int component);
+GLUTAPI void APIENTRY glutCopyColormap(int win);
+
+/* GLUT state retrieval sub-API. */
+GLUTAPI int APIENTRY glutGet(GLenum type);
+GLUTAPI int APIENTRY glutDeviceGet(GLenum type);
+#if (GLUT_API_VERSION >= 2)
+/* GLUT extension support sub-API */
+GLUTAPI int APIENTRY glutExtensionSupported(const char *name);
+#endif
+#if (GLUT_API_VERSION >= 3)
+GLUTAPI int APIENTRY glutGetModifiers(void);
+GLUTAPI int APIENTRY glutLayerGet(GLenum type);
+#endif
+
+/* GLUT font sub-API */
+GLUTAPI void APIENTRY glutBitmapCharacter(void *font, int character);
+GLUTAPI int APIENTRY glutBitmapWidth(void *font, int character);
+GLUTAPI void APIENTRY glutStrokeCharacter(void *font, int character);
+GLUTAPI int APIENTRY glutStrokeWidth(void *font, int character);
+#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9)
+GLUTAPI int APIENTRY glutBitmapLength(void *font, const unsigned char *string);
+GLUTAPI int APIENTRY glutStrokeLength(void *font, const unsigned char *string);
+#endif
+
+/* GLUT pre-built models sub-API */
+GLUTAPI void APIENTRY glutWireSphere(GLdouble radius, GLint slices, GLint stacks);
+GLUTAPI void APIENTRY glutSolidSphere(GLdouble radius, GLint slices, GLint stacks);
+GLUTAPI void APIENTRY glutWireCone(GLdouble base, GLdouble height, GLint slices, GLint stacks);
+GLUTAPI void APIENTRY glutSolidCone(GLdouble base, GLdouble height, GLint slices, GLint stacks);
+GLUTAPI void APIENTRY glutWireCube(GLdouble size);
+GLUTAPI void APIENTRY glutSolidCube(GLdouble size);
+GLUTAPI void APIENTRY glutWireTorus(GLdouble innerRadius, GLdouble outerRadius, GLint sides, GLint rings);
+GLUTAPI void APIENTRY glutSolidTorus(GLdouble innerRadius, GLdouble outerRadius, GLint sides, GLint rings);
+GLUTAPI void APIENTRY glutWireDodecahedron(void);
+GLUTAPI void APIENTRY glutSolidDodecahedron(void);
+GLUTAPI void APIENTRY glutWireTeapot(GLdouble size);
+GLUTAPI void APIENTRY glutSolidTeapot(GLdouble size);
+GLUTAPI void APIENTRY glutWireOctahedron(void);
+GLUTAPI void APIENTRY glutSolidOctahedron(void);
+GLUTAPI void APIENTRY glutWireTetrahedron(void);
+GLUTAPI void APIENTRY glutSolidTetrahedron(void);
+GLUTAPI void APIENTRY glutWireIcosahedron(void);
+GLUTAPI void APIENTRY glutSolidIcosahedron(void);
+
+#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9)
+/* GLUT video resize sub-API. */
+GLUTAPI int APIENTRY glutVideoResizeGet(GLenum param);
+GLUTAPI void APIENTRY glutSetupVideoResizing(void);
+GLUTAPI void APIENTRY glutStopVideoResizing(void);
+GLUTAPI void APIENTRY glutVideoResize(int x, int y, int width, int height);
+GLUTAPI void APIENTRY glutVideoPan(int x, int y, int width, int height);
+
+/* GLUT debugging sub-API. */
+GLUTAPI void APIENTRY glutReportErrors(void);
+#endif
+
+#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 13)
+/* GLUT device control sub-API. */
+/* glutSetKeyRepeat modes. */
+#define GLUT_KEY_REPEAT_OFF 0
+#define GLUT_KEY_REPEAT_ON 1
+#define GLUT_KEY_REPEAT_DEFAULT 2
+
+/* Joystick button masks. */
+#define GLUT_JOYSTICK_BUTTON_A 1
+#define GLUT_JOYSTICK_BUTTON_B 2
+#define GLUT_JOYSTICK_BUTTON_C 4
+#define GLUT_JOYSTICK_BUTTON_D 8
+
+GLUTAPI void APIENTRY glutIgnoreKeyRepeat(int ignore);
+GLUTAPI void APIENTRY glutSetKeyRepeat(int repeatMode);
+GLUTAPI void APIENTRY glutForceJoystickFunc(void);
+
+/* GLUT game mode sub-API. */
+/* glutGameModeGet. */
+#define GLUT_GAME_MODE_ACTIVE ((GLenum) 0)
+#define GLUT_GAME_MODE_POSSIBLE ((GLenum) 1)
+#define GLUT_GAME_MODE_WIDTH ((GLenum) 2)
+#define GLUT_GAME_MODE_HEIGHT ((GLenum) 3)
+#define GLUT_GAME_MODE_PIXEL_DEPTH ((GLenum) 4)
+#define GLUT_GAME_MODE_REFRESH_RATE ((GLenum) 5)
+#define GLUT_GAME_MODE_DISPLAY_CHANGED ((GLenum) 6)
+
+GLUTAPI void APIENTRY glutGameModeString(const char *string);
+GLUTAPI int APIENTRY glutEnterGameMode(void);
+GLUTAPI void APIENTRY glutLeaveGameMode(void);
+GLUTAPI int APIENTRY glutGameModeGet(GLenum mode);
+#endif
+
+#ifdef __cplusplus
+}
+
+#endif
+
+#ifdef GLUT_APIENTRY_DEFINED
+# undef GLUT_APIENTRY_DEFINED
+# undef APIENTRY
+#endif
+
+#ifdef GLUT_WINGDIAPI_DEFINED
+# undef GLUT_WINGDIAPI_DEFINED
+# undef WINGDIAPI
+#endif
+
+#ifdef GLUT_DEFINED___CDECL
+# undef GLUT_DEFINED___CDECL
+# undef __cdecl
+#endif
+
+#ifdef GLUT_DEFINED__CRTIMP
+# undef GLUT_DEFINED__CRTIMP
+# undef _CRTIMP
+#endif
+
+#endif /* __glut_h__ */
diff --git a/COM380/Project5/include/vld/vld.h b/COM380/Project5/include/vld/vld.h
new file mode 100644
index 0000000..29d1216
--- /dev/null
+++ b/COM380/Project5/include/vld/vld.h
@@ -0,0 +1,307 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Visual Leak Detector - Import Library Header
+// Copyright (c) 2005-2012 VLD Team
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+//
+// See COPYING.txt for the full terms of the GNU Lesser General Public License.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+#pragma once
+
+#include "vld_def.h"
+
+#if defined _DEBUG || defined VLD_FORCE_ENABLE
+
+#include
+
+#pragma comment(lib, "vld.lib")
+
+// Force a symbolic reference to the global VisualLeakDetector class object from
+// the DLL. This ensures that the DLL is loaded and linked with the program,
+// even if no code otherwise imports any of the DLL's exports.
+#pragma comment(linker, "/include:__imp_?g_vld@@3VVisualLeakDetector@@A")
+
+////////////////////////////////////////////////////////////////////////////////
+//
+// Visual Leak Detector APIs
+//
+
+#ifdef __cplusplus
+extern "C" {
+#endif // __cplusplus
+
+// VLDDisable - Disables Visual Leak Detector's memory leak detection at
+// runtime. If memory leak detection is already disabled, then calling this
+// function has no effect.
+//
+// Note: In multithreaded programs, this function operates on a per-thread
+// basis. In other words, if you call this function from one thread, then
+// memory leak detection is only disabled for that thread. If memory leak
+// detection is enabled for other threads, then it will remain enabled for
+// those other threads. It was designed to work this way to insulate you,
+// the programmer, from having to ensure thread synchronization when calling
+// VLDEnable() and VLDDisable(). Without this, calling these two functions
+// unsynchronized could result in unpredictable and unintended behavior.
+// But this also means that if you want to disable memory leak detection
+// process-wide, then you need to call this function from every thread in
+// the process.
+//
+// Return Value:
+//
+// None.
+//
+__declspec(dllimport) void VLDDisable ();
+
+// VLDEnable - Enables Visual Leak Detector's memory leak detection at runtime.
+// If memory leak detection is already enabled, which it is by default, then
+// calling this function has no effect.
+//
+// Note: In multithreaded programs, this function operates on a per-thread
+// basis. In other words, if you call this function from one thread, then
+// memory leak detection is only enabled for that thread. If memory leak
+// detection is disabled for other threads, then it will remain disabled for
+// those other threads. It was designed to work this way to insulate you,
+// the programmer, from having to ensure thread synchronization when calling
+// VLDEnable() and VLDDisable(). Without this, calling these two functions
+// unsynchronized could result in unpredictable and unintended behavior.
+// But this also means that if you want to enable memory leak detection
+// process-wide, then you need to call this function from every thread in
+// the process.
+//
+// Return Value:
+//
+// None.
+//
+__declspec(dllimport) void VLDEnable ();
+
+// VLDRestore - Restore Visual Leak Detector's previous state.
+//
+// Return Value:
+//
+// None.
+//
+__declspec(dllimport) void VLDRestore ();
+
+// VLDGlobalDisable - Disables Visual Leak Detector's memory leak detection at
+// runtime in all threads. If memory leak detection is already disabled,
+// then calling this function has no effect.
+//
+// Return Value:
+//
+// None.
+//
+__declspec(dllimport) void VLDGlobalDisable ();
+
+// VLDGlobalEnable - Enables Visual Leak Detector's memory leak detection
+// at runtime in all threads. If memory leak detection is already enabled,
+// which it is by default, then calling this function has no effect.
+//
+// Return Value:
+//
+// None.
+//
+__declspec(dllimport) void VLDGlobalEnable ();
+
+// VLDReportLeaks - Report leaks up to the execution point.
+//
+// Return Value:
+//
+// None.
+//
+__declspec(dllimport) UINT VLDReportLeaks ();
+
+// VLDGetLeaksCount - Return memory leaks count to the execution point.
+//
+// Return Value:
+//
+// None.
+//
+__declspec(dllimport) UINT VLDGetLeaksCount ();
+
+// VLDMarkAllLeaksAsReported - Mark all leaks as reported.
+//
+// Return Value:
+//
+// None.
+//
+__declspec(dllimport) void VLDMarkAllLeaksAsReported ();
+
+
+// VLDRefreshModules - Look for recently loaded DLLs and patch them if necessary.
+//
+// Return Value:
+//
+// None.
+//
+__declspec(dllimport) void VLDRefreshModules();
+
+
+// VLDEnableModule - Enable Memory leak checking on the specified module.
+//
+// module: module handle.
+//
+// Return Value:
+//
+// None.
+//
+
+__declspec(dllimport) void VLDEnableModule(HMODULE module);
+
+
+// VLDDisableModule - Disable Memory leak checking on the specified module.
+//
+// module: module handle.
+//
+// Return Value:
+//
+// None.
+//
+__declspec(dllimport) void VLDDisableModule(HMODULE module);
+
+// VLDGetOptions - Return all current options.
+//
+// Return Value:
+//
+// Mask of current options.
+//
+__declspec(dllimport) UINT VLDGetOptions();
+
+// VLDGetReportFilename - Return current report filename.
+//
+// filename: current report filename (max characters - MAX_PATH).
+//
+// Return Value:
+//
+// None.
+//
+__declspec(dllimport) void VLDGetReportFilename(WCHAR *filename);
+
+// VLDSetOptions - Update the report options via function call rather than INI file.
+//
+// option_mask: Only the following flags are checked
+// VLD_OPT_AGGREGATE_DUPLICATES
+// VLD_OPT_MODULE_LIST_INCLUDE
+// VLD_OPT_SAFE_STACK_WALK
+// VLD_OPT_SLOW_DEBUGGER_DUMP
+// VLD_OPT_TRACE_INTERNAL_FRAMES
+// VLD_OPT_START_DISABLED
+// VLD_OPT_SKIP_HEAPFREE_LEAKS
+// VLD_OPT_VALIDATE_HEAPFREE
+//
+// maxDataDump: maximum number of user-data bytes to dump for each leaked block.
+//
+// maxTraceFrames: maximum number of frames per stack trace for each leaked block.
+//
+// Return Value:
+//
+// None.
+//
+__declspec(dllimport) void VLDSetOptions(UINT option_mask, SIZE_T maxDataDump, UINT maxTraceFrames);
+
+// VLDSetModulesList - Set list of modules included/excluded in leak detection
+// depending on parameter "includeModules".
+//
+// modules: list of modules to be forcefully included/excluded in leak detection.
+//
+// includeModules: include or exclude that modules.
+//
+// Return Value:
+//
+// None.
+//
+__declspec(dllimport) void VLDSetModulesList(CONST WCHAR *modules, BOOL includeModules);
+
+// VLDGetModulesList - Return current list of included/excluded modules
+// depending on flag VLD_OPT_TRACE_INTERNAL_FRAMES.
+//
+// modules: destination string for list of included/excluded modules (maximum length 512 characters).
+//
+// size: maximum string size.
+//
+// Return Value:
+//
+// BOOL: TRUE if include modules, otherwise FALSE.
+//
+__declspec(dllimport) BOOL VLDGetModulesList(WCHAR *modules, UINT size);
+
+// VLDSetReportOptions - Update the report options via function call rather than INI file.
+//
+// Only the following flags are checked
+// VLD_OPT_REPORT_TO_DEBUGGER
+// VLD_OPT_REPORT_TO_FILE
+// VLD_OPT_REPORT_TO_STDOUT
+// VLD_OPT_UNICODE_REPORT
+//
+// filename is optional and can be NULL.
+//
+// Return Value:
+//
+// None.
+//
+__declspec(dllimport) void VLDSetReportOptions(UINT option_mask, CONST WCHAR *filename);
+
+// VLDSetReportHook - Installs or uninstalls a client-defined reporting function by hooking it
+// into the C run-time debug reporting process (debug version only).
+//
+// mode: The action to take: VLD_RPTHOOK_INSTALL or VLD_RPTHOOK_REMOVE.
+//
+// pfnNewHook: Report hook to install or remove.
+//
+// Return Value:
+//
+// int: 0 if success.
+//
+__declspec(dllimport) int VLDSetReportHook(int mode, VLD_REPORT_HOOK pfnNewHook);
+
+// VLDResolveCallstacks - Performs symbol resolution for all saved extent CallStack's that have
+// been tracked by Visual Leak Detector. This function is necessary for applications that
+// dynamically load and unload modules, and through which memory leaks might be included.
+// If this is NOT called, stack traces may have stack frames with no symbol information. This
+// happens because the symbol API's cannot look up symbols for a binary / module that has been unloaded
+// from the process.
+//
+// Return Value:
+//
+// None.
+//
+__declspec(dllexport) void VLDResolveCallstacks();
+
+#ifdef __cplusplus
+}
+#endif // __cplusplus
+
+#else // !_DEBUG
+
+#define VLDEnable()
+#define VLDDisable()
+#define VLDRestore()
+#define VLDReportLeaks() 0
+#define VLDGetLeaksCount() 0
+#define VLDMarkAllLeaksAsReported()
+#define VLDRefreshModules()
+#define VLDEnableModule(a)
+#define VLDDisableModule(b)
+#define VLDGetOptions() 0
+#define VLDGetReportFilename(a)
+#define VLDSetOptions(a, b, c)
+#define VLDSetReportHook(a, b)
+#define VLDSetModulesList(a)
+#define VLDGetModulesList(a, b) FALSE
+#define VLDSetReportOptions(a, b)
+
+#endif // _DEBUG
diff --git a/COM380/Project5/include/vld/vld_def.h b/COM380/Project5/include/vld/vld_def.h
new file mode 100644
index 0000000..252835d
--- /dev/null
+++ b/COM380/Project5/include/vld/vld_def.h
@@ -0,0 +1,45 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Visual Leak Detector - Import Library Header
+// Copyright (c) 2005-2012 VLD Team
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+//
+// See COPYING.txt for the full terms of the GNU Lesser General Public License.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+#pragma once
+
+#define VLD_OPT_AGGREGATE_DUPLICATES 0x0001 // If set, aggregate duplicate leaks in the leak report.
+#define VLD_OPT_MODULE_LIST_INCLUDE 0x0002 // If set, modules in the module list are included, all others are excluded.
+#define VLD_OPT_REPORT_TO_DEBUGGER 0x0004 // If set, the memory leak report is sent to the debugger.
+#define VLD_OPT_REPORT_TO_FILE 0x0008 // If set, the memory leak report is sent to a file.
+#define VLD_OPT_SAFE_STACK_WALK 0x0010 // If set, the stack is walked using the "safe" method (StackWalk64).
+#define VLD_OPT_SELF_TEST 0x0020 // If set, perform a self-test to verify memory leak self-checking.
+#define VLD_OPT_SLOW_DEBUGGER_DUMP 0x0040 // If set, inserts a slight delay between sending output to the debugger.
+#define VLD_OPT_START_DISABLED 0x0080 // If set, memory leak detection will initially disabled.
+#define VLD_OPT_TRACE_INTERNAL_FRAMES 0x0100 // If set, include useless frames (e.g. internal to VLD) in call stacks.
+#define VLD_OPT_UNICODE_REPORT 0x0200 // If set, the leak report will be encoded UTF-16 instead of ASCII.
+#define VLD_OPT_VLDOFF 0x0400 // If set, VLD will be completely deactivated. It will not attach to any modules.
+#define VLD_OPT_REPORT_TO_STDOUT 0x0800 // If set, the memory leak report is sent to stdout.
+#define VLD_OPT_SKIP_HEAPFREE_LEAKS 0x1000 // If set, VLD skip HeapFree memory leaks.
+#define VLD_OPT_VALIDATE_HEAPFREE 0x2000 // If set, VLD verifies and reports heap consistency for HeapFree calls.
+#define VLD_OPT_RELEASE_CRT_RUNTIME 0x4000 // If set, VLD treat CRT runtime as release version (use only with define VLD_FORCE_ENABLE).
+
+#define VLD_RPTHOOK_INSTALL 0
+#define VLD_RPTHOOK_REMOVE 1
+
+typedef int (__cdecl * VLD_REPORT_HOOK)(int reportType, wchar_t *message, int *returnValue);