Jump to content
  • Advertisement
Sign in to follow this  
Yashwinder

SlimDX

This topic is 2776 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have coded a video player using directx API and coded a scrolling tex using slimDX.D3D9 and have incorporated them into a single project. But there is a problem that the video and text scrolling is not happening simultaneously in the single form window.
I am also posting the code that I have made.

using System;
using System.Drawing;
using System.Windows.Forms;
using SlimDX;
using SlimDX.Direct3D9;
using SlimDX.SampleFramework;


using SlimDX.Windows;
using Microsoft.DirectX.AudioVideoPlayback;
namespace SlimScroller{
class Program:Sample
{
static Video video;
static String filepath;
static String str = "Moving Text";
[STAThread]
static void Main()
{


var form = new RenderForm("SlimScroller");
PictureBox pic = new PictureBox();
OpenFileDialog ofd = new OpenFileDialog();
ofd.ShowDialog();

filepath = ofd.FileName;
video = new Video(filepath);
// video.Owner = form; (Hides the scrolling text if given this statement )


var d3dpp = new PresentParameters();
d3dpp.BackBufferWidth = 1280;
d3dpp.BackBufferHeight = 720;
d3dpp.BackBufferCount = 1;
d3dpp.PresentationInterval = PresentInterval.One;
d3d.PresentFlags = PresentFlags.Video;
d3dpp.Windowed = true;


var device = new Device(new Direct3D(), 0, DeviceType.Hardware, form.Handle, CreateFlags.HardwareVertexProcessing, d3dpp);

var fontSprite = new Sprite(device);


var font = new SlimDX.Direct3D9.Font(device, 100, 0, FontWeight.ExtraLight, 1, false, CharacterSet.Default, Precision.Default, FontQuality.ClearTypeNatural, PitchAndFamily.Script, "tahoma");


var intXPos = 1000;


MessagePump.Run(form, () =>
{

device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 50.0f,0);

device.BeginScene();

if (intXPos < -500) { intXPos = 1000; };
intXPos = intXPos - 1;
fontSprite.Begin(SpriteFlags.AlphaBlend);

font.DrawString(fontSprite, str, new Rectangle(0, 475, 2000,200), DrawTextFormat.Left, Color.Red);
fontSprite.Transform = Matrix.Translation(intXPos, 0, 0.50f);
fontSprite.End();


device.EndScene();


device.Present();


});


foreach (var item in ObjectTable.Objects)
item.Dispose();








}


}


}

Share this post


Link to post
Share on other sites
Advertisement
Posted · Hidden
Hidden

I have coded a video player using directx API and coded a scrolling tex using slimDX.D3D9 and have incorporated them into a single project. But there is a problem that the video and text scrolling is not happening simultaneously in the single form window.
I am also posting the code that I have made.

using System;
using System.Drawing;
using System.Windows.Forms;
using SlimDX;
using SlimDX.Direct3D9;
using SlimDX.SampleFramework;


using SlimDX.Windows;
using Microsoft.DirectX.AudioVideoPlayback;
namespace SlimScroller{
class Program:Sample
{
static Video video;
static String filepath;
static String str = "Moving Text";
[STAThread]
static void Main()
{


var form = new RenderForm("SlimScroller");
PictureBox pic = new PictureBox();
OpenFileDialog ofd = new OpenFileDialog();
ofd.ShowDialog();

filepath = ofd.FileName;
video = new Video(filepath);
// video.Owner = form; (Hides the scrolling text if given this statement )


var d3dpp = new PresentParameters();
d3dpp.BackBufferWidth = 1280;
d3dpp.BackBufferHeight = 720;
d3dpp.BackBufferCount = 1;
d3dpp.PresentationInterval = PresentInterval.One;
d3d.PresentFlags = PresentFlags.Video;
d3dpp.Windowed = true;


var device = new Device(new Direct3D(), 0, DeviceType.Hardware, form.Handle, CreateFlags.HardwareVertexProcessing, d3dpp);

var fontSprite = new Sprite(device);


var font = new SlimDX.Direct3D9.Font(device, 100, 0, FontWeight.ExtraLight, 1, false, CharacterSet.Default, Precision.Default, FontQuality.ClearTypeNatural, PitchAndFamily.Script, "tahoma");


var intXPos = 1000;


MessagePump.Run(form, () =>
{

device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 50.0f,0);

device.BeginScene();

if (intXPos < -500) { intXPos = 1000; };
intXPos = intXPos - 1;
fontSprite.Begin(SpriteFlags.AlphaBlend);

font.DrawString(fontSprite, str, new Rectangle(0, 475, 2000,200), DrawTextFormat.Left, Color.Red);
fontSprite.Transform = Matrix.Translation(intXPos, 0, 0.50f);
fontSprite.End();


device.EndScene();


device.Present();


});


foreach (var item in ObjectTable.Objects)
item.Dispose();








}


}


}

Share this post


Link to post
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!