Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include "OpenGL.h"
- #include <Windows.h>
- #include <gl/GL.h>
- #include <stdlib.h>
- #include <cstdlib>
- #include <string>
- #include <gl/GLU.h>
- #include <sstream>
- #include <math.h>
- namespace OpenGL_on_a_Windows_Form {
- using namespace System;
- using namespace System::ComponentModel;
- using namespace System::Collections;
- using namespace System::Windows::Forms;
- using namespace System::Data;
- using namespace System::Drawing;
- using namespace OpenGLForm;
- using namespace System::Drawing;
- using namespace System::Drawing::Drawing2D;
- /// <summary>
- /// Summary for Form1
- ///
- /// WARNING: If you change the name of this class, you will need to change the
- /// 'Resource File Name' property for the managed resource compiler tool
- /// associated with all .resx files this class depends on. Otherwise,
- /// the designers will not be able to interact properly with localized
- /// resources associated with this form.
- /// </summary>
- public ref class Form1 : public System::Windows::Forms::Form
- {
- public:
- Form1(void)
- {
- InitializeComponent();
- //
- //TODO: Add the constructor code here
- //
- OpenGL = gcnew COpenGL(this, 640, 480);
- }
- protected:
- /// <summary>
- /// Clean up any resources being used.
- /// </summary>
- ~Form1()
- {
- if (components)
- {
- delete components;
- }
- }
- private: System::ComponentModel::IContainer^ components;
- protected:
- private: System::Windows::Forms::Timer^ timer1;
- private: System::Windows::Forms::PictureBox^ pictureBox1;
- private: System::Windows::Forms::GroupBox^ groupBox1;
- private: System::Windows::Forms::RadioButton^ radioButton2;
- private: System::Windows::Forms::RadioButton^ radioButton1;
- private: System::Windows::Forms::CheckBox^ checkBox1;
- private: System::Windows::Forms::GroupBox^ groupBox3;
- private: System::Windows::Forms::TextBox^ textBox4;
- private: System::Windows::Forms::Label^ label2;
- private: System::Windows::Forms::TextBox^ textBox3;
- private: System::Windows::Forms::TextBox^ textBox2;
- private: System::Windows::Forms::Label^ label1;
- private: System::Windows::Forms::TextBox^ textBox1;
- private: System::Windows::Forms::GroupBox^ groupBox2;
- private: System::Windows::Forms::Label^ label3;
- private: System::Windows::Forms::Panel^ panel2;
- private: System::Windows::Forms::CheckBox^ checkBox2;
- private: System::Windows::Forms::Button^ button2;
- private: System::Windows::Forms::Label^ label4;
- private: System::Windows::Forms::Button^ button1;
- private: System::Windows::Forms::GroupBox^ groupBox4;
- private: System::Windows::Forms::TrackBar^ trackBar1;
- private: System::Windows::Forms::ComboBox^ comboBox1;
- private: System::Windows::Forms::Label^ label5;
- private: System::Windows::Forms::Button^ button3;
- private: System::Windows::Forms::Label^ label6;
- private:
- /// <summary>
- /// Required designer variable.
- /// </summary>
- OpenGLForm::COpenGL ^ OpenGL;
- #pragma region Windows Form Designer generated code
- /// <summary>
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- /// </summary>
- void InitializeComponent(void)
- {
- this->components = (gcnew System::ComponentModel::Container());
- System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid));
- this->timer1 = (gcnew System::Windows::Forms::Timer(this->components));
- this->pictureBox1 = (gcnew System::Windows::Forms::PictureBox());
- this->groupBox1 = (gcnew System::Windows::Forms::GroupBox());
- this->groupBox3 = (gcnew System::Windows::Forms::GroupBox());
- this->label4 = (gcnew System::Windows::Forms::Label());
- this->button2 = (gcnew System::Windows::Forms::Button());
- this->label3 = (gcnew System::Windows::Forms::Label());
- this->panel2 = (gcnew System::Windows::Forms::Panel());
- this->checkBox2 = (gcnew System::Windows::Forms::CheckBox());
- this->textBox4 = (gcnew System::Windows::Forms::TextBox());
- this->label2 = (gcnew System::Windows::Forms::Label());
- this->textBox3 = (gcnew System::Windows::Forms::TextBox());
- this->textBox2 = (gcnew System::Windows::Forms::TextBox());
- this->label1 = (gcnew System::Windows::Forms::Label());
- this->textBox1 = (gcnew System::Windows::Forms::TextBox());
- this->groupBox2 = (gcnew System::Windows::Forms::GroupBox());
- this->trackBar1 = (gcnew System::Windows::Forms::TrackBar());
- this->radioButton1 = (gcnew System::Windows::Forms::RadioButton());
- this->checkBox1 = (gcnew System::Windows::Forms::CheckBox());
- this->radioButton2 = (gcnew System::Windows::Forms::RadioButton());
- this->button1 = (gcnew System::Windows::Forms::Button());
- this->groupBox4 = (gcnew System::Windows::Forms::GroupBox());
- this->button3 = (gcnew System::Windows::Forms::Button());
- this->comboBox1 = (gcnew System::Windows::Forms::ComboBox());
- this->label5 = (gcnew System::Windows::Forms::Label());
- this->label6 = (gcnew System::Windows::Forms::Label());
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->pictureBox1))->BeginInit();
- this->groupBox1->SuspendLayout();
- this->groupBox3->SuspendLayout();
- this->groupBox2->SuspendLayout();
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->trackBar1))->BeginInit();
- this->groupBox4->SuspendLayout();
- this->SuspendLayout();
- //
- // timer1
- //
- this->timer1->Enabled = true;
- this->timer1->Interval = 10;
- this->timer1->Tick += gcnew System::EventHandler(this, &Form1::timer1_Tick);
- //
- // pictureBox1
- //
- this->pictureBox1->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"pictureBox1.Image")));
- this->pictureBox1->Location = System::Drawing::Point(0, -1);
- this->pictureBox1->Name = L"pictureBox1";
- this->pictureBox1->Size = System::Drawing::Size(750, 80);
- this->pictureBox1->TabIndex = 1;
- this->pictureBox1->TabStop = false;
- //
- // groupBox1
- //
- this->groupBox1->Controls->Add(this->groupBox3);
- this->groupBox1->Controls->Add(this->groupBox2);
- this->groupBox1->Location = System::Drawing::Point(12, 94);
- this->groupBox1->Name = L"groupBox1";
- this->groupBox1->Size = System::Drawing::Size(345, 343);
- this->groupBox1->TabIndex = 3;
- this->groupBox1->TabStop = false;
- this->groupBox1->Text = L"Instellingen";
- //
- // groupBox3
- //
- this->groupBox3->Controls->Add(this->label4);
- this->groupBox3->Controls->Add(this->button2);
- this->groupBox3->Controls->Add(this->label3);
- this->groupBox3->Controls->Add(this->panel2);
- this->groupBox3->Controls->Add(this->checkBox2);
- this->groupBox3->Controls->Add(this->textBox4);
- this->groupBox3->Controls->Add(this->label2);
- this->groupBox3->Controls->Add(this->textBox3);
- this->groupBox3->Controls->Add(this->textBox2);
- this->groupBox3->Controls->Add(this->label1);
- this->groupBox3->Controls->Add(this->textBox1);
- this->groupBox3->Location = System::Drawing::Point(6, 128);
- this->groupBox3->Name = L"groupBox3";
- this->groupBox3->Size = System::Drawing::Size(333, 209);
- this->groupBox3->TabIndex = 5;
- this->groupBox3->TabStop = false;
- this->groupBox3->Text = L"Uiterlijk";
- //
- // label4
- //
- this->label4->AutoSize = true;
- this->label4->Location = System::Drawing::Point(12, 89);
- this->label4->Name = L"label4";
- this->label4->Size = System::Drawing::Size(14, 13);
- this->label4->TabIndex = 10;
- this->label4->Text = L"#";
- //
- // button2
- //
- this->button2->Enabled = false;
- this->button2->Location = System::Drawing::Point(99, 170);
- this->button2->Name = L"button2";
- this->button2->Size = System::Drawing::Size(100, 23);
- this->button2->TabIndex = 9;
- this->button2->Text = L"OK";
- this->button2->UseVisualStyleBackColor = true;
- this->button2->Click += gcnew System::EventHandler(this, &Form1::button2_Click);
- //
- // label3
- //
- this->label3->AutoSize = true;
- this->label3->Location = System::Drawing::Point(225, 22);
- this->label3->Name = L"label3";
- this->label3->Size = System::Drawing::Size(55, 13);
- this->label3->TabIndex = 8;
- this->label3->Text = L"Voorbeeld";
- //
- // panel2
- //
- this->panel2->BorderStyle = System::Windows::Forms::BorderStyle::Fixed3D;
- this->panel2->Location = System::Drawing::Point(211, 38);
- this->panel2->Name = L"panel2";
- this->panel2->Size = System::Drawing::Size(80, 80);
- this->panel2->TabIndex = 7;
- //
- // checkBox2
- //
- this->checkBox2->AutoSize = true;
- this->checkBox2->Location = System::Drawing::Point(14, 123);
- this->checkBox2->Name = L"checkBox2";
- this->checkBox2->Size = System::Drawing::Size(79, 17);
- this->checkBox2->TabIndex = 6;
- this->checkBox2->Text = L"BP Textuur";
- this->checkBox2->UseVisualStyleBackColor = true;
- //
- // textBox4
- //
- this->textBox4->Location = System::Drawing::Point(26, 86);
- this->textBox4->Name = L"textBox4";
- this->textBox4->Size = System::Drawing::Size(94, 20);
- this->textBox4->TabIndex = 5;
- //
- // label2
- //
- this->label2->AutoSize = true;
- this->label2->Location = System::Drawing::Point(11, 70);
- this->label2->Name = L"label2";
- this->label2->Size = System::Drawing::Size(26, 13);
- this->label2->TabIndex = 4;
- this->label2->Text = L"Hex";
- //
- // textBox3
- //
- this->textBox3->Location = System::Drawing::Point(114, 38);
- this->textBox3->Name = L"textBox3";
- this->textBox3->Size = System::Drawing::Size(44, 20);
- this->textBox3->TabIndex = 3;
- //
- // textBox2
- //
- this->textBox2->Location = System::Drawing::Point(64, 38);
- this->textBox2->Name = L"textBox2";
- this->textBox2->Size = System::Drawing::Size(44, 20);
- this->textBox2->TabIndex = 2;
- this->textBox2->TextChanged += gcnew System::EventHandler(this, &Form1::textBox2_TextChanged);
- //
- // label1
- //
- this->label1->AutoSize = true;
- this->label1->Location = System::Drawing::Point(11, 21);
- this->label1->Name = L"label1";
- this->label1->Size = System::Drawing::Size(30, 13);
- this->label1->TabIndex = 1;
- this->label1->Text = L"RGB";
- //
- // textBox1
- //
- this->textBox1->Location = System::Drawing::Point(14, 38);
- this->textBox1->Name = L"textBox1";
- this->textBox1->Size = System::Drawing::Size(44, 20);
- this->textBox1->TabIndex = 0;
- this->textBox1->TextChanged += gcnew System::EventHandler(this, &Form1::textBox1_TextChanged);
- //
- // groupBox2
- //
- this->groupBox2->Controls->Add(this->trackBar1);
- this->groupBox2->Controls->Add(this->radioButton1);
- this->groupBox2->Controls->Add(this->checkBox1);
- this->groupBox2->Controls->Add(this->radioButton2);
- this->groupBox2->Location = System::Drawing::Point(6, 19);
- this->groupBox2->Name = L"groupBox2";
- this->groupBox2->Size = System::Drawing::Size(333, 100);
- this->groupBox2->TabIndex = 4;
- this->groupBox2->TabStop = false;
- this->groupBox2->Text = L"Figuur";
- //
- // trackBar1
- //
- this->trackBar1->Location = System::Drawing::Point(99, 47);
- this->trackBar1->Maximum = 30;
- this->trackBar1->Name = L"trackBar1";
- this->trackBar1->Size = System::Drawing::Size(214, 45);
- this->trackBar1->TabIndex = 6;
- //
- // radioButton1
- //
- this->radioButton1->AutoSize = true;
- this->radioButton1->Checked = true;
- this->radioButton1->Location = System::Drawing::Point(14, 21);
- this->radioButton1->Name = L"radioButton1";
- this->radioButton1->Size = System::Drawing::Size(68, 17);
- this->radioButton1->TabIndex = 0;
- this->radioButton1->TabStop = true;
- this->radioButton1->Text = L"Driehoek";
- this->radioButton1->UseVisualStyleBackColor = true;
- //
- // checkBox1
- //
- this->checkBox1->AutoSize = true;
- this->checkBox1->Location = System::Drawing::Point(23, 64);
- this->checkBox1->Name = L"checkBox1";
- this->checkBox1->Size = System::Drawing::Size(69, 17);
- this->checkBox1->TabIndex = 3;
- this->checkBox1->Text = L"Draaiend";
- this->checkBox1->UseVisualStyleBackColor = true;
- this->checkBox1->CheckedChanged += gcnew System::EventHandler(this, &Form1::checkBox1_CheckedChanged);
- //
- // radioButton2
- //
- this->radioButton2->AutoSize = true;
- this->radioButton2->Location = System::Drawing::Point(14, 41);
- this->radioButton2->Name = L"radioButton2";
- this->radioButton2->Size = System::Drawing::Size(65, 17);
- this->radioButton2->TabIndex = 1;
- this->radioButton2->Text = L"Piramide";
- this->radioButton2->UseVisualStyleBackColor = true;
- //
- // button1
- //
- this->button1->Location = System::Drawing::Point(256, 443);
- this->button1->Name = L"button1";
- this->button1->Size = System::Drawing::Size(75, 23);
- this->button1->TabIndex = 4;
- this->button1->Text = L"button1";
- this->button1->UseVisualStyleBackColor = true;
- this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click_1);
- //
- // groupBox4
- //
- this->groupBox4->Controls->Add(this->button3);
- this->groupBox4->Controls->Add(this->comboBox1);
- this->groupBox4->Controls->Add(this->label5);
- this->groupBox4->Location = System::Drawing::Point(382, 94);
- this->groupBox4->Name = L"groupBox4";
- this->groupBox4->Size = System::Drawing::Size(355, 186);
- this->groupBox4->TabIndex = 4;
- this->groupBox4->TabStop = false;
- this->groupBox4->Text = L"Gegevens";
- //
- // button3
- //
- this->button3->Location = System::Drawing::Point(19, 150);
- this->button3->Name = L"button3";
- this->button3->Size = System::Drawing::Size(75, 23);
- this->button3->TabIndex = 2;
- this->button3->Text = L"Aanpassen";
- this->button3->UseVisualStyleBackColor = true;
- this->button3->Click += gcnew System::EventHandler(this, &Form1::button3_Click_1);
- //
- // comboBox1
- //
- this->comboBox1->FormattingEnabled = true;
- this->comboBox1->Items->AddRange(gcnew cli::array< System::Object^ >(13) {L"Rechthoekige driehoek", L"Gelijkbenige driehoek",
- L"Vierkant", L"Rechthoek", L"Cirkel", L"Pentagoon", L"Hexagoon", L"Octagoon", L"Kubus", L"Balk", L"Bol", L"Cilinder", L"Piramide"});
- this->comboBox1->Location = System::Drawing::Point(19, 35);
- this->comboBox1->Name = L"comboBox1";
- this->comboBox1->Size = System::Drawing::Size(132, 21);
- this->comboBox1->TabIndex = 1;
- //
- // label5
- //
- this->label5->AutoSize = true;
- this->label5->Location = System::Drawing::Point(16, 19);
- this->label5->Name = L"label5";
- this->label5->Size = System::Drawing::Size(36, 13);
- this->label5->TabIndex = 0;
- this->label5->Text = L"Figuur";
- //
- // label6
- //
- this->label6->AutoSize = true;
- this->label6->Location = System::Drawing::Point(815, 583);
- this->label6->Name = L"label6";
- this->label6->Size = System::Drawing::Size(35, 13);
- this->label6->TabIndex = 5;
- this->label6->Text = L"label6";
- //
- // Form1
- //
- this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
- this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
- this->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(232)), static_cast<System::Int32>(static_cast<System::Byte>(232)),
- static_cast<System::Int32>(static_cast<System::Byte>(232)));
- this->ClientSize = System::Drawing::Size(749, 605);
- this->Controls->Add(this->label6);
- this->Controls->Add(this->button1);
- this->Controls->Add(this->groupBox4);
- this->Controls->Add(this->groupBox1);
- this->Controls->Add(this->pictureBox1);
- this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::FixedDialog;
- this->MaximizeBox = false;
- this->Name = L"Form1";
- this->Text = L"Sector Werkstuk";
- this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->pictureBox1))->EndInit();
- this->groupBox1->ResumeLayout(false);
- this->groupBox3->ResumeLayout(false);
- this->groupBox3->PerformLayout();
- this->groupBox2->ResumeLayout(false);
- this->groupBox2->PerformLayout();
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->trackBar1))->EndInit();
- this->groupBox4->ResumeLayout(false);
- this->groupBox4->PerformLayout();
- this->ResumeLayout(false);
- this->PerformLayout();
- }
- #pragma endregion
- private: System::Void timer1_Tick(System::Object^ sender, System::EventArgs^ e)
- {
- UNREFERENCED_PARAMETER(sender);
- UNREFERENCED_PARAMETER(e);
- int kleur;
- if (this->checkBox1->Checked == true) {
- kleur = 1;}
- else if (this->checkBox1->Checked == false ) {
- kleur = 0;}
- int index = this->comboBox1->SelectedIndex;
- if (index != NULL) {
- OpenGL->Render(kleur,index);}
- OpenGL->SwapOpenGLBuffers();
- }
- private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
- }
- private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
- }
- private: System::Void label1_Click(System::Object^ sender, System::EventArgs^ e) {
- }
- private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
- System::String^ r = textBox1->Text;
- int R = int::Parse(r);
- System::String^ g = textBox2->Text;
- int G = int::Parse(g);
- System::String^ b = textBox3->Text;
- int B = int::Parse(b);
- if ( R >= 0 && G >= 0 && B >= 0 && R <= 255 && G <= 255 && B <= 255 ) {
- this->panel2->BackColor = System::Drawing::Color::FromArgb(R,G,B);}
- else { MessageBox::Show("Ongeldige kleureninstellingen (moet bestaan uit: RGB: 0-255, hex: 0-9 en A-F).",
- "Foutmelding", MessageBoxButtons::OK,
- MessageBoxIcon::Error);}
- }
- private: System::Void textBox1_TextChanged(System::Object^ sender, System::EventArgs^ e) {
- if ( textBox1->Text != "" ) {
- this->button2->Enabled = true;}
- else {
- this->button2->Enabled = false;
- }
- }
- private: System::Void textBox2_TextChanged(System::Object^ sender, System::EventArgs^ e) {
- }
- private: System::Void button1_Click_1(System::Object^ sender, System::EventArgs^ e) {
- }
- private: System::Void checkBox1_CheckedChanged(System::Object^ sender, System::EventArgs^ e) {
- }
- private: System::Void button3_Click_1(System::Object^ sender, System::EventArgs^ e) {
- }
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment