The MASM Forum

Projects => Game Development => Topic started by: aw27 on May 28, 2018, 06:45:49 PM

Title: 64-bit DirectX 11 - Part 2 - Mesh
Post by: aw27 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 (http://www.atelierweb.com/a/dx11_64App2a.zip).
Title: Re: 64-bit DirectX 11 - Part 2 - Mesh
Post by: six_L on May 28, 2018, 08:44:23 PM
 :t :t :t
Title: Re: 64-bit DirectX 11 - Part 2 - Mesh
Post by: felipe on May 29, 2018, 11:46:44 AM
 :greenclp:
Title: Re: 64-bit DirectX 11 - Part 2 - Mesh
Post by: Siekmanski on May 29, 2018, 06:41:47 PM
Cool example.  :t
Title: Re: 64-bit DirectX 11 - Part 2 - Mesh
Post by: aw27 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.
Title: Re: 64-bit DirectX 11 - Part 2 - Mesh
Post by: Siekmanski 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.
Title: Re: 64-bit DirectX 11 - Part 2 - Mesh
Post by: aw27 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.
Title: Re: 64-bit DirectX 11 - Part 2 - Mesh
Post by: Siekmanski 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

; 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


; 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,

(http://members.home.nl/siekmanski/D3d9Font.png)

An example using the text routine.
Title: Re: 64-bit DirectX 11 - Part 2 - Mesh
Post by: aw27 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:
Title: Re: 64-bit DirectX 11 - Part 2 - Mesh
Post by: felipe 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:
Title: Re: 64-bit DirectX 11 - Part 2 - Mesh
Post by: jj2007 on May 31, 2018, 07:32:40 AM
Quote from: Siekmanski on May 30, 2018, 08:00:59 PMAn 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.
Title: Re: 64-bit DirectX 11 - Part 2 - Mesh
Post by: Siekmanski 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.
Title: Re: 64-bit DirectX 11 - Part 2 - Mesh
Post by: jj2007 on May 31, 2018, 10:14:54 AM
Quote from: Siekmanski on May 31, 2018, 08:16:51 AMFor release applications I use multi colored very cool fonts using the exact same text routine.

I guessed so ;)
Title: Re: 64-bit DirectX 11 - Part 2 - Mesh
Post by: mineiro 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.
Title: Re: 64-bit DirectX 11 - Part 2 - Mesh
Post by: Lonewolff 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.

(https://i.imgur.com/pzW9dv1.png)
Title: Re: 64-bit DirectX 11 - Part 2 - Mesh
Post by: felipe on May 31, 2018, 12:58:56 PM
Looks nice Ascended, any sources to show?  :idea:
Title: Re: 64-bit DirectX 11 - Part 2 - Mesh
Post by: Lonewolff on May 31, 2018, 01:11:43 PM
Thanks, if you want  :t
Title: Re: 64-bit DirectX 11 - Part 2 - Mesh
Post by: felipe on May 31, 2018, 01:23:35 PM
Of course will be good to see some other ideas.  :idea:
Title: Re: 64-bit DirectX 11 - Part 2 - Mesh
Post by: daydreamer on May 31, 2018, 08:43:14 PM
Quote from: Siekmanski 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.
Knowing uv is floats,mean you could use 4096x4096,maybe try make text with help of multitexture, one layer is front of text,bottom layer is a cool background,in-between layer has different color/pattern for isometric 3d part of text
Title: Re: 64-bit DirectX 11 - Part 2 - Mesh
Post by: Siekmanski on May 31, 2018, 09:43:59 PM
Quote from: daydreamer on May 31, 2018, 08:43:14 PM
Knowing uv is floats,mean you could use 4096x4096,maybe try make text with help of multitexture, one layer is front of text,bottom layer is a cool background,in-between layer has different color/pattern for isometric 3d part of text

Yeah.  :t

There are many ways and techniques to create cool text effects.
- mipmap text zoomers/rotators
- 2D/3D scrollers
- turn scrollers
- sine scrollers
- twister scrollers
- type writers
- etc.

The limit is your own creative imagination.

Maybe we can discuss how to create various effects?
Title: Re: 64-bit DirectX 11 - Part 2 - Mesh
Post by: aw27 on May 31, 2018, 10:48:40 PM
Quote from: Siekmanski on May 31, 2018, 09:43:59 PM
Maybe we can discuss how to create various effects?
Looks like a brilliant idea.  :t
Title: Re: 64-bit DirectX 11 - Part 2 - Mesh
Post by: daydreamer on June 01, 2018, 02:14:43 AM
Quote from: Siekmanski on May 31, 2018, 09:43:59 PM
Quote from: daydreamer on May 31, 2018, 08:43:14 PM
Knowing uv is floats,mean you could use 4096x4096,maybe try make text with help of multitexture, one layer is front of text,bottom layer is a cool background,in-between layer has different color/pattern for isometric 3d part of text

Yeah.  :t

There are many ways and techniques to create cool text effects.
- mipmap text zoomers/rotators
- 2D/3D scrollers
- turn scrollers
- sine scrollers
- twister scrollers
- type writers
- etc.

The limit is your own creative imagination.

Maybe we can discuss how to create various effects?
this was a way to create a avatar,with masm oop,masmbox,aoa book(didnt get texture to work),but it turned out to big
http://masm32.com/board/index.php?topic=6842.0 (http://masm32.com/board/index.php?topic=6842.0)
possible also to create with help of coding physics code with some random factor
@ascended
sometimes its good to come back to a shelved Project,with new knowledge and new ideas
Title: Re: 64-bit DirectX 11 - Part 2 - Mesh
Post by: Siekmanski on June 01, 2018, 03:46:52 AM
Pity it was too big
Would be a nice forum avatar.
Title: Re: 64-bit DirectX 11 - Part 2 - Mesh
Post by: Lonewolff on June 01, 2018, 07:26:50 AM
Quote from: daydreamer on June 01, 2018, 02:14:43 AM
@ascended
sometimes its good to come back to a shelved Project,with new knowledge and new ideas

True, but there isn't much in DX11 that I don't know how to do. I have been coding with it for the past nine years.
Title: Re: 64-bit DirectX 11 - Part 2 - Mesh
Post by: aw27 on June 01, 2018, 02:35:19 PM
Quote from: Ascended on June 01, 2018, 07:26:50 AM
Quote from: daydreamer on June 01, 2018, 02:14:43 AM
@ascended
sometimes its good to come back to a shelved Project,with new knowledge and new ideas

True, but there isn't much in DX11 that I don't know how to do. I have been coding with it for the past nine years.
So, you don't post source code because you don't have any source code to post or is  there another reason?  :badgrin:
Why are you posting useless images, is this an art gallery?
Title: Re: 64-bit DirectX 11 - Part 2 - Mesh
Post by: Lonewolff on June 01, 2018, 04:20:39 PM
Quote from: AW on June 01, 2018, 02:35:19 PM
So, you don't post source code because you don't have any source code to post or is  there another reason?  :badgrin:

You got me. My 4Kb executables were clearly done in C++.  :t


Quote from: AW on June 01, 2018, 02:35:19 PM
Why are you posting useless images, is this an art gallery?

Well isn't it? Coding is an art form in my opinion.

Come see me when you want to progress from wire frame cars, I personally don't think you have a hope in hell to be honest. I believe this is why you made it wire frame in the first place as you couldn't figure out how to change it from a solid white mass.  :eusa_clap:

You are struggling with the concept on how to do text for christ sake, so why would I offer source code to someone who has been arrogant and belittling to me since I started posting in this forum? Figure it out yourself ass hole...  :t

Your fledgling business has made you a cranky bastard.  :eusa_boohoo:
Title: Re: 64-bit DirectX 11 - Part 2 - Mesh
Post by: aw27 on June 01, 2018, 04:33:07 PM
You are the true con artist, @Ascend.  :badgrin:
You have not the faintest idea what programming is all about.

Quote
You are struggling with the concept on how to do text for christ sake,
Not struggling, I have done it. Are you waiting to know how, right?

Title: Re: 64-bit DirectX 11 - Part 2 - Mesh
Post by: Lonewolff on June 01, 2018, 04:33:57 PM
Quote from: AW on June 01, 2018, 04:33:07 PM
You are the true con artist, @Ascend.  :badgrin:
You have not the faintest idea what programming is all about.

Yep, you got me.  :t

A con artist usually has an agenda. So I must be the worst con artist out there - ROFL.
Title: Re: 64-bit DirectX 11 - Part 2 - Mesh
Post by: Lonewolff on June 01, 2018, 04:42:32 PM
Quote from: Ascended on June 01, 2018, 04:33:57 PM
You are the true con artist, @Ascend.  :badgrin:
You have not the faintest idea what programming is all about.

Yep, you got me.  :t

A con artist usually has an agenda. So I must be the worst con artist out there - ROFL.


Quote from: AW on June 01, 2018, 04:33:07 PMAre you waiting to know how, right?

Oh yes, big time. I'd love to know how to add lighting to my meshes so they can look as good as the fake executable I posted two months ago.  :bgrin:
Title: Re: 64-bit DirectX 11 - Part 2 - Mesh
Post by: Lonewolff on June 01, 2018, 04:44:25 PM
Quote from: AW on June 01, 2018, 04:42:32 PM
You are the true con artist, @Ascend.  :badgrin:
You have not the faintest idea what programming is all about.

Yep, you got me.  :t

A con artist usually has an agenda. So I must be the worst con artist out there - ROFL.


Quote from: AW on June 01, 2018, 04:33:07 PMAre you waiting to know how, right?

Oh yes, big time. I'd love to know how to add lighting to my meshes so they can look as good as the fake executable I posted two months ago.  :bgrin:


Have, fun jerking each other off. I have a game I need to ship.

https://steamcommunity.com/workshop/browse/?section=concepts&appid=765&browsesort=toprated&browsefilter=toprated&p=1

#13 All time highest rated Steam Concept - More con artistry, of course. :eusa_clap:


Title: Re: 64-bit DirectX 11 - Part 2 - Mesh
Post by: jj2007 on June 01, 2018, 04:49:18 PM
@Ascended: Please ignore him. Every once in a while he has a hormonal problem, we got used to it. Some days later, he'll be back to normal. José is not a bad guy, just a bit frustrated :icon14:

P.S.:
Quote from: Ascended on June 01, 2018, 04:44:25 PMI have a game I need to ship.

https://steamcommunity.com/workshop/browse/?section=concepts&appid=765&browsesort=toprated&browsefilter=toprated&p=1
Which one is yours? #13 doesn't tell me much here...
Title: Re: 64-bit DirectX 11 - Part 2 - Mesh
Post by: aw27 on June 01, 2018, 04:57:37 PM
@JJ,
Poor soul, always trying to join forces against me, right?

Quote
Which one is yours? #13 doesn't tell me much here...

LOL, and you believed.  :dazzled:
Title: Re: 64-bit DirectX 11 - Part 2 - Mesh
Post by: jj2007 on June 01, 2018, 05:05:25 PM
Quote from: AW on June 01, 2018, 04:57:37 PMPoor soul, always trying to join forces against me, right?

No, José, I respect you because you are a very knowledgeable coder. I guess nobody doubts that. But everybody can also see that you are frustrated. Don't pull down the whole forum with your personal problems. There are people here who have much bigger problems, and yet they don't seminate hatred. This is a peaceful place in general, don't spoil it.

@Hutch: Please do us a favour and delete the last 4 or 5 posts ;)
Title: Re: 64-bit DirectX 11 - Part 2 - Mesh
Post by: aw27 on June 01, 2018, 05:09:40 PM
Quote from: jj2007 on June 01, 2018, 05:05:25 PM
No, José, I respect you because you are a very knowledgeable coder. I guess nobody doubts that. But everybody can also see that you are frustrated. Don't pull down the whole forum with your personal problems. There are people here who have much bigger problems, and yet they don't seminate hatred. This is a peaceful place in general, don't spoil it.
The most frustrated person I found here is indeed you. You don't really have another life except this forum. You are here 24x7
All frustrated guys have a tendency to judge the others.
Title: Re: 64-bit DirectX 11 - Part 2 - Mesh
Post by: Lonewolff on June 01, 2018, 07:22:02 PM
Quote from: AW on June 01, 2018, 04:57:37 PM
@JJ,
Poor soul, always trying to join forces against me, right?

Quote
Which one is yours? #13 doesn't tell me much here...

LOL, and you believed.  :dazzled:


'One of them' is the beast   8)

@HormonalGuy - Feel free to send the developer a message. See who responds  :t


Quote from: AW on June 01, 2018, 05:09:40 PM
Quote from: jj2007 on June 01, 2018, 05:05:25 PM
No, José, I respect you because you are a very knowledgeable coder. I guess nobody doubts that. But everybody can also see that you are frustrated. Don't pull down the whole forum with your personal problems. There are people here who have much bigger problems, and yet they don't seminate hatred. This is a peaceful place in general, don't spoil it.
The most frustrated person I found here is indeed you. You don't really have another life except this forum. You are here 24x7
All frustrated guys have a tendency to judge the others.

Classic case of the pot calling the kettle black, I'd say.

JJ2007 has shown nothing but respect (for everyone). I have never caught a hint of the said 'frustration' with him.
Title: Re: 64-bit DirectX 11 - Part 2 - Mesh
Post by: aw27 on June 01, 2018, 07:38:45 PM
Quote
@HormonalGuy - Feel free to send the developer a message. See who responds  :t
So, in that games forum you are saying you are a MASM guru and here you are saying you have to dispatch your latest games titles.
Can you post a link to your famous conversion of Siekmanski code to DirectX 11 or whatever 4KB ASM built executable you are referring to ? I want to disassemble it with IDA Pro and see what is your secret.  ;)
Title: Re: 64-bit DirectX 11 - Part 2 - Mesh
Post by: Siekmanski on June 01, 2018, 07:47:20 PM
Make CODE, not WAR.  :biggrin:
Title: Re: 64-bit DirectX 11 - Part 2 - Mesh
Post by: Lonewolff on June 01, 2018, 07:56:00 PM
Quote from: AW on June 01, 2018, 07:38:45 PM
Quote
@HormonalGuy - Feel free to send the developer a message. See who responds  :t
So, in that games forum you are saying you are a MASM guru and here you are saying you have to dispatch your latest games titles.
Can you post a link to your famous conversion of Siekmanski code to DirectX 11 or whatever 4KB ASM built executable you are referring to ? I want to disassemble it with IDA Pro and see what is your secret.  ;)

When did I say I was an MASM guru? I am far from it. :icon_confused: Highly proficient in C++ and the DirectX family - Yes, yes I am. Thank you for asking.  8)



If you are after the executables I posted take a look in my games thread, dickhead  :t
Title: Re: 64-bit DirectX 11 - Part 2 - Mesh
Post by: aw27 on June 01, 2018, 08:36:39 PM
@Ascend

From you I can only find this:
Quote
3D mathematics - Ugghh!
Yeah, DDraw isn't something I have really touched.
I'm no guru at the API's
Woot! My first DX11 render window,
@Siekmanski - Hey dude, I am trying to learn COM myself also

Now, tell me , how can you develop any game with such short knowledge of fundamental things. Are you using Unity?
Title: Re: 64-bit DirectX 11 - Part 2 - Mesh
Post by: Lonewolff on June 01, 2018, 08:44:51 PM
Quote from: AW on June 01, 2018, 08:36:39 PM
@Ascend

From you I can only find this:
Quote
3D mathematics - Ugghh! (This is what DXMath.h is for)
Yeah, DDraw isn't something I have really touched. (DDraw has been deprecated since DirectX7 (20 years ago) and is primarily a 2D API, why would I know it well?)
I'm no guru at the API's (what API's are you referring to?)
Woot! My first DX11 render window, (in assembly, idiot)
@Siekmanski - Hey dude, I am trying to learn COM myself also (see previous, but here's a reminder - 'in assembly, idiot')

That's all you found? You have proven my point.


Quote
Now, tell me , how can you develop any game with such a short knowledge of fundamental things. Are you using Unity?

Um, no....
Title: Re: 64-bit DirectX 11 - Part 2 - Mesh
Post by: aw27 on June 01, 2018, 08:48:39 PM
@Ascend,
You don't stop to call me names, probably trying this way to balance the evidence against your scam.
Title: Re: 64-bit DirectX 11 - Part 2 - Mesh
Post by: Lonewolff on June 01, 2018, 08:50:37 PM
Quote from: AW on June 01, 2018, 08:48:39 PM
@Ascend,
You don't stop to call me names, probably trying this way to balance the evidence against your scam.

Still waiting for your money. My scam is no good unless you pay me.  :bgrin:

If I recall correctly (which I always do) you were the one who introduced the name calling, so why do you suddenly take issue with it?


(AW runs to edit all of his initial posts towards me - LOL  :eusa_clap:)
Title: Re: 64-bit DirectX 11 - Part 2 - Mesh
Post by: aw27 on June 01, 2018, 09:12:28 PM
All right, @Ascend or @HormonalGuy

Take your time to put to market your game titles.  :badgrin:

BTW,

Quote
DDraw has been deprecated since DirectX7 (20 years ago) and is primarily a 2D API, why would I know it well

Because you need it to write 2D text (unless you are using bitmap fonts). You should know this.

Quote
AW runs to edit all of his initial posts towards me - LOL
If I recall, you are the one who use to do it. It is not a common practice of other members.


Title: Re: 64-bit DirectX 11 - Part 2 - Mesh
Post by: Lonewolff on June 01, 2018, 09:28:37 PM
Quote from: AW on June 01, 2018, 09:12:28 PM
All right, @Ascend or @HormonalGuy

Take your time to put to market your game titles.  :badgrin:

BTW,

Quote
DDraw has been deprecated since DirectX7 (20 years ago) and is primarily a 2D API, why would I know it well

Because you need it to write 2D text (unless you are using bitmap fonts). You should know this.

You are incorrect. But you are too stubourn to take advice from others who have more experience in the given field.
Title: Re: 64-bit DirectX 11 - Part 2 - Mesh
Post by: Siekmanski on June 01, 2018, 09:42:09 PM
No need to use ddraw to write 2D text, you can use a 3D vertex format that includes the position of a transformed vertex to draw texture bitmaps in 2D mode.
Title: Re: 64-bit DirectX 11 - Part 2 - Mesh
Post by: Lonewolff on June 01, 2018, 09:54:29 PM
Quote from: Siekmanski on June 01, 2018, 09:42:09 PM
No need to use ddraw to write 2D text, you can use a 3D vertex format that includes the position of a transformed vertex to draw texture bitmaps in 2D mode.

You dare to suggest that AW is incorrect?  :bgrin:
Title: Re: 64-bit DirectX 11 - Part 2 - Mesh
Post by: aw27 on June 01, 2018, 09:56:04 PM
Quote from: Siekmanski on June 01, 2018, 09:42:09 PM
No need to use ddraw to write 2D text, you can use a 3D vertex format that includes the position of a transformed vertex to draw texture bitmaps in 2D mode.
Yes, but Direct2D/DirectWrite will print with true vector font quality and will include any Unicode Character in any typeface, size or style.
But I am not saying that we should use it for most games.
Title: Re: 64-bit DirectX 11 - Part 2 - Mesh
Post by: Lonewolff on June 01, 2018, 10:02:31 PM
Quote from: AW on June 01, 2018, 09:56:04 PM
Quote from: Siekmanski on June 01, 2018, 09:42:09 PM
No need to use ddraw to write 2D text, you can use a 3D vertex format that includes the position of a transformed vertex to draw texture bitmaps in 2D mode.
Yes, but Direct2D/DirectWrite will print with true vector font quality and will include any Unicode Character in any typeface, size or style.
But I am not saying that we should use it for most games.

More backflips than an Olympic gymnast.
Title: Re: 64-bit DirectX 11 - Part 2 - Mesh
Post by: nidud on June 01, 2018, 10:06:24 PM
deleted
Title: Re: 64-bit DirectX 11 - Part 2 - Mesh
Post by: Lonewolff on June 01, 2018, 10:10:26 PM
He's a scammer, he grabbed some dudes DMath.lib and is trying to pass it off as his own  :P
Title: Re: 64-bit DirectX 11 - Part 2 - Mesh
Post by: aw27 on June 01, 2018, 10:11:32 PM
@Nidud,
It is not the DirectXMath library it is the DMath Library.
https://www.codeproject.com/Tips/1174521/DMath-is-DirectXMath-for-All
It does not use vector call it is compatible with any programming language. The syntax and function names are the same as DirectXmath

Title: Re: 64-bit DirectX 11 - Part 2 - Mesh
Post by: nidud on June 01, 2018, 10:20:56 PM
deleted
Title: Re: 64-bit DirectX 11 - Part 2 - Mesh
Post by: aw27 on June 01, 2018, 10:24:05 PM
I got your point, it is a library of 1 object:
lib.exe /out:DMathSt64.lib DMath64.obj

I could have made 500+ objects, however it would have complicated a lot because many functions call other functions.
Title: Re: 64-bit DirectX 11 - Part 2 - Mesh
Post by: felipe on June 03, 2018, 03:13:11 AM
Quote from: jj2007 on June 01, 2018, 05:05:25 PM
But everybody can also see that you are frustrated.

:idea: I don't pretend to make more fight here, but i want to express myself to say i don't feet in that group. My opinion is that you have some "acid" sense of humour and you are also a critic person. I also want to point here (in some kind of respecfull way to a human person) that you have contributed in this forum helping others and with good working source code for 32 and 64 bits. Please, don't get discouraged with this kind of fights in the forum, you are a good member i think.  :icon14: