Lord_SoniK | Je vous mets un bout de code mais je sais pas si ca va vous aider beaucoup.
La boucle principale (dans le main) :
Code :
- while (!bQuit)
- {
- bQuit = m_Game.Update(m_GraphicEngine);
- if(!bQuit)
- bQuit = m_GraphicEngine.IsExiting();
- if (!bQuit)
- m_GraphicEngine.Screen.Render();
- }
|
La création du device (dans le GraphicForm qui hérité de Windows.Form) :
Code :
- this.SuspendLayout();
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.AutoSize = true;
- this.ClientSize = new System.Drawing.Size(800, 600);
- this.Name = "Form1";
- this.RightToLeftLayout = true;
- this.Text = "STU 2";
- if(p_bFullScreen)
- this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
- this.ResumeLayout(false);
- this.SetStyle(ControlStyles.Opaque | ControlStyles.SupportsTransparentBackColor | ControlStyles.UserPaint, true);
- // Initialisation du device
- PresentParameters presentParams = new PresentParameters();
-
- presentParams.SwapEffect = SwapEffect.Discard;
- Format current = Manager.Adapters[0].CurrentDisplayMode.Format;
- if (Manager.CheckDeviceType(0, DeviceType.Hardware, current, current, false))
- {
- presentParams.Windowed = !p_bFullScreen;
- presentParams.BackBufferFormat = current;
- }
- else
- presentParams.Windowed = true;
- m_Device = new Device(0, DeviceType.Hardware, this, CreateFlags.SoftwareVertexProcessing, presentParams);
- m_Device.ShowCursor(p_bShowCursor);
- System.Windows.Forms.Cursor.Clip = this.ClientRectangle;
- m_RenderWindow = this;
|
et la méthode Render () :
Code :
- public void Render()
- {
- m_Device.Clear(ClearFlags.Target, m_BackgroundColor, 1.0f, 0);
- m_Device.BeginScene();
- m_Sprite.Begin(SpriteFlags.AlphaBlend);
- foreach (cSprite s in m_SpriteList)
- {
- m_Sprite.Draw( s.Texture,
- s.TextureSize,
- s.v3Center,
- s.v3Pos,
- Color.White);
- }
- m_Sprite.Flush();
- m_Sprite.End();
- foreach (cFont f in m_FontList)
- {
- foreach (cText t in m_TextList)
- {
- f.Font.DrawText(null, t.sText, t.v2Pos.x, t.v2Pos.y, t.cColor);
- }
- }
- m_Device.EndScene();
- m_Device.Present();
- Application.DoEvents();
- }
|
Certaines partie du code sont encore en test donc tout n'est peut etre pas très bon  |