随笔 - 505  文章 - 1034  trackbacks - 0
<2007年8月>
2930311234
567891011
12131415161718
19202122232425
2627282930311
2345678


子曾经曰过:编程无他,唯手熟尔!

常用链接

留言簿(94)

随笔分类(649)

随笔档案(505)

相册

BCB

Crytek

  • crymod
  • Crytek's Offical Modding Portal

Game Industry

OGRE

other

Programmers

Qt

WOW Stuff

搜索

  •  

积分与排名

  • 积分 - 800076
  • 排名 - 16

最新随笔

最新评论

阅读排行榜

评论排行榜

索性这几个UI库都试试 ^_^

截图


重点
 1)取得句柄
      
pSystem->InitD3D((HWND)this->Handle.ToPointer());

 2)刷新画面也跟Qt一样靠定时器:拖个Timer(注意:默认是Enabled:false,改成true),双击下,改下面的函数
     
    private: System::Void timerRender_Tick(System::Object^  sender, System::EventArgs^  e) {
                 
if (pSystem)
                 {
                     pSystem
->Render();
                 }
             }

       本来我是打Run的主意的
Application::Run(gcnew MainForm());
写个类继承自Application,然后override这个Run,在其中调用Render(),试了下,编译出错
错误    1    error C3246: “EditorApplication”: 无法从“System::Windows::Forms::Application”继承,因为它已被声明为“sealed”    f:\Practise\Practise_2005\WorldEditor\WorldEditor.cpp    9    
Application类不能被继承!!!

看了下xoyojank写的 原创 DirectX in C++/CLI ,也用定时器好了。

3)项目配置: 公共语言运行库支持(/clr)    多线程调试 DLL (/MDd)


posted on 2008-11-26 23:35 七星重剑 阅读(972) 评论(6)  编辑 收藏 引用 所属分类: PL--c/c++Game GraphicsIDE -- visual c++

FeedBack:
# re: 每天30分钟写Editor--(2)在CLR窗口里用D3D画转动的三角形 2008-11-27 21:39 xoyojank
# re: 每天30分钟写Editor--(2)在CLR窗口里用D3D画转动的三角形 2008-11-28 14:20 七星重剑
 
protected override void WndProc(ref Message m)

{

   
if (m.Msg == 0x000F)

   {

      Frame();

      
this.Invalidate();

   }

   
else

      
base.WndProc(ref m);

}

 
[DllImport("user32.dll")]

public static extern int SendNotifyMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam); 



protected override void WndProc(ref Message m)

{

if (m.Msg == 0x000F)

{

   Frame();

   SendNotifyMessage(
this.Handle, 0x000F, IntPtr.Zero, IntPtr.Zero);

}

else

   
base.WndProc(ref m);

}

  回复  更多评论
  
# re: 每天30分钟写Editor--(2)在CLR窗口里用D3D画转动的三角形 2008-11-28 14:21 七星重剑
这种方式是最好的?
  回复  更多评论
  
# re: 每天30分钟写Editor--(2)在CLR窗口里用D3D画转动的三角形 2010-04-19 15:46 七星重剑
http://blogs.msdn.com/tmiller/archive/2005/05/05/415008.aspx

My last post on render loops (hopefully)..
The most common topic on my blog returns again. This time it will be brief as all I'm going to to do now is show you the render loop the June'05 SDK will be using. A coworker in another group came up with this markedly simple, yet deceptively effective loop for that groups projects. I liked it so much, i'm sharing it with everyone else. =)

The basic loop (slightly modified from his original version and the version in the new SDK for ease of reading):

public void MainLoop()
{
// Hook the application's idle event
System.Windows.Forms.Application.Idle += new EventHandler(OnApplicationIdle);
System.Windows.Forms.Application.Run(myForm);
}

private void OnApplicationIdle(object sender, EventArgs e)
{
while (AppStillIdle)
{
// Render a frame during idle time (no messages are waiting)
UpdateEnvironment();
Render3DEnvironment();
}
}

private bool AppStillIdle
{
get
{
NativeMethods.Message msg;
return !NativeMethods.PeekMessage(out msg, IntPtr.Zero, 0, 0, 0);
}
}


And the declarations for those two native methods members:

[StructLayout(LayoutKind.Sequential)]
public struct Message
{
public IntPtr hWnd;
public WindowMessage msg;
public IntPtr wParam;
public IntPtr lParam;
public uint time;
public System.Drawing.Point p;
}

[System.Security.SuppressUnmanagedCodeSecurity] // We won't use this maliciously
[DllImport("User32.dll", CharSet=CharSet.Auto)]
public static extern bool PeekMessage(out Message msg, IntPtr hWnd, uint messageFilterMin, uint messageFilterMax, uint flags);


------

Simple, elegant, effective. No extra allocations, no extra collections, it just works.. The Idle event fires when there's no messages in the queue, and then the handler keeps looping continuously until a message does appear, in which case it stops.. Once all the messages are handled, the idle event is fired again, and the process starts over.

  回复  更多评论
  
# re: 每天30分钟写Editor--(2)在CLR窗口里用D3D画转动的三角形 2010-04-19 15:55 七星重剑
现在见到这种方式,把控件invalidate了让其重新绘制。

Application.Idle += new EventHandler(form.Application_Idle);
Application.Run(form);

Invalidator.Shutdown();
MFramework.Shutdown();
}

private void Application_Idle(object sender, EventArgs e)
{
if (this.Visible &&
this.WindowState != FormWindowState.Minimized &&
Form.ActiveForm == this)
{
Invalidator.Instance.Update(true);
}
}

在控件的protected override void OnPaint(PaintEventArgs e)里绘制3D内容。  回复  更多评论
  
# re: 每天30分钟写Editor--(2)在CLR窗口里用D3D画转动的三角形 2010-10-31 18:42 funcman
Void OnIdle(Object^ sender, EventArgs^ e) {
MSG msg;
while( !PeekMessage(&msg, 0, 0, 0, 0) ) {
Render();
}
}

//...

int main(array<System::String^>^ args) {
//...

EventHandler^ idle = gcnew EventHandler(OnIdle);
Application::Idle += idle;
Application::Run(gcnew MainForm());
Application::Idle -= idle;

return 0;
}  回复  更多评论
  

只有注册用户登录后才能发表评论。
【推荐】超50万行VC++源码: 大型组态工控、电力仿真CAD与GIS源码库
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理