GxRuntime: Cleanup and better handling of newer libraries

This commit is contained in:
Michael Fabian Dirks
2017-04-09 05:36:11 +02:00
parent 11cc383e7b
commit 590f4eb155
7 changed files with 97 additions and 22 deletions
+2
View File
@@ -1,4 +1,6 @@
#pragma once
#include <windows.h>
// Direct Draw
#define DIRECTDRAW_VERSION 0x0700
#include <ddraw.h>
+10 -10
View File
@@ -6,10 +6,10 @@
#include "gxcanvas.h"
#include "gxruntime.h"
extern gxRuntime *gx_runtime;
#define FREEIMAGE_LIB
#include "..\#ThirdParty\FreeImage\Dist\x32\freeimage.h"
extern gxRuntime *gx_runtime;
static AsmCoder asm_coder;
static void calcShifts(unsigned mask, unsigned char *shr, unsigned char *shl) {
@@ -120,9 +120,9 @@ static void buildMask(ddSurf *surf) {
unsigned char *surf_p = (unsigned char*)desc.lpSurface;
PixelFormat fmt(desc.ddpfPixelFormat);
for (int y = 0; y < desc.dwHeight; ++y) {
for (DWORD y = 0; y < desc.dwHeight; ++y) {
unsigned char *p = surf_p;
for (int x = 0; x < desc.dwWidth; ++x) {
for (DWORD x = 0; x < desc.dwWidth; ++x) {
unsigned argb = fmt.getPixel(p);
unsigned rgb = argb & 0xffffff;
unsigned a = rgb ? 0xff000000 : 0;
@@ -141,9 +141,9 @@ static void buildAlpha(ddSurf *surf, bool whiten) {
unsigned char *surf_p = (unsigned char*)desc.lpSurface;
PixelFormat fmt(desc.ddpfPixelFormat);
for (int y = 0; y < desc.dwHeight; ++y) {
for (DWORD y = 0; y < desc.dwHeight; ++y) {
unsigned char *p = surf_p;
for (int x = 0; x < desc.dwWidth; ++x) {
for (DWORD x = 0; x < desc.dwWidth; ++x) {
unsigned argb = fmt.getPixel(p);
unsigned alpha = (((argb >> 16) & 0xff) + ((argb >> 8) & 0xff) + (argb & 0xff)) / 3;
argb = (alpha << 24) | (argb & 0xffffff);
@@ -182,7 +182,7 @@ void ddUtil::buildMipMaps(ddSurf *surf) {
PixelFormat dest_fmt(dest_desc.ddpfPixelFormat);
if (src_desc.dwWidth == 1) {
for (int y = 0; y < dest_desc.dwHeight; ++y) {
for (DWORD y = 0; y < dest_desc.dwHeight; ++y) {
unsigned p1 = src_fmt.getPixel(src_p);
unsigned p2 = src_fmt.getPixel(src_p + src_desc.lPitch);
unsigned argb =
@@ -194,7 +194,7 @@ void ddUtil::buildMipMaps(ddSurf *surf) {
dest_p += dest_desc.lPitch;
}
} else if (src_desc.dwHeight == 1) {
for (int x = 0; x < dest_desc.dwWidth; ++x) {
for (DWORD x = 0; x < dest_desc.dwWidth; ++x) {
unsigned p1 = src_fmt.getPixel(src_p);
unsigned p2 = src_fmt.getPixel(src_p + src_fmt.getPitch());
unsigned argb =
@@ -206,10 +206,10 @@ void ddUtil::buildMipMaps(ddSurf *surf) {
dest_p += dest_fmt.getPitch();
}
} else {
for (int y = 0; y < dest_desc.dwHeight; ++y) {
for (DWORD y = 0; y < dest_desc.dwHeight; ++y) {
unsigned char *src_t = src_p;
unsigned char *dest_t = dest_p;
for (int x = 0; x < dest_desc.dwWidth; ++x) {
for (DWORD x = 0; x < dest_desc.dwWidth; ++x) {
unsigned p1 = src_fmt.getPixel(src_t);
unsigned p2 = src_fmt.getPixel(src_t + src_fmt.getPitch());
+1
View File
@@ -6,6 +6,7 @@
#include <string>
#include "GraphicsRuntime.h"
#include <windows.h>
#include <d3d.h>
#include "ddutil.h"
+2
View File
@@ -2,6 +2,8 @@
#ifndef GXMESH_H
#define GXMESH_H
#include <windows.h>
#include "GraphicsRuntime.h"
#include <d3d.h>
class gxGraphics;
+2 -4
View File
@@ -6,8 +6,6 @@
#include "zmouse.h"
#include "windows.h"
#define SPI_SETMOUSESPEED 113
struct gxRuntime::GfxMode {
DDSURFACEDESC2 desc;
};
@@ -1038,9 +1036,9 @@ void gxRuntime::enumGfx() {
}
void gxRuntime::denumGfx() {
for (int k = 0; k < drivers.size(); ++k) {
for (size_t k = 0; k < drivers.size(); ++k) {
gxRuntime::GfxDriver *d = drivers[k];
for (unsigned int j = 0; j < d->modes.size(); ++j) delete d->modes[j];
for (size_t j = 0; j < d->modes.size(); ++j) delete d->modes[j];
delete d->guid;
delete d;
}
+78 -7
View File
@@ -9,6 +9,10 @@
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="RelWithDebInfo|Win32">
<Configuration>RelWithDebInfo</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<SccProjectName />
@@ -20,7 +24,7 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<PlatformToolset>v140</PlatformToolset>
<PlatformToolset>v140_xp</PlatformToolset>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
<WholeProgramOptimization>false</WholeProgramOptimization>
@@ -30,6 +34,13 @@
<PlatformToolset>v140</PlatformToolset>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<PlatformToolset>v140_xp</PlatformToolset>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
<WholeProgramOptimization>false</WholeProgramOptimization>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
@@ -43,22 +54,79 @@
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VCTargetsPath)Microsoft.Cpp.UpgradeFromVC60.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VCTargetsPath)Microsoft.Cpp.UpgradeFromVC60.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>..\#Build\$(ProjectName)\$(Configuration)-$(PlatformTarget)\</OutDir>
<IntDir>..\#Intermediate\$(ProjectName)\$(Configuration)-$(PlatformTarget)\</IntDir>
<LinkIncremental>false</LinkIncremental>
<IncludePath>$(DXSDK_DIR)Include\;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
<LibraryPath>$(DXSDK_DIR)Lib\x86\;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86</LibraryPath>
<IncludePath>C:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\shared;C:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\um;$(IncludePath)</IncludePath>
<LibraryPath>C:\Program Files (x86)\Windows Kits\10\Lib\10.0.14393.0\um\x86;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">
<OutDir>..\#Build\$(ProjectName)\$(Configuration)-$(PlatformTarget)\</OutDir>
<IntDir>..\#Intermediate\$(ProjectName)\$(Configuration)-$(PlatformTarget)\</IntDir>
<LinkIncremental>false</LinkIncremental>
<IncludePath>C:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\shared;C:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\um;$(IncludePath)</IncludePath>
<LibraryPath>C:\Program Files (x86)\Windows Kits\10\Lib\10.0.14393.0\um\x86;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>..\#Build\$(ProjectName)\$(Configuration)-$(PlatformTarget)\</OutDir>
<IntDir>..\#Intermediate\$(ProjectName)\$(Configuration)-$(PlatformTarget)\</IntDir>
<LinkIncremental>true</LinkIncremental>
<IncludePath>$(DXSDK_DIR)Include\;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
<LibraryPath>$(DXSDK_DIR)Lib\x86\;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86</LibraryPath>
<IncludePath>C:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\shared;C:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\um;$(IncludePath)</IncludePath>
<LibraryPath>C:\Program Files (x86)\Windows Kits\10\Lib\10.0.14393.0\um\x86;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>false</FunctionLevelLinking>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<WarningLevel>Level3</WarningLevel>
<ControlFlowGuard>false</ControlFlowGuard>
<ProgramDataBaseFileName>$(IntDir)vc$(PlatformToolsetVersion).pdb</ProgramDataBaseFileName>
<CallingConvention>StdCall</CallingConvention>
<ExceptionHandling>Async</ExceptionHandling>
<RemoveUnreferencedCodeData>false</RemoveUnreferencedCodeData>
<Optimization>Full</Optimization>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<WholeProgramOptimization>true</WholeProgramOptimization>
<StructMemberAlignment>4Bytes</StructMemberAlignment>
<BufferSecurityCheck>false</BufferSecurityCheck>
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
<FloatingPointModel>Fast</FloatingPointModel>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAsManaged>false</CompileAsManaged>
<SDLCheck>
</SDLCheck>
<MultiProcessorCompilation>false</MultiProcessorCompilation>
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
</ClCompile>
<ResourceCompile>
<Culture>0x0409</Culture>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ResourceCompile>
<Bscmake>
<SuppressStartupBanner>true</SuppressStartupBanner>
<OutputFile>.\Release\gxruntime.bsc</OutputFile>
</Bscmake>
<Lib>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalDependencies>dxguid.lib;ddraw.lib;dinput8.lib;dsound.lib;dxgi.lib;d3d9.lib</AdditionalDependencies>
<TargetMachine>MachineX86</TargetMachine>
<LinkTimeCodeGeneration>true</LinkTimeCodeGeneration>
</Lib>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">
<ClCompile>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>false</FunctionLevelLinking>
@@ -81,7 +149,7 @@
</Bscmake>
<Lib>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalDependencies>dxguid.lib;ddraw.lib;dinput8.lib;dsound.lib;d3dxof.lib;dxgi.lib;d3dx9.lib</AdditionalDependencies>
<AdditionalDependencies>dxguid.lib;ddraw.lib;dinput8.lib;dsound.lib;dxgi.lib;d3d9.lib</AdditionalDependencies>
<TargetMachine>MachineX86</TargetMachine>
</Lib>
</ItemDefinitionGroup>
@@ -109,7 +177,7 @@
</Bscmake>
<Lib>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalDependencies>dxguid.lib;ddraw.lib;dinput8.lib;dsound.lib;d3dxof.lib;dxgi.lib;d3dx9.lib</AdditionalDependencies>
<AdditionalDependencies>dxguid.lib;ddraw.lib;dinput8.lib;dsound.lib;dxgi.lib;d3d9.lib</AdditionalDependencies>
<TargetMachine>MachineX86</TargetMachine>
</Lib>
</ItemDefinitionGroup>
@@ -129,13 +197,16 @@
<ClCompile Include="gxmovie.cpp" />
<ClCompile Include="gxruntime.cpp">
<AssemblerOutput Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AssemblyAndSourceCode</AssemblerOutput>
<AssemblerOutput Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">AssemblyAndSourceCode</AssemblerOutput>
</ClCompile>
<ClCompile Include="gxscene.cpp" />
<ClCompile Include="gxsound.cpp" />
<ClCompile Include="gxtimer.cpp" />
<ClCompile Include="std.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">Create</PrecompiledHeader>
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">std.h</PrecompiledHeaderFile>
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">std.h</PrecompiledHeaderFile>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">std.h</PrecompiledHeaderFile>
</ClCompile>
+2 -1
View File
@@ -1,10 +1,11 @@
#include "GraphicsRuntime.h"
#ifndef GXSCENE_H
#define GXSCENE_H
#include <map>
#include "GraphicsRuntime.h"
#include <windows.h>
#include <d3d.h>
#include "gxlight.h"