Rapid-Q Documentation by William Yu (c)1999, appended by John Kelly Appendix B: QDXSCREEN

QDXSCREEN Component

QDXScreen allows you to create a Direct Draw/Direct3D screen for all DirectX components. All drawing is done on the off-screen buffer, so nothing is displayed until you flip to it. If you use FullScreen=True make sure border style is bsNone. QDXScreen causes problems with QForm.OnClose and cannot return when the user clicks the 'X' close button.. Windows only (DirectX version 6.0 or higher) 

QDXScreen Properties
FieldTypeR/WDefault




AlignINTEGERRWalNone
AllowStretchINTEGERRWTrue
AutoSizeINTEGERRWTrue
BitCountINTEGERRW8
ColorINTEGERRW
CursorINTEGERRWcrDefault
EnabledINTEGERRWTrue
FontQFONTW
See QFont 
FONT.BOLD		FONT.COLOR 		FONT.FONTNAME
FONT.NAME		FONT.HANDLE		FONT.SIZE
FONT.CHARSET		FONT.ADDSTYLES		FONT.PITCH
FONT.DELSTYLES		FONT.ITALIC		FONT.FONTCOUNT
FONT.UNDERLINE		FONT.STRIKEOUT
FullScreenINTEGERRWFalse
FullScreen = True, and make sure your form border style is bsNone. If  you don't it will temporarily change the screen resolution.  QDXScreen allows faster graphics than a QCANVAS because of direct writing to video memory. You can have menus, buttons, etc. with a DXscreen fullscreen **but** you must specify  qdxscreen.fullScreen = True before you do Form.ShowModal. Once you are in fullscreen mode, you can't toggle back to non-fullscreen  mode until the program ends. 
HeightINTEGERRW
HintSTRINGRW
LeftINTEGERRW
ParentQFORM/QPANEL/QTABCONTROL
The screen can be rapidly moved to another form by changing its Parent
W
Pixel2D ARRAY of INTEGER
This reads/writes color information to the screen. There is not the way to get the memory pointer of the screen buffer
RW
ShowHintINTEGERRWFalse
TopINTEGERRW
Use3DINTEGERRWFalse
UseHardwareINTEGER  (hardware acceleration, always try to use this)RWTrue
VisibleINTEGERRWTrue
WidthINTEGERRW

QDXScreen Methods
MethodTypeDescriptionParams




CircleSUB (x1%, y1%, x2%, y2%, c%, fill%)Draw & Fill Circle6
CopyRectSUB (D, Image, S)D and S are QRECTs, Image can be a QImage, QCanvas, or QBitmap3
DrawSUB (x%, y%, BMP)Draw Bitmap at (X,Y)3
FastPsetSUB (X1%, Y1%, C%)  not fully implemented? Direct write pixel at x, y3
FillSUB (Color%)Fill screen with color with BGR code
(&HFF = Blue, &HFF00 = Green, &HFF0000 = Red)
1
FillRectSUB (x1%, y1%, x2%, y2%, c%)Draw & Fill a rectangle5
FlipSUBCopies off-screen buffer to visible page, always flip to see it0
InitSUB (Width%, Height%)Create Screen2
LineSUB (x1%, y1%, x2%, y2%, c%)Draws a line5
PaintSUB (x%, y%, c%, borderc%)Fill Region4
PsetSUB (x%, y%, c%)Pixel Plot3
RectangleSUB (x1%, y1%, x2%, y2%, c%)Draws a rectangle5
ReleaseSUBForce update0
RotateSUB (xOrigin%, yOrigin%, Angle%)Rotates entire screen at specified origin3
RoundRectSUB (x1%, y1%, x2%, y2%, x3%, y3%, c%)Draws & Fills a rounded rectangle7
StretchDrawSUB (Rect AS QRECT, BMP)Draw BMP and stretch to fit inside Rect2
TextHeightFUNCTION (Text$) AS WORDReturns the height, in pixels, of Text$ string1
TextWidthFUNCTION (Text$) AS WORDReturns the width, in pixels, of Text$ string1
TextRectSUB (Rect AS QRECT, x%, y%, S$, fc%, bc%)Write text, and clip within region Rect6
TextOutSUB (x%, y%, S$, fc%, bc%)Writes text5

QDXScreen 3D Methods 
(also see
D3D constants)
MethodTypeDescriptionParams




AddLightSUB (Light AS QD3DLight)Add light to scene1
CameraLookAtSUB (F AS QD3DFrame, Constraint AS INTEGER)Fix frame and constrain rotation2
CreateFaceSUB (Face AS QD3DFace)Creates a face1
CreateFrameSUB (Frame AS QD3DFrame)Creates frame1
CreateLightRGBSUB (LightType%, R#, G#, B#, Light AS QD3DLight)Create light object5
CreateMeshBuilderSUB (MB AS QD3DMeshBuilder)Creates meshbuilder1
CreateShadowSUB (MB AS QD3DMeshBuilder, Light AS QD3DLight, px#, py#, pz#, nx#, ny#, nz#, V AS QD3DVisual)Creates a visual shadow object9
CreateWrapSUB (WrapType%, A#, B#, C#, D#, E#, F#, G#, H#, I#, J#, K#, L#, M#, W AS QD3DWrap)Creates a wrap object15
ForceUpdateSUB (X1%, Y1%, X2%, Y2%)Force update on specific region4
LoadTextureSUB (File AS STRING, Tex AS QD3DTexture)Create a texture object2
MoveSUB (D AS DOUBLE)Moves/animates scene
(Quaterion operation)
1
SetBackgroundImageSUB (Tex AS QD3DTexture)Set background image for scene1
SetCameraPositionSUB (X#, Y#, Z#)Set camera position for entire scene3
SetCameraOrientationSUB (DX#, DY#, DZ#, UX#, UY#, UZ#) 
The camera.is a hidden QD3DFrame. 
DX,DY, DZ range from -1 to 1 set left-right vs up- down.
UX, UY,  range from -1 to 1 and set the roll (set UZ = 1;  it has no effect)
Set camera orientation for scene6
SetRenderModeSUB (M AS INTEGER)Set render mode for scene1
SetVelocity SUB (X#, Y#, Z#, R%)  Undocumented should affect
QDXSCREEN.MOVE(), QD3DFRAME.MOVE()
set rotation velocity of a Quaterion operation6
SetTextureQualitySUB (Quality AS INTEGER)Set texture quality for scene1

QDXScreen
3D ViewPort Methods (undocumented)
   
The viewport defines how a 3D scene is rendered on a 2D Screen. It implements a IDirectD3DRMViewPort object that sets the “viewing frustum” which is a 3D volume in a scene positioned relative to the viewport's camera. Objects within the viewing frustum are visible. For perspective viewing, the viewing frustum is the volume of an imaginary pyramid that is between the front clipping plane and the back clipping plane. The camera is at the tip of the pyramid, and its z-axis runs from the tip of the pyramid to the center of the pyramid's base. The front clipping plane is a distance D from the camera, and the back clipping plane is a distance F from the front clipping plane. You can set and retrieve these values by using the .VIEW.SETFRONT, .VIEW.SETBACK, .VIEW.GETFRONT, and .VIEW.GETBACK methods.. Why change the viewport? Change the perspective view or speed up the rendering process and eliminate objects you don’t want in the scene.
VIEW.CLEARSUB ()
e.g., QDXScreen.View.Clear
 ‘clears the DXSCREEN 0
VIEW.GETFRONT FUNCTION () AS SINGLE ‘gets the front clipping plane 0
VIEW.SETFRONT SUB (RVFRONT AS SINGLE) 
i.e.,
DIM a as SINGLE
a = QDXSCREEN.VIEW.GETFRONT
QDXSCREEN.VIEW.SETFRONT(a + 10) ‘ render less
‘ set front clipping plane 1
VIEW.GETBACKFUNCTION () AS SINGLE ‘gets the back clipping plane 0
VIEW.SETBACK SUB (RVBACK AS SINGLE)  'default back is 5000 ‘gets the front clipping plane 1
VIEW.SETPLANESUB ((LEFT#, RIGHT#, BOTTOM#, TOP#)sets the front clipping plane of the viewing frustum with the coordinates of the four sides, relative to the camera's z-axis.
Changes the 3D perspective
4

QDXScreen Events

EventTypeOccurs when...Params




OnClickVOIDMouse button clicked0
OnDblClickVOIDMouse button double clicked0
OnInitializeVOIDDirectX succeeds in initializing0
OnInitializeSurfaceVOIDAnother event for you to do initializing0
You must wait for QDXScreen surface to initialize before drawing on it.  
OnKeyDownSUB (Key AS Word, Shift AS INTEGER)Key held down2
OnKeyPressSUB (Key AS BYTE)User presses a key1
OnMouseDownSUB (Button%, X%, Y%)Mouse button held down3
OnMouseMoveSUB (X%, Y%)Mouse moves2
OnMouseUpSUB (Button%, X%, Y%)Mouse button is released3


QDXScreen Examples
$TYPECHECK ON
$INCLUDE "RAPIDQ.INC"

DECLARE SUB DrawOnScreen

DIM TheBMP AS QBITMAP
CREATE Form AS QForm
    ClientHeight = 480
    ClientWidth = 640
CREATE QScreen AS QDXScreen
    BitCount = 24
    width = Form.ClientWidth
    height = Form.ClientHeight
    Init(640, 480)  'define its memory, can be larger than visible screen
    OnClick  = DrawOnScreen
'   OnInitialize  = DrawOnScreen'will clear..
END CREATE
END CREATE
Form.ShowModal

SUB DrawOnScreen(Sender AS QDXScreen)
    TheBMP.LoadFromFile("test.bmp")
    QScreen.Draw(0,0, TheBMP.BMP)  'draw a picutre on it
    QScreen.Line(0,0,200,200,&HFF) 'draw a red line on picture
    QScreen.Flip  'need this for each new drawing
END SUB

Prev Component Contents Next Component