本文整理汇总了C#中SharpDX.Windows.RenderForm类的典型用法代码示例。如果您正苦于以下问题:C# RenderForm类的具体用法?C# RenderForm怎么用?C# RenderForm使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RenderForm类属于SharpDX.Windows命名空间,在下文中一共展示了RenderForm类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Game
public Game(int width, int height, string title)
{
Form = new RenderForm {
Size = new Size(width, height),
StartPosition = FormStartPosition.CenterScreen,
AutoScaleMode = AutoScaleMode.None,
Text = title
};
InputManager = new InputManager();
//初始化渲染组件
InitRenderComponent(width, height, title);
//初始化所有组件
ResourcesManager = new ResourcesManager(renderTarget);
GameClock = new GameClock();
UpdateDispatcher = new UpdateDispatcher();
SpriteManager = new SpriteManager();
EngineInfoDrawer = new EngineInfoDrawer(renderTarget);
//为需要更新的组件添加更新关联
UpdateDispatcher.Schedule(InputManager.Update);
UpdateDispatcher.Schedule(EngineInfoDrawer.Update, 0.4f);
Instance = this;
}
示例2: Dx11
public Dx11(RenderForm form)
{
AcquireGpu();
CreateDeviceAndSwapChain(form);
InitializeBuffers();
CreateMatrices();
}
示例3: Player
public Player(ref RenderForm form, Matrix proj)
{
form.FormClosing += TurnOFFThread;
this.form = form;
this.proj = proj;
if (!ThreadLaunched)
{
ThreadLaunched = true;
ThOrientCamera = new Thread(orient_camera);
ThOrientCamera.Start();
}
else
{
debug.WriteNicely("!", ConsoleColor.Magenta, "?? WTF ARE YOU DOING WITH MY SOURCE CODE ??", 0);
}
input = new Input(ref form);
previous_mousepoint = Cursor.Position;
view = Matrix.Translation(position.X, position.Y, position.Z) *
Matrix.RotationAxis(new Vector3(0, 1, 0), angle.Y) *
Matrix.RotationAxis(new Vector3(1, 0, 0), angle.X) *
Matrix.RotationAxis(new Vector3(0, 0, 1), angle.Z);
speedTranslationPythagore = new Vector3(
Convert.ToSingle(speedTranslation.X * speedTranslation.X / Math.Sqrt(speedTranslation.X * speedTranslation.X * 2)),
Convert.ToSingle(speedTranslation.Y * speedTranslation.Y / Math.Sqrt(speedTranslation.Y * speedTranslation.Y * 2)),
Convert.ToSingle(speedTranslation.Z * speedTranslation.Z / Math.Sqrt(speedTranslation.Z * speedTranslation.Z * 2)));
speedTranslationPythagoreRun = new Vector3(
Convert.ToSingle(speedTranslationRun.X * speedTranslationRun.X / Math.Sqrt(speedTranslationRun.X * speedTranslationRun.X * 2)),
Convert.ToSingle(speedTranslationRun.Y * speedTranslationRun.Y / Math.Sqrt(speedTranslationRun.Y * speedTranslationRun.Y * 2)),
Convert.ToSingle(speedTranslationRun.Z * speedTranslationRun.Z / Math.Sqrt(speedTranslationRun.Z * speedTranslationRun.Z * 2)));
}
示例4: Main
private static void Main(string[] args)
{
if (args.Length != 1)
{
Console.WriteLine("Args: filepath");
return;
}
else
{
var file = args[0];
var form = new RenderForm("Assimp Viewer");
form.Show();
using (var app = new AssimpViewWindow(file))
{
app.Initialize(form);
using (var loop = new RenderLoop(form))
{
while (loop.NextFrame())
{
app.Update();
app.Render();
}
}
}
}
}
示例5: Main
private static void Main(string[] args)
{
string save_path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\TechArts3D\TDCG";
OcuConfig ocu_config;
string ocu_config_file = Path.Combine(Application.StartupPath, @"ocuconfig.xml");
if (File.Exists(ocu_config_file))
ocu_config = OcuConfig.Load(ocu_config_file);
else
ocu_config = new OcuConfig();
RenderForm form = new RenderForm("TSOView for Oculus (SharpDX Direct3D11 net40)");
OculusViewer viewer = new OculusViewer();
if (viewer.InitializeApplication(form, ocu_config))
{
foreach (string arg in args)
viewer.figures.LoadAnyFile(arg, true);
if (viewer.figures.Count == 0)
viewer.figures.LoadAnyFile(Path.Combine(save_path, @"system.tdcgsav.png"), true);
viewer.MotionEnabled = true;
RenderLoop.Run(form, () => { viewer.FrameMove(); viewer.Render(); });
}
viewer.Dispose();
}
示例6: Graphics
public Graphics(RenderForm form, int width, int height)
{
reset = () => form.Invoke(new Action(() =>
{
device.Reset(presentParameters);
fontRenderer.Flush();
textureRenderer.Flush();
resized = false;
}));
form.UserResized += (sender, args) => Resize(form.ClientSize.Width, form.ClientSize.Height);
presentParameters = new PresentParameters
{
Windowed = true,
SwapEffect = SwapEffect.Discard,
BackBufferFormat = Format.A8R8G8B8,
BackBufferCount = 1,
BackBufferWidth = width,
BackBufferHeight = height,
PresentationInterval = PresentInterval.One,
MultiSampleType = MultisampleType.None,
MultiSampleQuality = 0,
PresentFlags = PresentFlags.LockableBackBuffer
};
direct3D = new Direct3DEx();
device = new DeviceEx(direct3D, 0, DeviceType.Hardware, form.Handle, CREATE_FLAGS, presentParameters);
fontRenderer = new FontRenderer(device);
textureRenderer = new TextureRenderer(device);
renderLocker.Reset();
}
示例7: GBuffer
public GBuffer(IKernel kernel)
{
IDeviceProvider provider = kernel.Get<IDeviceProvider>();
_device = provider.Device;
_form = provider.RenderForm;
}
示例8: Main
static void Main(string[] args)
{
RenderForm form = new RenderForm("Underground - POO version");
form.Size = new Size(1280, 700);
Direct3D direct3D = new Direct3D();
PresentParameters parameters = new PresentParameters(form.ClientSize.Width, form.ClientSize.Height);
Device device = new Device(direct3D, 0, DeviceType.Hardware, form.Handle, CreateFlags.HardwareVertexProcessing, parameters);
ResManager.Initialize(ref device, ref form);
IngameClass ingame = new IngameClass(ref device, ref form);
Stopwatch clock = new Stopwatch();
clock.Start();
RenderLoop.Run(form, () =>
{
device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);
device.BeginScene();
ingame.Draw(ref device, ref form, ref clock);
device.EndScene();
device.Present();
});
ResManager.Dispose();
device.Dispose();
direct3D.Dispose();
}
示例9: Main
static void Main()
{
var form = new RenderForm("SlimDX2 - MiniTri Direct3D9 Sample");
var device = new Device(new Direct3D(), 0, DeviceType.Hardware, form.Handle, CreateFlags.HardwareVertexProcessing, new PresentParameters(form.ClientSize.Width,form.ClientSize.Height));
var vertices = new VertexBuffer(device, 3 * 20, Usage.WriteOnly, VertexFormat.None, Pool.Managed);
vertices.Lock(0, 0, LockFlags.None).WriteRange(new[] {
new Vertex() { Color = Color.Red, Position = new Vector4(400.0f, 100.0f, 0.5f, 1.0f) },
new Vertex() { Color = Color.Blue, Position = new Vector4(650.0f, 500.0f, 0.5f, 1.0f) },
new Vertex() { Color = Color.Green, Position = new Vector4(150.0f, 500.0f, 0.5f, 1.0f) }
});
vertices.Unlock();
var vertexElems = new[] {
new VertexElement(0, 0, DeclarationType.Float4, DeclarationMethod.Default, DeclarationUsage.PositionTransformed, 0),
new VertexElement(0, 16, DeclarationType.Color, DeclarationMethod.Default, DeclarationUsage.Color, 0),
VertexElement.VertexDeclarationEnd
};
var vertexDecl = new VertexDeclaration(device, vertexElems);
RenderLoop.Run(form, () =>
{
device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);
device.BeginScene();
device.SetStreamSource(0, vertices, 0, 20);
device.VertexDeclaration = vertexDecl;
device.DrawPrimitives(PrimitiveType.TriangleList, 0, 1);
device.EndScene();
device.Present();
});
}
示例10: Game
public Game()
{
renderForm = new RenderForm("My first SharpDX app");
renderForm.ClientSize = new Size(Width, Height);
renderForm.AllowUserResizing = false;
InitializeDeviceResources();
}
示例11: GraphicSystem
public GraphicSystem(RenderLoop.RenderCallback LogicMethod, RenderLoop.RenderCallback RenderMethod)
{
_logicMethod = LogicMethod;
_renderMethod = RenderMethod;
_renderForm = new RenderForm();
_graphicsDevice = new GraphicsDevice(this);
_graphicsDevice.CreateDevice(_renderForm.Handle);
}
示例12: Main
static void Main()
{
var form = new RenderForm("KinectLight");
form.Size = new System.Drawing.Size(1920,1200);
var desc = new SwapChainDescription()
{
BufferCount = 1,
ModeDescription = new ModeDescription(form.ClientSize.Width, form.ClientSize.Height, new Rational(60, 1), Format.R8G8B8A8_UNorm),
IsWindowed = true,
OutputHandle = form.Handle,
SampleDescription = new SampleDescription(1, 0),
SwapEffect = SwapEffect.Discard,
Usage = Usage.RenderTargetOutput
};
SharpDX.Direct3D10.Device1 device;
SwapChain swapChain;
SharpDX.Direct3D10.Device1.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.BgraSupport, desc, SharpDX.Direct3D10.FeatureLevel.Level_10_1, out device, out swapChain);
var d2dFactory = new SharpDX.Direct2D1.Factory();
var surface = Surface.FromSwapChain(swapChain, 0);
RenderTarget dc = new RenderTarget(d2dFactory, surface, new RenderTargetProperties(new PixelFormat(Format.Unknown, AlphaMode.Premultiplied)));
MainGame.Instance.Height = form.ClientSize.Height;
MainGame.Instance.Width = form.ClientSize.Width;
GameTime gameTime = new GameTime();
var config = new HttpSelfHostConfiguration("http://localhost:8080");
config.Routes.MapHttpRoute(
"API Default", "api/{controller}/{action}/{name}",
new { id = RouteParameter.Optional });
HttpSelfHostServer server = new HttpSelfHostServer(config);
server.OpenAsync().Wait();
RenderLoop.Run(form, () =>
{
gameTime.StartFrame();
MainGame.Instance.Update(gameTime);
dc.BeginDraw();
dc.Clear(Colors.White);
MainGame.Instance.Render(dc);
var res = dc.EndDraw();
swapChain.Present(1, PresentFlags.None);
//Thread.Sleep(1);
});
server.Dispose();
MainGame.Instance.Dispose();
dc.Dispose();
surface.Dispose();
d2dFactory.Dispose();
device.Dispose();
swapChain.Dispose();
}
示例13: Main
private static void Main()
{
RenderForm form = new RenderForm("Galaxies - test");
Global._G.form = form;
form.ClientSize = new System.Drawing.Size(1280, 720);// 2540, 1550);
//form.ClientSize = new System.Drawing.Size(2540, 1550);
form.MouseDown += new System.Windows.Forms.MouseEventHandler(form_MouseDown);
form.MouseUp += new System.Windows.Forms.MouseEventHandler(form_MouseUp);
form.MouseMove += new System.Windows.Forms.MouseEventHandler(form_MouseMove);
form.MouseWheel += new System.Windows.Forms.MouseEventHandler(form_MouseWheel);
form.Resize += new EventHandler(form_Resize);
Global._G.camera = new Camera(1, form.ClientSize.Width, form.ClientSize.Height);
#if DEBUG
Configuration.EnableObjectTracking = true; // some sharpDX COM object tracking that slows performance.
#endif
Global._G.InitDX(form);
Mesh mesh = new Mesh();
mesh.MakeLatLonSphere2(64, 64);
// Prepare All the stages
Global._G.context.Rasterizer.SetViewports(new Viewport(0, 0, form.ClientSize.Width, form.ClientSize.Height, 0.0f, 1.0f));
Global._G.context.OutputMerger.SetTargets(Global._G.depthView, Global._G.renderView);
Global._G.shaderParams.sunDir = new Vector4(Vector3.Normalize(new Vector3(-1, -1, 1)), 1);
Global._G.shaderParams.sunColor = new Vector4(5.25f, 4.0f, 2.75f, 1);
Global._G.camera.SetupCamera();
// Use clock
var clock = new Stopwatch();
clock.Start();
// Main loop
RenderLoop.Run(form, () =>
{
var time = clock.ElapsedMilliseconds / 1000.0f;
// Clear views
Global._G.context.ClearDepthStencilView(Global._G.depthView, DepthStencilClearFlags.Depth, 1.0f, 0);
Global._G.context.ClearRenderTargetView(Global._G.renderView, SharpDX.Color.Black);
Global._G.shaderParams.world = Matrix.RotationY(time * 0.02f);// Matrix.Identity;// Matrix.RotationX(time) * Matrix.RotationY(time * 2) * Matrix.RotationZ(time * .7f);
Global._G.shaderParams.world.Transpose();
Global._G.context.UpdateSubresource(ref Global._G.shaderParams, Global._G.constantBuffer);
// Draw the cube
mesh.Render();
// Present!
Global._G.swapChain.Present(0, PresentFlags.None);
});
// Release all resources
Global._G.ShutdownDX();
}
示例14: CreateWindow
private void CreateWindow()
{
_form = new RenderForm(ConfigurationManager.Config.Title)
{
ClientSize = new Size(ConfigurationManager.Config.ScreenSize.X, ConfigurationManager.Config.ScreenSize.Y),
FormBorderStyle = FormBorderStyle.FixedSingle
};
_form.Show();
_form.Name = "Alpha";
}
示例15: Main
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
RenderForm form = new RenderForm("Kinect color sample");
RenderDevice device = new RenderDevice(SharpDX.Direct3D11.DeviceCreationFlags.BgraSupport);
RenderContext context = new RenderContext(device);
DX11SwapChain swapChain = DX11SwapChain.FromHandle(device, form.Handle);
KinectSensor sensor = KinectSensor.GetDefault();
sensor.Open();
bool doQuit = false;
bool doUpload = false;
ColorRGBAFrameData currentData = null;
DynamicColorRGBATexture colorTexture = new DynamicColorRGBATexture(device);
KinectSensorColorRGBAFrameProvider provider = new KinectSensorColorRGBAFrameProvider(sensor);
provider.FrameReceived += (sender, args) => { currentData = args.FrameData; doUpload = true; };
form.KeyDown += (sender, args) => { if (args.KeyCode == Keys.Escape) { doQuit = true; } };
RenderLoop.Run(form, () =>
{
if (doQuit)
{
form.Dispose();
return;
}
if (doUpload)
{
colorTexture.Copy(context, currentData);
doUpload = false;
}
context.RenderTargetStack.Push(swapChain);
device.Primitives.ApplyFullTri(context, colorTexture.ShaderView);
device.Primitives.FullScreenTriangle.Draw(context);
context.RenderTargetStack.Pop();
swapChain.Present(0, SharpDX.DXGI.PresentFlags.None);
});
swapChain.Dispose();
context.Dispose();
device.Dispose();
colorTexture.Dispose();
provider.Dispose();
sensor.Close();
}