Author Topic: 64-bit DirectX 11 - Part 2 - Mesh  (Read 1487 times)

AW

  • Member
  • *****
  • Posts: 1512
  • Let's Make ASM Great Again!
64-bit DirectX 11 - Part 2 - Mesh
« on: May 28, 2018, 06:45:49 PM »
Producing vertices, as we did in the previous example, works fine for simple objects like cubes, however for sophisticated objects we will uses meshes. Meshes can be obtained from 3d modelling programs, such as Blender (or others).
All right, I am not a gamer, some people here may know a lot about this, all I am doing is experimenting.

This is a wireframed rotating car.

There is a similar sample, which is obtained by simply changing the _vertices.inc. However, it is too big to post here due to the huge number of vertices, so I am uploading it to my website.

six_L

  • Member
  • **
  • Posts: 141
Re: 64-bit DirectX 11 - Part 2 - Mesh
« Reply #1 on: May 28, 2018, 08:44:23 PM »
 :t :t :t

felipe

  • Member
  • ****
  • Posts: 944
  • Eagles are just great!
Re: 64-bit DirectX 11 - Part 2 - Mesh
« Reply #2 on: May 29, 2018, 11:46:44 AM »
 :greenclp:
Felipe.

Siekmanski

  • Member
  • *****
  • Posts: 1674
Re: 64-bit DirectX 11 - Part 2 - Mesh
« Reply #3 on: May 29, 2018, 06:41:47 PM »
Cool example.  :t
Creative coders use backward thinking techniques as a strategy.

AW

  • Member
  • *****
  • Posts: 1512
  • Let's Make ASM Great Again!
Re: 64-bit DirectX 11 - Part 2 - Mesh
« Reply #4 on: May 30, 2018, 05:58:29 AM »
Thank you for the comments!  :biggrin:
My next DX endeavour will be to find out how to output text to the screen. It appears that is something not as easy as we would expect it to be. Let me take a long breath and start thinking about it.

Siekmanski

  • Member
  • *****
  • Posts: 1674
Re: 64-bit DirectX 11 - Part 2 - Mesh
« Reply #5 on: May 30, 2018, 08:14:01 AM »
It can be done like this,

Create a texture bitmap with the font characters in ascii order for fast and easy access.
Fill an index and vertex buffer ( 2D trianglelist mode ) with the texture coords and screen positions of the characters in the text string you want to draw.
Then you can draw the text string with only one call.
The text routine in my D3D9 examples are done this way.
Creative coders use backward thinking techniques as a strategy.

AW

  • Member
  • *****
  • Posts: 1512
  • Let's Make ASM Great Again!
Re: 64-bit DirectX 11 - Part 2 - Mesh
« Reply #6 on: May 30, 2018, 06:59:16 PM »
Thank you Marinus  :t
However, I don't know if this will work for what I have in mind, show the fps in the left top corner.

Siekmanski

  • Member
  • *****
  • Posts: 1674
Re: 64-bit DirectX 11 - Part 2 - Mesh
« Reply #7 on: May 30, 2018, 08:00:59 PM »
Yes it can be done, see attachment.

Here are the draw_text and texture_loader sources from my D3D9extra.lib

Code: [Select]
; d3d9extra library routines by Siekmanski.
     .686p
     .model  flat,stdcall
     .xmm
      option casemap:none

include     \masm32\include\windows.inc
include     \masm32\include\kernel32.inc
includelib  \masm32\lib\kernel32.lib
include     \masm32\include\user32.inc
includelib  \masm32\lib\user32.lib
include     \masm32\include\gdiplus.inc
includelib  \masm32\lib\gdiplus.lib
include     \masm32\include\ole32.inc
includelib  \masm32\lib\ole32.lib

include     ..\..\includes\d3d9.inc
includelib  d3d9.lib    ; must also be present in the "d3d9extra" folder to create the library!

include     d3d9GDIplus.inc               

.data?
align 4
ImageBuffer         dd ?
hRsrc               dd ?
pStream             dd ?
pImage              dd ?
ReturnMessage       dd ?
ImagePointer        dd ?
ImageSize           dd ?
GdiplusToken        dd ?
GDIplusBitmapData   BitmapData <?>
pLockedRect         D3DLOCKED_RECT <?>
FilenameW           dw  MAX_PATH dup (?)

.code
align 4
D3DLoadImage proc uses ebx esi edi pD3DDevice:DWORD,ImageName:DWORD,ColorKey:DWORD,pTexture:DWORD

    mov     ReturnMessage,E_FAIL
   
    invoke  GdiplusStartup,offset GdiplusToken,offset GdiplusInput,NULL
    test    eax,eax
    jnz     Exit_LoadTexture

    mov     ImageBuffer,NULL
    mov     pStream,NULL
   
    ; Image found in the resource ?
     invoke  FindResource,NULL,ImageName,TEXT_("INCBIN")
    test    eax,eax
    jz      Image_as_File

    mov     hRsrc,eax
    invoke  SizeofResource,NULL,eax
    mov     ImageSize,eax
    invoke  LoadResource,NULL,hRsrc
    invoke  LockResource,eax
    mov     ImagePointer,eax
    jmp     CreateStream
   
    ; Nothing in the resource, try to load Image from file.
Image_as_File:
    invoke  MultiByteToWideChar,CP_ACP,0,ImageName,-1,offset FilenameW,MAX_PATH-1
    invoke  GdipCreateBitmapFromFile,offset FilenameW,addr pImage
    test    eax,eax
    jz      LockBitmap 

    ; Load Image from memory
    mov     esi,ImageName
    mov     eax,dword ptr[esi]
    add     esi,4
    mov     ImageSize,eax
    mov     ImagePointer,esi
   
CreateStream:
    invoke  GlobalAlloc,GMEM_FIXED or GMEM_ZEROINIT,ImageSize
    test    eax,eax
    jz      ShutdownGDIplus
    mov     ImageBuffer,eax

    invoke  RtlMoveMemory,ImageBuffer,ImagePointer,ImageSize
    invoke  CreateStreamOnHGlobal,ImageBuffer,TRUE,addr pStream
    test    eax,eax
    jnz     Close_Gdiplus

    invoke  GdipCreateBitmapFromStream,pStream,addr pImage
    test    eax,eax
    jnz     Close_Gdiplus

LockBitmap:
    invoke  GdipBitmapLockBits,pImage,NULL,ImageLockModeRead,PixelFormat32bppARGB,offset GDIplusBitmapData
    test    eax,eax
    jnz     Close_Image

    mov     esi,pTexture
    SAFE_RELEASE dword ptr [esi]

    coinvoke pD3DDevice,IDirect3DDevice9,CreateTexture,GDIplusBitmapData.dwWidth,GDIplusBitmapData.dwHeight,\
                                1,NULL,D3DFMT_A8R8G8B8,D3DPOOL_MANAGED,pTexture,NULL
    cmp     eax,D3D_OK
    jne     UnlockBitmap

lockIT:
    mov     esi,pTexture
    coinvoke dword ptr [esi],IDirect3DTexture9,LockRect,0,addr pLockedRect,NULL,D3DLOCK_DISCARD
    cmp     eax,D3D_OK
    jne     UnlockBitmap
   
    mov     esi,GDIplusBitmapData.Scan0     ; pointer to the bitmap data
    mov     edi,pLockedRect.pBits           ; pointer to the texture data
   
    mov     ecx,GDIplusBitmapData.dwHeight
Height_lp:
    mov     edx,GDIplusBitmapData.dwWidth
    xor     ebx,ebx
Width_lp:
    mov     eax,dword ptr [esi+ebx]
   
    cmp     ColorKey,NULL                   ; Check if we need to set a certain color of this bipmap to transparent.
    jz      NoColorKey
    or      eax,D3DCOLOR_ARGB(255,0,0,0)
    cmp     ColorKey,eax
    jne     NoColorKey
    xor     eax,eax
NoColorKey:
   
    mov     dword ptr [edi+ebx],eax
    add     ebx,4
    dec     edx
    jnz     Width_lp
    add     esi,GDIplusBitmapData.Stride   
    add     edi,pLockedRect.Pitch
    dec     ecx
    jnz     Height_lp   

    mov     esi,pTexture
    coinvoke dword ptr [esi],IDirect3DTexture9,UnlockRect,0

    mov     ReturnMessage,D3D_OK

UnlockBitmap:
    invoke  GdipBitmapUnlockBits,pImage,offset GDIplusBitmapData
Close_Image:
    invoke  GdipDisposeImage,pImage
Close_Gdiplus:
    SAFE_RELEASE  pStream
    cmp     ImageBuffer,NULL
    jz      ShutdownGDIplus
    invoke  GlobalFree,ImageBuffer
ShutdownGDIplus:
    invoke  GdiplusShutdown,GdiplusToken
Exit_LoadTexture:
    mov     eax,ReturnMessage
    ret

D3DLoadImage endp

end

Code: [Select]
; d3d9extra library routines by Siekmanski.
     .686p
     .model  flat,stdcall
     .xmm
      option casemap:none

include     \masm32\include\windows.inc
include     \masm32\include\kernel32.inc
includelib  \masm32\lib\kernel32.lib
include     \masm32\include\user32.inc
includelib  \masm32\lib\user32.lib

include     ..\..\includes\d3d9.inc
includelib  d3d9.lib    ; must also be present in the "d3d9extra" folder to create the library!

D3DLoadImage        PROTO   :DWORD,:DWORD,:DWORD,:DWORD

.const
D3DFVF_FONTCOLORVERTEX equ (D3DFVF_XYZRHW or D3DFVF_DIFFUSE or D3DFVF_TEX1)

FONTCOLORVERTEX struct
   position D3DVECTOR4 <?>
   color    D3DCOLOR ?
   tu       REAL4 ?
   tv       REAL4 ?
FONTCOLORVERTEX ends

MaxCharacters   equ 96

.data
align 4
g_pVBFont         LPDIRECT3DVERTEXBUFFER9 NULL
g_pIBFont         LPDIRECT3DINDEXBUFFER9  NULL
g_pFontTexture    LPDIRECT3DTEXTURE9      NULL

; "D3d9Font.png"
D3d9Font dd 940 ; Size of file in bytes.
    dd 0474E5089h,00A1A0A0Dh,00D000000h,052444849h,080000000h,080000000h,000000301h,0F3F0F900h
    dd 000000088h,04D497407h,002DF0745h,00324151Ch,09A6EBF3Dh,009000000h,073594870h,0120B0000h
    dd 0120B0000h,07EDDD201h,0000000FCh,04D416704h,0B1000041h,061FC0B8Fh,000000005h,0544C5006h
    dd 000000045h,0A5FFFFFFh,000DD9FD9h,049290300h,078544144h,0BDD59DDAh,014311B4Fh,0B577F000h
    dd 0D7A62CE4h,0D92911D1h,0D4CA3B3Ah,095D2ED29h,0A427CD99h,06E890164h,028C45520h,0B150B392h
    dd 0CD2EB874h,0ECC4C0BFh,044B252A8h,05976E99Dh,054B61AC2h,077BEA28Ah,0A52D07DFh,07E024539h
    dd 0D9EFCF38h,047803E7Eh,0266A630Fh,079C53980h,044C69D01h,0380AC12Bh,08E00F2FEh,0A5AD5B5Eh
    dd 00022A567h,00DE4736Fh,0A06F481Ch,011D98012h,045C20CF3h,0B1874194h,06BF86110h,0E58EC293h
    dd 0DE11A5B7h,0938AC766h,088D0063Ch,09B20A14Bh,0F3F8E085h,0079E414Ch,0387FAD05h,07FA880ADh
    dd 096AC85BFh,074CC1F2Dh,0F346F6B9h,0B7F24DFBh,06EBC8608h,09B3CC859h,02D4215C1h,060C819E4h
    dd 009DF25C0h,0401CF039h,048823AF2h,0B4131D40h,04125D346h,07D418A33h,0CA574C0Ah,0D0468464h
    dd 0C3180CBCh,0EF9690C5h,078678182h,00091013Fh,01985E4E6h,051E60D8Ch,05D3F8E85h,0EFABBDADh
    dd 0C5B9044Bh,0000EF852h,00C538527h,004035CB4h,06685A6A1h,06EC20B30h,0C1C0A6DDh,073EFB0BBh
    dd 0B6E68A70h,0052608FBh,03F348CD9h,0041701C8h,0EC20E23Fh,0247423DDh,03CA47E02h,011E22D18h
    dd 042325157h,0F4315F65h,082518C6Fh,0FB071678h,00C3CC025h,01E4993BCh,04CA281C6h,0E3A04E95h
    dd 08B54D01Bh,0AA3D84EAh,0BCE78B65h,0075AB779h,0F5667343h,0631237ABh,0705C4A1Ch,04D96A8DCh
    dd 014C20967h,09163752Eh,075082181h,07AD70AB3h,0488157B7h,08257DECBh,0ADFE70D1h,0E830E08Fh
    dd 01C5072CFh,0C32B3DD1h,002DBC235h,0C952CE38h,0091E6383h,03CF299A4h,002E6F3D3h,0DCC196B0h
    dd 06CC0F1F6h,03A7D1EB7h,0F8DA7D15h,04EADEC20h,05DFC5A69h,06D3418C8h,0C4C11FEBh,011EE16D0h
    dd 05B0E02A8h,08D384F76h,05FB897D0h,0719A8831h,0CF645674h,03D9B8270h,0E86266BCh,08CDA04BAh
    dd 0211A0241h,08CDA6F98h,0475F80A7h,0106B81F8h,089417D43h,0C0CDB1E9h,0F0B5C89Fh,03045F8DDh
    dd 0002D51A8h,0082F7FD1h,0C67D87E6h,0428069A9h,072DFBC68h,0540C3170h,06FDE1405h,0C065ABD8h
    dd 0DDFE0CE3h,0BEC1DD72h,031917DC5h,0B6384BA4h,088293025h,011146027h,07808D2F0h,03A6F0E04h
    dd 09E22C096h,0AC3A61C5h,0A3D1E716h,02E4B9C3Ch,015936F36h,0C0EB3DEAh,0D32D0668h,00CA20878h
    dd 0D093F754h,02B47C1AFh,0FCD0749Ah,020EE8AC9h,01BB12EEAh,0C2F4C7AFh,040661026h,0919DC465h
    dd 0288324C2h,047975803h,0FC5A5060h,014868622h,0020B3A58h,02AD8F45Dh,0C5DB5B2Dh,07111A156h
    dd 0E5945EF9h,09293CCFCh,0F10DC15Fh,025875F12h,0BE2BD7C0h,02705FF0Eh,0A65CF3F8h,091BD96EDh
    dd 0155DD665h,022AD4B68h,0A804B9E1h,0C5D6A455h,0FC3C0408h,0FE7B02AEh,0CC1014DCh,00870DA6Fh
    dd 00DF1E805h,0F0728DBEh,003ADC8FDh,02D615D33h,0F37D12A5h,0037FEAD7h,090AFCD67h,09768B818h
    dd 000000000h,0444E4549h,0826042AEh

.data?
align 16
FontVertexData    real4 4 dup (?)
FontTextureCoords real4 96*8 dup (?)
ALPHATESTENABLE   dd ?
ALPHAREF          dd ?
ALPHAFUNC         dd ?

.code
align 4
InitD3DDrawText proc uses ebx edi esi pD3DDevice:DWORD
LOCAL Buffer_ptr:DWORD

    mov         eax,(sizeof FONTCOLORVERTEX)
    imul        eax,MaxCharacters*4
    coinvoke    pD3DDevice,IDirect3DDevice9,CreateVertexBuffer,eax,D3DUSAGE_WRITEONLY or D3DUSAGE_DYNAMIC,D3DFVF_FONTCOLORVERTEX,D3DPOOL_DEFAULT,addr g_pVBFont,NULL
    test        eax,eax
    js          FontObjectsError

    coinvoke    g_pVBFont,IDirect3DVertexBuffer9,Lock,NULL,NULL,addr Buffer_ptr,NULL
    test        eax,eax
    js          FontObjectsError

    mov         edi,Buffer_ptr
    mov         ecx,MaxCharacters*4
    lea         eax,FontVertexData
    movss       xmm0,FLT4(0.1)   ; Z
    movss       real4 ptr[eax+8],xmm0
    movss       xmm0,FLT4(1.0)   ; W
    movss       real4 ptr[eax+12],xmm0
    movaps      xmm0,[eax]
VertexLP:
    movups      [edi],xmm0
    add         edi,(sizeof FONTCOLORVERTEX)
    dec         ecx
    jnz         VertexLP
   
    coinvoke    g_pVBFont,IDirect3DVertexBuffer9,Unlock

    mov         eax,MaxCharacters*6
    shl         eax,1
    coinvoke    pD3DDevice,IDirect3DDevice9,CreateIndexBuffer,eax,D3DUSAGE_WRITEONLY or D3DUSAGE_DYNAMIC,D3DFMT_INDEX16,D3DPOOL_DEFAULT,addr g_pIBFont,NULL
    test        eax,eax
    js          FontObjectsError

    coinvoke    g_pIBFont,IDirect3DIndexBuffer9,Lock,NULL,NULL,addr Buffer_ptr,NULL
    test        eax,eax
    js          FontObjectsError

    mov         edi,Buffer_ptr
    mov         ecx,MaxCharacters
    mov         eax,010000h    ; index order font quad: 0,1,2,2,1,3
    mov         ebx,020002h
    mov         edx,030001h
IndexLP:
    mov         dword ptr[edi],eax
    mov         dword ptr[edi+4],ebx
    mov         dword ptr[edi+8],edx
    add         eax,040004h
    add         ebx,040004h
    add         edx,040004h
    add         edi,12
    dec         ecx
    jnz         IndexLP

    coinvoke    g_pIBFont,IDirect3DIndexBuffer9,Unlock


    lea         edi,FontTextureCoords
    movss       xmm4,FLT4(0.0)  ; start position in FontTexture
    movss       xmm5,FLT4(1.0)  ; Texture UV range
    divss       xmm5,FLT4(12.8) ; 128/120*12

    movss       xmm6,FLT4(1.0)  ; Texture UV range
    divss       xmm6,FLT4(8.0)  ; 128/16

    movss       xmm0,xmm4       ; X1
    movss       xmm1,xmm5       ; X2
    movss       xmm2,xmm4       ; Y1
    movss       xmm3,xmm6       ; Y2
    mov         edx,8           ; 8 rows of characters
rowLP:
    mov         ecx,12          ; 12 characters per row ( total of 8*12=96 characters )
charLP:
    movss       real4 ptr[edi],xmm0    ; X1
    movss       real4 ptr[edi+4],xmm2  ; Y1
    movss       real4 ptr[edi+8],xmm1  ; X2
    movss       real4 ptr[edi+12],xmm2 ; Y1
    movss       real4 ptr[edi+16],xmm0 ; X1
    movss       real4 ptr[edi+20],xmm3 ; Y2
    movss       real4 ptr[edi+24],xmm1 ; X2
    movss       real4 ptr[edi+28],xmm3 ; Y2
    add         edi,32
    addss       xmm0,xmm5       ; increase X1
    addss       xmm1,xmm5       ; increase X2
    dec         ecx
    jnz         charLP
    movss       xmm0,xmm4       ; reset X1
    movss       xmm1,xmm5       ; reset X2
    addss       xmm2,xmm6       ; increase Y1
    addss       xmm3,xmm6       ; increase Y2
    dec         edx             ; next row
    jnz         rowLP

    invoke      D3DLoadImage,pD3DDevice,offset D3d9Font,D3DCOLOR_ARGB(255,0,0,0),offset g_pFontTexture
               
    return  S_OK

FontObjectsError:
    return  E_FAIL
InitD3DDrawText endp

align 4
D3DDrawText proc uses ecx edx edi esi pD3DDevice:DWORD,Xstart:REAL4,Ystart:REAL4,Fsize:REAL4,Color:DWORD,pText:DWORD
LOCAL Buffer_ptr,FontVertexCount,FontPrimitiveCount:DWORD

    mov         FontVertexCount,0
    mov         FontPrimitiveCount,0
   
    coinvoke    g_pVBFont,IDirect3DVertexBuffer9,Lock,NULL,NULL,addr Buffer_ptr,NULL
    test        eax,eax
    js          DrawTextError

    movss       xmm0,Xstart
    movss       xmm1,Ystart
    movss       xmm2,Fsize
    movaps      xmm4,xmm2
    addss       xmm4,FLT4(-1.0)             ; Position X add + character spacing
    shufps      xmm4,xmm4,Shuffle(1,0,1,0)  ; X add,  0, X add, 0   
    shufps      xmm0,xmm1,Shuffle(0,1,1,0)  ; X1,  0,  0,  Y1
    shufps      xmm0,xmm0,Shuffle(3,0,3,0)  ; X1, Y1, X1,  Y1
    shufps      xmm2,xmm2,Shuffle(1,0,1,1)  ;  0,  0, Size, 0   
    addps       xmm0,xmm2                   ; X1, Y1, X2,  Y1
    movaps      xmm1,xmm0
    shufps      xmm2,xmm2,Shuffle(2,0,2,0)  ;  0,  Size, 0, Size   
    addps       xmm1,xmm2                   ; X1, Y2, X2, Y2

    mov         esi,pText
    test        esi,esi
    jz          EndOfString
    mov         ecx,Color
    mov         edi,Buffer_ptr
    lea         edx,FontTextureCoords

align 16
charLP:
    movzx       eax,byte ptr[esi]
    test        eax,eax
    jz          EndOfString
    cmp         eax,' '         ; space
    je          dont_draw
    cmp         eax,'~'         ; last Ascii character
    ja          dont_draw
    sub         eax,32          ; jump over first 32 Ascii characters
    shl         eax,5
    add         eax,edx         ; get character texture coords

    movaps      xmm2,[eax]
    movaps      xmm3,[eax+16]

    movlps      qword ptr[edi],xmm0     ; X1,Y1
    movlps      qword ptr[edi+20],xmm2  ; U1,V1
    movlps      qword ptr[edi+56],xmm1  ; X1,Y2
    movlps      qword ptr[edi+76],xmm3  ; U1,V2
    movhps      qword ptr[edi+28],xmm0  ; X2,Y1
    movhps      qword ptr[edi+48],xmm2  ; U2,V1
    movhps      qword ptr[edi+84],xmm1  ; X2,Y2
    movhps      qword ptr[edi+104],xmm3 ; U2,V2

    mov         dword ptr[edi+16],ecx   ; Color
    mov         dword ptr[edi+44],ecx   ; Color
    mov         dword ptr[edi+72],ecx   ; Color
    mov         dword ptr[edi+100],ecx  ; Color

    add         edi,112
    add         FontVertexCount,4
    add         FontPrimitiveCount,2
    cmp         FontPrimitiveCount,MaxCharacters*2
    ja          EndOfString
dont_draw:
    add         esi,1
    addps       xmm0,xmm4       ; increase X1
    addps       xmm1,xmm4       ; increase X2
    jmp         charLP

EndOfString:
    coinvoke    g_pVBFont,IDirect3DVertexBuffer9,Unlock

    cmp         FontVertexCount,0
    je          DrawTextError


    ; Draw the text to screen   
    coinvoke    pD3DDevice,IDirect3DDevice9,SetTexture,0,g_pFontTexture
    coinvoke    pD3DDevice,IDirect3DDevice9,SetFVF,D3DFVF_FONTCOLORVERTEX
    coinvoke    pD3DDevice,IDirect3DDevice9,SetStreamSource,0,g_pVBFont,0,sizeof FONTCOLORVERTEX
    coinvoke    pD3DDevice,IDirect3DDevice9,SetIndices,g_pIBFont
    coinvoke    pD3DDevice,IDirect3DDevice9,DrawIndexedPrimitive,D3DPT_TRIANGLELIST,0,0,FontVertexCount,0,FontPrimitiveCount
    return  S_OK

DrawTextError:
    return  E_FAIL
D3DDrawText endp

align 4
D3DStartTextMode proc pD3DDevice:DWORD
    ; Save Alpha RenderStates
    coinvoke    pD3DDevice,IDirect3DDevice9,GetRenderState,D3DRS_ALPHATESTENABLE,addr ALPHATESTENABLE
    coinvoke    pD3DDevice,IDirect3DDevice9,GetRenderState,D3DRS_ALPHAREF,addr ALPHAREF
    coinvoke    pD3DDevice,IDirect3DDevice9,GetRenderState,D3DRS_ALPHAFUNC,addr ALPHAFUNC

    ; Set Alpha RenderStates, the fonts have a tranparent background
    coinvoke    pD3DDevice,IDirect3DDevice9,SetRenderState,D3DRS_ALPHATESTENABLE,TRUE
    coinvoke    pD3DDevice,IDirect3DDevice9,SetRenderState,D3DRS_ALPHAREF,01h
    coinvoke    pD3DDevice,IDirect3DDevice9,SetRenderState,D3DRS_ALPHAFUNC,D3DCMP_GREATEREQUAL
    ret
D3DStartTextMode endp

align 4
D3DEndTextMode proc pD3DDevice:DWORD
    ; Restore Alpha RenderStates
    coinvoke    pD3DDevice,IDirect3DDevice9,SetRenderState,D3DRS_ALPHATESTENABLE,ALPHATESTENABLE
    coinvoke    pD3DDevice,IDirect3DDevice9,SetRenderState,D3DRS_ALPHAREF,ALPHAREF
    coinvoke    pD3DDevice,IDirect3DDevice9,SetRenderState,D3DRS_ALPHAFUNC,ALPHAFUNC
    ret
D3DEndTextMode endp

align 4
ReleaseD3DDrawText proc
    SAFE_RELEASE g_pVBFont
    SAFE_RELEASE g_pIBFont
    SAFE_RELEASE g_pFontTexture
    ret
ReleaseD3DDrawText endp

END

Here is the the font bitmap used in the text routine,



An example using the text routine.
Creative coders use backward thinking techniques as a strategy.

AW

  • Member
  • *****
  • Posts: 1512
  • Let's Make ASM Great Again!
Re: 64-bit DirectX 11 - Part 2 - Mesh
« Reply #8 on: May 30, 2018, 11:02:45 PM »
Quote
Yes it can be done, see attachment.

Thank you.  :t
It looks different than the general approach which is a real mess to my eyes.
https://bell0bytes.eu/text-with-directwrite/

I have to make sense of all this (may take a while).  :biggrin:

felipe

  • Member
  • ****
  • Posts: 944
  • Eagles are just great!
Re: 64-bit DirectX 11 - Part 2 - Mesh
« Reply #9 on: May 31, 2018, 07:14:42 AM »
Siekmanski it doesn't work on my system. Is there a requirement before running the program? Thanks.  :idea:
Felipe.

jj2007

  • Member
  • *****
  • Posts: 8776
  • Assembler is fun ;-)
    • MasmBasic
Re: 64-bit DirectX 11 - Part 2 - Mesh
« Reply #10 on: May 31, 2018, 07:32:40 AM »
An example using the text routine

MsgBox "XInput dll not found" - but then it shows the helicopter at 68fps. The text quality is not so impressive, though.

Siekmanski

  • Member
  • *****
  • Posts: 1674
Re: 64-bit DirectX 11 - Part 2 - Mesh
« Reply #11 on: May 31, 2018, 08:16:51 AM »
Hi Felipe,

The sources are part of my library and are only the routines for drawing text to the screen.

Hi Jochen,

I better had posted an other example to show the text example, this one was a testbed for an Xbox game controller. ( forgot it was not finished, this is why the message XInput.dll came up )

The quality of the text font is not great but very small ( 2 colors, 128 * 128 pixels ), I only use it for debugging.
For release applications I use multi colored very cool fonts using the exact same text routine.
Creative coders use backward thinking techniques as a strategy.

jj2007

  • Member
  • *****
  • Posts: 8776
  • Assembler is fun ;-)
    • MasmBasic
Re: 64-bit DirectX 11 - Part 2 - Mesh
« Reply #12 on: May 31, 2018, 10:14:54 AM »
For release applications I use multi colored very cool fonts using the exact same text routine.

I guessed so ;)

mineiro

  • Member
  • ***
  • Posts: 448
Re: 64-bit DirectX 11 - Part 2 - Mesh
« Reply #13 on: May 31, 2018, 10:22:51 AM »
Sorry for offtopic but anyone here knows about how directx born? I remember that one magazine said about "ufo 2" game, that microsoft buy that company or program, something like this. After they created directx. I'm asking because new versions of game ufo are update, so I think can be fake old news. Not sure.
Again, maybe I'm wrong but video cards sounds that have better processors than pc processors. Well, these guys come from Amiga world.
I'd rather be this ambulant metamorphosis than to have that old opinion about everything

Ascended

  • Member
  • ***
  • Posts: 331
Re: 64-bit DirectX 11 - Part 2 - Mesh
« Reply #14 on: May 31, 2018, 11:20:01 AM »
This is a funny community.  :bgrin:

I shelved my DX11 project a few weeks back through lack of community interest.

This is where I left it.