Skip to content

Commit

Permalink
Windows fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ivansafrin committed Dec 25, 2011
1 parent b92961b commit d362e3d
Show file tree
Hide file tree
Showing 26 changed files with 847 additions and 14 deletions.
21 changes: 21 additions & 0 deletions Assets/Templates/C++/Windows/PolycodeTemplate.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include <Polycode.h>
#include "PolycodeTemplateApp.h"
#include "PolycodeView.h"
#include "windows.h"

using namespace Polycode;

int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
PolycodeView *view = new PolycodeView(hInstance, nCmdShow, L"Polycode Template");
PolycodeTemplateApp *app = new PolycodeTemplateApp(view);

MSG Msg;
do {
if(PeekMessage(&Msg, NULL, 0,0,PM_REMOVE)) {
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
} while(app->Update());
return Msg.wParam;
}
20 changes: 20 additions & 0 deletions Assets/Templates/C++/Windows/PolycodeTemplate.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual C++ Express 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PolycodeTemplate", "PolycodeTemplate.vcxproj", "{D6C2171B-9167-4FB6-851A-DC1CEDCFC43D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D6C2171B-9167-4FB6-851A-DC1CEDCFC43D}.Debug|Win32.ActiveCfg = Debug|Win32
{D6C2171B-9167-4FB6-851A-DC1CEDCFC43D}.Debug|Win32.Build.0 = Debug|Win32
{D6C2171B-9167-4FB6-851A-DC1CEDCFC43D}.Release|Win32.ActiveCfg = Release|Win32
{D6C2171B-9167-4FB6-851A-DC1CEDCFC43D}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
93 changes: 93 additions & 0 deletions Assets/Templates/C++/Windows/PolycodeTemplate.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{D6C2171B-9167-4FB6-851A-DC1CEDCFC43D}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>PolycodeTemplate</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>$(SolutionDir)..\..\Core\include;$(SolutionDir)..\..\Core\Dependencies\include;$(SolutionDir)..\..\Core\PolycodeView;$(SolutionDir)..\..\Core\Dependencies\include\AL;$(IncludePath)</IncludePath>
<LibraryPath>$(SolutionDir)..\..\Core\lib;$(SolutionDir)..\..\Core\Dependencies\lib;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>$(SolutionDir)..\..\Core\Include;$(SolutionDir)..\..\Core\Dependencies\Include;$(SolutionDir)..\..\Core\Dependencies\Include\AL;$(IncludePath)</IncludePath>
<LibraryPath>$(SolutionDir)..\..\Core\lib;$(SolutionDir)..\..\Core\Dependencies\lib;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>opengl32.lib;glu32.lib;Polycore_d.lib;zlibd.lib;freetype_d.lib;liboggd.lib;libvorbisd.lib;libvorbisfiled.lib;OpenAL32d.lib;kernel32.lib;physfsd.lib;libpng15_staticd.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>opengl32.lib;glu32.lib;Polycore.lib;zlib.lib;freetype.lib;libogg.lib;libvorbis.lib;libvorbisfile.lib;OpenAL32.lib;kernel32.lib;physfs.lib;libpng15_static.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="PolycodeTemplate.cpp" />
<ClCompile Include="PolycodeTemplateApp.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="PolycodeTemplateApp.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
16 changes: 16 additions & 0 deletions Assets/Templates/C++/Windows/PolycodeTemplateApp.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include "PolycodeTemplateApp.h"

PolycodeTemplateApp::PolycodeTemplateApp(PolycodeView *view) {
core = new Win32Core(view, 640,480,false, false, 0, 0,60);
CoreServices::getInstance()->getResourceManager()->addArchive("default.pak");
CoreServices::getInstance()->getResourceManager()->addDirResource("default", false);

// Write your code here
}
PolycodeTemplateApp::~PolycodeTemplateApp() {

}

bool PolycodeTemplateApp::Update() {
return core->Update();
}
15 changes: 15 additions & 0 deletions Assets/Templates/C++/Windows/PolycodeTemplateApp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include "PolycodeView.h"
#include "Polycode.h"

using namespace Polycode;

class PolycodeTemplateApp {
public:
PolycodeTemplateApp(PolycodeView *view);
~PolycodeTemplateApp();

bool Update();

private:
Core *core;
};
3 changes: 3 additions & 0 deletions Assets/Templates/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ IF(POLYCODE_INSTALL_TEMPLATE)
IF(APPLE)
INSTALL(DIRECTORY "C++/Xcode"
DESTINATION "Template/")
ELSEIF(MSVC)
INSTALL(DIRECTORY "C++/Windows"
DESTINATION "Template/")
ELSE(APPLE)
INSTALL(DIRECTORY "C++/Linux"
DESTINATION "Template/")
Expand Down
1 change: 0 additions & 1 deletion CMake/ExternalOpenAL.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ SET(openal_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/openal)

SET(openal_CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
-DLIBTYPE=STATIC
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_DEBUG_POSTFIX=d
)
Expand Down
45 changes: 45 additions & 0 deletions CMake/FindPNG.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@

set(PNG_FIND_DEBUG TRUE CACHE BOOL "Also search for the debug version of the PNG library")

SET(LUA_SEARCH_PATHS
${POLYCODE_RELEASE_DIR}/Framework/Core/Dependencies/lib
${POLYCODE_RELEASE_DIR}/Framework/Core/Dependencies/include
${POLYCODE_RELEASE_DIR}/Framework/Core/Dependencies/include/libpng15
${POLYCODE_RELEASE_DIR}/Framework/Modules/Dependencies/lib
${POLYCODE_RELEASE_DIR}/Framework/Tools/Dependencies/lib
)

if(PNG_FIND_DEBUG)
if(PNG_INCLUDE_DIR AND PNG_LIBRARY AND PNG_LIBRARY_DEBUG)
set(PNG_FIND_QUIETLY TRUE)
endif(PNG_INCLUDE_DIR AND PNG_LIBRARY AND PNG_LIBRARY_DEBUG)
else(PNG_FIND_DEBUG)
if(PNG_INCLUDE_DIR AND PNG_LIBRARY)
set(PNG_FIND_QUIETLY TRUE)
endif(PNG_INCLUDE_DIR AND PNG_LIBRARY)
endif(PNG_FIND_DEBUG)

find_path(PNG_INCLUDE_DIR png.h DOC "Directory containing png.h")

find_library(PNG_LIBRARY NAMES png libpng png15 libpng15 libpng15_static DOC "Path to PNG library")
if(PNG_FIND_DEBUG)
find_library(PNG_LIBRARY_DEBUG NAMES pngd libpngd png15d libpng15d libpng15_staticd DOC "Path to PNG debug library")
endif(PNG_FIND_DEBUG)

# handle the QUIETLY and REQUIRED arguments and set PNG_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(PNG DEFAULT_MSG PNG_LIBRARY PNG_INCLUDE_DIR)

if(PNG_FOUND)
if(PNG_FIND_DEBUG)
if(NOT PNG_LIBRARY_DEBUG)
set(PNG_LIBRARY_DEBUG ${PNG_LIBRARY})
endif(NOT PNG_LIBRARY_DEBUG)
set(PNG_LIBRARIES debug ${PNG_LIBRARY_DEBUG} optimized ${PNG_LIBRARY})
else(PNG_FIND_DEBUG)
set(PNG_LIBRARIES ${PNG_LIBRARY})
endif(PNG_FIND_DEBUG)
else(PNG_FOUND)
SET(PNG_LIBRARIES )
endif(PNG_FOUND)
4 changes: 3 additions & 1 deletion CMake/lua51.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ SET(lualib_SRCS

INCLUDE_DIRECTORIES(src)

ADD_DEFINITIONS(-DLUA_USE_POSIX -DLUA_USE_DLOPEN)
IF(NOT MSVC)
ADD_DEFINITIONS(-DLUA_USE_POSIX -DLUA_USE_DLOPEN)
ENDIF(NOT MSVC)

# We only want a static lib
ADD_LIBRARY(lualib ${lualib_SRCS})
Expand Down
9 changes: 3 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,9 @@ ENDIF(POLYCODE_BUILD_TOOLS)
INSTALL(FILES LICENSE.txt
DESTINATION ./)

# No Windows Build yet
IF (NOT WIN32)
INSTALL(DIRECTORY ${Polycode_SOURCE_DIR}/Examples/C++/Build/${CMAKE_SYSTEM_NAME} DESTINATION Examples)
INSTALL(DIRECTORY ${Polycode_SOURCE_DIR}/Examples/C++/Contents DESTINATION Examples/${CMAKE_SYSTEM_NAME})
INSTALL(DIRECTORY ${Polycode_SOURCE_DIR}/Examples/C++/Resources DESTINATION Examples/${CMAKE_SYSTEM_NAME})
ENDIF(NOT WIN32)
INSTALL(DIRECTORY ${Polycode_SOURCE_DIR}/Examples/C++/Build/${CMAKE_SYSTEM_NAME} DESTINATION Examples)
INSTALL(DIRECTORY ${Polycode_SOURCE_DIR}/Examples/C++/Contents DESTINATION Examples/${CMAKE_SYSTEM_NAME})
INSTALL(DIRECTORY ${Polycode_SOURCE_DIR}/Examples/C++/Resources DESTINATION Examples/${CMAKE_SYSTEM_NAME})

INSTALL(DIRECTORY ${POLYCODE_RELEASE_DIR}/Framework/Core/Dependencies DESTINATION Core)
INSTALL(DIRECTORY ${POLYCODE_RELEASE_DIR}/Framework/Modules/Dependencies DESTINATION Modules)
Expand Down
4 changes: 2 additions & 2 deletions Core/Contents/Include/PolyWinCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ namespace Polycode {
void handleMouseDown(int mouseCode,LPARAM lParam, WPARAM wParam);
void handleMouseUp(int mouseCode,LPARAM lParam, WPARAM wParam);

void setVideoMode(int xRes, int yRes, bool fullScreen, int aaLevel);

void setVideoMode(int xRes, int yRes, bool fullScreen, bool vSync, int aaLevel, int anisotropyLevel);
void initContext(bool usePixelFormat, unsigned int pixelFormat);
void destroyContext();

Expand Down
3 changes: 3 additions & 0 deletions Core/Contents/Include/Polycode.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,6 @@
#include "PolySoundManager.h"
#include "PolySceneSound.h"
#include "PolyScreenSound.h"
#ifdef _WINDOWS
#include "PolyWinCore.h"
#endif
8 changes: 8 additions & 0 deletions Core/Contents/Source/PolyGLRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ PFNGLUNMAPBUFFERARBPROC glUnmapBufferARB;
PFNGLGETBUFFERPARAMETERIVARBPROC glGetBufferParameterivARB;
PFNGLGETBUFFERPOINTERVARBPROC glGetBufferPointervARB;

PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer;
PFNGLENABLEVERTEXATTRIBARRAYARBPROC glEnableVertexAttribArrayARB;
PFNGLBINDATTRIBLOCATIONPROC glBindAttribLocation;

// GL_EXT_framebuffer_object
PFNGLISRENDERBUFFEREXTPROC glIsRenderbufferEXT;
PFNGLBINDRENDERBUFFEREXTPROC glBindRenderbufferEXT;
Expand Down Expand Up @@ -110,6 +114,10 @@ void OpenGLRenderer::initOSSpecific(){
glGetBufferParameterivARB = (PFNGLGETBUFFERPARAMETERIVARBPROC)wglGetProcAddress("glGetBufferParameterivARB");
glGetBufferPointervARB = (PFNGLGETBUFFERPOINTERVARBPROC)wglGetProcAddress("glGetBufferPointervARB");

glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)wglGetProcAddress("glVertexAttribPointer");
glEnableVertexAttribArrayARB = (PFNGLENABLEVERTEXATTRIBARRAYARBPROC)wglGetProcAddress("glEnableVertexAttribArrayARB");
glBindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC)wglGetProcAddress("glBindAttribLocation");

glIsRenderbufferEXT = (PFNGLISRENDERBUFFEREXTPROC)wglGetProcAddress("glIsRenderbufferEXT");
glBindRenderbufferEXT = (PFNGLBINDRENDERBUFFEREXTPROC)wglGetProcAddress("glBindRenderbufferEXT");
glDeleteRenderbuffersEXT = (PFNGLDELETERENDERBUFFERSEXTPROC)wglGetProcAddress("glDeleteRenderbuffersEXT");
Expand Down
1 change: 1 addition & 0 deletions Core/Contents/Source/PolyGLSLShader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ extern PFNGLLINKPROGRAMPROC glLinkProgram;
extern PFNGLDETACHSHADERPROC glDetachShader;
extern PFNGLDELETESHADERPROC glDeleteShader;
extern PFNGLDELETEPROGRAMPROC glDeleteProgram;
extern PFNGLBINDATTRIBLOCATIONPROC glBindAttribLocation;
#endif

using namespace Polycode;
Expand Down
4 changes: 4 additions & 0 deletions Core/Contents/Source/PolyGLTexture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@

using namespace Polycode;

#ifdef _WINDOWS
extern PFNGLDELETEFRAMEBUFFERSEXTPROC glDeleteFramebuffersEXT;
#endif

OpenGLTexture::OpenGLTexture(unsigned int width, unsigned int height, char *textureData, bool clamp, bool createMipmaps, int filteringMode, int type) : Texture(width, height, textureData,clamp, createMipmaps, type) {
this->filteringMode = filteringMode;
glTextureLoaded = false;
Expand Down
4 changes: 2 additions & 2 deletions Core/Contents/Source/PolyWinCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Win32Core::Win32Core(PolycodeViewBase *view, int xRes, int yRes, bool fullScreen
renderer = new OpenGLRenderer();
services->setRenderer(renderer);

setVideoMode(xRes, yRes, fullScreen, aaLevel);
setVideoMode(xRes, yRes, fullScreen, vSync, aaLevel, anisotropyLevel);

// WSADATA WsaData;
/// if(WSAStartup( MAKEWORD(2,2), &WsaData ) != NO_ERROR ){
Expand Down Expand Up @@ -112,7 +112,7 @@ bool Win32Core::Update() {
return running;
}

void Win32Core::setVideoMode(int xRes, int yRes, bool fullScreen, int aaLevel) {
void Win32Core::setVideoMode(int xRes, int yRes, bool fullScreen, bool vSync, int aaLevel, int anisotropyLevel) {

if(fullScreen) {

Expand Down
Loading

0 comments on commit d362e3d

Please sign in to comment.