How to play Text animation while playing a video in slimdx or Directx

541c7040fb34352ce0d9cda14be6201e
0
yashwinder 101 May 04, 2011 at 10:17

Hi
I want to incorporate text and video simultaneously in my code but don’t know hoe to do it while coding with slimdx or directx.

Please help me out to do so.
Thank you.

2 Replies

Please log in or register to post a reply.

541c7040fb34352ce0d9cda14be6201e
0
yashwinder 101 May 05, 2011 at 08:31

Hi I am posting my code for playing a video and scrolling a text but both of them are being displayed in different windows, please help me out to integrate both of them.

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

using SlimDX.Windows;
using Microsoft.DirectX.AudioVideoPlayback;
namespace SlimScroller{
static class Program
{
static Video video;
static String filepath;
static String str = “Moving Text”;
[STAThread]
static void Main()
{
PictureBox pic = new PictureBox();
OpenFileDialog ofd = new OpenFileDialog();
ofd.ShowDialog();
filepath = ofd.FileName;
video = new Video(filepath, true);

var form = new RenderForm(“SlimScroller”);

//var form1 = new RenderForm(“Video player”);
//video.Owner = form;
//form.AddOwnedForm(form1);
var display=new DisplayModeEx();
display.Height=form.Height;
display.Width=form.Width;
display.RefreshRate=12;

var d3dpp = new PresentParameters();

d3dpp.BackBufferWidth = form.Width;
d3dpp.BackBufferHeight = form.Height;
d3dpp.PresentationInterval = PresentInterval.One;
d3dpp.PresentFlags = PresentFlags.Video;

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

//var device1 = new Device(new Direct3D(), 0, DeviceType.Hardware, form1.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 - 8;
fontSprite.Begin(SpriteFlags.AlphaBlend);

font.DrawString(fontSprite,str, new Rectangle(0, 475, 2000,500 ), 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();

}

}

}

8676d29610e6c98d6dd2d9c38528cd9c
0
alphadog 101 May 05, 2011 at 11:57

Your best bet is, as per the SlimDX homepage, to post on:

http://www.gamedev.net/forum/10-directx-and-xna/

It’s hit-or-miss on our forums for help on a specific platform.

Also, use code tags for posting code.