Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix compile errors and warnings on Windows

  • Loading branch information...
commit 90be2456f42de8c6d92fb1322a4c41ee4d6d3d41 1 parent 4f10dc0
@jhasse authored
View
3  python/main.cpp
@@ -139,7 +139,6 @@ BOOST_PYTHON_MODULE(jngl)
def("mousePressed", mousePressed1);
def("mousePressed", mousePressed2);
def("setMouse", setMouse);
- def("drawButton", drawButton);
def("setTitle", setTitle);
def("setBackgroundColor", setBackgroundColor);
def("setColor", setColor1);
@@ -160,6 +159,8 @@ BOOST_PYTHON_MODULE(jngl)
def("readPixel", readPixel);
def("getWindowWidth", getWindowWidth);
def("getWindowHeight", getWindowHeight);
+ def("getScreenWidth", getScreenWidth);
+ def("getScreenHeight", getScreenHeight);
def("setAntiAliasing", setAntiAliasing);
def("getAntiAliasing", getAntiAliasing);
def("getTextWidth", getTextWidth);
View
2  src/draw.hpp
@@ -51,7 +51,7 @@ namespace draw
std::vector<T> vertexes;
vertexes.push_back(0);
vertexes.push_back(0);
- for (T t = startAngle; t < 2 * M_PI; t += 0.1) {
+ for (T t = startAngle; t < 2 * M_PI; t += 0.1f) {
vertexes.push_back(width * sin(t));
vertexes.push_back(-height * cos(t));
}
View
2  src/framebufferimpl.cpp
@@ -6,7 +6,7 @@ For conditions of distribution and use, see copyright notice in LICENSE.txt
#include "framebufferimpl.hpp"
#include "windowptr.hpp"
#include "main.hpp"
-#include "jngl.hpp"
+#include "jngl/matrix.hpp"
namespace jngl {
View
24 src/freetype.cpp
@@ -100,8 +100,7 @@ namespace jngl {
opengl::translate(width_, 0);
}
- double Character::GetWidth() const
- {
+ int Character::getWidth() const {
return width_;
}
@@ -231,21 +230,18 @@ namespace jngl {
return lines;
}
- double FontImpl::getTextWidth(const std::string& text) {
- double maxWidth = 0;
+ int FontImpl::getTextWidth(const std::string& text) {
+ int maxWidth = 0;
std::vector<std::string> lines(ParseString(text));
- std::vector<std::string>::iterator lineEnd = lines.end();
- for(std::vector<std::string>::iterator lineIter = lines.begin(); lineIter != lineEnd; ++lineIter)
- {
- double lineWidth = 0;
- std::string::iterator charEnd = lineIter->end();
- for(std::string::iterator charIter = lineIter->begin(); charIter != charEnd; ++charIter)
- {
- lineWidth += GetCharacter(charIter, charEnd).GetWidth();
+ auto lineEnd = lines.end();
+ for (auto lineIter = lines.begin(); lineIter != lineEnd; ++lineIter) {
+ int lineWidth = 0;
+ auto charEnd = lineIter->end();
+ for (auto charIter = lineIter->begin(); charIter != charEnd; ++charIter) {
+ lineWidth += GetCharacter(charIter, charEnd).getWidth();
}
- if(lineWidth > maxWidth)
- {
+ if (lineWidth > maxWidth) {
maxWidth = lineWidth;
}
}
View
4 src/freetype.hpp
@@ -31,7 +31,7 @@ namespace jngl {
Character(unsigned long ch, unsigned int height, FT_Face);
~Character();
void Draw() const;
- double GetWidth() const;
+ int getWidth() const;
private:
Texture* texture_;
int width_;
@@ -45,7 +45,7 @@ namespace jngl {
FontImpl(const std::string& filename, unsigned int height);
~FontImpl();
void print(int x, int y, const std::string& text);
- double getTextWidth(const std::string& text);
+ int getTextWidth(const std::string& text);
int getLineHeight() const;
void setLineHeight(int);
private:
View
7 src/jngl/all.hpp
@@ -19,13 +19,14 @@ For conditions of distribution and use, see copyright notice in LICENSE.txt
#include "job.hpp"
#include "shapes.hpp"
#include "matrix.hpp"
-#include "rgb.hpp"
#include <string>
#include <vector>
#include <stdexcept>
+#ifndef _MSC_VER
#pragma GCC visibility push(default)
+#endif
namespace jngl {
bool running();
@@ -154,4 +155,6 @@ namespace jngl {
std::vector<std::string> getArgs();
}
-#pragma GCC visibility pop
+#ifndef _MSC_VER
+#pragma GCC visibility pop
+#endif
View
4 src/jngl/drawable.cpp
@@ -72,10 +72,10 @@ namespace jngl {
}
int Drawable::getWidth() const {
- return width / getScaleFactor();
+ return int(width / getScaleFactor());
}
int Drawable::getHeight() const {
- return height / getScaleFactor();
+ return int(height / getScaleFactor());
}
}
View
4 src/jngl/drawable.hpp
@@ -7,7 +7,9 @@ For conditions of distribution and use, see copyright notice in LICENSE.txt
#include "types.hpp"
+#ifndef _MSC_VER
#pragma GCC visibility push(default)
+#endif
namespace jngl {
class Drawable {
public:
@@ -57,4 +59,6 @@ namespace jngl {
int height;
};
}
+#ifndef _MSC_VER
#pragma GCC visibility pop
+#endif
View
2  src/jngl/font.cpp
@@ -23,7 +23,7 @@ namespace jngl {
std::stack<RGB> rgbs;
void pushFontColor(unsigned char red, unsigned char green, unsigned char blue) {
- rgbs.push({fontColorRed, fontColorGreen, fontColorBlue});
+ rgbs.push(RGB(fontColorRed, fontColorGreen, fontColorBlue));
setFontColor(red, green, blue);
}
View
6 src/jngl/font.hpp
@@ -8,7 +8,9 @@ For conditions of distribution and use, see copyright notice in LICENSE.txt
#include <string>
#include <boost/shared_ptr.hpp>
+#ifndef _MSC_VER
#pragma GCC visibility push(default)
+#endif
namespace jngl {
class FontImpl;
@@ -36,4 +38,6 @@ namespace jngl {
double getTextWidth(const std::string& text);
}
-#pragma GCC visibility pop
+#ifndef _MSC_VER
+#pragma GCC visibility pop
+#endif
View
6 src/jngl/framebuffer.hpp
@@ -5,7 +5,9 @@ For conditions of distribution and use, see copyright notice in LICENSE.txt
#pragma once
+#ifndef _MSC_VER
#pragma GCC visibility push(default)
+#endif
namespace jngl {
class FrameBufferImpl;
@@ -23,4 +25,6 @@ namespace jngl {
FrameBufferImpl* pImpl;
};
}
-#pragma GCC visibility pop
+#ifndef _MSC_VER
+#pragma GCC visibility pop
+#endif
View
6 src/jngl/input.hpp
@@ -7,7 +7,9 @@ For conditions of distribution and use, see copyright notice in LICENSE.txt
#include <string>
+#ifndef _MSC_VER
#pragma GCC visibility push(default)
+#endif
namespace jngl {
namespace key {
enum KeyType {
@@ -115,4 +117,6 @@ namespace jngl {
void setMouse(int xposition, int yposition);
}
-#pragma GCC visibility pop
+#ifndef _MSC_VER
+#pragma GCC visibility pop
+#endif
View
6 src/jngl/job.hpp
@@ -7,7 +7,9 @@ For conditions of distribution and use, see copyright notice in LICENSE.txt
#include <boost/shared_ptr.hpp>
+#ifndef _MSC_VER
#pragma GCC visibility push(default)
+#endif
namespace jngl {
class Job {
public:
@@ -18,4 +20,6 @@ namespace jngl {
void addJob(boost::shared_ptr<Job> job);
}
-#pragma GCC visibility pop
+#ifndef _MSC_VER
+#pragma GCC visibility pop
+#endif
View
6 src/jngl/matrix.hpp
@@ -5,7 +5,9 @@ For conditions of distribution and use, see copyright notice in LICENSE.txt
#pragma once
+#ifndef _MSC_VER
#pragma GCC visibility push(default)
+#endif
namespace jngl {
void rotate(double degree);
@@ -26,4 +28,6 @@ namespace jngl {
void reset();
}
-#pragma GCC visibility pop
+#ifndef _MSC_VER
+#pragma GCC visibility pop
+#endif
View
6 src/jngl/screen.hpp
@@ -7,7 +7,9 @@ For conditions of distribution and use, see copyright notice in LICENSE.txt
#include "types.hpp"
+#ifndef _MSC_VER
#pragma GCC visibility push(default)
+#endif
namespace jngl {
Float getScaleFactor();
@@ -17,4 +19,6 @@ namespace jngl {
int getScreenHeight();
}
-#pragma GCC visibility pop
+#ifndef _MSC_VER
+#pragma GCC visibility pop
+#endif
View
6 src/jngl/shapes.hpp
@@ -5,7 +5,9 @@ For conditions of distribution and use, see copyright notice in LICENSE.txt
#pragma once
+#ifndef _MSC_VER
#pragma GCC visibility push(default)
+#endif
namespace jngl {
void setColor(unsigned char red, unsigned char green, unsigned char blue);
@@ -31,4 +33,6 @@ namespace jngl {
void drawPoint(double x, double y);
}
-#pragma GCC visibility pop
+#ifndef _MSC_VER
+#pragma GCC visibility pop
+#endif
View
4 src/jngl/sprite.cpp
@@ -336,8 +336,8 @@ namespace jngl {
WebPInitDecoderConfig(&config);
if (getScaleFactor() != 1) {
config.options.use_scaling = true;
- width *= getScaleFactor();
- height *= getScaleFactor();
+ width = static_cast<int>(width * getScaleFactor());
+ height = static_cast<int>(height * getScaleFactor());
if (width < 1) width = 1;
if (height < 1) height = 1;
config.options.scaled_width = width;
View
6 src/jngl/sprite.hpp
@@ -13,7 +13,9 @@ For conditions of distribution and use, see copyright notice in LICENSE.txt
#include <string>
#include <vector>
+#ifndef _MSC_VER
#pragma GCC visibility push(default)
+#endif
namespace jngl {
class Texture;
@@ -66,4 +68,6 @@ namespace jngl {
void popSpriteAlpha();
}
-#pragma GCC visibility pop
+#ifndef _MSC_VER
+#pragma GCC visibility pop
+#endif
View
2  src/jngl/text.cpp
@@ -35,7 +35,7 @@ namespace jngl {
}
void Text::draw() const {
- font->print(x, y, text);
+ font->print(int(x), int(y), text);
glColor4ub(spriteColorRed, spriteColorGreen, spriteColorBlue, spriteColorAlpha);
}
}
View
6 src/jngl/text.hpp
@@ -10,7 +10,9 @@ For conditions of distribution and use, see copyright notice in LICENSE.txt
#include <string>
#include <boost/shared_ptr.hpp>
+#ifndef _MSC_VER
#pragma GCC visibility push(default)
+#endif
namespace jngl {
enum Alignment {
LEFT,
@@ -35,4 +37,6 @@ namespace jngl {
Alignment align;
};
}
-#pragma GCC visibility pop
+#ifndef _MSC_VER
+#pragma GCC visibility pop
+#endif
View
6 src/jngl/window.hpp
@@ -7,7 +7,9 @@ For conditions of distribution and use, see copyright notice in LICENSE.txt
#include <string>
+#ifndef _MSC_VER
#pragma GCC visibility push(default)
+#endif
namespace jngl {
void showWindow(const std::string& title,
int width,
@@ -20,4 +22,6 @@ namespace jngl {
int getDesktopHeight();
}
-#pragma GCC visibility pop
+#ifndef _MSC_VER
+#pragma GCC visibility pop
+#endif
View
6 src/jngl/work.hpp
@@ -7,7 +7,9 @@ For conditions of distribution and use, see copyright notice in LICENSE.txt
#include <boost/shared_ptr.hpp>
+#ifndef _MSC_VER
#pragma GCC visibility push(default)
+#endif
namespace jngl {
class Work {
public:
@@ -26,4 +28,6 @@ namespace jngl {
void resetFrameLimiter();
}
-#pragma GCC visibility pop
+#ifndef _MSC_VER
+#pragma GCC visibility pop
+#endif
View
1  src/spriteimpl.cpp
@@ -7,7 +7,6 @@ For conditions of distribution and use, see copyright notice in LICENSE.txt
#include "spriteimpl.hpp"
#include "window.hpp"
-#include "jngl.hpp"
#include "finally.hpp"
#include "windowptr.hpp"
#include "texture.hpp"
View
16 src/win32/windowimpl.cpp
@@ -4,7 +4,7 @@ For conditions of distribution and use, see copyright notice in LICENSE.txt
*/
#include "../window.hpp"
-#include "../debug.hpp"
+#include "../jngl/debug.hpp"
#include "../finally.hpp"
#include "../opengl.hpp"
#include "../ConvertUTF.h"
@@ -80,7 +80,7 @@ namespace jngl
Window::Window(const std::string& title, const int width, const int height, const bool fullscreen)
: fullscreen_(fullscreen), running_(false), isMouseVisible_(true), relativeMouseMode(false),
isMultisampleSupported_(false), anyKeyPressed_(false), fontSize_(12), width_(width), height_(height),
- mouseWheel_(0), oldTime_(0), changeWork_(false)
+ mouseWheel_(0), oldTime(0), changeWork_(false), stepsPerFrame(1)
{
mouseDown_.assign(false);
mousePressed_.assign(false);
@@ -293,7 +293,7 @@ namespace jngl
{
if(!::ReleaseDC(hwnd, hdc))
{
- Debug("Release device context failed.");
+ debug("Release device context failed.");
}
}
@@ -301,11 +301,11 @@ namespace jngl
{
if(!wglMakeCurrent(NULL, NULL))
{
- Debug("Release of DC and RC failed.");
+ debug("Release of DC and RC failed.");
}
if(!wglDeleteContext(hrc))
{
- Debug("Release rendering context failed.");
+ debug("Release rendering context failed.");
}
}
@@ -409,7 +409,7 @@ namespace jngl
ConversionResult result = ConvertUTF16toUTF8(sourceStart, sourceEnd, targetStart, targetEnd, lenientConversion);
if(result != conversionOK)
{
- Debug("WARNING: Couldn't convert UTF16 to UTF8.\n");
+ debug("WARNING: Couldn't convert UTF16 to UTF8.\n");
break;
}
std::vector<char>::iterator end = ++(buf.begin());
@@ -508,12 +508,12 @@ namespace jngl
}
}
- bool Window::KeyDown(const std::string& key)
+ bool Window::getKeyDown(const std::string& key)
{
return characterDown_[key];
}
- bool Window::KeyPressed(const std::string& key)
+ bool Window::getKeyPressed(const std::string& key)
{
if(characterPressed_[key])
{
View
8 src/window.cpp
@@ -214,9 +214,9 @@ namespace jngl {
}
void Window::stepIfNeeded() {
- const static double timePerStep = 1.0 / 60.0;
+ const static float timePerStep = 1.0f / 60.0f;
if (jngl::getTime() - oldTime > timePerStep * stepsPerFrame) {
- stepsPerFrame += 0.1;
+ stepsPerFrame += 0.1f;
}
for (int i = 0; i < int(stepsPerFrame + 0.5); ++i) {
oldTime += timePerStep;
@@ -239,10 +239,10 @@ namespace jngl {
}
auto timeToSleep = oldTime - jngl::getTime();
if (timeToSleep > 0.005) {
- jngl::sleep(timeToSleep * 1000);
+ jngl::sleep(int(timeToSleep * 1000));
}
if (timeToSleep > timePerStep && stepsPerFrame > 0.6) {
- stepsPerFrame -= timeToSleep - timePerStep;
+ stepsPerFrame -= float(timeToSleep - timePerStep);
}
}
View
4 src/window.hpp
@@ -126,7 +126,11 @@ namespace jngl
boost::shared_ptr<Work> newWork_;
std::string configPath;
std::vector<boost::shared_ptr<Job>> jobs;
+#ifdef _MSC_VER
+ float stepsPerFrame;
+#else
float stepsPerFrame = 1;
+#endif
// <fontSize, <fontName, FontImpl>>
boost::ptr_unordered_map<int, boost::unordered_map<std::string, boost::shared_ptr<FontImpl>>> fonts_;
View
24 visualcpp/jngl.vcxproj
@@ -15,10 +15,19 @@
<ClCompile Include="..\src\callbacks.c" />
<ClCompile Include="..\src\ConvertUTF.c" />
<ClCompile Include="..\src\finally.cpp" />
- <ClCompile Include="..\src\framebuffer.cpp" />
<ClCompile Include="..\src\framebufferimpl.cpp" />
<ClCompile Include="..\src\freetype.cpp" />
+ <ClCompile Include="..\src\jngl\drawable.cpp" />
+ <ClCompile Include="..\src\jngl\font.cpp" />
+ <ClCompile Include="..\src\jngl\framebuffer.cpp" />
+ <ClCompile Include="..\src\jngl\input.cpp" />
+ <ClCompile Include="..\src\jngl\job.cpp" />
+ <ClCompile Include="..\src\jngl\rgb.cpp" />
+ <ClCompile Include="..\src\jngl\screen.cpp" />
+ <ClCompile Include="..\src\jngl\shapes.cpp" />
<ClCompile Include="..\src\jngl\sprite.cpp" />
+ <ClCompile Include="..\src\jngl\text.cpp" />
+ <ClCompile Include="..\src\jngl\work.cpp" />
<ClCompile Include="..\src\main.cpp" />
<ClCompile Include="..\src\opengl.cpp" />
<ClCompile Include="..\src\spriteimpl.cpp" />
@@ -29,7 +38,6 @@
<ClCompile Include="..\src\win32\windowimpl.cpp" />
<ClCompile Include="..\src\window.cpp" />
<ClCompile Include="..\src\windowptr.cpp" />
- <ClCompile Include="..\src\work.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\src\audio.hpp" />
@@ -40,7 +48,19 @@
<ClInclude Include="..\src\framebufferimpl.hpp" />
<ClInclude Include="..\src\freetype.hpp" />
<ClInclude Include="..\src\jngl.hpp" />
+ <ClInclude Include="..\src\jngl\all.hpp" />
+ <ClInclude Include="..\src\jngl\debug.hpp" />
+ <ClInclude Include="..\src\jngl\drawable.hpp" />
+ <ClInclude Include="..\src\jngl\font.hpp" />
+ <ClInclude Include="..\src\jngl\framebuffer.hpp" />
+ <ClInclude Include="..\src\jngl\input.hpp" />
+ <ClInclude Include="..\src\jngl\job.hpp" />
+ <ClInclude Include="..\src\jngl\matrix.hpp" />
+ <ClInclude Include="..\src\jngl\rgb.hpp" />
+ <ClInclude Include="..\src\jngl\screen.hpp" />
+ <ClInclude Include="..\src\jngl\shapes.hpp" />
<ClInclude Include="..\src\jngl\sprite.hpp" />
+ <ClInclude Include="..\src\jngl\text.hpp" />
<ClInclude Include="..\src\jngl\types.hpp" />
<ClInclude Include="..\src\jngl\window.hpp" />
<ClInclude Include="..\src\jngl\work.hpp" />
View
72 visualcpp/jngl.vcxproj.filters
@@ -60,21 +60,45 @@
<ClCompile Include="..\src\window.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="..\src\framebuffer.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="..\src\framebufferimpl.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="..\src\work.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="..\src\spriteimpl.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\jngl\sprite.cpp">
<Filter>Source Files\jngl</Filter>
</ClCompile>
+ <ClCompile Include="..\src\jngl\drawable.cpp">
+ <Filter>Source Files\jngl</Filter>
+ </ClCompile>
+ <ClCompile Include="..\src\jngl\font.cpp">
+ <Filter>Source Files\jngl</Filter>
+ </ClCompile>
+ <ClCompile Include="..\src\jngl\framebuffer.cpp">
+ <Filter>Source Files\jngl</Filter>
+ </ClCompile>
+ <ClCompile Include="..\src\jngl\input.cpp">
+ <Filter>Source Files\jngl</Filter>
+ </ClCompile>
+ <ClCompile Include="..\src\jngl\job.cpp">
+ <Filter>Source Files\jngl</Filter>
+ </ClCompile>
+ <ClCompile Include="..\src\jngl\rgb.cpp">
+ <Filter>Source Files\jngl</Filter>
+ </ClCompile>
+ <ClCompile Include="..\src\jngl\screen.cpp">
+ <Filter>Source Files\jngl</Filter>
+ </ClCompile>
+ <ClCompile Include="..\src\jngl\shapes.cpp">
+ <Filter>Source Files\jngl</Filter>
+ </ClCompile>
+ <ClCompile Include="..\src\jngl\text.cpp">
+ <Filter>Source Files\jngl</Filter>
+ </ClCompile>
+ <ClCompile Include="..\src\jngl\work.cpp">
+ <Filter>Source Files\jngl</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\src\ConvertUTF.h">
@@ -128,5 +152,41 @@
<ClInclude Include="..\src\jngl\work.hpp">
<Filter>Header Files\jngl</Filter>
</ClInclude>
+ <ClInclude Include="..\src\jngl\all.hpp">
+ <Filter>Header Files\jngl</Filter>
+ </ClInclude>
+ <ClInclude Include="..\src\jngl\debug.hpp">
+ <Filter>Header Files\jngl</Filter>
+ </ClInclude>
+ <ClInclude Include="..\src\jngl\drawable.hpp">
+ <Filter>Header Files\jngl</Filter>
+ </ClInclude>
+ <ClInclude Include="..\src\jngl\font.hpp">
+ <Filter>Header Files\jngl</Filter>
+ </ClInclude>
+ <ClInclude Include="..\src\jngl\framebuffer.hpp">
+ <Filter>Header Files\jngl</Filter>
+ </ClInclude>
+ <ClInclude Include="..\src\jngl\input.hpp">
+ <Filter>Header Files\jngl</Filter>
+ </ClInclude>
+ <ClInclude Include="..\src\jngl\job.hpp">
+ <Filter>Header Files\jngl</Filter>
+ </ClInclude>
+ <ClInclude Include="..\src\jngl\matrix.hpp">
+ <Filter>Header Files\jngl</Filter>
+ </ClInclude>
+ <ClInclude Include="..\src\jngl\rgb.hpp">
+ <Filter>Header Files\jngl</Filter>
+ </ClInclude>
+ <ClInclude Include="..\src\jngl\screen.hpp">
+ <Filter>Header Files\jngl</Filter>
+ </ClInclude>
+ <ClInclude Include="..\src\jngl\shapes.hpp">
+ <Filter>Header Files\jngl</Filter>
+ </ClInclude>
+ <ClInclude Include="..\src\jngl\text.hpp">
+ <Filter>Header Files\jngl</Filter>
+ </ClInclude>
</ItemGroup>
</Project>
Please sign in to comment.
Something went wrong with that request. Please try again.