Von04 Posted January 5, 2012 Share Posted January 5, 2012 Just wondering if anyone has gotten CreateCustomeBuffer to work with c++ and windows forms yet? I want to make a GMF Fracture tool for destructibles objects, but I can only use c++ because converting the code to c# would take way to long. Quote 3d world studio. 3ds Max 8. GTX 260. Visual Studio 2010. Dual Core 2.6 Mhz processor. Link to comment Share on other sites More sharing options...
Pixel Perfect Posted January 5, 2012 Share Posted January 5, 2012 Not that I've ever seen although MasterXilo did release some code for changing the graphics resolution in game which I seem to remember used a custom buffer so you might glean some useful info from that. Whisper may have done something with managed code and windows forms but it's so long ago I can't remember exactly. Quote Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++ Link to comment Share on other sites More sharing options...
Josh Posted January 5, 2012 Share Posted January 5, 2012 I know it's been done with Windows Forms. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Pixel Perfect Posted January 5, 2012 Share Posted January 5, 2012 I know it's been done with Windows Forms. With C# it certainly has, can you point us at a C++ implementation because I'd be interested in that too! Quote Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++ Link to comment Share on other sites More sharing options...
Von04 Posted January 7, 2012 Author Share Posted January 7, 2012 So here is what I've come up with so far. The program ran fine and the createcustombuffer function seems to be working. Although when I added the line World = CreateWorld(), the program hangs up and freezes and never gets to the line MessageBox::Show("Failed to create world!"). Do you think this is because CreateCustomBuffer isn't being made current or isn't getting a valid DC? #pragma warning(disable: 4793) #pragma warning(disable: 4441) #pragma once #include "stdafx.h" #include "Engine.Cpp" namespace GMFTool { 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 Tao::Platform::Windows; using namespace Tao::OpenGl; using namespace LE; static void _stdcall GetSize(int *width, int *height) { width[0] = 800; height[0] = 600; } static void _stdcall MakeCurrent() { wglMakeCurrent(wglGetCurrentDC(), wglGetCurrentContext()); } public ref class Form1 : public System::Windows::Forms::Form { public: TBuffer Buffer; TWorld World; public: Form1(void) { InitializeComponent(); Window->InitializeContexts(); Initialize(); Buffer = CreateCustomBuffer((byte *)&GetSize, (byte*)&MakeCurrent); World = CreateWorld(); if (!World) MessageBox::Show("Failed to create world!", "Error!"); } protected: ~Form1() { if (components) { delete components; } } public: Tao::Platform::Windows::SimpleOpenGlControl^ Window; private: System::ComponentModel::IContainer^ components; public: #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->Window = (gcnew Tao::Platform::Windows::SimpleOpenGlControl()); this->SuspendLayout(); // // Window // this->Window->AccumBits = static_cast<System::Byte>(0); this->Window->AutoCheckErrors = false; this->Window->AutoFinish = false; this->Window->AutoMakeCurrent = true; this->Window->AutoSwapBuffers = true; this->Window->BackColor = System::Drawing::Color::Black; this->Window->ColorBits = static_cast<System::Byte>(32); this->Window->DepthBits = static_cast<System::Byte>(16); this->Window->Dock = System::Windows::Forms::DockStyle::Fill; this->Window->Location = System::Drawing::Point(0, 0); this->Window->Name = L"Window"; this->Window->Size = System::Drawing::Size(1184, 662); this->Window->StencilBits = static_cast<System::Byte>(0); this->Window->TabIndex = 0; // // Form1 // this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; this->ClientSize = System::Drawing::Size(1184, 662); this->Controls->Add(this->Window); this->Name = L"Form1"; this->Text = L"Form1"; this->WindowState = System::Windows::Forms::FormWindowState::Maximized; this->ResumeLayout(false); } #pragma endregion }; } Quote 3d world studio. 3ds Max 8. GTX 260. Visual Studio 2010. Dual Core 2.6 Mhz processor. Link to comment Share on other sites More sharing options...
Von04 Posted January 17, 2012 Author Share Posted January 17, 2012 Finally, after many tiring hours, I have succesfully created an OpenGL Control that renders leadwerks to a custum buffer on a c++ windows forms application. All you have to do is drag and drog the control onto your form and it sets up leadwerks for you with or without framework, it's your choice. I just need to tidy up my code and do some bug testing, and then I will release the control and a demo project to the community. Hopefully this helps a lot of people. Quote 3d world studio. 3ds Max 8. GTX 260. Visual Studio 2010. Dual Core 2.6 Mhz processor. Link to comment Share on other sites More sharing options...
Pixel Perfect Posted January 17, 2012 Share Posted January 17, 2012 Wow! That's brilliant. I'm sure a lot of people will be very grateful. Many thanks for your effort and for making this available once its complete. Quote Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++ Link to comment Share on other sites More sharing options...
Von04 Posted January 17, 2012 Author Share Posted January 17, 2012 Does anyone know if I can mark this thread as [sOLVED], or if a website administrator has to do that? Quote 3d world studio. 3ds Max 8. GTX 260. Visual Studio 2010. Dual Core 2.6 Mhz processor. Link to comment Share on other sites More sharing options...
Pixel Perfect Posted January 17, 2012 Share Posted January 17, 2012 You can do that, just edit the first post Quote Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++ Link to comment Share on other sites More sharing options...
Von04 Posted January 19, 2012 Author Share Posted January 19, 2012 I have no idea what happened to my code. I went to run my test form, and every time it gets to the line CreateWorld the form closes without any errors. What would cause CreateWorld to crash my form? Is it that there is not a active GLContext? I don't believe that I changed any of the code to cause this. I'm at a loss. Quote 3d world studio. 3ds Max 8. GTX 260. Visual Studio 2010. Dual Core 2.6 Mhz processor. Link to comment Share on other sites More sharing options...
Pixel Perfect Posted January 22, 2012 Share Posted January 22, 2012 Any update on this? Did you manage to resolve the problem? Quote Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++ Link to comment Share on other sites More sharing options...
Von04 Posted January 22, 2012 Author Share Posted January 22, 2012 Any update on this? Did you manage to resolve the problem? I did resolve the problems. The only thing now is trying to implement a Timer inside of the control to fire an event, and use that to create an internal loop. The problem is that whenever I add a Threading.Timer to the control it crashes Visual Studio. I've read about a lot of other people having the same problem but I haven't figured out a work-around yet. If I can't figure this out by tomorrow, I'll just release the code as-is, and users will just have to add their own timer to their windows forms, and use that as a render loop. I post later tonight when I have some more time to work on this. Quote 3d world studio. 3ds Max 8. GTX 260. Visual Studio 2010. Dual Core 2.6 Mhz processor. Link to comment Share on other sites More sharing options...
Von04 Posted January 23, 2012 Author Share Posted January 23, 2012 I did resolve the problems. The only thing now is trying to implement a Timer inside of the control to fire an event, and use that to create an internal loop. The problem is that whenever I add a Threading.Timer to the control it crashes Visual Studio. I've read about a lot of other people having the same problem but I haven't figured out a work-around yet. If I can't figure this out by tomorrow, I'll just release the code as-is, and users will just have to add their own timer to their windows forms, and use that as a render loop. I post later tonight when I have some more time to work on this. Just uploaded a working version of the control to the Asset Store -> Tools section. Check it out and let me know how it goes. Hope my directions are clear enough for setting it up. The included LEControl.Dll contains the control. The example.cpp and form1.h files included are examples of how to set up leadwerks using the control. Best of luck. Quote 3d world studio. 3ds Max 8. GTX 260. Visual Studio 2010. Dual Core 2.6 Mhz processor. Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.