Polycode Visual Studio setup
Setting up a Polycode project in Visual Studio is a royal pain in the ass. The fact that you have to use a Win32 project is the main reason. We can resume this in two dreaded words : HUNGARIAN NOTATION. God I hate this.
Of course, this is just for the entry point and fortunately, once this is done, you won’t have to face those horrible names in your code (unless you like this, which should be considered scary). Anyways, here’s a step by step on how to setup a basic Visual Studio project and get you running on trully interesting code in no time:
- First of all, we’re going to need a VC++ Win32 project. We’re going to make it empty (screw you, precompiled headers) so that we don’t get a load of files that we won’t need later
- We’ve got our neat empty project and I’m going to assume that you’ve got a release build of Polycode. The path for this example will be “C:\Polycode\Framework”. We’re going to go into project properties for our project and set your configuration to “All Configurations”
- Go to C/C++ > General and Edit on “Additional Include Directories”. Add the following folders
- C:\Polycode\Framework\Core\include
- C:\Polycode\Framework\Core\Dependencies\include
- C:\Polycode\Framework\Core\Dependencies\include\AL
- Go to Linker > General and Edit on “Additional Library Directories”. Add the following folders
- C:\Polycode\Framework\Core\lib
- C:\Polycode\Framework\Core\Dependencies\lib
- Go to Linker > Input, Edit on “Additional Dependencies” and add the following after setting the Configuration to the correct value
- For Debug Configuration :
Polycore_d.lib
zlibd.lib
freetype_d.lib
liboggd.lib
libvorbisd.lib
libvorbisfiled.lib
OpenAL32d.lib
physfsd.lib
libpng15_staticd.lib
opengl32.lib
glu32.lib
winmm.lib
ws2_32.lib - For Release Configuration :
Polycore.lib
zlib.lib
freetype.lib
libogg.lib
libvorbis.lib
libvorbisfile.lib
OpenAL32.lib
physfs.lib
libpng15_static.lib
opengl32.lib
glu32.lib
winmm.lib
ws2_32.lib
- For Debug Configuration :
- Back in “All Configurations”, go to Build Events > Post-Build Event and Edit “Command Line” to add following command
if not exist "$(ProjectDir)default.pak" copy "C:\Polycode\Framework\Core\Assets\default.pak" "$(ProjectDir)"
if "$(ConfigurationName)" == "Debug" (
if not exist "$(TargetDir)OpenAL32d.dll" copy "C:\Polycode\Framework\Core\Dependencies\bin\OpenAL32d.dll" "$(TargetDir)"
) else (
if not exist "$(TargetDir)OpenAL32.dll" copy "C:\Polycode\Framework\Core\Dependencies\bin\OpenAL32.dll" "$(TargetDir)"
)What this does is it copies to build directory the OpenAL dlls so that the sound module runs correctly. Polycode author Ivan Safrin recently spoke about removing it for a more low level sound API, so keep that in mind for the future. This also adds the default.pak file to the project, which is not an obligation, but it contains starter resources to get you up and running a Polycode app directly, like fonts, default shaders, textures, stuff like that.
- We’re normally ready to code! Let’s add a file. I’ll name it
main.cpp
, because I like simple stuff, and if we could keep this file simple, it would be great. Anyways, let’s fill it with our entry point, that is, ugly Win32 code :#include <PolycodeView.h>
#include "windows.h"
#include "PolyApp.h"
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
PolycodeView *view = new PolycodeView(hInstance, nCmdShow, L"My polycode app");
PolyApp *app = new PolyApp(view);
MSG Msg;
do {
if (PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE)) {
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
} while (app->Update());
delete app;
delete view;
return Msg.wParam;
}So this is where your creativity comes in. Following the main wiki, you’re going to create an entry class (here, it’s called
PolyApp
) that is polled by the Win32 API for events (the do/while part) until you decide to shut it down. Protip : if you plan on doing something cross-platform, use thePOLYCODE_CORE
define that is defined at build depending on OS. You’re better off that way. - Have fun with Polycode
So that’s it, don’t forget to change your Polycode build path, and you should have a project running. Hit me up on if something’s wrong!
Tuxic