Jump to content


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


2 replies to this topic

#1 yashwinder

    New Member

  • Members
  • Pip
  • 5 posts

Posted 04 May 2011 - 10:17 AM

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 yashwinder

    New Member

  • Members
  • Pip
  • 5 posts

Posted 05 May 2011 - 08:31 AM

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();








}

}

}

#3 alphadog

    DevMaster Staff

  • Moderators
  • 1716 posts

Posted 05 May 2011 - 11:57 AM

Your best bet is, as per the SlimDX homepage, to post on:
http://www.gamedev.n...irectx-and-xna/

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

Also, use code tags for posting code.
Hyperbole is, like, the absolute best, most wonderful thing ever! However, you'd be an idiot to not think dogmatism is always bad.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users