Tri3: Triangle D3D Sample

Click to open or copy the files for the Tri3 sample.

Click to open or copy the Misc files (required).

This sample (Tri3 or D3DApp) is a collection of helper functions for Direct3D applications.  D3DApp consists of the following files:

File Description
D3dmain.cpp Each of the Direct3D samples must be linked with this file.  It contains the code which allows them to run in the Windows environment. A window is created using D3dmain.res which allows the user to select the Direct3D driver to use and change the render options.  The D3DApp collection of functions is used to initialize DirectDraw, Direct3D and keep surfaces and D3D devices available for rendering.
D3dapp.c Top level D3DApp functions and internal global variables.
D3dapp.h Main D3DApp header to be included by application
D3dappi.h Internal header
D3dapp.c D3DApp functions seen by application.
Ddcalls.c All calls to DirectDraw objects except textures. Manages DirectDraw objects needed for rendering.
D3dcalls.c All calls to Direct3D objects except textures.  Calls to Direct3D objects needed for rendering.
Texture.c Texture loading and managing texture list.  Loads and manages textures.
Misc.c Miscellaneous calls. Miscellaneous functions not involving DD and D3D.
Stats.cpp Functions to Blt frame rate and a screen mode information buffer to the screen.

Each sample is executed through the functions InitScene, InitView, RenderScene, ReleaseView, ReleaseScene and OverrideDefaults, as described in D3ddemo.h.  Samples can also read mouse and keyboard input via SetMouseCallback and SetKeyboardCallback.

Building SDK Samples

This sample uses the following keywords:

addattachedsurface; addviewport; adjustwindowrectex; afterdevicecreated; appabout; appendmenu; appinit; apppause; attempt; beforedevicedestroyed; beginpaint; beginscene; blt; bltfast; calculateframerate; ceil; checkmenuitem; checksurf; cleanupandpostquit; clear; clienttoscreen; clock; comparemodes; createclipper; created3dapp; createdevice; createfont; creategridstrip; creatematerial; creatematrix; createpalette; createsurface; createviewport; createwindowex; d3dappaddtexture; d3dappchangedriver; d3dappchangetextureformat; d3dappcheckforlostsurfaces; d3dappclearbackbuffer; d3dappcreatefromhwnd; d3dappcreatesurface; d3dappdestroy; d3dappdisabletextures; d3dapperrortostring; d3dappfullscreen; d3dappgetrenderstate; d3dappiaddpathlist; d3dappibpptoddbd; d3dappicalldevicecreatecallback; d3dappicalldevicedestroycallback; d3dappicheckforpalettized; d3dappiclearbuffers; d3dappicopyrectlist; d3dappicreatebuffers; d3dappicreated3d; d3dappicreatedd; d3dappicreatedevice; d3dappicreatesurface; d3dappicreatezbuffer; d3dappiddenumcallback; d3dappienumdevices; d3dappienumdisplaymodes; d3dappienumtextureformats; d3dappifilterdisplaymodes; d3dappifilterdrivers; d3dappifindfile; d3dappigetclientwin; d3dappigetsurfdesc; d3dappigettexturehandle; d3dappihandlewm_size; d3dappiinitialisepathlist; d3dappiloadalltextures; d3dappiloadsurface; d3dappiloadtexturesurf; d3dappimergerectlists; d3dappipickdisplaymode; d3dappipickdriver; d3dappireleasealltextures; d3dappireleasepathlist; d3dappireleasetexture; d3dappireloadtexturesurf; d3dappirememberwindowsmode; d3dappirestoredispmode; d3dappisetclientsize; d3dappisetcooplevel; d3dappisetdefaults; d3dappisetdisplaymode; d3dappisetdispmode; d3dappiseterrorstring; d3dappisetrenderstate; d3dappivalidatedirtyrects; d3dappiverifydriverandmode; d3dapplasterror; d3dapplasterrorstring; d3dapppause; d3dapprenderextents; d3dappsetrenderstate; d3dappshowbackbuffer; d3dappswaptextures; d3dapptotalvideomemory; d3dappwindow; d3dappwindowproc; d3dmatrixinvert; d3dmatrixsetrotation; d3dval; d3dvectorcrossproduct; d3dvectornormalise; defwindowproc; deletemenu; deleteobject; destroywindow; dialogbox; directdrawcreate; directdrawenumerate; dispatchmessage; displayframerate; dpf; drawmenubar; drawprimitive; enablemenuitem; enddialog; endpaint; endscene; enumdevicefunc; enumdevices; enumdisplaymodes; enumdisplaymodescallback; enumtextureformats; enumtextureformatscallback; exttextout; failed; fclose; flip; fliptogdisurface; floor; fopen; fread; free; fseek; generatesphere; getattachedsurface; getc; getcaps; getclientrect; getclipstatus; getdc; getdisplaymode; getentries; getenv; gethandle; getmenu; getstats; getstockobject; getsubmenu; getsurfacedesc; getsystempaletteentries; gettextextentpoint; gettextextentpoint32; getwindowlong; getwindowrect; initfontandtextbuffers; initglobals; initscene; initview; insertmenu; isdigit; islost; isspace; line_list_data; load; loadaccelerators; loadcursor; loadicon; loadppmheader; lock; lstrcat; lstrchr; lstrcmp; lstrcpy; lstrcpyn; lstrlen; lstrrchr; make_matrix; malloc; matrix_multiply_data; max; memcpy; memset; merge; messagebox; min; msg; multiplyd3dmatrix; op_branch_forward; op_exit; op_line_list; op_matrix_multiply; op_nop; op_point_list; op_process_vertices; op_set_status; op_span_list; op_state_light; op_state_render; op_state_transform; op_triangle_list; outputdebugstring; overridedefaults; peekmessage; postquitmessage; ppm_getbyte; ppm_getint; processvertices_data; putd3dinstruction; qsort; queryinterface; qword_aligned; redrawwindow; regclosekey; registerclass; regopenkeyex; regqueryvalueex; release; releasedc; releasefontandtextbuffers; releasescene; releaseview; renderloop; renderscene; reportd3dapperror; resetframerate; restore; restoredisplaymode; restoresurfaces; rgb; rgb_getblue; rgb_getgreen; rgb_getred; rgb_make; rgba_make; selectobject; sendmessage; setbackground; setbkcolor; setbkmode; setclipper; setclipstatus; setcolorkey; setcooperativelevel; setcurrentviewport; setcursor; setdisplaymode; setentries; sethwnd; setkeyboardcallback; setlightstate; setmaterial; setmatrix; setmousecallback; setpalette; setrect; setrenderstate; settextcolor; setviewport2; setwindowpos; setwindowtext; showwindow; spline; state_data; strtok; swaptexturehandles; switch; translateaccelerator; translatemessage; triangle_list_data; unlock; updatewindow; va_end; va_start; vertex_data; waitmessage; windowproc; winmain; writeframeratebuffer; writeinfobuffer; wsprintf; wvsprintf; zeromem

The Misc files demonstrate the following keywords:

_lclose; _lopen; _lread; addattachedsurface; addlight; addtoviewport; adjustwindowrectex; afterdevicecreated; appabout; appendmenu; appinit; apppause; attempt; beforedevicedestroyed; beginpaint; blt; bltfast; bpptoddbd; buildscene; calculateframerate; checkmenuitem; cleanupandpostquit; clear; clienttoscreen; clock; comparemodes; copymemory; cos; createclipper; createcompatibledc; created3dapp; created3drm; createdevandview; createdevicefromclipper; createdevicefromd3d; createfont; createframe; createlight; creatematerial; creatematrix; createpalette; createsurface; createviewport; createwindow; createwindowex; crossproduct; d3dappchangedriver; d3dappcheckforlostsurfaces; d3dappcreatefromhwnd; d3dappcreatesurface; d3dappdestroy; d3dappenumeratedddevices; d3dapperrortostring; d3dappfullscreen; d3dappibpptoddbd; d3dappicalldevicecreatecallback; d3dappicalldevicedestroycallback; d3dappicheckforpalettized; d3dappiclearbuffers; d3dappicopyrectlist; d3dappicreatebuffers; d3dappicreatedd; d3dappicreatedevice; d3dappicreatesurface; d3dappicreatezbuffer; d3dappiddenumcallback; d3dappienumdddevices; d3dappienumdisplaymodes; d3dappifilterdisplaymodes; d3dappigetclientwin; d3dappigetsurfdesc; d3dappigettexturehandle; d3dappihandlewm_size; d3dappimergerectlists; d3dappipickdisplaymode; d3dappipickdriver; d3dappirememberwindowsmode; d3dappirestoredispmode; d3dappisetclientsize; d3dappisetcooplevel; d3dappisetdefaults; d3dappisetdisplaymode; d3dappiseterrorstring; d3dappisetrenderstate; d3dappivalidatedirtyrects; d3dappiverifydriverandmode; d3dapplasterrorstring; d3dapppause; d3dappshowbackbuffer; d3dapptotalvideomemory; d3dappwindow; d3dappwindowproc; d3drmerrortostring; d3dval; ddcolormatch; ddcolormatch2; ddcopybitmap; ddcopybitmap2; ddloadbitmap; ddloadbitmap2; ddloadpalette; ddloadpalette2; ddreloadbitmap; ddreloadbitmap2; ddsetcolorkey; ddsetcolorkey2; declare_handle; declare_handle32; defined; defwindowproc; deletedc; deletelight; deletemenu; deleteobject; destroyd3dapp; destroywindow; dialogbox; direct3drmcreate; directdrawcreate; directdrawcreateclipper; directdrawcreatefromdevice; directdrawcreatefromwindow; directdrawdevicefromwindow; directdrawenumerate; directionallight; dispatchmessage; displayframerate; dpf; dsfillsoundbuffer; dsgetwaveresource; dsloadsoundbuffer; dsparsewaveresource; dsreloadsoundbuffer; enablemenuitem; enddialog; endpaint; enumdevicefunc; enumdevices; enumdisplaymodes; enumdisplaymodescallback; enumdisplaymonitors; exttextout; fabs; failed; finddevicecallback; findresource; float; forceupdate; free; freelibrary; getalpha; getambient; getattachedsurface; getattenuation; getcaps; getclientrect; getclipbox; getcolor; getdc; getdevicecaps; getdiffuse; getdirection; getdisplaymode; getdither; getdxversion; getemissive; geterrorstring; getfalloff; getflags; gethandle; getheight; getmenu; getmodulehandle; getmonitorinfo; getobject; getpenumbra; getpixel; getposition; getpower; getprocaddress; getquality; getrampsize; getrange; getspecular; getstockobject; getsubmenu; getsurfacedesc; getsystemmetrics; getsystempaletteentries; gettextextentpoint; gettextextentpoint32; gettexturehandle; gettexturequality; gettrianglesdrawn; getumbra; getupdaterect; getversionex; getwidth; getwindowinstance; getwindowlong; getwindowrect; handleactivate; handlepaint; identitymatrix; idirectsound_createsoundbuffer; idirectsound_duplicatesoundbuffer; idirectsoundbuffer_getstatus; idirectsoundbuffer_lock; idirectsoundbuffer_play; idirectsoundbuffer_release; idirectsoundbuffer_restore; idirectsoundbuffer_setcurrentposition; idirectsoundbuffer_stop; idirectsoundbuffer_unlock; initapp; initfontandtextbuffers; initglobals; initmultiplemonitorstubs; insertmenu; intersectrect; islost; lbclear; lbcreate; lbprintf; lbprintfddrc; lbsize; light; line_list_data; loadaccelerators; loadcursor; loadicon; loadimage; loadlibrary; loadresource; localalloc; localfree; lock; lockresource; lpfnenumproc; lstrcat; lstrcmp; lstrcmpi; lstrcpy; lstrlen; lubksb; ludcmp; make_matrix; malloc; mapwindowpoints; material; matrix_multiply_data; matrixinverse; matrixmult; matrixtranspose; memcpy; memset; merge; messagebox; mmiofourcc; move; movewindow; msg; normalize; onemonitorcallback; onemonitorfromwindow; op_branch_forward; op_exit; op_line_list; op_matrix_multiply; op_nop; op_point_list; op_process_vertices; op_set_status; op_span_list; op_state_light; op_state_render; op_state_transform; op_triangle_list; op_triangleex_list; outputdebugstring; overridedefaults; parallelpointlight; peekmessage; pointlight; postquitmessage; processvertices_data; projectionmatrix; putd3dinstruction; qsort; queryinterface; qword_aligned; rand; readmouse; registerclass; release; releasedc; releasefontandtextbuffers; removefromviewport; render; renderloop; reportd3dapperror; resetframerate; restore; restoredisplaymode; restoresurfaces; ret; rgb; rgb_make; rnd; rotatexmatrix; rotateymatrix; rotatezmatrix; scalematrix; selectobject; sendmessage; set; setalpha; setambient; setasbackground; setascurrent; setattenuation; setback; setbackground; setbkcolor; setbkmode; setbuffercount; setclipper; setcolor; setcolorkey; setcooperativelevel; setdefaulttexturecolors; setdefaulttextureshades; setdiffuse; setdirection; setdisplaymode; setdither; setemissive; setfalloff; setflags; sethwnd; setlight; setlightstate; setmaterial; setmatrix; setpalette; setpenumbra; setpixel; setposition; setpower; setquality; setrampsize; setrange; setrect; setrectempty; setrenderstate; setshades; setspecular; settextcolor; settexturehandle; settexturequality; setumbra; setwindowpos; showwindow; sin; sndobjcreate; sndobjdestroy; sndobjgetfreebuffer; sndobjplay; sndobjstop; spotlight; state_data; stretchblt; strtok; succeeded; switch; systemparametersinfo; text; transformnormal; transformvector; translateaccelerator; translatematrix; translatemessage; triangle_list_data; triangleex_list_data; unlock; update; updatewindow; va_end; va_start; vertex_data; view; viewmatrix; waitmessage; windowfromdc; windowproc; winmain; writeframeratebuffer; writeinfobuffer; wsprintf; wvsprintf; xenumdisplaymonitors; xgetmonitorinfo; xgetsystemmetrics; xmonitorfrompoint; xmonitorfromrect; xmonitorfromwindow; zeromatrix; zeromem; zeromemory