[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 624
  • Last Modified:

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

0
marginal
Asked:
marginal
  • 4
  • 3
  • 2
  • +2
1 Solution
 
manojaminCommented:
0
 
manojaminCommented:
0
 
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
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
caraf_gCommented:
Don't know, but a 2000 point question makes me very curious. Mind if a hitch a ride?
0
 
bruintjeCommented:
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....
0
 
caraf_gCommented:
bruintje, you know very well there are no Answers. Just Questions.
0
 
AnswerTheManCommented:
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 ???
0
 
AnswerTheManCommented:
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 DDSDPrimary As DDSURFACEDESC2
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("")
    MainFrm.Show
    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.lFlags = DDSD_CAPS Or DDSD_BACKBUFFERCOUNT
    DDSDPrimary.ddsCaps.lCaps = DDSCAPS_PRIMARYSURFACE Or DDSCAPS_3DDEVICE Or DDSCAPS_COMPLEX Or DDSCAPS_FLIP
    DDSDPrimary.lBackBufferCount = 1
    Set SurfPrimary = DD.CreateSurface(DDSDPrimary)
           
    ' get the back buffer
    DDCapsBack.lCaps = DDSCAPS_BACKBUFFER
    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.SetQuality D3DRMLIGHT_ON Or D3DRMFILL_SOLID Or D3DRMRENDER_GOURAUD
    rmDevice.SetTextureQuality D3DRMTEXTURE_NEAREST
    rmDevice.SetRenderMode D3DRMRENDERMODE_BLENDEDTRANSPARENCY
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
        DoEvents
       
        ' this will keep us from trying to blt in case we lose the surfaces (alt-tab)
        bRestore = False
        Do Until ExModeActive
            DoEvents
            bRestore = True
        Loop
   
        ' if we lost and got back the surfaces, then restore them
        DoEvents
        If bRestore Then
            bRestore = False
            DD.RestoreAllSurfaces
        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
    Loop
End Sub

Function ExModeActive() As Boolean
    Dim TestCoopRes As Long
   
    TestCoopRes = DD.TestCooperativeLevel
   
    If (TestCoopRes = DD_OK) Then
        ExModeActive = True
    Else
        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()
    Show
    DoEvents
    InitDX
    FindMediaDir "teapot.x"
    InitScene "teapot.x"
    RenderLoop
    End
End Sub


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

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

Private Sub Form_Click()
    EndIT
End Sub

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

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

                                                                   Marginal
0
 
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
0
 
AnswerTheManCommented:
for 2000 points the answer to "Patrice Scribe's TLB" issue, should be positive....
Unfortunatly - i don't even know what it is.....
sorry.

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

thank you.
0
 
marginalAuthor Commented:
Well, Thanks anyway. Here are your Points
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 4
  • 3
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now