Direct3DRM on fullscreen

Hello, i put all my points on this question because its very rare and i need the answer urgent.
    I need to make a fullscreen aplication using Direct3D Retained Mode. I was trying with DirectX7 Visual Basic's TLB, but it makes a unknow error when I try to create a Direct3DRMDevice from DirectDraw's Fullscreen Back Surface.
Any Suggestions???
Thanks:    Marginal

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

marginalAuthor Commented:
manijamin: I already downloaded that example, and it works!, but only on C++.
 The article explain a bug on Direct3D on windowed mode, i need how to make a call to Direct3DRM.CreateDeviceformSurface (...) work, because under Visual Basic that function crash, or any another method to create a Direct3DRM application on fullscreen mode (to Control the Screen Resolution).
  Thanks     Marginal
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

Don't know, but a 2000 point question makes me very curious. Mind if a hitch a ride?
I thought you had an answer there :O)

couldn't find anything, except for a C++ sample on the directX site from MS, even Technet wasn't that helpful, maybe i've been out of this for too long....
bruintje, you know very well there are no Answers. Just Questions.
until i'll work out that DX solution... you say that all you need for a start is a full screen.
well, how about starting a new VB project (Form1 generated by default), then set in design time this Form1 props :

1. BackColor - select Black color
2. BorderStyle - select 0-None
3. Caption     - Set it empty
4. ControlBox  - False
5. WindowState - select 2-maximized

run it.

now - you have a Full Black Screen Application.
can't it be the basis for further development ???
now, strickly DirectX :

i hope you are talking DirextX 7.0 here, since that's the one i'm talking about.
if so - i hope you are not on winNT, since you can't make it there. i'm testing it on win95 machine now.
have you installed DirectX7.0 ?
have you installed the 122MB DirectX7.0 SDK ?????

i did - and trying the tutorials that are in the VB section of the SDK - i've no truble running those exampls which creat and run on full screen.

i'm talking about the tutorials that are in this locations :

1. ...mssdk\samples\multimedia\VBsamples\D3DRM\src\teapot\teapot.vbp  

2. ...mssdk\samples\multimedia\VBsamples\DDRAW\src\tutorial3\tutorial3.vbp

3. ...mssdk\samples\multimedia\VBsamples\DDRAW\src\tutorial4\tutorial4.vbp


this examples works just fine.
it's all VB code.
if you dont have it - post your email and i can send you them source code.

for now, here is the source code of the no 1. example. :

(you won't be able to run it, since you don't have the Graphic relevant file(s) referencedd in the code, BUT you may LEARN from the code itself) :


' Sample showing how to use the shadow object as well as going full screen in RM
Option Explicit

Dim DX As New DirectX7
Dim DD As DirectDraw4
Dim ddClipper As DirectDrawClipper
Dim RM As Direct3DRM3

Dim SurfPrimary As DirectDrawSurface4
Dim SurfBack As DirectDrawSurface4
Dim DDCapsBack As DDSCAPS2
Dim rmDevice As Direct3DRMDevice3
Dim rmViewport As Direct3DRMViewport2
Dim rootFrame As Direct3DRMFrame3
Dim lightFrame As Direct3DRMFrame3
Dim cameraFrame As Direct3DRMFrame3
Dim objectFrame As Direct3DRMFrame3
Dim light As Direct3DRMLight
Dim shadow_light As Direct3DRMLight
Dim meshBuilder As Direct3DRMMeshBuilder3
Dim object As Direct3DRMMeshBuilder3
Dim shadow As Direct3DRMShadow2
Dim bRunning As Boolean
Dim CurModeActiveStatus As Boolean
Dim bRestore As Boolean

Sub InitDX()

    ' create the ddraw object and set the cooperative level
    Set DD = DX.DirectDraw4Create("")
    DD.SetCooperativeLevel MainFrm.hWnd, DDSCL_FULLSCREEN Or DDSCL_EXCLUSIVE
    ' this will be full-screen, so set the display mode
    DD.SetDisplayMode 640, 480, 16, 0, DDSDM_DEFAULT
    ' create the primary surface
    DDSDPrimary.lBackBufferCount = 1
    Set SurfPrimary = DD.CreateSurface(DDSDPrimary)
    ' get the back buffer
    Set SurfBack = SurfPrimary.GetAttachedSurface(DDCapsBack)
    ' Create the Retained Mode object
    Set RM = DX.Direct3DRMCreate()
    ' Now, create the device from the full screen DD surface
    Set rmDevice = RM.CreateDeviceFromSurface("IID_IDirect3DRGBDevice", DD, SurfBack, D3DRMDEVICE_DEFAULT)
    rmDevice.SetBufferCount 2
    rmDevice.SetTextureQuality D3DRMTEXTURE_NEAREST
End Sub

Sub InitScene(sMesh As String)
    ' Create the scene frames
    Set rootFrame = RM.CreateFrame(Nothing)
    Set cameraFrame = RM.CreateFrame(rootFrame)
    Set lightFrame = RM.CreateFrame(rootFrame)
    Set objectFrame = RM.CreateFrame(rootFrame)
    ' Set the background color
    rootFrame.SetSceneBackgroundRGB 0, 255, 255
    ' create & position lights and the viewport
    cameraFrame.SetPosition Nothing, 0, 0, -10
    Set rmViewport = RM.CreateViewport(rmDevice, cameraFrame, 0, 0, 640, 480)
    lightFrame.SetPosition Nothing, 2, 5, -10
    Set shadow_light = RM.CreateLightRGB(D3DRMLIGHT_POINT, 0.9, 0.8, 0.7)
    lightFrame.AddLight shadow_light
    Set light = RM.CreateLightRGB(D3DRMLIGHT_AMBIENT, 0.1, 0.1, 0.1)
    rootFrame.AddLight light
    ' create the mesh and load the teapot x file
    Set meshBuilder = RM.CreateMeshBuilder()
    meshBuilder.LoadFromFile sMesh, 0, 0, Nothing, Nothing
    ' make the shadow and enable alpha
    Set shadow = RM.CreateShadow(meshBuilder, shadow_light, 0, -3, 0, 0, 1, 0)
    shadow.SetOptions D3DRMSHADOW_TRUEALPHA

    ' add the visuals
    objectFrame.AddVisual meshBuilder
    objectFrame.AddVisual shadow
    'Have the object rotating
    objectFrame.SetRotation Nothing, 3, 3, 1, 0.45

End Sub

Sub RenderLoop()
    Dim t1 As Long
    Dim t2 As Long
    Dim delta As Single
    On Local Error Resume Next
    bRunning = True
    t1 = DX.TickCount()
    Do While bRunning = True
        ' this will keep us from trying to blt in case we lose the surfaces (alt-tab)
        bRestore = False
        Do Until ExModeActive
            bRestore = True
        ' if we lost and got back the surfaces, then restore them
        If bRestore Then
            bRestore = False
        End If
        rootFrame.Move 0.5
        rmViewport.Clear D3DRMCLEAR_TARGET Or D3DRMCLEAR_ZBUFFER ' clear the viewport
        rmDevice.Update   'blt the image to the screen
        rmViewport.Render rootFrame 'render to the device
        Call SurfBack.DrawText(10, 10, "D3DRM Full Screen with Alpha Shadow", False)
        Call SurfBack.DrawText(10, 30, "Click screen or hit ESC to exit", False)
        SurfPrimary.Flip Nothing, DDFLIP_WAIT
End Sub

Function ExModeActive() As Boolean
    Dim TestCoopRes As Long
    TestCoopRes = DD.TestCooperativeLevel
    If (TestCoopRes = DD_OK) Then
        ExModeActive = True
        ExModeActive = False
    End If
End Function

Sub FindMediaDir(sFile As String)
    On Local Error Resume Next
    If Mid$(App.Path, 2, 1) = ":" Then
        ChDrive Mid$(App.Path, 1, 1)
    End If
    ChDir App.Path
    If Dir$(sFile) = "" Then
        ChDir "..\media"
    End If
    If Dir$(sFile) = "" Then
        ChDir "..\..\media"
    End If
End Sub

Private Sub Form_Load()
    FindMediaDir "teapot.x"
    InitScene "teapot.x"
End Sub

Sub EndIT()
    bRunning = False
    Call DD.RestoreDisplayMode
    Call DD.SetCooperativeLevel(Me.hWnd, DDSCL_NORMAL)
End Sub

Private Sub Form_KeyPress(KeyAscii As Integer)
    If KeyAscii = 27 Then ' if ESC is pressed
    End If
End Sub

Private Sub Form_Click()
End Sub

marginalAuthor Commented:
Uhmmmm.... Let me check it.

Actually, i didn't pass the "IID_IDirect3DRGBDevice" to the CreateDeviceFromSurface.
    Maybe thats the problem.

marginalAuthor Commented:
That example work's. Ok AnswerTheMan, i'll give you the points, but you know how to create the Direct3DRMDevice using Patrice Scribe's TLB???

Please post your Answer.
           Thanks a lot, Marginal
for 2000 points the answer to "Patrice Scribe's TLB" issue, should be positive....
Unfortunatly - i don't even know what it is.....

anyway, i advise you to download the DirectX7.0 SDK from MS directX site.
it's full of usefull examples and Help.

thank you.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
marginalAuthor Commented:
Well, Thanks anyway. Here are your Points
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.