Имеется такой код:
form11.h
| Код |
#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;
using namespace Microsoft::Win32;
namespace shape {
public ref class shape : public System::Windows::Forms::Form { public: shape(void) { InitializeComponent();
}
protected: /// <summary> /// Clean up any resources being used. /// </summary> ~shape() { if (components) { delete components; } } private: System::Windows::Forms::RadioButton^ radioButton1; protected: private: System::Windows::Forms::RadioButton^ radioButton2; private: System::Windows::Forms::GroupBox^ groupBox1; private: System::Windows::Forms::RadioButton^ radioButton3; private: System::Windows::Forms::GroupBox^ groupBox2; private: System::Windows::Forms::RadioButton^ radioButton6; private: System::Windows::Forms::RadioButton^ radioButton5; private: System::Windows::Forms::RadioButton^ radioButton4; private: System::Windows::Forms::Panel^ panel1; private: System::Windows::Forms::GroupBox^ groupBox3; private: System::Windows::Forms::RadioButton^ radioButton9; private: System::Windows::Forms::RadioButton^ radioButton8; private: System::Windows::Forms::RadioButton^ radioButton7;
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) { this->radioButton1 = (gcnew System::Windows::Forms::RadioButton()); this->radioButton2 = (gcnew System::Windows::Forms::RadioButton()); this->groupBox1 = (gcnew System::Windows::Forms::GroupBox()); this->radioButton3 = (gcnew System::Windows::Forms::RadioButton()); this->groupBox2 = (gcnew System::Windows::Forms::GroupBox()); this->radioButton6 = (gcnew System::Windows::Forms::RadioButton()); this->radioButton5 = (gcnew System::Windows::Forms::RadioButton()); this->radioButton4 = (gcnew System::Windows::Forms::RadioButton()); this->panel1 = (gcnew System::Windows::Forms::Panel()); this->groupBox3 = (gcnew System::Windows::Forms::GroupBox()); this->radioButton7 = (gcnew System::Windows::Forms::RadioButton()); this->radioButton8 = (gcnew System::Windows::Forms::RadioButton()); this->radioButton9 = (gcnew System::Windows::Forms::RadioButton()); this->groupBox1->SuspendLayout(); this->groupBox2->SuspendLayout(); this->groupBox3->SuspendLayout(); this->SuspendLayout(); // // radioButton1 // this->radioButton1->AutoSize = true; this->radioButton1->Location = System::Drawing::Point(6, 19); this->radioButton1->Name = L"radioButton1"; this->radioButton1->Size = System::Drawing::Size(50, 17); this->radioButton1->TabIndex = 0; this->radioButton1->TabStop = true; this->radioButton1->Text = L"Cube"; this->radioButton1->UseVisualStyleBackColor = true; // // radioButton2 // this->radioButton2->AutoSize = true; this->radioButton2->Location = System::Drawing::Point(6, 42); this->radioButton2->Name = L"radioButton2"; this->radioButton2->Size = System::Drawing::Size(52, 17); this->radioButton2->TabIndex = 1; this->radioButton2->TabStop = true; this->radioButton2->Text = L"Torus"; this->radioButton2->UseVisualStyleBackColor = true; // // groupBox1 // this->groupBox1->Controls->Add(this->radioButton3); this->groupBox1->Controls->Add(this->radioButton1); this->groupBox1->Controls->Add(this->radioButton2); this->groupBox1->Location = System::Drawing::Point(12, 12); this->groupBox1->Name = L"groupBox1"; this->groupBox1->Size = System::Drawing::Size(77, 91); this->groupBox1->TabIndex = 2; this->groupBox1->TabStop = false; this->groupBox1->Text = L"Object"; this->groupBox1->Enter += gcnew System::EventHandler(this, &shape::groupBox1_Enter); // // radioButton3 // this->radioButton3->AutoSize = true; this->radioButton3->Location = System::Drawing::Point(7, 66); this->radioButton3->Name = L"radioButton3"; this->radioButton3->Size = System::Drawing::Size(59, 17); this->radioButton3->TabIndex = 2; this->radioButton3->TabStop = true; this->radioButton3->Text = L"Teapot"; this->radioButton3->UseVisualStyleBackColor = true; // // groupBox2 // this->groupBox2->Controls->Add(this->radioButton6); this->groupBox2->Controls->Add(this->radioButton5); this->groupBox2->Controls->Add(this->radioButton4); this->groupBox2->Location = System::Drawing::Point(12, 109); this->groupBox2->Name = L"groupBox2"; this->groupBox2->Size = System::Drawing::Size(77, 91); this->groupBox2->TabIndex = 3; this->groupBox2->TabStop = false; this->groupBox2->Text = L"Speed"; // // radioButton6 // this->radioButton6->AutoSize = true; this->radioButton6->Location = System::Drawing::Point(7, 66); this->radioButton6->Name = L"radioButton6"; this->radioButton6->Size = System::Drawing::Size(36, 17); this->radioButton6->TabIndex = 2; this->radioButton6->TabStop = true; this->radioButton6->Text = L"x3"; this->radioButton6->UseVisualStyleBackColor = true; // // radioButton5 // this->radioButton5->AutoSize = true; this->radioButton5->Location = System::Drawing::Point(7, 42); this->radioButton5->Name = L"radioButton5"; this->radioButton5->Size = System::Drawing::Size(36, 17); this->radioButton5->TabIndex = 1; this->radioButton5->TabStop = true; this->radioButton5->Text = L"x2"; this->radioButton5->UseVisualStyleBackColor = true; // // radioButton4 // this->radioButton4->AutoSize = true; this->radioButton4->Location = System::Drawing::Point(7, 20); this->radioButton4->Name = L"radioButton4"; this->radioButton4->Size = System::Drawing::Size(36, 17); this->radioButton4->TabIndex = 0; this->radioButton4->TabStop = true; this->radioButton4->Text = L"x1"; this->radioButton4->UseVisualStyleBackColor = true; // // panel1 // this->panel1->Location = System::Drawing::Point(95, 16); this->panel1->Name = L"panel1"; this->panel1->Size = System::Drawing::Size(400, 400); this->panel1->TabIndex = 4; // // groupBox3 // this->groupBox3->Controls->Add(this->radioButton9); this->groupBox3->Controls->Add(this->radioButton8); this->groupBox3->Controls->Add(this->radioButton7); this->groupBox3->Location = System::Drawing::Point(12, 206); this->groupBox3->Name = L"groupBox3"; this->groupBox3->Size = System::Drawing::Size(77, 100); this->groupBox3->TabIndex = 5; this->groupBox3->TabStop = false; this->groupBox3->Text = L"Trajectory"; this->groupBox3->Enter += gcnew System::EventHandler(this, &shape::groupBox3_Enter); // // radioButton7 // this->radioButton7->AutoSize = true; this->radioButton7->Location = System::Drawing::Point(7, 20); this->radioButton7->Name = L"radioButton7"; this->radioButton7->Size = System::Drawing::Size(45, 17); this->radioButton7->TabIndex = 0; this->radioButton7->TabStop = true; this->radioButton7->Text = L"Line"; this->radioButton7->UseVisualStyleBackColor = true; // // radioButton8 // this->radioButton8->AutoSize = true; this->radioButton8->Location = System::Drawing::Point(7, 44); this->radioButton8->Name = L"radioButton8"; this->radioButton8->Size = System::Drawing::Size(51, 17); this->radioButton8->TabIndex = 1; this->radioButton8->TabStop = true; this->radioButton8->Text = L"Circle"; this->radioButton8->UseVisualStyleBackColor = true; // // radioButton9 // this->radioButton9->AutoSize = true; this->radioButton9->Location = System::Drawing::Point(6, 68); this->radioButton9->Name = L"radioButton9"; this->radioButton9->Size = System::Drawing::Size(59, 17); this->radioButton9->TabIndex = 2; this->radioButton9->TabStop = true; this->radioButton9->Text = L"Square"; this->radioButton9->UseVisualStyleBackColor = true; // // shape // this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; this->ClientSize = System::Drawing::Size(509, 430); this->Controls->Add(this->groupBox3); this->Controls->Add(this->panel1); this->Controls->Add(this->groupBox2); this->Controls->Add(this->groupBox1); this->Name = L"shape"; this->Text = L"Shape"; this->Load += gcnew System::EventHandler(this, &shape::shape_Load); this->groupBox1->ResumeLayout(false); this->groupBox1->PerformLayout(); this->groupBox2->ResumeLayout(false); this->groupBox2->PerformLayout(); this->groupBox3->ResumeLayout(false); this->groupBox3->PerformLayout(); this->ResumeLayout(false);
} #pragma endregion
private: System::Void groupBox1_Enter(System::Object^ sender, System::EventArgs^ e) { } private: System::Void shape_Load(System::Object^ sender, System::EventArgs^ e) {
wglMakeCurrent(0, 0); Handle=(HWND)Panel1->Handle.ToPointer(); hdc=GetDC(Handle); int PixelFormat=ChoosePixelFormat( hdc, &pfd ); SetPixelFormat( hdc, PixelFormat ,&pfd ); hrc=wglCreateContext(hdc);
float pos[4] = {3,3,3,1}; float dir[3] = {-1,-1,-1};
auxInitPosition( 50, 10, 300, 300); auxInitDisplayMode( AUX_RGB | AUX_DEPTH | AUX_DOUBLE ); auxInitWindow(L"Shapes"); auxIdleFunc(display); auxReshapeFunc(resize);
glEnable(GL_DEPTH_TEST); glEnable(GL_COLOR_MATERIAL); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0);
glLightfv(GL_LIGHT0, GL_POSITION, pos); glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, dir);
auxMainLoop(display);
}
System::Void display(void) { glViewport( 0, 0, Panel1->Width, Panel1->Height ); wglMakeCurrent( hdc, hrc );
static double time = 0; static double x= 0; static bool fl = false;
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glPushMatrix(); glTranslated(x,0,0); glRotated(time, 0.0, 1.0, 0.0);
glColor3d(0,0,1); auxSolidCube(2); // куб glPopMatrix(); time= time + 0.05;
if (x >= 4) fl = true; if (x <= -4) fl = false; if (fl == true) x-=0.002; if (fl == false) x+=0.002;
//x= x + 0.001;
auxSwapBuffers();
SwapBuffers(hdc); wglMakeCurrent(0, 0); } private: System::Void groupBox3_Enter(System::Object^ sender, System::EventArgs^ e) { } }; }
|
main.cpp
| Код |
#include <stdio.h> #include "stdafx.h" #include <stdlib.h> #include <windows.h> #include <gl/GLAUX.h> #include <gl/gl.h> #include <gl/glu.h> #include <Form11.h>
using namespace shape;
[STAThreadAttribute] int main(array<System::String ^> ^args) { // Enabling Windows XP visual effects before any controls are created Application::EnableVisualStyles(); Application::SetCompatibleTextRenderingDefault(false);
// Create the main window and run it Application::Run(gcnew shape());
return 0; }
|
при компиляции выводит тучу ошибок в стиле:
C:\Program Files\Microsoft Visual Studio 8\VC\include\winnt.h(530) : warning C4793: '__asm' : causes native code generation for function 'ULONGLONG Int64ShllMod32(ULONGLONG,DWORD)'
C:\Program Files\Microsoft Visual Studio 8\VC\include\winnt.h(502) : see declaration of 'Int64ShllMod32'
C:\Program Files\Microsoft Visual Studio 8\VC\include\winnt.h(546) : warning C4793: '__asm' : causes native code generation for function 'LONGLONG Int64ShraMod32(LONGLONG,DWORD)'
C:\Program Files\Microsoft Visual Studio 8\VC\include\winnt.h(509) : see declaration of 'Int64ShraMod32'
C:\Program Files\Microsoft Visual Studio 8\VC\include\winnt.h(562) : warning C4793: '__asm' : causes native code generation for function 'ULONGLONG Int64ShrlMod32(ULONGLONG,DWORD)'
C:\Program Files\Microsoft Visual Studio 8\VC\include\winnt.h(516) : see declaration of 'Int64ShrlMod32'
C:\Program Files\Microsoft Visual Studio 8\VC\include\winnt.h(1519) : warning C4793: '__asm' : causes native code generation for function 'PVOID GetFiberData(void)'
C:\Program Files\Microsoft Visual Studio 8\VC\include\winnt.h(1519) : see declaration of 'GetFiberData'
C:\Program Files\Microsoft Visual Studio 8\VC\include\winnt.h(1524) : warning C4793: '__asm' : causes native code generation for function 'PVOID GetCurrentFiber(void)'
C:\Program Files\Microsoft Visual Studio 8\VC\include\winnt.h(1524) : see declaration of 'GetCurrentFiber'
C:\Program Files\Microsoft Visual Studio 8\VC\include\objbase.h(367) : error C2146: syntax error : missing ';' before identifier 'IRpcStubBuffer'
C:\Program Files\Microsoft Visual Studio 8\VC\include\objbase.h(367) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files\Microsoft Visual Studio 8\VC\include\objbase.h(367) : error C2079: 'IRpcStubBuffer' uses undefined struct 'IRpcStubBuffer'
C:\Program Files\Microsoft Visual Studio 8\VC\include\objbase.h(368) : error C2146: syntax error : missing ';' before identifier 'IRpcChannelBuffer'
C:\Program Files\Microsoft Visual Studio 8\VC\include\objbase.h(368) : error C2371: 'IRpcChannelBuffer' : redefinition; different basic types
C:\Program Files\Microsoft Visual Studio 8\VC\include\rpcndr.h(937) : see declaration of 'IRpcChannelBuffer'
C:\Program Files\Microsoft Visual Studio 8\VC\include\unknwn.h(42) : error C2146: syntax error : missing ';' before identifier 'IUnknown'
C:\Program Files\Microsoft Visual Studio 8\VC\include\unknwn.h(42) : warning C4091: '' : ignored on left of 'interface' when no variable is declared
C:\Program Files\Microsoft Visual Studio 8\VC\include\unknwn.h(48) : error C2146: syntax error : missing ';' before identifier 'IClassFactory'
C:\Program Files\Microsoft Visual Studio 8\VC\include\unknwn.h(48) : warning C4091: '' : ignored on left of 'interface' when no variable is declared
C:\Program Files\Microsoft Visual Studio 8\VC\include\unknwn.h(106) : error C2371: 'IUnknown' : redefinition; different basic types
C:\Program Files\Microsoft Visual Studio 8\VC\include\unknwn.h(42) : see declaration of 'IUnknown'
C:\Program Files\Microsoft Visual Studio 8\VC\include\unknwn.h(183) : error C2065: 'This' : undeclared identifier
C:\Program Files\Microsoft Visual Studio 8\VC\include\unknwn.h(184) : error C2065: '_pRpcChannelBuffer' : undeclared identifier
Помогите пожалуйста решить эту пробему.