Problem displaying text in DirectX7
Problem displaying text in DirectX7
Problem displaying text in DirectX7
Problem displaying text in DirectX7
Problem displaying text in DirectX7
Problem displaying text in DirectX7 Problem displaying text in DirectX7 Problem displaying text in DirectX7 Problem displaying text in DirectX7 Problem displaying text in DirectX7 Problem displaying text in DirectX7 Problem displaying text in DirectX7 Problem displaying text in DirectX7
Problem displaying text in DirectX7 Problem displaying text in DirectX7
Problem displaying text in DirectX7
Go Back  Xtreme Visual Basic Talk > > > > Problem displaying text in DirectX7


Reply
 
Thread Tools Display Modes
  #1  
Old 02-02-2004, 10:18 PM
BuddyR BuddyR is offline
Newcomer
 
Join Date: Nov 2003
Posts: 10
Question Problem displaying text in DirectX7


Can anybody tell me how to display text in Direct3d7:RM in windowed mode? A got a heap of samples, but all they work only in fullscreen mode (via backbuffer etc...)
Reply With Quote
  #2  
Old 02-03-2004, 03:41 AM
JimCamel's Avatar
JimCamelProblem displaying text in DirectX7 JimCamel is offline
Mostly Absent

* Expert *
 
Join Date: Jun 2002
Location: Christchurch, New Zealand
Posts: 2,006
Default

Is this a question for VB .Net or VB 6?

But the idea is basically, when you call your 3dDevice.EndScene, it will draw your 3D Scene onto the surface which you have created the 3DDevice with in the first place (using the CreateDevice call). You can then draw your text onto that surface using the Surface.DrawText code.

And besides, even if you're using windowed mode you should still be using some sort of backbuffering method to avoid flickering in your drawing.
__________________
Sometimes it happens feelings die, Whole years are lost in the blink of an eye
We once had it all but event conspired, Sometimes
Now that it's over, it is through, It gets me everytime I think of you
Sometimes It happens, feelings die, Sometimes
Reply With Quote
  #3  
Old 02-03-2004, 04:00 AM
BuddyR BuddyR is offline
Newcomer
 
Join Date: Nov 2003
Posts: 10
Default

First of all, thanks for a soon post!
As for my version of VB - it's VB 6.
Your post clarified many things to me (I'm still a novice to D3D), but still I got questions about this problem.
Coud you post just a tiny piece of code here?
Reply With Quote
  #4  
Old 02-04-2004, 02:01 AM
JimCamel's Avatar
JimCamelProblem displaying text in DirectX7 JimCamel is offline
Mostly Absent

* Expert *
 
Join Date: Jun 2002
Location: Christchurch, New Zealand
Posts: 2,006
Default

If you want to post your project here, I'd be happy to add the appropriate code (with comments) to show you how it's done.
__________________
Sometimes it happens feelings die, Whole years are lost in the blink of an eye
We once had it all but event conspired, Sometimes
Now that it's over, it is through, It gets me everytime I think of you
Sometimes It happens, feelings die, Sometimes
Reply With Quote
  #5  
Old 02-04-2004, 02:53 AM
BuddyR BuddyR is offline
Newcomer
 
Join Date: Nov 2003
Posts: 10
Default

Thanks, JimCamel!
So, here we go. This is my code (I omit everything that is not realted to d3d):

First, here goes a module (mdlDirect3DRM.bas) with some initializations etc.
Code is almost (except MeshBuilders) completely not mine - I borrowed it from some tutorial.

Option Explicit

Public dx As New DirectX7
Public dd7 As DirectDraw7
Public d3d As Direct3D7
Public d3dRm As Direct3DRM3
Public ddsd As DDSURFACEDESC2
Public Caps As DDSCAPS2
Public Device As Direct3DDevice7
Public Scene As Direct3DRMFrame3
Public Camera As Direct3DRMFrame3
Public World As Direct3DRMFrame3
Public MeshBuilder(16) As Direct3DRMMeshBuilder3
Public Viewport As Direct3DRMViewport2
Public Clipper As DirectDrawClipper
Public driverGuid As String
Public renderGuid As String
Public Running As Boolean
Public PickArray As Direct3DRMPickArray
Public Desc As D3DRMPICKDESC

Public Sub InitWindowed(Window As Form)
Set dd7 = dx.DirectDrawCreate(driverGuid)
Set Clipper = dd7.CreateClipper(0)
Clipper.SetHWnd Window.hWnd
Set d3dRm = dx.Direct3DRMCreate
Set Device = d3dRm.CreateDeviceFromClipper(Clipper, renderGuid, Window.ScaleWidth, Window.ScaleHeight)
Set Scene = d3dRm.CreateFrame(Nothing)
Set Camera = d3dRm.CreateFrame(Scene)
Set Viewport = d3dRm.CreateViewport(Device, Camera, 0, 0, Device.GetWidth, Device.GetHeight)
Scene.AddLight d3dRm.CreateLight(D3DRMLIGHT_AMBIENT, dx.CreateColorRGB(1, 1, 1))
Set MeshBuilder(0) = d3dRm.CreateMeshBuilder
Set MeshBuilder(1) = d3dRm.CreateMeshBuilder
Set MeshBuilder(2) = d3dRm.CreateMeshBuilder
End Sub

Private Sub Main()
frmDriver.Show vbModal
frmMain.Show
End Sub

Public Sub DestroyEverything()
Set Viewport = Nothing
Set Device = Nothing
Set d3dRm = Nothing
Set dd4 = Nothing
Set dd7 = Nothing
End Sub

Now, here goes Form code (Form1):

Option Explicit

Private Sub Form_Load()
Me.Show
mdlDirect3DRM.InitWindowed Me
SetMyDefaults
Running = True
Run
End Sub

Private Sub Form_KeyPress(KeyAscii As Integer)

Select Case KeyAscii
Case vbKeyEscape
Running = False
End Select
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
mdlDirect3DRM.DestroyEverything
End Sub

Private Sub Run()
Do While Running = True
DoEvents
d3dRm.Tick 1
Loop
End
End Sub

Private Sub SetMyDefaults()

CreateMyObject
Set World = d3dRm.CreateFrame(Scene)
World.AddVisual MeshBuilder(0)
World.AddVisual MeshBuilder(1)
World.AddVisual MeshBuilder(2)
World.SetRotation Nothing, 0, 1, 0, 0.003
Camera.SetPosition Nothing, 0, 0, -3.5
Device.SetQuality D3DRMRENDER_GOURAUD

End Sub

Private Sub CreateMyObject()

Dim Tex As Direct3DRMTexture3
Dim vect1, vect2 As D3DVECTOR
Dim Wrap As Direct3DRMWrap, Box As D3DRMBOX
Dim maxy As Single, miny As Single, height As Single
ChDir App.Path
MeshBuilder(0).LoadFromFile "top.x", 0, D3DRMLOAD_FROMFILE, Nothing, Nothing
MeshBuilder(0).SetName "Top"
MeshBuilder(1).LoadFromFile "bardis.x", 0, D3DRMLOAD_FROMFILE, Nothing, Nothing
MeshBuilder(1).SetName "Tank"
MeshBuilder(2).LoadFromFile "bottom.x", 0, D3DRMLOAD_FROMFILE, Nothing, Nothing
MeshBuilder(2).SetName "Bottom"
MeshBuilder(0).ScaleMesh 0.12, 0.12, 0.12
MeshBuilder(1).ScaleMesh 0.12, 0.12, 0.12
MeshBuilder(2).ScaleMesh 0.12, 0.12, 0.12
MeshBuilder(0).SetColorRGB 0, 200, 0
MeshBuilder(1).SetColorRGB 0, 200, 0
MeshBuilder(2).SetColorRGB 0, 200, 0
MeshBuilder(0).Translate 0, 0.66, 0
MeshBuilder(1).Translate 0, 2, 0
MeshBuilder(2).Translate 0, -0.84, 0

End Sub

That's all, the rest is interface and different stuff.

I'd be very grateful if you teach me how to DrawText. I plan to put text not on meshes, just aside from them (that'll be some their numeric parameters).

Also, could you explain me BackCulling related stuff using my example? I need to see not only front sides of my triangles, but also their back sides.

Thanks a lot !!
Reply With Quote
  #6  
Old 02-04-2004, 04:55 AM
BuddyR BuddyR is offline
Newcomer
 
Join Date: Nov 2003
Posts: 10
Default

Oops, a couple of mistakes in code above:

1. in module,
Public Device As Direct3DRMDevice3 (not Direct3DRMDevice7)

2. there's one more form, frmDriver. It's used to select driver.

Option Explicit

Dim EnumVideo As DirectDrawEnum
Dim EnumDevice As Direct3DEnumDevices
Dim i As Integer

Private Sub cmbVideo_Click()
txtDriver.Text = EnumVideo.GetName(cmbVideo.ListIndex + 1)
cmdOK.Enabled = False
lstDevice.Clear
If cmbVideo.ListIndex = 0 Then
Set dd7 = dx.DirectDrawCreate(EnumVideo.GetGuid(cmbVideo.ListIndex + 1))
Set d3d = dd7.GetDirect3D
Set EnumDevice = d3d.GetDevicesEnum
For i = 1 To EnumDevice.GetCount
lstDevice.AddItem EnumDevice.GetDescription(i)
Next i
Set d3d = Nothing
Set dd7 = Nothing
Else
lstDevice.AddItem "3D Acceleration through Direct3D HAL"
End If
End Sub

Private Sub cmdCancel_Click()
If MsgBox("Really quit?", vbYesNo, "") = vbYes Then
End
End If
End Sub

Private Sub cmdOK_Click()

If cmbVideo.ListIndex = 0 Then
mdlDirect3DRM.driverGuid = ""
mdlDirect3DRM.renderGuid = EnumDevice.GetGuid(lstDevice.ListIndex + 1)
Else
mdlDirect3DRM.driverGuid = EnumVideo.GetGuid(cmbVideo.ListIndex + 1)
mdlDirect3DRM.renderGuid = "IID_IDirect3DHALDevice"
End If
Unload Me
End Sub

Private Sub Form_Load()
Set EnumVideo = dx.GetDDEnum
For i = 1 To EnumVideo.GetCount
cmbVideo.AddItem EnumVideo.GetDescription(i)
Next i
cmbVideo.ListIndex = 0
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Set EnumVideo = Nothing
Set EnumDevice = Nothing
Set d3d = Nothing
Set dd4 = Nothing
Set dd7 = Nothing
End Sub

Private Sub lstDevice_Click()
cmdOK.Enabled = True
End Sub
Reply With Quote
  #7  
Old 02-04-2004, 04:29 PM
JimCamel's Avatar
JimCamelProblem displaying text in DirectX7 JimCamel is offline
Mostly Absent

* Expert *
 
Join Date: Jun 2002
Location: Christchurch, New Zealand
Posts: 2,006
Default

When I said to post your project I actually meant the files zipped up, not the source code, but anyway...

Okay, you're creating your D3D Retained Mode object by using the CreateDeviceFromClipper method. If you want to easily put text in, you should use the CreateDeviceFromSurface method, and create a primary surface to use as the surface to create it from. That way you can then draw your scene onto that surface, then draw your text on afterwards.

However, you're using Retained Mode, which I'm not entirely familiar with (all my work recently has been with Immediate Mode), so I probably can't offer you much help other than that sorry.
__________________
Sometimes it happens feelings die, Whole years are lost in the blink of an eye
We once had it all but event conspired, Sometimes
Now that it's over, it is through, It gets me everytime I think of you
Sometimes It happens, feelings die, Sometimes
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Bullettin problem pckm_123 Word, PowerPoint, Outlook, and Other Office Products 1 12-03-2003 06:59 AM
Probably really basic problem with displaying text MatthewH86 General 2 07-31-2003 04:49 AM
Problem with Text Box: Displaying Text and Scroll Bar Steven_Teo General 1 04-09-2003 12:40 AM
Wraping text around an image? Serevinus Web Programming 7 06-20-2002 01:46 PM
Problem displaying text with Direct3D 8 Roy Lazarovich DirectX 1 03-31-2002 02:10 PM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Problem displaying text in DirectX7
Problem displaying text in DirectX7
Problem displaying text in DirectX7 Problem displaying text in DirectX7
Problem displaying text in DirectX7
Problem displaying text in DirectX7
Problem displaying text in DirectX7 Problem displaying text in DirectX7 Problem displaying text in DirectX7 Problem displaying text in DirectX7 Problem displaying text in DirectX7 Problem displaying text in DirectX7 Problem displaying text in DirectX7
Problem displaying text in DirectX7
Problem displaying text in DirectX7
 
Problem displaying text in DirectX7
Problem displaying text in DirectX7
 
-->