dx9
Some checks failed
pyrite-dev/milsko/pipeline/head There was a failure building this commit

This commit is contained in:
IoIxD 2026-09-17 20:58:41 -07:00
commit f2dd0ac3f1
13 changed files with 698 additions and 15 deletions

View file

@ -32,6 +32,10 @@ else()
option(MW_TRY_OPENGL "Try to compile OpenGL widget or not" ON) option(MW_TRY_OPENGL "Try to compile OpenGL widget or not" ON)
option(MW_TRY_VULKAN "Try to compile Vulkan widget or not" ON) option(MW_TRY_VULKAN "Try to compile Vulkan widget or not" ON)
endif() endif()
if(${CMAKE_SYSTEM_NAME} MATCHES Windows)
option(MW_TRY_DIRECTX "Try to compile DirectX widget or not" ON)
endif()
option(MW_INSTALL_HEADERS "Install headers" ON) option(MW_INSTALL_HEADERS "Install headers" ON)
@ -90,6 +94,16 @@ if(MW_TRY_VULKAN)
endif() endif()
endif() endif()
if(MW_TRY_DIRECTX)
include(${CMAKE_CURRENT_SOURCE_DIR}/resource/FindDirectX.cmake)
if(DIRECTX_FOUND)
set(MW_BUILD_DIRECTX ON)
message(STATUS "DirectX widget has been enabled")
else()
message(STATUS "DirectX widget has been disabled")
endif()
endif()
if(MW_BUILD_STATIC) if(MW_BUILD_STATIC)
message(STATUS "Building Milsko as a static library") message(STATUS "Building Milsko as a static library")
add_library( add_library(
@ -477,6 +491,15 @@ if(MW_BUILD_VULKAN)
endif() endif()
endif() endif()
if(MW_BUILD_DIRECTX)
list(APPEND LIBRARIES ${DIRECTX_D3DX9_LIBRARIES})
target_compile_definitions(
Mw
PRIVATE
MW_DIRECTX
)
endif()
target_compile_definitions( target_compile_definitions(
Mw Mw
PRIVATE PRIVATE

8
Jenkinsfile vendored
View file

@ -30,7 +30,7 @@ pipeline {
} }
steps { steps {
sh("git clean -dfx") sh("git clean -dfx")
sh("./configure --enable-opengl --enable-vulkan --without-vulkan-string-helper") sh("./configure --enable-opengl --enable-directx --enable-vulkan --without-vulkan-string-helper")
sh("make -j4") sh("make -j4")
sh("mv src/libMw.so libMw64.so") sh("mv src/libMw.so libMw64.so")
archiveArtifacts("libMw64.so") archiveArtifacts("libMw64.so")
@ -42,7 +42,7 @@ pipeline {
} }
steps { steps {
sh("git clean -dfx") sh("git clean -dfx")
sh("./configure --enable-opengl --cross --target=Windows --host=i686-w64-mingw32") sh("./configure --enable-opengl --enable-directx --cross --target=Windows --host=i686-w64-mingw32")
sh("make -j4") sh("make -j4")
sh("mv src/Mw.dll Mw32.dll") sh("mv src/Mw.dll Mw32.dll")
sh("mv src/libMw.dll.a libMw32.dll.a") sh("mv src/libMw.dll.a libMw32.dll.a")
@ -55,7 +55,7 @@ pipeline {
} }
steps { steps {
sh("git clean -dfx") sh("git clean -dfx")
sh("./configure --enable-opengl --cross --target=Windows --host=x86_64-w64-mingw32") sh("./configure --enable-opengl --enable-directx --cross --target=Windows --host=x86_64-w64-mingw32")
sh("make -j4") sh("make -j4")
sh("mv src/Mw.dll Mw64.dll") sh("mv src/Mw.dll Mw64.dll")
sh("mv src/libMw.dll.a libMw64.dll.a") sh("mv src/libMw.dll.a libMw64.dll.a")
@ -80,7 +80,7 @@ pipeline {
} }
environment { environment {
WATCOM = "/usr/watcom" WATCOM = "/usr/watcom"
INCLUDE = "/usr/watcom/h:/usr/watcom/h/nt" INCLUDE = "/usr/watcom/h:/usr/watcom/h/nt:/usr/watcom/h/nt/directx"
PATH = "/usr/watcom/binl64:${env.PATH}" PATH = "/usr/watcom/binl64:${env.PATH}"
} }
steps { steps {

21
NTMakefile generated
View file

@ -1,7 +1,20 @@
CC = cl /TC /c /nologo CC = cl /TC /c /nologo
LD = link /nologo LD = link /nologo
MW_CFLAGS = /Iinclude /Iexternal\libz\include /D_MILSKO /D_MILSKO_BUILD /DUSE_GDI /DUSE_STB_IMAGE /DSTBI_NO_SIMD /DUSE_GDI_TEXT /DMW_OPENGL !if [where d3d9.h >nul 2>nul]
!if [for /f "delims=" %P in ('where d3d9.h 2^>nul') do @echo DX9_FLAGS = /DMW_DIRECTX /I"%~dpP">dx9flags.mk]
!endif
!else
!if [echo DX9_FLAGS =>dx9flags.mk]
!endif
!endif
!if exist("dx9flags.mk")
!include "dx9flags.mk"
!else
DX9_FLAGS =
!endif
MW_CFLAGS = /Iinclude /Iexternal\libz\include /D_MILSKO /D_MILSKO_BUILD /DUSE_GDI /DUSE_STB_IMAGE /DSTBI_NO_SIMD /DUSE_GDI_TEXT /DMW_OPENGL $(DX9_FLAGS)
MW_LDFLAGS = /DLL MW_LDFLAGS = /DLL
EXE_CFLAGS = /Iinclude EXE_CFLAGS = /Iinclude
EXE_LDFLAGS = EXE_LDFLAGS =
@ -86,6 +99,7 @@ clean:
del /f /q src\widget\checkbox.obj del /f /q src\widget\checkbox.obj
del /f /q src\widget\clock.obj del /f /q src\widget\clock.obj
del /f /q src\widget\combobox.obj del /f /q src\widget\combobox.obj
del /f /q src\widget\directx.obj
del /f /q src\widget\document.obj del /f /q src\widget\document.obj
del /f /q src\widget\entry.obj del /f /q src\widget\entry.obj
del /f /q src\widget\frame.obj del /f /q src\widget\frame.obj
@ -108,6 +122,7 @@ clean:
del /f /q src\widget\window.obj del /f /q src\widget\window.obj
del /f /q src\Mw.dll del /f /q src\Mw.dll
del /f /q src\Mw.lib del /f /q src\Mw.lib
del /f /q dx9flags.mk
del /f /q examples\basic\box.obj del /f /q examples\basic\box.obj
del /f /q examples\basic\calculator.obj del /f /q examples\basic\calculator.obj
del /f /q examples\basic\checkbox.obj del /f /q examples\basic\checkbox.obj
@ -342,8 +357,8 @@ examples\gldemos\tripaint.obj: examples/gldemos/tripaint.c
$(CC) $(EXE_CFLAGS) /Fo$@ examples/gldemos/tripaint.c $(CC) $(EXE_CFLAGS) /Fo$@ examples/gldemos/tripaint.c
src\Mw.dll: external\libz\src\adler32.obj external\libz\src\compress.obj external\libz\src\crc32.obj external\libz\src\deflate.obj external\libz\src\gzclose.obj external\libz\src\gzlib.obj external\libz\src\gzread.obj external\libz\src\gzwrite.obj external\libz\src\infback.obj external\libz\src\inffast.obj external\libz\src\inflate.obj external\libz\src\inftrees.obj external\libz\src\trees.obj external\libz\src\uncompr.obj external\libz\src\zutil.obj external\md4c.obj external\stb_ds.obj external\stb_image.obj external\stb_truetype.obj src\abstract\charset.obj src\abstract\directory.obj src\abstract\dynamic.obj src\abstract\time.obj src\backend\gdi.obj src\color.obj src\core.obj src\cursor\arrow.obj src\cursor\center.obj src\cursor\cross.obj src\cursor\default.obj src\cursor\hand.obj src\cursor\hidden.obj src\cursor\text.obj src\default.obj src\dialog\colorpicker.obj src\dialog\directorychooser.obj src\dialog\filechooser.obj src\dialog\messagebox.obj src\draw.obj src\icon\back.obj src\icon\clock.obj src\icon\computer.obj src\icon\directory.obj src\icon\down.obj src\icon\error.obj src\icon\file.obj src\icon\forward.obj src\icon\info.obj src\icon\left.obj src\icon\news.obj src\icon\note.obj src\icon\right.obj src\icon\search.obj src\icon\up.obj src\icon\warning.obj src\lowlevel.obj src\string.obj src\text\font\boldfont.obj src\text\font\boldmonottf.obj src\text\font\boldttf.obj src\text\font\font.obj src\text\font\monottf.obj src\text\font\ttf.obj src\text\ft2.obj src\text\gdi.obj src\text\stbtt.obj src\text\text.obj src\truetype.obj src\unicode.obj src\widget\box.obj src\widget\button.obj src\widget\calendar.obj src\widget\chart.obj src\widget\checkbox.obj src\widget\clock.obj src\widget\combobox.obj src\widget\document.obj src\widget\entry.obj src\widget\frame.obj src\widget\image.obj src\widget\label.obj src\widget\listbox.obj src\widget\menu.obj src\widget\numberentry.obj src\widget\opengl.obj src\widget\progressbar.obj src\widget\radiobox.obj src\widget\scrollbar.obj src\widget\separator.obj src\widget\submenu.obj src\widget\subwindow.obj src\widget\tab.obj src\widget\table.obj src\widget\treeview.obj src\widget\viewport.obj src\widget\window.obj src\Mw.dll: external\libz\src\adler32.obj external\libz\src\compress.obj external\libz\src\crc32.obj external\libz\src\deflate.obj external\libz\src\gzclose.obj external\libz\src\gzlib.obj external\libz\src\gzread.obj external\libz\src\gzwrite.obj external\libz\src\infback.obj external\libz\src\inffast.obj external\libz\src\inflate.obj external\libz\src\inftrees.obj external\libz\src\trees.obj external\libz\src\uncompr.obj external\libz\src\zutil.obj external\md4c.obj external\stb_ds.obj external\stb_image.obj external\stb_truetype.obj src\abstract\charset.obj src\abstract\directory.obj src\abstract\dynamic.obj src\abstract\time.obj src\backend\gdi.obj src\color.obj src\core.obj src\cursor\arrow.obj src\cursor\center.obj src\cursor\cross.obj src\cursor\default.obj src\cursor\hand.obj src\cursor\hidden.obj src\cursor\text.obj src\default.obj src\dialog\colorpicker.obj src\dialog\directorychooser.obj src\dialog\filechooser.obj src\dialog\messagebox.obj src\draw.obj src\icon\back.obj src\icon\clock.obj src\icon\computer.obj src\icon\directory.obj src\icon\down.obj src\icon\error.obj src\icon\file.obj src\icon\forward.obj src\icon\info.obj src\icon\left.obj src\icon\news.obj src\icon\note.obj src\icon\right.obj src\icon\search.obj src\icon\up.obj src\icon\warning.obj src\lowlevel.obj src\string.obj src\text\font\boldfont.obj src\text\font\boldmonottf.obj src\text\font\boldttf.obj src\text\font\font.obj src\text\font\monottf.obj src\text\font\ttf.obj src\text\ft2.obj src\text\gdi.obj src\text\stbtt.obj src\text\text.obj src\truetype.obj src\unicode.obj src\widget\box.obj src\widget\button.obj src\widget\calendar.obj src\widget\chart.obj src\widget\checkbox.obj src\widget\clock.obj src\widget\combobox.obj src\widget\directx.obj src\widget\document.obj src\widget\entry.obj src\widget\frame.obj src\widget\image.obj src\widget\label.obj src\widget\listbox.obj src\widget\menu.obj src\widget\numberentry.obj src\widget\opengl.obj src\widget\progressbar.obj src\widget\radiobox.obj src\widget\scrollbar.obj src\widget\separator.obj src\widget\submenu.obj src\widget\subwindow.obj src\widget\tab.obj src\widget\table.obj src\widget\treeview.obj src\widget\viewport.obj src\widget\window.obj
$(LD) $(MW_LDFLAGS) /OUT:$@ external\libz\src\adler32.obj external\libz\src\compress.obj external\libz\src\crc32.obj external\libz\src\deflate.obj external\libz\src\gzclose.obj external\libz\src\gzlib.obj external\libz\src\gzread.obj external\libz\src\gzwrite.obj external\libz\src\infback.obj external\libz\src\inffast.obj external\libz\src\inflate.obj external\libz\src\inftrees.obj external\libz\src\trees.obj external\libz\src\uncompr.obj external\libz\src\zutil.obj external\md4c.obj external\stb_ds.obj external\stb_image.obj external\stb_truetype.obj src\abstract\charset.obj src\abstract\directory.obj src\abstract\dynamic.obj src\abstract\time.obj src\backend\gdi.obj src\color.obj src\core.obj src\cursor\arrow.obj src\cursor\center.obj src\cursor\cross.obj src\cursor\default.obj src\cursor\hand.obj src\cursor\hidden.obj src\cursor\text.obj src\default.obj src\dialog\colorpicker.obj src\dialog\directorychooser.obj src\dialog\filechooser.obj src\dialog\messagebox.obj src\draw.obj src\icon\back.obj src\icon\clock.obj src\icon\computer.obj src\icon\directory.obj src\icon\down.obj src\icon\error.obj src\icon\file.obj src\icon\forward.obj src\icon\info.obj src\icon\left.obj src\icon\news.obj src\icon\note.obj src\icon\right.obj src\icon\search.obj src\icon\up.obj src\icon\warning.obj src\lowlevel.obj src\string.obj src\text\font\boldfont.obj src\text\font\boldmonottf.obj src\text\font\boldttf.obj src\text\font\font.obj src\text\font\monottf.obj src\text\font\ttf.obj src\text\ft2.obj src\text\gdi.obj src\text\stbtt.obj src\text\text.obj src\truetype.obj src\unicode.obj src\widget\box.obj src\widget\button.obj src\widget\calendar.obj src\widget\chart.obj src\widget\checkbox.obj src\widget\clock.obj src\widget\combobox.obj src\widget\document.obj src\widget\entry.obj src\widget\frame.obj src\widget\image.obj src\widget\label.obj src\widget\listbox.obj src\widget\menu.obj src\widget\numberentry.obj src\widget\opengl.obj src\widget\progressbar.obj src\widget\radiobox.obj src\widget\scrollbar.obj src\widget\separator.obj src\widget\submenu.obj src\widget\subwindow.obj src\widget\tab.obj src\widget\table.obj src\widget\treeview.obj src\widget\viewport.obj src\widget\window.obj opengl32.lib gdi32.lib ole32.lib uuid.lib user32.lib advapi32.lib $(LD) $(MW_LDFLAGS) /OUT:$@ external\libz\src\adler32.obj external\libz\src\compress.obj external\libz\src\crc32.obj external\libz\src\deflate.obj external\libz\src\gzclose.obj external\libz\src\gzlib.obj external\libz\src\gzread.obj external\libz\src\gzwrite.obj external\libz\src\infback.obj external\libz\src\inffast.obj external\libz\src\inflate.obj external\libz\src\inftrees.obj external\libz\src\trees.obj external\libz\src\uncompr.obj external\libz\src\zutil.obj external\md4c.obj external\stb_ds.obj external\stb_image.obj external\stb_truetype.obj src\abstract\charset.obj src\abstract\directory.obj src\abstract\dynamic.obj src\abstract\time.obj src\backend\gdi.obj src\color.obj src\core.obj src\cursor\arrow.obj src\cursor\center.obj src\cursor\cross.obj src\cursor\default.obj src\cursor\hand.obj src\cursor\hidden.obj src\cursor\text.obj src\default.obj src\dialog\colorpicker.obj src\dialog\directorychooser.obj src\dialog\filechooser.obj src\dialog\messagebox.obj src\draw.obj src\icon\back.obj src\icon\clock.obj src\icon\computer.obj src\icon\directory.obj src\icon\down.obj src\icon\error.obj src\icon\file.obj src\icon\forward.obj src\icon\info.obj src\icon\left.obj src\icon\news.obj src\icon\note.obj src\icon\right.obj src\icon\search.obj src\icon\up.obj src\icon\warning.obj src\lowlevel.obj src\string.obj src\text\font\boldfont.obj src\text\font\boldmonottf.obj src\text\font\boldttf.obj src\text\font\font.obj src\text\font\monottf.obj src\text\font\ttf.obj src\text\ft2.obj src\text\gdi.obj src\text\stbtt.obj src\text\text.obj src\truetype.obj src\unicode.obj src\widget\box.obj src\widget\button.obj src\widget\calendar.obj src\widget\chart.obj src\widget\checkbox.obj src\widget\clock.obj src\widget\combobox.obj src\widget\directx.obj src\widget\document.obj src\widget\entry.obj src\widget\frame.obj src\widget\image.obj src\widget\label.obj src\widget\listbox.obj src\widget\menu.obj src\widget\numberentry.obj src\widget\opengl.obj src\widget\progressbar.obj src\widget\radiobox.obj src\widget\scrollbar.obj src\widget\separator.obj src\widget\submenu.obj src\widget\subwindow.obj src\widget\tab.obj src\widget\table.obj src\widget\treeview.obj src\widget\viewport.obj src\widget\window.obj opengl32.lib gdi32.lib ole32.lib uuid.lib user32.lib advapi32.lib
.c.obj: .c.obj:

9
WatMakefile generated
View file

@ -1,7 +1,7 @@
CC = wcc386 -bt=nt -q CC = wcc386 -bt=nt -q
LD = wlink option quiet LD = wlink option quiet
MW_CFLAGS = -bd -i=include -i=external/libz/include -d_MILSKO -d_MILSKO_BUILD -dUSE_GDI -dUSE_STB_IMAGE -dSTBI_NO_SIMD -dUSE_GDI_TEXT -dMW_OPENGL MW_CFLAGS = -bd -i=include -i=external/libz/include -d_MILSKO -d_MILSKO_BUILD -dUSE_GDI -dUSE_STB_IMAGE -dSTBI_NO_SIMD -dUSE_GDI_TEXT -dMW_OPENGL -dMW_DIRECTX
MW_LDFLAGS = system nt_dll MW_LDFLAGS = system nt_dll
EXE_CFLAGS = -i=include EXE_CFLAGS = -i=include
EXE_LDFLAGS = system nt EXE_LDFLAGS = system nt
@ -85,6 +85,7 @@ clean: .SYMBOLIC
%erase src/widget/checkbox.obj %erase src/widget/checkbox.obj
%erase src/widget/clock.obj %erase src/widget/clock.obj
%erase src/widget/combobox.obj %erase src/widget/combobox.obj
%erase src/widget/directx.obj
%erase src/widget/document.obj %erase src/widget/document.obj
%erase src/widget/entry.obj %erase src/widget/entry.obj
%erase src/widget/frame.obj %erase src/widget/frame.obj
@ -341,8 +342,8 @@ examples/gldemos/tripaint.obj: examples/gldemos/tripaint.c
$(CC) $(EXE_CFLAGS) -fo=$@ examples/gldemos/tripaint.c $(CC) $(EXE_CFLAGS) -fo=$@ examples/gldemos/tripaint.c
src/Mw.dll: external/libz/src/adler32.obj external/libz/src/compress.obj external/libz/src/crc32.obj external/libz/src/deflate.obj external/libz/src/gzclose.obj external/libz/src/gzlib.obj external/libz/src/gzread.obj external/libz/src/gzwrite.obj external/libz/src/infback.obj external/libz/src/inffast.obj external/libz/src/inflate.obj external/libz/src/inftrees.obj external/libz/src/trees.obj external/libz/src/uncompr.obj external/libz/src/zutil.obj external/md4c.obj external/stb_ds.obj external/stb_image.obj external/stb_truetype.obj src/abstract/charset.obj src/abstract/directory.obj src/abstract/dynamic.obj src/abstract/time.obj src/backend/gdi.obj src/color.obj src/core.obj src/cursor/arrow.obj src/cursor/center.obj src/cursor/cross.obj src/cursor/default.obj src/cursor/hand.obj src/cursor/hidden.obj src/cursor/text.obj src/default.obj src/dialog/colorpicker.obj src/dialog/directorychooser.obj src/dialog/filechooser.obj src/dialog/messagebox.obj src/draw.obj src/icon/back.obj src/icon/clock.obj src/icon/computer.obj src/icon/directory.obj src/icon/down.obj src/icon/error.obj src/icon/file.obj src/icon/forward.obj src/icon/info.obj src/icon/left.obj src/icon/news.obj src/icon/note.obj src/icon/right.obj src/icon/search.obj src/icon/up.obj src/icon/warning.obj src/lowlevel.obj src/string.obj src/text/font/boldfont.obj src/text/font/boldmonottf.obj src/text/font/boldttf.obj src/text/font/font.obj src/text/font/monottf.obj src/text/font/ttf.obj src/text/ft2.obj src/text/gdi.obj src/text/stbtt.obj src/text/text.obj src/truetype.obj src/unicode.obj src/widget/box.obj src/widget/button.obj src/widget/calendar.obj src/widget/chart.obj src/widget/checkbox.obj src/widget/clock.obj src/widget/combobox.obj src/widget/document.obj src/widget/entry.obj src/widget/frame.obj src/widget/image.obj src/widget/label.obj src/widget/listbox.obj src/widget/menu.obj src/widget/numberentry.obj src/widget/opengl.obj src/widget/progressbar.obj src/widget/radiobox.obj src/widget/scrollbar.obj src/widget/separator.obj src/widget/submenu.obj src/widget/subwindow.obj src/widget/tab.obj src/widget/table.obj src/widget/treeview.obj src/widget/viewport.obj src/widget/window.obj src/Mw.dll: external/libz/src/adler32.obj external/libz/src/compress.obj external/libz/src/crc32.obj external/libz/src/deflate.obj external/libz/src/gzclose.obj external/libz/src/gzlib.obj external/libz/src/gzread.obj external/libz/src/gzwrite.obj external/libz/src/infback.obj external/libz/src/inffast.obj external/libz/src/inflate.obj external/libz/src/inftrees.obj external/libz/src/trees.obj external/libz/src/uncompr.obj external/libz/src/zutil.obj external/md4c.obj external/stb_ds.obj external/stb_image.obj external/stb_truetype.obj src/abstract/charset.obj src/abstract/directory.obj src/abstract/dynamic.obj src/abstract/time.obj src/backend/gdi.obj src/color.obj src/core.obj src/cursor/arrow.obj src/cursor/center.obj src/cursor/cross.obj src/cursor/default.obj src/cursor/hand.obj src/cursor/hidden.obj src/cursor/text.obj src/default.obj src/dialog/colorpicker.obj src/dialog/directorychooser.obj src/dialog/filechooser.obj src/dialog/messagebox.obj src/draw.obj src/icon/back.obj src/icon/clock.obj src/icon/computer.obj src/icon/directory.obj src/icon/down.obj src/icon/error.obj src/icon/file.obj src/icon/forward.obj src/icon/info.obj src/icon/left.obj src/icon/news.obj src/icon/note.obj src/icon/right.obj src/icon/search.obj src/icon/up.obj src/icon/warning.obj src/lowlevel.obj src/string.obj src/text/font/boldfont.obj src/text/font/boldmonottf.obj src/text/font/boldttf.obj src/text/font/font.obj src/text/font/monottf.obj src/text/font/ttf.obj src/text/ft2.obj src/text/gdi.obj src/text/stbtt.obj src/text/text.obj src/truetype.obj src/unicode.obj src/widget/box.obj src/widget/button.obj src/widget/calendar.obj src/widget/chart.obj src/widget/checkbox.obj src/widget/clock.obj src/widget/combobox.obj src/widget/directx.obj src/widget/document.obj src/widget/entry.obj src/widget/frame.obj src/widget/image.obj src/widget/label.obj src/widget/listbox.obj src/widget/menu.obj src/widget/numberentry.obj src/widget/opengl.obj src/widget/progressbar.obj src/widget/radiobox.obj src/widget/scrollbar.obj src/widget/separator.obj src/widget/submenu.obj src/widget/subwindow.obj src/widget/tab.obj src/widget/table.obj src/widget/treeview.obj src/widget/viewport.obj src/widget/window.obj
$(LD) $(MW_LDFLAGS) option implib=src/Mw.lib name $@ file external/libz/src/adler32.obj file external/libz/src/compress.obj file external/libz/src/crc32.obj file external/libz/src/deflate.obj file external/libz/src/gzclose.obj file external/libz/src/gzlib.obj file external/libz/src/gzread.obj file external/libz/src/gzwrite.obj file external/libz/src/infback.obj file external/libz/src/inffast.obj file external/libz/src/inflate.obj file external/libz/src/inftrees.obj file external/libz/src/trees.obj file external/libz/src/uncompr.obj file external/libz/src/zutil.obj file external/md4c.obj file external/stb_ds.obj file external/stb_image.obj file external/stb_truetype.obj file src/abstract/charset.obj file src/abstract/directory.obj file src/abstract/dynamic.obj file src/abstract/time.obj file src/backend/gdi.obj file src/color.obj file src/core.obj file src/cursor/arrow.obj file src/cursor/center.obj file src/cursor/cross.obj file src/cursor/default.obj file src/cursor/hand.obj file src/cursor/hidden.obj file src/cursor/text.obj file src/default.obj file src/dialog/colorpicker.obj file src/dialog/directorychooser.obj file src/dialog/filechooser.obj file src/dialog/messagebox.obj file src/draw.obj file src/icon/back.obj file src/icon/clock.obj file src/icon/computer.obj file src/icon/directory.obj file src/icon/down.obj file src/icon/error.obj file src/icon/file.obj file src/icon/forward.obj file src/icon/info.obj file src/icon/left.obj file src/icon/news.obj file src/icon/note.obj file src/icon/right.obj file src/icon/search.obj file src/icon/up.obj file src/icon/warning.obj file src/lowlevel.obj file src/string.obj file src/text/font/boldfont.obj file src/text/font/boldmonottf.obj file src/text/font/boldttf.obj file src/text/font/font.obj file src/text/font/monottf.obj file src/text/font/ttf.obj file src/text/ft2.obj file src/text/gdi.obj file src/text/stbtt.obj file src/text/text.obj file src/truetype.obj file src/unicode.obj file src/widget/box.obj file src/widget/button.obj file src/widget/calendar.obj file src/widget/chart.obj file src/widget/checkbox.obj file src/widget/clock.obj file src/widget/combobox.obj file src/widget/document.obj file src/widget/entry.obj file src/widget/frame.obj file src/widget/image.obj file src/widget/label.obj file src/widget/listbox.obj file src/widget/menu.obj file src/widget/numberentry.obj file src/widget/opengl.obj file src/widget/progressbar.obj file src/widget/radiobox.obj file src/widget/scrollbar.obj file src/widget/separator.obj file src/widget/submenu.obj file src/widget/subwindow.obj file src/widget/tab.obj file src/widget/table.obj file src/widget/treeview.obj file src/widget/viewport.obj file src/widget/window.obj library clib3r.lib library opengl32.lib library gdi32.lib library ole32.lib library uuid.lib library user32.lib library advapi32.lib $(LD) $(MW_LDFLAGS) option implib=src/Mw.lib name $@ file external/libz/src/adler32.obj file external/libz/src/compress.obj file external/libz/src/crc32.obj file external/libz/src/deflate.obj file external/libz/src/gzclose.obj file external/libz/src/gzlib.obj file external/libz/src/gzread.obj file external/libz/src/gzwrite.obj file external/libz/src/infback.obj file external/libz/src/inffast.obj file external/libz/src/inflate.obj file external/libz/src/inftrees.obj file external/libz/src/trees.obj file external/libz/src/uncompr.obj file external/libz/src/zutil.obj file external/md4c.obj file external/stb_ds.obj file external/stb_image.obj file external/stb_truetype.obj file src/abstract/charset.obj file src/abstract/directory.obj file src/abstract/dynamic.obj file src/abstract/time.obj file src/backend/gdi.obj file src/color.obj file src/core.obj file src/cursor/arrow.obj file src/cursor/center.obj file src/cursor/cross.obj file src/cursor/default.obj file src/cursor/hand.obj file src/cursor/hidden.obj file src/cursor/text.obj file src/default.obj file src/dialog/colorpicker.obj file src/dialog/directorychooser.obj file src/dialog/filechooser.obj file src/dialog/messagebox.obj file src/draw.obj file src/icon/back.obj file src/icon/clock.obj file src/icon/computer.obj file src/icon/directory.obj file src/icon/down.obj file src/icon/error.obj file src/icon/file.obj file src/icon/forward.obj file src/icon/info.obj file src/icon/left.obj file src/icon/news.obj file src/icon/note.obj file src/icon/right.obj file src/icon/search.obj file src/icon/up.obj file src/icon/warning.obj file src/lowlevel.obj file src/string.obj file src/text/font/boldfont.obj file src/text/font/boldmonottf.obj file src/text/font/boldttf.obj file src/text/font/font.obj file src/text/font/monottf.obj file src/text/font/ttf.obj file src/text/ft2.obj file src/text/gdi.obj file src/text/stbtt.obj file src/text/text.obj file src/truetype.obj file src/unicode.obj file src/widget/box.obj file src/widget/button.obj file src/widget/calendar.obj file src/widget/chart.obj file src/widget/checkbox.obj file src/widget/clock.obj file src/widget/combobox.obj file src/widget/directx.obj file src/widget/document.obj file src/widget/entry.obj file src/widget/frame.obj file src/widget/image.obj file src/widget/label.obj file src/widget/listbox.obj file src/widget/menu.obj file src/widget/numberentry.obj file src/widget/opengl.obj file src/widget/progressbar.obj file src/widget/radiobox.obj file src/widget/scrollbar.obj file src/widget/separator.obj file src/widget/submenu.obj file src/widget/subwindow.obj file src/widget/tab.obj file src/widget/table.obj file src/widget/treeview.obj file src/widget/viewport.obj file src/widget/window.obj library clib3r.lib library opengl32.lib library gdi32.lib library ole32.lib library uuid.lib library user32.lib library advapi32.lib
@ -498,6 +499,8 @@ src/widget/clock.obj: src/widget/clock.c
$(CC) $(MW_CFLAGS) -fo=$@ src/widget/clock.c $(CC) $(MW_CFLAGS) -fo=$@ src/widget/clock.c
src/widget/combobox.obj: src/widget/combobox.c src/widget/combobox.obj: src/widget/combobox.c
$(CC) $(MW_CFLAGS) -fo=$@ src/widget/combobox.c $(CC) $(MW_CFLAGS) -fo=$@ src/widget/combobox.c
src/widget/directx.obj: src/widget/directx.c
$(CC) $(MW_CFLAGS) -fo=$@ src/widget/directx.c
src/widget/document.obj: src/widget/document.c src/widget/document.obj: src/widget/document.c
$(CC) $(MW_CFLAGS) -fo=$@ src/widget/document.c $(CC) $(MW_CFLAGS) -fo=$@ src/widget/document.c
src/widget/entry.obj: src/widget/entry.c src/widget/entry.obj: src/widget/entry.c

8
configure vendored
View file

@ -54,6 +54,9 @@ param_set("examples", 1);
# (option that only makes sense on x11) # (option that only makes sense on x11)
param_set("allow-sloppy-focus", 0); param_set("allow-sloppy-focus", 0);
# (option that only makes sense on Windows)
param_set("directx", 0);
my %features = ( my %features = (
"classic-theme" => "use classic theme", "classic-theme" => "use classic theme",
"stb-image" => "use stb_image, instead use libjpeg/libpng", "stb-image" => "use stb_image, instead use libjpeg/libpng",
@ -69,7 +72,8 @@ my %features = (
"wayland" => "enable wayland backend", "wayland" => "enable wayland backend",
"gnustep" => "use gnustep", "gnustep" => "use gnustep",
"dbus" => "use DBus on supported platform", "dbus" => "use DBus on supported platform",
"allow-sloppy-focus" => "prevent the x11 backend from using XSetInputFocus to enforce click-to-focus" "allow-sloppy-focus" => "prevent the x11 backend from using XSetInputFocus to enforce click-to-focus",
"directx" => "(Windows only) build DirectX widget"
); );
my @features_keys = ( my @features_keys = (
"1classic-theme", "1stb-image", "1classic-theme", "1stb-image",
@ -78,7 +82,7 @@ my @features_keys = (
"1vulkan", "2vulkan-string-helper", "1vulkan", "2vulkan-string-helper",
"1shared", "1static", "1shared", "1static",
"1wayland", "1gnustep", "1wayland", "1gnustep",
"1dbus" "1dbus", "1directx"
); );
sub def_platform { sub def_platform {

View file

@ -5,3 +5,8 @@ endif()
if(${MW_TRY_VULKAN}) if(${MW_TRY_VULKAN})
add_subdirectory(vkdemos) add_subdirectory(vkdemos)
endif() endif()
if(WIN32)
if(${MW_TRY_DIRECTX})
add_subdirectory(dxdemos)
endif()
endif()

View file

@ -0,0 +1,24 @@
file(
GLOB
EXAMPLES_DIRECTX_SOURCES
*.c
)
include(${CMAKE_CURRENT_SOURCE_DIR}/../../resource/FindDirectX.cmake)
if(${DIRECTX_FOUND})
foreach(PATH IN LISTS EXAMPLES_DIRECTX_SOURCES)
get_filename_component(TARGET ${PATH} NAME_WE)
add_executable(${TARGET} MACOSX_BUNDLE ${PATH})
target_include_directories(
${TARGET}
PRIVATE
${DIRECTX_INCLUDE_DIRS}
)
target_link_libraries(
${TARGET}
PRIVATE
Mw
${DIRECTX_D3DX9_LIBRARIES}
)
endforeach()
endif()

View file

@ -0,0 +1,93 @@
/*
* Adapted from:
* http://www.directxtutorial.com/Lesson.aspx?lessonid=9-4-1
* http://www.directxtutorial.com/Lesson.aspx?lessonid=9-4-4
*/
#include <Mw/Milsko.h>
#include <Mw/Widget/DirectX.h>
MwWidget window, d3d9;
LPDIRECT3D9 d3d;
LPDIRECT3DDEVICE9 d3ddev;
LPDIRECT3DVERTEXBUFFER9 v_buffer;
struct CUSTOMVERTEX {
FLOAT x, y, z, rhw; // from the D3DFVF_XYZRHW flag
DWORD color; // from the D3DFVF_DIFFUSE flag
};
#define CUSTOMFVF (D3DFVF_XYZRHW | D3DFVF_DIFFUSE)
static void MWAPI draw(MwWidget handle, void* user, void* client) {
// clear the window to a deep blue
d3ddev->lpVtbl->Clear(d3ddev, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 40, 100), 1.0f, 0);
d3ddev->lpVtbl->BeginScene(d3ddev); // begins the 3D scene
// select which vertex format we are using
d3ddev->lpVtbl->SetFVF(d3ddev, CUSTOMFVF);
// select the vertex buffer to display
d3ddev->lpVtbl->SetStreamSource(d3ddev, 0, v_buffer, 0, sizeof(struct CUSTOMVERTEX));
// copy the vertex buffer to the back buffer
d3ddev->lpVtbl->DrawPrimitive(d3ddev, D3DPT_TRIANGLELIST, 0, 1);
d3ddev->lpVtbl->EndScene(d3ddev); // ends the 3D scene
d3ddev->lpVtbl->Present(d3ddev, NULL, NULL, NULL, NULL); // displays the created frame
}
int main() {
MwLibraryInit();
window = MwCreateWidget(MwWindowClass, NULL, NULL, MwDEFAULT, MwDEFAULT, 1024, 768);
d3d9 = MwCreateWidget(MwD3D9Class, NULL, window, (1024 - 800) / 2, (768 - 600) / 2, 800, 600);
d3d = MwDirectXGetD3D9(d3d9);
d3ddev = MwDirectXGetD3Dev9(d3d9);
// create three vertices using the CUSTOMVERTEX struct built earlier
struct CUSTOMVERTEX vertices[] =
{
{
400.0f,
0.0f,
0.5f,
1.0f,
D3DCOLOR_XRGB(0, 0, 255),
},
{
800.0f,
600.0f,
0.5f,
1.0f,
D3DCOLOR_XRGB(0, 255, 0),
},
{
0.0f,
600.0f,
0.5f,
1.0f,
D3DCOLOR_XRGB(255, 0, 0),
},
};
d3ddev->lpVtbl->CreateVertexBuffer(d3ddev,
3 * sizeof(struct CUSTOMVERTEX),
0,
CUSTOMFVF,
D3DPOOL_MANAGED,
&v_buffer,
NULL);
VOID* pVoid; // the void pointer
v_buffer->lpVtbl->Lock(v_buffer, 0, 0, (void**)&pVoid, 0); // lock the vertex buffer
memcpy(pVoid, vertices, sizeof(vertices)); // copy the vertices to the locked buffer
v_buffer->lpVtbl->Unlock(v_buffer); // unlock the vertex buffer
MwAddUserHandler(window, MwNtickHandler, draw, NULL);
MwLoop(window);
}

View file

@ -0,0 +1,53 @@
/*!
* @file Mw/Widget/DirectX.h
* @brief DirectX widget.
* @warning Only avaliable on Windows.
*/
#ifndef __MW_WIDGET_DIRECTX_H__
#define __MW_WIDGET_DIRECTX_H__
#include <Mw/Core.h>
#include <Mw/MachDep.h>
#include <Mw/TypeDefs.h>
#if !defined(MW_DIRECTX_NO_INCLUDE)
/* https://github.com/microsoft/Windows-classic-samples/issues/317 */
#if defined(__MINGW32__) || defined(__MINGW64__)
#define NTDDI_VERSION 0x07000000
#define _WIN32_WINNT 0x0A00
#endif
#include <d3d9.h>
#endif
#ifndef _WIN32
#error DirectX widget only avaliable for Win32 backends
#endif
/*!
* @brief D3D9 widget class
*/
MWDECL MwClass MwD3D9Class;
#ifdef __cplusplus
extern "C" {
#endif
MwInline LPDIRECT3D9 MwDirectXGetD3D9(MwWidget handle) {
LPDIRECT3D9 out = NULL;
MwVaWidgetExecute(handle, "mwDirectXGetD3D9", &out, NULL);
return out;
};
MwInline LPDIRECT3DDEVICE9 MwDirectXGetD3Dev9(MwWidget handle) {
LPDIRECT3DDEVICE9 out = NULL;
MwVaWidgetExecute(handle, "mwDirectXGetD3Dev9", &out);
return out;
};
#ifdef __cplusplus
}
#endif
#endif

View file

@ -178,6 +178,7 @@ new_object("src/widget/window.c");
new_object("src/widget/opengl.c"); new_object("src/widget/opengl.c");
new_object("src/widget/vulkan.c"); new_object("src/widget/vulkan.c");
new_object("src/widget/directx.c");
if (param_get("opengl")) { if (param_get("opengl")) {
add_cflags("-DMW_OPENGL"); add_cflags("-DMW_OPENGL");
@ -185,6 +186,9 @@ if (param_get("opengl")) {
if (param_get("vulkan")) { if (param_get("vulkan")) {
add_cflags("-DMW_VULKAN"); add_cflags("-DMW_VULKAN");
} }
if (param_get("directx")) {
add_cflags("-DMW_DIRECTX");
}
new_object("src/dialog/*.c"); new_object("src/dialog/*.c");
@ -230,4 +234,8 @@ if (param_get("vulkan")) {
new_example("examples/vkdemos/vulkan"); new_example("examples/vkdemos/vulkan");
} }
if (param_get("directx")) {
new_example("examples/dxdemos/directx9");
}
1; 1;

325
resource/FindDirectX.cmake Normal file
View file

@ -0,0 +1,325 @@
# - try to find part of DirectX SDK
#
# Cache Variables: (probably not for direct use in your scripts)
# DIRECTX_INCLUDE_DIR
#
# Variables you should use in your CMakeLists.txt:
# DIRECTX_DXGUID_LIBRARY - deprecated, see below
# DIRECTX_DXERR_LIBRARY - deprecated, see http://blogs.msdn.com/b/chuckw/archive/2012/04/24/where-s-dxerr-lib.aspx
# DIRECTX_DINPUT_LIBRARY
# DIRECTX_DINPUT_INCLUDE_DIR
# DIRECTX_D3D9_LIBRARY
# DIRECTX_D3DXOF_LIBRARY
# DIRECTX_D3DX9_LIBRARIES
# DIRECTX_INCLUDE_DIRS
# DIRECTX_FOUND - if this is not true, do not attempt to use this library
#
# Defines these macros:
# find_directx_include - wrapper for find_path that provides PATHS, HINTS, and PATH_SUFFIXES.
# find_directx_library - wrapper for find_library that provides PATHS, HINTS, and PATH_SUFFIXES.
# Requires these CMake modules:
# FindPackageHandleStandardArgs (known included with CMake >=2.6.2)
# SelectLibraryConfigurations
#
# Original Author:
# 2012 Rylie Pavlik <rylie@ryliepavlik.com>
# https://ryliepavlik.com/
# Iowa State University HCI Graduate Program/VRAC
#
# Copyright 2012, Iowa State University
#
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
#
# SPDX-License-Identifier: BSL-1.0
set(DIRECTX_ROOT_DIR
"${DIRECTX_ROOT_DIR}"
CACHE
PATH
"Root directory to search for DirectX")
if(MSVC)
file(TO_CMAKE_PATH "$ENV{ProgramFiles}" _PROG_FILES)
set(_PF86 "ProgramFiles(x86)")
file(TO_CMAKE_PATH "$ENV{${_PF86}}" _PROG_FILES_X86)
if(_PROG_FILES_X86)
set(_PROG_FILES "${_PROG_FILES_X86}")
endif()
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(_dx_lib_suffixes lib/x64 lib)
else()
set(_dx_lib_suffixes lib/x86 lib)
endif()
set(DXSDK_DIRS)
set(_dx_quiet)
if(DirectX_FIND_QUIETLY)
set(_dx_quiet QUIET)
endif()
find_package(WindowsSDK ${_dx_quiet})
if(WINDOWSSDK_FOUND)
foreach(_dir ${WINDOWSSDK_DIRS})
get_windowssdk_include_dirs(${_dir} _include_dirs)
if(_include_dirs)
list(APPEND DXSDK_DIRS ${_include_dirs})
endif()
endforeach()
endif()
macro(_append_dxsdk_in_inclusive_range _low _high)
if((NOT MSVC_VERSION LESS ${_low}) AND (NOT MSVC_VERSION GREATER ${_high}))
list(APPEND DXSDK_DIRS ${ARGN})
endif()
endmacro()
_append_dxsdk_in_inclusive_range(1500 1600 "${_PROG_FILES}/Microsoft DirectX SDK (June 2010)")
_append_dxsdk_in_inclusive_range(1400 1600
"${_PROG_FILES}/Microsoft DirectX SDK (February 2010)"
"${_PROG_FILES}/Microsoft DirectX SDK (August 2009)"
"${_PROG_FILES}/Microsoft DirectX SDK (March 2009)"
"${_PROG_FILES}/Microsoft DirectX SDK (November 2008)"
"${_PROG_FILES}/Microsoft DirectX SDK (August 2008)"
"${_PROG_FILES}/Microsoft DirectX SDK (June 2008)"
"${_PROG_FILES}/Microsoft DirectX SDK (March 2008)")
_append_dxsdk_in_inclusive_range(1310 1500
"${_PROG_FILES}/Microsoft DirectX SDK (November 2007)"
"${_PROG_FILES}/Microsoft DirectX SDK (August 2007)"
"${_PROG_FILES}/Microsoft DirectX SDK (June 2007)"
"${_PROG_FILES}/Microsoft DirectX SDK (April 2007)"
"${_PROG_FILES}/Microsoft DirectX SDK (February 2007)"
"${_PROG_FILES}/Microsoft DirectX SDK (December 2006)"
"${_PROG_FILES}/Microsoft DirectX SDK (October 2006)"
"${_PROG_FILES}/Microsoft DirectX SDK (August 2006)"
"${_PROG_FILES}/Microsoft DirectX SDK (June 2006)"
"${_PROG_FILES}/Microsoft DirectX SDK (April 2006)"
"${_PROG_FILES}/Microsoft DirectX SDK (February 2006)")
file(TO_CMAKE_PATH "$ENV{DXSDK_DIR}" ENV_DXSDK_DIR)
if(ENV_DXSDK_DIR)
list(APPEND DXSDK_DIRS ${ENV_DXSDK_DIR})
endif()
else()
set(_dx_lib_suffixes lib)
set(DXSDK_DIRS /mingw)
endif()
find_path(DIRECTX_INCLUDE_DIR
NAMES
dxdiag.h
dinput.h
dxerr8.h
PATHS
${DXSDK_DIRS}
HINTS
"${DIRECTX_ROOT_DIR}"
PATH_SUFFIXES
include)
find_path(DIRECTX_DINPUT_INCLUDE_DIR
NAMES
dinput.h
PATHS
${DXSDK_DIRS}
HINTS
"${DIRECTX_ROOT_DIR}"
PATH_SUFFIXES
include)
set(DXLIB_HINTS)
if(WINDOWSSDK_FOUND AND DIRECTX_INCLUDE_DIR)
get_windowssdk_from_component("${DIRECTX_INCLUDE_DIR}" _winsdk)
if(_winsdk)
get_windowssdk_library_dirs("${_winsdk}" _libdirs)
if(_libdirs)
list(APPEND DXLIB_HINTS ${_libdirs})
endif()
endif()
endif()
if(WINDOWSSDK_FOUND AND DIRECTX_DINPUT_INCLUDE_DIR)
get_windowssdk_from_component("${DIRECTX_DINPUT_INCLUDE_DIR}" _winsdk)
if(_winsdk)
get_windowssdk_library_dirs("${_winsdk}" _includes)
if(_includes)
list(APPEND DXLIB_HINTS ${_includes})
endif()
endif()
endif()
find_library(DIRECTX_DXGUID_LIBRARY
NAMES
dxguid
PATHS
${DXLIB_HINTS}
${DXSDK_DIRS}
HINTS
"${DIRECTX_ROOT_DIR}"
PATH_SUFFIXES
${_dx_lib_suffixes})
if(DIRECTX_DXGUID_LIBRARY)
get_filename_component(_dxsdk_lib_dir ${DIRECTX_DXGUID_LIBRARY} PATH)
list(APPEND DXLIB_HINTS "${_dxsdk_lib_dir}")
endif()
find_library(DIRECTX_DINPUT_LIBRARY
NAMES
dinput8
dinput
PATHS
${DXSDK_DIRS}
HINTS
${DXLIB_HINTS}
"${DIRECTX_ROOT_DIR}"
PATH_SUFFIXES
${_dx_lib_suffixes})
find_library(DIRECTX_DXERR_LIBRARY
NAMES
dxerr
dxerr9
dxerr8
PATHS
${DXSDK_DIRS}
HINTS
${DXLIB_HINTS}
"${DIRECTX_ROOT_DIR}"
PATH_SUFFIXES
${_dx_lib_suffixes})
find_library(DIRECTX_D3D9_LIBRARY
NAMES
d3d9
PATHS
${DXSDK_DIRS}
HINTS
${DXLIB_HINTS}
"${DIRECTX_ROOT_DIR}"
PATH_SUFFIXES
${_dx_lib_suffixes})
find_library(DIRECTX_D3DXOF_LIBRARY
NAMES
d3dxof
PATHS
${DXSDK_DIRS}
HINTS
${DXLIB_HINTS}
"${DIRECTX_ROOT_DIR}"
PATH_SUFFIXES
${_dx_lib_suffixes})
find_library(DIRECTX_D3DX9_LIBRARY_RELEASE
NAMES
d3dx9
PATHS
${DXSDK_DIRS}
HINTS
${DXLIB_HINTS}
"${DIRECTX_ROOT_DIR}"
PATH_SUFFIXES
${_dx_lib_suffixes})
find_library(DIRECTX_D3DX9_LIBRARY_DEBUG
NAMES
d3dx9d
PATHS
${DXSDK_DIRS}
HINTS
${DXLIB_HINTS}
"${DIRECTX_ROOT_DIR}"
PATH_SUFFIXES
${_dx_lib_suffixes})
find_library(DIRECTX_XINPUT_LIBRARY
NAMES
Xinput9_1_0
Xinput
PATHS
${DXSDK_DIRS}
HINTS
${DXLIB_HINTS}
"${DIRECTX_ROOT_DIR}"
PATH_SUFFIXES
${_dx_lib_suffixes})
include(SelectLibraryConfigurations)
select_library_configurations(DIRECTX_D3DX9)
set(DIRECTX_EXTRA_CHECK)
if(DIRECTX_INCLUDE_DIR)
if(MSVC80)
set(DXSDK_DEPRECATION_BUILD 1962)
endif()
if(DXSDK_DEPRECATION_BUILD)
include(CheckCSourceCompiles)
set(_dinput_old_includes ${CMAKE_REQUIRED_INCLUDES})
set(CMAKE_REQUIRED_INCLUDES "${DIRECTX_INCLUDE_DIR}")
check_c_source_compiles("
#include <dxsdkver.h>
#if _DXSDK_BUILD_MAJOR >= ${DXSDK_DEPRECATION_BUILD}
#error
#else
int main(int argc, char * argv[]) {
return 0;
}
#endif
"
DIRECTX_SDK_SUPPORTS_COMPILER)
set(DIRECTX_EXTRA_CHECK DIRECTX_SDK_SUPPORTS_COMPILER)
set(CMAKE_REQUIRED_INCLUDES "${_dinput_old_includes}")
else()
# Until proven otherwise.
set(DIRECTX_SDK_SUPPORTS_COMPILER TRUE)
endif()
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(DirectX
DEFAULT_MSG
DIRECTX_DXGUID_LIBRARY
DIRECTX_DINPUT_LIBRARY
DIRECTX_INCLUDE_DIR
${DIRECTX_EXTRA_CHECK})
if(DIRECTX_FOUND)
set(DIRECTX_LIBRARIES
"${DIRECTX_DXGUID_LIBRARY}"
"${DIRECTX_DINPUT_LIBRARY}")
set(DIRECTX_INCLUDE_DIRS "${DIRECTX_INCLUDE_DIR}")
mark_as_advanced(DIRECTX_ROOT_DIR)
endif()
macro(find_directx_library)
find_library(${ARGN}
PATHS
${DXSDK_DIRS}
HINTS
${DXLIB_HINTS}
"${DIRECTX_ROOT_DIR}"
PATH_SUFFIXES
${_dx_lib_suffixes})
endmacro()
macro(find_directx_include)
find_path(${ARGN}
PATHS
${DXSDK_DIRS}
HINTS
${DIRECTX_INCLUDE_DIR}
"${DIRECTX_ROOT_DIR}"
PATH_SUFFIXES
include)
endmacro()
mark_as_advanced(DIRECTX_DINPUT_LIBRARY
DIRECTX_DXGUID_LIBRARY
DIRECTX_DXERR_LIBRARY
DIRECTX_D3D9_LIBRARY
DIRECTX_D3DXOF_LIBRARY
DIRECTX_D3DX9_LIBRARY_RELEASE
DIRECTX_D3DX9_LIBRARY_DEBUG
DIRECTX_INCLUDE_DIR)

96
src/widget/directx.c Normal file
View file

@ -0,0 +1,96 @@
#include <Mw/Milsko.h>
#ifndef MW_DIRECTX
#define MW_DIRECTX_NO_INCLUDE
MWDECL MwClass MwDX9Class;
MwClass MwDX9Class = NULL;
#else
#include <Mw/Widget/DirectX.h>
typedef struct gdid3d9 {
void* d3d9dll;
IDirect3D9* (*Direct3DCreate9)(UINT sdk_version);
LPDIRECT3D9 d3d; // the pointer to our Direct3D interface
LPDIRECT3DDEVICE9 d3ddev; // the pointer to the device class\
} gdid3d9_t;
static int wcreate(MwWidget handle) {
void* r = NULL;
MwWidget w = handle;
gdid3d9_t* o = malloc(sizeof(gdid3d9_t));
o->d3d9dll = LoadLibrary("d3d9.dll");
if(!o->d3d9dll) {
MessageBox(NULL, "d3d9.dll not found! Is DirectX9 installed?", "Error", MB_OK);
ExitProcess(-1);
}
o->Direct3DCreate9 = (void*)GetProcAddress(o->d3d9dll, "Direct3DCreate9");
o->d3d = o->Direct3DCreate9(D3D_SDK_VERSION); // create the Direct3D interface
D3DPRESENT_PARAMETERS d3dpp; // create a struct to hold various device information
ZeroMemory(&d3dpp, sizeof(d3dpp)); // clear out the struct for use
d3dpp.Windowed = TRUE; // program windowed, not fullscreen
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; // discard old frames
d3dpp.hDeviceWindow = handle->lowlevel->gdi.hWnd; // set the window to be used by Direct3D
// create a device class using this information and information from the d3dpp stuct
o->d3d->lpVtbl->CreateDevice(o->d3d,
D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL,
handle->lowlevel->gdi.hWnd,
D3DCREATE_MIXED_VERTEXPROCESSING,
&d3dpp,
&o->d3ddev);
handle->internal = o;
return 0;
}
static void destroy(MwWidget handle) {
MwWidget w = handle;
gdid3d9_t* o = handle->internal;
o->d3ddev->lpVtbl->Release(o->d3ddev); // close and release the 3D device
o->d3d->lpVtbl->Release(o->d3d); // close and release Direct3D
free(handle->internal);
}
static void func_handler(MwWidget handle, const char* name, void* out,
va_list va) {
gdid3d9_t* o = handle->internal;
if(strcmp(name, "mwDirectXGetD3D9") == 0) {
*(LPDIRECT3D9*)out = o->d3d;
}
if(strcmp(name, "mwDirectXGetD3Dev9") == 0) {
*(LPDIRECT3DDEVICE9*)out = o->d3ddev;
}
}
MwClassRec MwDX9ClassRec = {wcreate, /* create */
destroy, /* destroy */
NULL, /* draw */
NULL, /* click */
NULL, /* parent_resize */
NULL, /* prop_change */
NULL, /* mouse_move */
NULL, /* mouse_up */
NULL, /* mouse_down */
NULL, /* key */
func_handler, /* execute */
NULL, /* tick */
NULL, /* resize */
NULL, /* children_update */
NULL, /* children_prop_change */
NULL, /* clipboard */
NULL, /* props_change */
NULL, NULL, NULL};
MwClass MwD3D9Class = &MwDX9ClassRec;
#endif

View file

@ -42,6 +42,23 @@ sub cobjs {
return $r; return $r;
} }
sub dx9_detect_block {
return <<'EOF';
!if [where d3d9.h >nul 2>nul]
!if [for /f "delims=" %P in ('where d3d9.h 2^>nul') do @echo DX9_FLAGS = /DMW_DIRECTX /I"%~dpP">dx9flags.mk]
!endif
!else
!if [echo DX9_FLAGS =>dx9flags.mk]
!endif
!endif
!if exist("dx9flags.mk")
!include "dx9flags.mk"
!else
DX9_FLAGS =
!endif
EOF
}
sub generate { sub generate {
my ($output, $type) = @_; my ($output, $type) = @_;
@ -65,6 +82,8 @@ sub generate {
my $lib = ""; my $lib = "";
my $c_dllout = ""; my $c_dllout = "";
my $c_dllafter = ""; my $c_dllafter = "";
my $dx9_flags = "";
my $dx9_block = "";
if ($type eq "Borland") { if ($type eq "Borland") {
$cc = "bcc32 -c"; $cc = "bcc32 -c";
@ -88,6 +107,12 @@ sub generate {
$def = "/D"; $def = "/D";
$inc = "/I"; $inc = "/I";
$dll = "/DLL"; $dll = "/DLL";
# DX9 headers aren't part of every MSVC/Windows SDK install, so probe
# PATH for a d3d9.h at build time (on the machine actually running
# nmake) rather than baking in a yes/no here.
$dx9_flags = "\$(DX9_FLAGS)";
$dx9_block = dx9_detect_block();
} }
elsif ($type eq "Watcom") { elsif ($type eq "Watcom") {
$cc = "wcc386 -bt=nt -q"; $cc = "wcc386 -bt=nt -q";
@ -109,14 +134,20 @@ sub generate {
$prefobj = "file "; $prefobj = "file ";
$needlibs = "${lib}clib3r.lib"; $needlibs = "${lib}clib3r.lib";
$c_dllout = "option implib=src${dir}Mw.lib"; $c_dllout = "option implib=src${dir}Mw.lib";
$dx9_flags = "${def}MW_DIRECTX";
} }
open(OUT, ">", $output); open(OUT, ">", $output);
print(OUT "CC = $cc\n"); print(OUT "CC = $cc\n");
print(OUT "LD = $link\n"); print(OUT "LD = $link\n");
print(OUT "\n"); print(OUT "\n");
if ($dx9_block ne "") {
print(OUT $dx9_block);
print(OUT "\n");
}
print(OUT print(OUT
"MW_CFLAGS = ${cdll} ${inc}include ${inc}external${dir}libz${dir}include ${def}_MILSKO ${def}_MILSKO_BUILD ${def}USE_GDI ${def}USE_STB_IMAGE ${def}STBI_NO_SIMD ${def}USE_GDI_TEXT ${def}MW_OPENGL\n" "MW_CFLAGS = ${cdll} ${inc}include ${inc}external${dir}libz${dir}include ${def}_MILSKO ${def}_MILSKO_BUILD ${def}USE_GDI ${def}USE_STB_IMAGE ${def}STBI_NO_SIMD ${def}USE_GDI_TEXT ${def}MW_OPENGL ${dx9_flags}\n"
); );
print(OUT "MW_LDFLAGS = $dll\n"); print(OUT "MW_LDFLAGS = $dll\n");
print(OUT "EXE_CFLAGS = ${inc}include\n"); print(OUT "EXE_CFLAGS = ${inc}include\n");
@ -152,6 +183,9 @@ sub generate {
} }
print(OUT " $del src${dir}Mw.dll\n"); print(OUT " $del src${dir}Mw.dll\n");
print(OUT " $del src${dir}Mw.lib\n"); print(OUT " $del src${dir}Mw.lib\n");
if ($dx9_block ne "") {
print(OUT " $del dx9flags.mk\n");
}
foreach my $f (@examples) { foreach my $f (@examples) {
my $b = $f; my $b = $f;
$b =~ s/\.c$/.obj/; $b =~ s/\.c$/.obj/;