I’m using visual c++ 7. I would like to know how to get opengl displaying inside c++ .net form builder window. Basically, I’ve built my gui using the .net wizard and toolbox but now I need to implement an opengl screen in the main part of my program. Any suggestions on how to?
First thing: I’m rather new to c++. Got working with OpenGL recently but didn’t do much more than the stuff in DrawScene. Now I need to make an OpenGL something in a (System::Windows::Forms::Form) in a .Net (2005) created interface of my friend for this school project we’re doing.
So I created a Panel object with the toolbox provided in Visual Studio and got myself
private: System::Windows::Forms::Panel^ panel1;
So far I haven’t messed with the by VS created header file, which is:
#pragma once
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
namespace RoboGenSim
{
/// <summary>
/// Summary for OpenGLWindow
///
/// 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 OpenGLWindow : public System::Windows::Forms::Form
{
public:
OpenGLWindow(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
//HDC hDC = GetDC( hWnd );
}
protected:
void Dispose(Boolean disposing)
{
if (disposing && components)
{
components->Dispose();
}
__super::Dispose(disposing);
}
private: System::Windows::Forms::Panel^ panel1;
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;
#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)
{
System::ComponentModel::ComponentResourceManager^ resources = gcnew System::ComponentModel::ComponentResourceManager(typeid<OpenGLWindow >);
this->panel1 = gcnew System::Windows::Forms::Panel();
this->SuspendLayout();
//
// panel1
//
this->panel1->Dock = System::Windows::Forms::DockStyle::Fill;
this->panel1->Location = System::Drawing::Point(0, 0);
this->panel1->Name = L"panel1";
this->panel1->Size = System::Drawing::Size(292, 266);
this->panel1->TabIndex = 0;
//
// OpenGLWindow
//
this->AutoScaleBaseSize = System::Drawing::Size(5, 13);
this->ClientSize = System::Drawing::Size(292, 266);
this->Controls->Add(this->panel1);
this->Icon = (stdcli::language::safe_cast<System::Drawing::Icon^ >(resources->GetObject(L"$this.Icon")));
this->Name = L"OpenGLWindow";
this->Text = L"Environment";
this->ResumeLayout(false);
}
#pragma endregion
};
}
But it gives me a lot of errors when I try to build this. So I’m sure I’m forgetting something obvious, for the more experienced programmer at least. Like I forget to include something, I just don’t know.
The errors it gives:
Compiling...
OpenGLWindow.cpp
OpenGLWindow.cpp(10) : error C2146: syntax error : missing ';' before identifier 'hDC'
OpenGLWindow.cpp(10) : error C2501: 'HDC' : missing storage-class or type specifiers
OpenGLWindow.cpp(10) : error C2501: 'hDC' : missing storage-class or type specifiers
OpenGLWindow.cpp(10) : error C2065: 'panel1' : undeclared identifier
OpenGLWindow.cpp(10) : error C2227: left of '->Handle' must point to class/struct/union
type is ''unknown-type''
OpenGLWindow.cpp(10) : error C2228: left of '.ToPointer' must have class/struct/union/generic type
OpenGLWindow.cpp(10) : error C3861: 'GetDC': identifier not found
I really hope someone can point me in the right direction
Thanks!!