ENTENDENDO DIRECT X
Option Explicit
'API functions
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
'DirectX variables
Dim DirectX As DirectX7 'Grandpa!
Dim DirectDraw As DirectDraw7 'Daddy!
Dim Principal As DirectDrawSurface7 'Front surface (the screen)
Dim PlanoVirtual As DirectDrawSurface7 'Flipping Surface
Dim FotoEstatica As DirectDrawSurface7
Dim FotoDinamica As DirectDrawSurface7
Dim Foto1 As DirectDrawSurface7
Dim Foto2 As DirectDrawSurface7
'Some constants
Const LarguraTela = 800
Const AlturaTela = 600
Const Bits = 32
Const LarguraFoto = 68
Const AlturaFoto = 104
Const Velocidade = 4
'Const COLOUR_KEY = 0
'Our permanent rectangles
Dim JanelaPrincipal As RECT 'Rectangle the size of the screen
'Our object's coordinates
Dim X As Integer
Dim Y As Integer
'Keyboard stuff
Dim Esquerda As Boolean 'Is the left arrow-key depressed?
Dim Direita As Boolean 'Is the right arrow-key depressed?
Dim Baixo As Boolean 'Is the down arrow-key depressed?
Dim Cima As Boolean 'Is the up arrow-key depressed?
'Program flow variables
Dim Continua As Boolean 'Is the main loop still running?
Dim Tempo As Long 'Our timer variable
Dim Contador As Integer 'acumulador de frames por segundo
Dim Quantidade As Integer 'mostra os frames calculados
'Blit data
Private Const BLITTYPE_NUM = 7 'How many different types are we using? (Zero based)
Dim mbytBlitType As Byte 'What manner of blit?
Dim NomeCopia As String 'And what is she called?
Dim TipoCopia As Long 'What's the associated constant value?
'Hardware capability storage
Dim mblnROPCap(BLITTYPE_NUM) As Boolean 'Can the video card handle this ROP code?
Private Sub Form_Load()
Dim ddsdMain As DDSURFACEDESC2
Dim ddsdFlip As DDSURFACEDESC2
Dim ddsdObjects As DDSURFACEDESC2
Dim i As Integer
'Initialize DirectDraw
Set DirectX = New DirectX7
Set DirectDraw = DirectX.DirectDrawCreate("")
'Set the cooperative level (Fullscreen exclusive)
DirectDraw.SetCooperativeLevel frmMain.hWnd, DDSCL_FULLSCREEN Or DDSCL_EXCLUSIVE
'Set the resolution
DirectDraw.SetDisplayMode LarguraTela, AlturaTela, Bits, 0, DDSDM_DEFAULT
'Describe the flipping chain architecture we'd like to use
ddsdMain.lFlags = DDSD_CAPS Or DDSD_BACKBUFFERCOUNT
ddsdMain.lBackBufferCount = 1
ddsdMain.ddsCaps.lCaps = DDSCAPS_COMPLEX Or DDSCAPS_FLIP Or DDSCAPS_PRIMARYSURFACE
'Create the primary surface
Set Principal = DirectDraw.CreateSurface(ddsdMain)
'Create the backbuffer
ddsdFlip.ddsCaps.lCaps = DDSCAPS_BACKBUFFER
Set PlanoVirtual = Principal.GetAttachedSurface(ddsdFlip.ddsCaps)
'Set the text colour for the backbuffer
PlanoVirtual.SetForeColor vbBlack
PlanoVirtual.SetFontTransparency True
'Set our "moving object" surface in system memory!
ddsdObjects.lFlags = DDSD_CAPS Or DDSD_HEIGHT Or DDSD_WIDTH
ddsdObjects.ddsCaps.lCaps = DDSCAPS_SYSTEMMEMORY Or DDSCAPS_OFFSCREENPLAIN
ddsdObjects.lHeight = AlturaFoto
ddsdObjects.lWidth = LarguraFoto
Set FotoDinamica = DirectDraw.CreateSurfaceFromFile(App.Path & "\moving.bmp", ddsdObjects)
'Allow the others to be placed by DX (likely in vidmem)
ddsdObjects.ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN
Set FotoEstatica = DirectDraw.CreateSurfaceFromFile(App.Path & "\center.bmp", ddsdObjects)
Set Foto1 = DirectDraw.CreateSurfaceFromFile(App.Path & "\planet1.bmp", ddsdObjects)
Set Foto2 = DirectDraw.CreateSurfaceFromFile(App.Path & "\05.bmp", ddsdObjects)
'Create our screen-sized rectangle
JanelaPrincipal.Bottom = AlturaTela
JanelaPrincipal.Right = LarguraTela
'Set the blit data
mbytBlitType = 0
NomeCopia = "vbSrcPaint"
TipoCopia = vbSrcPaint
'Store the hardware caps
For i = 0 To BLITTYPE_NUM
mblnROPCap(i) = TestROP(PlanoVirtual, TipoCopia)
MudaTipoCopia
Next i
'Start the main loop!
MainLoop
End Sub
virei e revirei esse código... mas não consigo setar uma figura diferente das padrões... eu gostaria de colocar um cenário... mas num consigo alguém pode me explicar passo a passo como que se usa uma variável do tipo DirectDrawSurface7
e todos os seus métodos...
código retirado de um dos links passados por ese fórum nos tópicos sobre directX
Nem entendi tb
???
quero em portugues saber todos os padroes da variavel
blt
fastblt
set...
etc
e setar um cenario como fundo dentro do mainloop... achu q eh la q coloca
quero em portugues saber todos os padroes da variavel
blt
fastblt
set...
etc
e setar um cenario como fundo dentro do mainloop... achu q eh la q coloca
Tópico encerrado , respostas não são mais permitidas