0001: #pragma once
0002: #include "tpotGL.h"
0003: 
0004: void MyRender( void *p, float dt, int w, int h );
0005: void MyInitRender( void *p );
0006: 
0007: namespace GLTest
0008: {
0009:     using namespace System;
0010:     using namespace System::ComponentModel;
0011:     using namespace System::Collections;
0012:     using namespace System::Windows::Forms;
0013:     using namespace System::Data;
0014:     using namespace System::Drawing;
0015: 
0016:     /// <summary> 
0017:     /// Form1 の概要
0018:     ///
0019:     /// 警告 : このクラスの名前を変更する場合、このクラスが依存するすべての .resx ファイルに関連付けられた 
0020:     ///          マネージ リソース コンパイラ ツールに対して 'Resource File Name' プロパティを
0021:     ///          変更する必要があります。この変更を行わないと、
0022:     ///          デザイナと、このフォームに関連付けられたローカライズ済みリソースとが正しく相互に利用できなくなります。
0023:     /// </summary>
0024:     public __gc class Form1 : public System::Windows::Forms::Form
0025:     {   
0026:         bool bPause;
0027:         void *_pGL;
0028: 
0029:         // 更新時間
0030:         int iPrev;
0031:     public:
0032: 
0033:         Form1(void)
0034:             : bPause(0)
0035:         {
0036:             InitializeComponent();
0037:             
0038:             // OpenGL の初期化
0039:             _pGL = tpot::InitGL(pictureBox1->Handle);
0040:             if(_pGL) MyInitRender(_pGL );
0041: 
0042:             // 時間を保存
0043:             iPrev = System::Environment::TickCount;
0044:         }
0045:   
0046:     protected:
0047:         void Dispose(Boolean disposing)
0048:         {
0049:             // OpenGLの開放
0050:             tpot::DestroyGL( _pGL );
0051: 
0052:             if (disposing && components)
0053:             {
0054:                 components->Dispose();
0055:             }
0056:             __super::Dispose(disposing);
0057:         }
0058: 
0059:     private: System::Windows::Forms::Timer *  timer1;
0060:     private: System::Windows::Forms::Panel *  panel1;
0061:     private: System::Windows::Forms::PictureBox *  pictureBox1;
0062:     private: System::Windows::Forms::Button *  button1;
0063: 
0064: 
0065:     private: System::ComponentModel::IContainer *  components;
0066: 
0067:     private:
0068:         /// <summary>
0069:         /// 必要なデザイナ変数です。
0070:         /// </summary>
0071: 
0072: 
0073:         /// <summary>
0074:         /// デザイナ サポートに必要なメソッドです。このメソッドの内容を
0075:         /// コード エディタで変更しないでください。
0076:         /// </summary>
0077:         void InitializeComponent(void)
0078:         {
0079:             this->components = new System::ComponentModel::Container();
0080:             this->timer1 = new System::Windows::Forms::Timer(this->components);
0081:             this->panel1 = new System::Windows::Forms::Panel();
0082:             this->button1 = new System::Windows::Forms::Button();
0083:             this->pictureBox1 = new System::Windows::Forms::PictureBox();
0084:             this->panel1->SuspendLayout();
0085:             this->SuspendLayout();
0086:             // 
0087:             // timer1
0088:             // 
0089:             this->timer1->Enabled = true;
0090:             this->timer1->Interval = 16;
0091:             this->timer1->Tick += new System::EventHandler(this, timer1_Tick);
0092:             // 
0093:             // panel1
0094:             // 
0095:             this->panel1->Controls->Add(this->button1);
0096:             this->panel1->Dock = System::Windows::Forms::DockStyle::Left;
0097:             this->panel1->Location = System::Drawing::Point(0, 0);
0098:             this->panel1->Name = S"panel1";
0099:             this->panel1->Size = System::Drawing::Size(96, 266);
0100:             this->panel1->TabIndex = 4;
0101:             // 
0102:             // button1
0103:             // 
0104:             this->button1->Location = System::Drawing::Point(8, 208);
0105:             this->button1->Name = S"button1";
0106:             this->button1->Size = System::Drawing::Size(80, 48);
0107:             this->button1->TabIndex = 0;
0108:             this->button1->Text = S"時よッ!!\n止まれッ!!";
0109:             this->button1->Click += new System::EventHandler(this, button1_Click);
0110:             // 
0111:             // pictureBox1
0112:             // 
0113:             this->pictureBox1->Dock = System::Windows::Forms::DockStyle::Fill;
0114:             this->pictureBox1->Location = System::Drawing::Point(96, 0);
0115:             this->pictureBox1->Name = S"pictureBox1";
0116:             this->pictureBox1->Size = System::Drawing::Size(304, 266);
0117:             this->pictureBox1->TabIndex = 5;
0118:             this->pictureBox1->TabStop = false;
0119:             this->pictureBox1->Paint += new System::Windows::Forms::PaintEventHandler(this, pictureBox1_Paint);
0120:             // 
0121:             // Form1
0122:             // 
0123:             this->AutoScaleBaseSize = System::Drawing::Size(5, 12);
0124:             this->ClientSize = System::Drawing::Size(400, 266);
0125:             this->Controls->Add(this->pictureBox1);
0126:             this->Controls->Add(this->panel1);
0127:             this->Name = S"Form1";
0128:             this->Text = S"Form1";
0129:             this->panel1->ResumeLayout(false);
0130:             this->ResumeLayout(false);
0131: 
0132:         }   
0133: 
0134: 
0135: 
0136: 
0137:     private: System::Void pictureBox1_Paint(System::Object *  sender, System::Windows::Forms::PaintEventArgs *  e)
0138:              {
0139:                  if(_pGL) MyRender( _pGL, 0.0, pictureBox1->Width, pictureBox1->Height );
0140:              }
0141: 
0142:     private: System::Void timer1_Tick(System::Object *  sender, System::EventArgs *  e)
0143:              {
0144:                 float dTime;
0145:                 int iNow;
0146: 
0147:                 // カウンタの更新
0148:                 iNow = System::Environment::TickCount;
0149:                 dTime = 0.001f * (float)(iNow - iPrev);
0150:                 iPrev = iNow;
0151:                 
0152:                 if(bPause) dTime = 0.0f;// ポーズ処理
0153: 
0154:                 // 再描画
0155:                 if(_pGL) MyRender( _pGL, dTime, pictureBox1->Width, pictureBox1->Height );
0156:              }
0157: 
0158:     private: System::Void button1_Click(System::Object *  sender, System::EventArgs *  e)
0159:              {
0160:                  bPause = !bPause;
0161:                  if(bPause)
0162:                  {
0163:                      this->button1->Text = "そして時は\n動き出すッ!!";
0164:                  }else{
0165:                      this->button1->Text = "時よッ!!\n止まれッ!!";
0166:                  }
0167:              }
0168: 
0169: };
0170: }
0171: 
0172: 
0173: