Guest User

Untitled

a guest
Mar 5th, 2011
552
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 18.48 KB | None | 0 0
  1. #pragma once
  2.  
  3. #include "OpenGL.h"
  4. #include <Windows.h>
  5. #include <gl/GL.h>
  6. #include <stdlib.h>
  7. #include <cstdlib>
  8. #include <string>
  9. #include <gl/GLU.h>
  10. #include <sstream>
  11. #include <math.h>
  12.  
  13. namespace OpenGL_on_a_Windows_Form {
  14.  
  15.     using namespace System;
  16.     using namespace System::ComponentModel;
  17.     using namespace System::Collections;
  18.     using namespace System::Windows::Forms;
  19.     using namespace System::Data;
  20.     using namespace System::Drawing;
  21.     using namespace OpenGLForm;
  22.     using namespace System::Drawing;
  23.     using namespace System::Drawing::Drawing2D;
  24.  
  25.    
  26.  
  27.     /// <summary>
  28.     /// Summary for Form1
  29.     ///
  30.     /// WARNING: If you change the name of this class, you will need to change the
  31.     ///          'Resource File Name' property for the managed resource compiler tool
  32.     ///          associated with all .resx files this class depends on.  Otherwise,
  33.     ///          the designers will not be able to interact properly with localized
  34.     ///          resources associated with this form.
  35.     /// </summary>
  36.     public ref class Form1 : public System::Windows::Forms::Form
  37.     {
  38.     public:
  39.         Form1(void)
  40.         {
  41.             InitializeComponent();
  42.             //
  43.             //TODO: Add the constructor code here
  44.             //
  45.             OpenGL = gcnew COpenGL(this, 640, 480);
  46.         }
  47.  
  48.     protected:
  49.         /// <summary>
  50.         /// Clean up any resources being used.
  51.         /// </summary>
  52.         ~Form1()
  53.         {
  54.             if (components)
  55.             {
  56.                 delete components;
  57.             }
  58.         }
  59.  
  60.  
  61.     private: System::ComponentModel::IContainer^  components;
  62.     protected:
  63.     private: System::Windows::Forms::Timer^  timer1;
  64.  
  65.     private: System::Windows::Forms::PictureBox^  pictureBox1;
  66.  
  67.     private: System::Windows::Forms::GroupBox^  groupBox1;
  68.     private: System::Windows::Forms::RadioButton^  radioButton2;
  69.     private: System::Windows::Forms::RadioButton^  radioButton1;
  70.  
  71.     private: System::Windows::Forms::CheckBox^  checkBox1;
  72.     private: System::Windows::Forms::GroupBox^  groupBox3;
  73.     private: System::Windows::Forms::TextBox^  textBox4;
  74.     private: System::Windows::Forms::Label^  label2;
  75.     private: System::Windows::Forms::TextBox^  textBox3;
  76.     private: System::Windows::Forms::TextBox^  textBox2;
  77.     private: System::Windows::Forms::Label^  label1;
  78.     private: System::Windows::Forms::TextBox^  textBox1;
  79.     private: System::Windows::Forms::GroupBox^  groupBox2;
  80.     private: System::Windows::Forms::Label^  label3;
  81.     private: System::Windows::Forms::Panel^  panel2;
  82.     private: System::Windows::Forms::CheckBox^  checkBox2;
  83.     private: System::Windows::Forms::Button^  button2;
  84.     private: System::Windows::Forms::Label^  label4;
  85.     private: System::Windows::Forms::Button^  button1;
  86.     private: System::Windows::Forms::GroupBox^  groupBox4;
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.     private: System::Windows::Forms::TrackBar^  trackBar1;
  101.     private: System::Windows::Forms::ComboBox^  comboBox1;
  102.     private: System::Windows::Forms::Label^  label5;
  103.     private: System::Windows::Forms::Button^  button3;
  104.     private: System::Windows::Forms::Label^  label6;
  105.  
  106.  
  107.     private:
  108.         /// <summary>
  109.         /// Required designer variable.
  110.         /// </summary>
  111.  
  112.         OpenGLForm::COpenGL ^ OpenGL;
  113.  
  114. #pragma region Windows Form Designer generated code
  115.         /// <summary>
  116.         /// Required method for Designer support - do not modify
  117.         /// the contents of this method with the code editor.
  118.         /// </summary>
  119.         void InitializeComponent(void)
  120.         {
  121.             this->components = (gcnew System::ComponentModel::Container());
  122.             System::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid));
  123.             this->timer1 = (gcnew System::Windows::Forms::Timer(this->components));
  124.             this->pictureBox1 = (gcnew System::Windows::Forms::PictureBox());
  125.             this->groupBox1 = (gcnew System::Windows::Forms::GroupBox());
  126.             this->groupBox3 = (gcnew System::Windows::Forms::GroupBox());
  127.             this->label4 = (gcnew System::Windows::Forms::Label());
  128.             this->button2 = (gcnew System::Windows::Forms::Button());
  129.             this->label3 = (gcnew System::Windows::Forms::Label());
  130.             this->panel2 = (gcnew System::Windows::Forms::Panel());
  131.             this->checkBox2 = (gcnew System::Windows::Forms::CheckBox());
  132.             this->textBox4 = (gcnew System::Windows::Forms::TextBox());
  133.             this->label2 = (gcnew System::Windows::Forms::Label());
  134.             this->textBox3 = (gcnew System::Windows::Forms::TextBox());
  135.             this->textBox2 = (gcnew System::Windows::Forms::TextBox());
  136.             this->label1 = (gcnew System::Windows::Forms::Label());
  137.             this->textBox1 = (gcnew System::Windows::Forms::TextBox());
  138.             this->groupBox2 = (gcnew System::Windows::Forms::GroupBox());
  139.             this->trackBar1 = (gcnew System::Windows::Forms::TrackBar());
  140.             this->radioButton1 = (gcnew System::Windows::Forms::RadioButton());
  141.             this->checkBox1 = (gcnew System::Windows::Forms::CheckBox());
  142.             this->radioButton2 = (gcnew System::Windows::Forms::RadioButton());
  143.             this->button1 = (gcnew System::Windows::Forms::Button());
  144.             this->groupBox4 = (gcnew System::Windows::Forms::GroupBox());
  145.             this->button3 = (gcnew System::Windows::Forms::Button());
  146.             this->comboBox1 = (gcnew System::Windows::Forms::ComboBox());
  147.             this->label5 = (gcnew System::Windows::Forms::Label());
  148.             this->label6 = (gcnew System::Windows::Forms::Label());
  149.             (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox1))->BeginInit();
  150.             this->groupBox1->SuspendLayout();
  151.             this->groupBox3->SuspendLayout();
  152.             this->groupBox2->SuspendLayout();
  153.             (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->trackBar1))->BeginInit();
  154.             this->groupBox4->SuspendLayout();
  155.             this->SuspendLayout();
  156.             //
  157.             // timer1
  158.             //
  159.             this->timer1->Enabled = true;
  160.             this->timer1->Interval = 10;
  161.             this->timer1->Tick += gcnew System::EventHandler(this, &Form1::timer1_Tick);
  162.             //
  163.             // pictureBox1
  164.             //
  165.             this->pictureBox1->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"pictureBox1.Image")));
  166.             this->pictureBox1->Location = System::Drawing::Point(0, -1);
  167.             this->pictureBox1->Name = L"pictureBox1";
  168.             this->pictureBox1->Size = System::Drawing::Size(750, 80);
  169.             this->pictureBox1->TabIndex = 1;
  170.             this->pictureBox1->TabStop = false;
  171.             //
  172.             // groupBox1
  173.             //
  174.             this->groupBox1->Controls->Add(this->groupBox3);
  175.             this->groupBox1->Controls->Add(this->groupBox2);
  176.             this->groupBox1->Location = System::Drawing::Point(12, 94);
  177.             this->groupBox1->Name = L"groupBox1";
  178.             this->groupBox1->Size = System::Drawing::Size(345, 343);
  179.             this->groupBox1->TabIndex = 3;
  180.             this->groupBox1->TabStop = false;
  181.             this->groupBox1->Text = L"Instellingen";
  182.             //
  183.             // groupBox3
  184.             //
  185.             this->groupBox3->Controls->Add(this->label4);
  186.             this->groupBox3->Controls->Add(this->button2);
  187.             this->groupBox3->Controls->Add(this->label3);
  188.             this->groupBox3->Controls->Add(this->panel2);
  189.             this->groupBox3->Controls->Add(this->checkBox2);
  190.             this->groupBox3->Controls->Add(this->textBox4);
  191.             this->groupBox3->Controls->Add(this->label2);
  192.             this->groupBox3->Controls->Add(this->textBox3);
  193.             this->groupBox3->Controls->Add(this->textBox2);
  194.             this->groupBox3->Controls->Add(this->label1);
  195.             this->groupBox3->Controls->Add(this->textBox1);
  196.             this->groupBox3->Location = System::Drawing::Point(6, 128);
  197.             this->groupBox3->Name = L"groupBox3";
  198.             this->groupBox3->Size = System::Drawing::Size(333, 209);
  199.             this->groupBox3->TabIndex = 5;
  200.             this->groupBox3->TabStop = false;
  201.             this->groupBox3->Text = L"Uiterlijk";
  202.             //
  203.             // label4
  204.             //
  205.             this->label4->AutoSize = true;
  206.             this->label4->Location = System::Drawing::Point(12, 89);
  207.             this->label4->Name = L"label4";
  208.             this->label4->Size = System::Drawing::Size(14, 13);
  209.             this->label4->TabIndex = 10;
  210.             this->label4->Text = L"#";
  211.             //
  212.             // button2
  213.             //
  214.             this->button2->Enabled = false;
  215.             this->button2->Location = System::Drawing::Point(99, 170);
  216.             this->button2->Name = L"button2";
  217.             this->button2->Size = System::Drawing::Size(100, 23);
  218.             this->button2->TabIndex = 9;
  219.             this->button2->Text = L"OK";
  220.             this->button2->UseVisualStyleBackColor = true;
  221.             this->button2->Click += gcnew System::EventHandler(this, &Form1::button2_Click);
  222.             //
  223.             // label3
  224.             //
  225.             this->label3->AutoSize = true;
  226.             this->label3->Location = System::Drawing::Point(225, 22);
  227.             this->label3->Name = L"label3";
  228.             this->label3->Size = System::Drawing::Size(55, 13);
  229.             this->label3->TabIndex = 8;
  230.             this->label3->Text = L"Voorbeeld";
  231.             //
  232.             // panel2
  233.             //
  234.             this->panel2->BorderStyle = System::Windows::Forms::BorderStyle::Fixed3D;
  235.             this->panel2->Location = System::Drawing::Point(211, 38);
  236.             this->panel2->Name = L"panel2";
  237.             this->panel2->Size = System::Drawing::Size(80, 80);
  238.             this->panel2->TabIndex = 7;
  239.             //
  240.             // checkBox2
  241.             //
  242.             this->checkBox2->AutoSize = true;
  243.             this->checkBox2->Location = System::Drawing::Point(14, 123);
  244.             this->checkBox2->Name = L"checkBox2";
  245.             this->checkBox2->Size = System::Drawing::Size(79, 17);
  246.             this->checkBox2->TabIndex = 6;
  247.             this->checkBox2->Text = L"BP Textuur";
  248.             this->checkBox2->UseVisualStyleBackColor = true;
  249.             //
  250.             // textBox4
  251.             //
  252.             this->textBox4->Location = System::Drawing::Point(26, 86);
  253.             this->textBox4->Name = L"textBox4";
  254.             this->textBox4->Size = System::Drawing::Size(94, 20);
  255.             this->textBox4->TabIndex = 5;
  256.             //
  257.             // label2
  258.             //
  259.             this->label2->AutoSize = true;
  260.             this->label2->Location = System::Drawing::Point(11, 70);
  261.             this->label2->Name = L"label2";
  262.             this->label2->Size = System::Drawing::Size(26, 13);
  263.             this->label2->TabIndex = 4;
  264.             this->label2->Text = L"Hex";
  265.             //
  266.             // textBox3
  267.             //
  268.             this->textBox3->Location = System::Drawing::Point(114, 38);
  269.             this->textBox3->Name = L"textBox3";
  270.             this->textBox3->Size = System::Drawing::Size(44, 20);
  271.             this->textBox3->TabIndex = 3;
  272.             //
  273.             // textBox2
  274.             //
  275.             this->textBox2->Location = System::Drawing::Point(64, 38);
  276.             this->textBox2->Name = L"textBox2";
  277.             this->textBox2->Size = System::Drawing::Size(44, 20);
  278.             this->textBox2->TabIndex = 2;
  279.             this->textBox2->TextChanged += gcnew System::EventHandler(this, &Form1::textBox2_TextChanged);
  280.             //
  281.             // label1
  282.             //
  283.             this->label1->AutoSize = true;
  284.             this->label1->Location = System::Drawing::Point(11, 21);
  285.             this->label1->Name = L"label1";
  286.             this->label1->Size = System::Drawing::Size(30, 13);
  287.             this->label1->TabIndex = 1;
  288.             this->label1->Text = L"RGB";
  289.             //
  290.             // textBox1
  291.             //
  292.             this->textBox1->Location = System::Drawing::Point(14, 38);
  293.             this->textBox1->Name = L"textBox1";
  294.             this->textBox1->Size = System::Drawing::Size(44, 20);
  295.             this->textBox1->TabIndex = 0;
  296.             this->textBox1->TextChanged += gcnew System::EventHandler(this, &Form1::textBox1_TextChanged);
  297.             //
  298.             // groupBox2
  299.             //
  300.             this->groupBox2->Controls->Add(this->trackBar1);
  301.             this->groupBox2->Controls->Add(this->radioButton1);
  302.             this->groupBox2->Controls->Add(this->checkBox1);
  303.             this->groupBox2->Controls->Add(this->radioButton2);
  304.             this->groupBox2->Location = System::Drawing::Point(6, 19);
  305.             this->groupBox2->Name = L"groupBox2";
  306.             this->groupBox2->Size = System::Drawing::Size(333, 100);
  307.             this->groupBox2->TabIndex = 4;
  308.             this->groupBox2->TabStop = false;
  309.             this->groupBox2->Text = L"Figuur";
  310.             //
  311.             // trackBar1
  312.             //
  313.             this->trackBar1->Location = System::Drawing::Point(99, 47);
  314.             this->trackBar1->Maximum = 30;
  315.             this->trackBar1->Name = L"trackBar1";
  316.             this->trackBar1->Size = System::Drawing::Size(214, 45);
  317.             this->trackBar1->TabIndex = 6;
  318.             //
  319.             // radioButton1
  320.             //
  321.             this->radioButton1->AutoSize = true;
  322.             this->radioButton1->Checked = true;
  323.             this->radioButton1->Location = System::Drawing::Point(14, 21);
  324.             this->radioButton1->Name = L"radioButton1";
  325.             this->radioButton1->Size = System::Drawing::Size(68, 17);
  326.             this->radioButton1->TabIndex = 0;
  327.             this->radioButton1->TabStop = true;
  328.             this->radioButton1->Text = L"Driehoek";
  329.             this->radioButton1->UseVisualStyleBackColor = true;
  330.             //
  331.             // checkBox1
  332.             //
  333.             this->checkBox1->AutoSize = true;
  334.             this->checkBox1->Location = System::Drawing::Point(23, 64);
  335.             this->checkBox1->Name = L"checkBox1";
  336.             this->checkBox1->Size = System::Drawing::Size(69, 17);
  337.             this->checkBox1->TabIndex = 3;
  338.             this->checkBox1->Text = L"Draaiend";
  339.             this->checkBox1->UseVisualStyleBackColor = true;
  340.             this->checkBox1->CheckedChanged += gcnew System::EventHandler(this, &Form1::checkBox1_CheckedChanged);
  341.             //
  342.             // radioButton2
  343.             //
  344.             this->radioButton2->AutoSize = true;
  345.             this->radioButton2->Location = System::Drawing::Point(14, 41);
  346.             this->radioButton2->Name = L"radioButton2";
  347.             this->radioButton2->Size = System::Drawing::Size(65, 17);
  348.             this->radioButton2->TabIndex = 1;
  349.             this->radioButton2->Text = L"Piramide";
  350.             this->radioButton2->UseVisualStyleBackColor = true;
  351.             //
  352.             // button1
  353.             //
  354.             this->button1->Location = System::Drawing::Point(256, 443);
  355.             this->button1->Name = L"button1";
  356.             this->button1->Size = System::Drawing::Size(75, 23);
  357.             this->button1->TabIndex = 4;
  358.             this->button1->Text = L"button1";
  359.             this->button1->UseVisualStyleBackColor = true;
  360.             this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click_1);
  361.             //
  362.             // groupBox4
  363.             //
  364.             this->groupBox4->Controls->Add(this->button3);
  365.             this->groupBox4->Controls->Add(this->comboBox1);
  366.             this->groupBox4->Controls->Add(this->label5);
  367.             this->groupBox4->Location = System::Drawing::Point(382, 94);
  368.             this->groupBox4->Name = L"groupBox4";
  369.             this->groupBox4->Size = System::Drawing::Size(355, 186);
  370.             this->groupBox4->TabIndex = 4;
  371.             this->groupBox4->TabStop = false;
  372.             this->groupBox4->Text = L"Gegevens";
  373.             //
  374.             // button3
  375.             //
  376.             this->button3->Location = System::Drawing::Point(19, 150);
  377.             this->button3->Name = L"button3";
  378.             this->button3->Size = System::Drawing::Size(75, 23);
  379.             this->button3->TabIndex = 2;
  380.             this->button3->Text = L"Aanpassen";
  381.             this->button3->UseVisualStyleBackColor = true;
  382.             this->button3->Click += gcnew System::EventHandler(this, &Form1::button3_Click_1);
  383.             //
  384.             // comboBox1
  385.             //
  386.             this->comboBox1->FormattingEnabled = true;
  387.             this->comboBox1->Items->AddRange(gcnew cli::array< System::Object^  >(13) {L"Rechthoekige driehoek", L"Gelijkbenige driehoek",
  388.                 L"Vierkant", L"Rechthoek", L"Cirkel", L"Pentagoon", L"Hexagoon", L"Octagoon", L"Kubus", L"Balk", L"Bol", L"Cilinder", L"Piramide"});
  389.             this->comboBox1->Location = System::Drawing::Point(19, 35);
  390.             this->comboBox1->Name = L"comboBox1";
  391.             this->comboBox1->Size = System::Drawing::Size(132, 21);
  392.             this->comboBox1->TabIndex = 1;
  393.             //
  394.             // label5
  395.             //
  396.             this->label5->AutoSize = true;
  397.             this->label5->Location = System::Drawing::Point(16, 19);
  398.             this->label5->Name = L"label5";
  399.             this->label5->Size = System::Drawing::Size(36, 13);
  400.             this->label5->TabIndex = 0;
  401.             this->label5->Text = L"Figuur";
  402.             //
  403.             // label6
  404.             //
  405.             this->label6->AutoSize = true;
  406.             this->label6->Location = System::Drawing::Point(815, 583);
  407.             this->label6->Name = L"label6";
  408.             this->label6->Size = System::Drawing::Size(35, 13);
  409.             this->label6->TabIndex = 5;
  410.             this->label6->Text = L"label6";
  411.             //
  412.             // Form1
  413.             //
  414.             this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
  415.             this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
  416.             this->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(232)), static_cast<System::Int32>(static_cast<System::Byte>(232)),
  417.                 static_cast<System::Int32>(static_cast<System::Byte>(232)));
  418.             this->ClientSize = System::Drawing::Size(749, 605);
  419.             this->Controls->Add(this->label6);
  420.             this->Controls->Add(this->button1);
  421.             this->Controls->Add(this->groupBox4);
  422.             this->Controls->Add(this->groupBox1);
  423.             this->Controls->Add(this->pictureBox1);
  424.             this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::FixedDialog;
  425.             this->MaximizeBox = false;
  426.             this->Name = L"Form1";
  427.             this->Text = L"Sector Werkstuk";
  428.             this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
  429.             (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox1))->EndInit();
  430.             this->groupBox1->ResumeLayout(false);
  431.             this->groupBox3->ResumeLayout(false);
  432.             this->groupBox3->PerformLayout();
  433.             this->groupBox2->ResumeLayout(false);
  434.             this->groupBox2->PerformLayout();
  435.             (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->trackBar1))->EndInit();
  436.             this->groupBox4->ResumeLayout(false);
  437.             this->groupBox4->PerformLayout();
  438.             this->ResumeLayout(false);
  439.             this->PerformLayout();
  440.  
  441.         }
  442. #pragma endregion
  443.  
  444.  
  445.        
  446.     private: System::Void timer1_Tick(System::Object^  sender, System::EventArgs^  e)
  447.              {
  448.                  UNREFERENCED_PARAMETER(sender);
  449.                  UNREFERENCED_PARAMETER(e);
  450.                  int kleur;
  451.                  if (this->checkBox1->Checked == true) {
  452.                      kleur = 1;}
  453.                  else if (this->checkBox1->Checked == false ) {
  454.                      kleur = 0;}
  455.                  
  456.                  int index = this->comboBox1->SelectedIndex;
  457.                  if (index != NULL) {
  458.                  OpenGL->Render(kleur,index);}
  459.                  OpenGL->SwapOpenGLBuffers();
  460.              }
  461.  
  462.              
  463.  
  464.     private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {
  465.            
  466.  
  467.              }
  468.     private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
  469.                  
  470.                  
  471.  
  472.              }
  473.     private: System::Void label1_Click(System::Object^  sender, System::EventArgs^  e) {
  474.              }
  475.  
  476.              
  477. private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) {
  478.              System::String^ r = textBox1->Text;
  479.              int R = int::Parse(r);
  480.              System::String^ g = textBox2->Text;
  481.              int G = int::Parse(g);
  482.              System::String^ b = textBox3->Text;
  483.              int B = int::Parse(b);
  484.              if ( R >= 0 && G >= 0 && B >= 0 && R <= 255 && G <= 255 && B <= 255 ) {
  485.                  this->panel2->BackColor = System::Drawing::Color::FromArgb(R,G,B);}
  486.              else { MessageBox::Show("Ongeldige kleureninstellingen (moet bestaan uit: RGB: 0-255, hex: 0-9 en A-F).",
  487.          "Foutmelding", MessageBoxButtons::OK,
  488.          MessageBoxIcon::Error);}
  489.              
  490.          }
  491. private: System::Void textBox1_TextChanged(System::Object^  sender, System::EventArgs^  e) {
  492.              if ( textBox1->Text != "" ) {
  493.                  this->button2->Enabled = true;}
  494.              else {
  495.                  this->button2->Enabled = false;
  496.              }
  497.          }
  498. private: System::Void textBox2_TextChanged(System::Object^  sender, System::EventArgs^  e) {
  499.  
  500.          }
  501. private: System::Void button1_Click_1(System::Object^  sender, System::EventArgs^  e) {
  502.  
  503.          }
  504.          
  505. private: System::Void checkBox1_CheckedChanged(System::Object^  sender, System::EventArgs^  e) {
  506.              
  507.          }
  508. private: System::Void button3_Click_1(System::Object^  sender, System::EventArgs^  e) {
  509.  
  510.          }
  511. };
  512. }
Advertisement
Add Comment
Please, Sign In to add comment