Use std::min/max instead of the Windows macros.

TRAC #11024 * Define NOMINMAX so that the Windows headers don't define min or max. * Use std::min/std::max where we were using the min/max macros. Signed-off-by: Daniel Koch Author: Andrew Lewycky <andrew.lewycky@transgaming.com> git-svn-id: https://angleproject.googlecode.com/svn/trunk@10 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent e2b22129
...@@ -10,11 +10,12 @@ ...@@ -10,11 +10,12 @@
#include "Display.h" #include "Display.h"
#include <algorithm>
#include <vector>
#include "main.h" #include "main.h"
#include "debug.h" #include "debug.h"
#include <vector>
namespace egl namespace egl
{ {
Display::Display(HDC deviceContext) : mDc(deviceContext) Display::Display(HDC deviceContext) : mDc(deviceContext)
...@@ -65,11 +66,11 @@ bool Display::initialize() ...@@ -65,11 +66,11 @@ bool Display::initialize()
EGLint minSwapInterval = 4; EGLint minSwapInterval = 4;
EGLint maxSwapInterval = 0; EGLint maxSwapInterval = 0;
if (caps.PresentationIntervals & D3DPRESENT_INTERVAL_IMMEDIATE) {minSwapInterval = min(minSwapInterval, 0); maxSwapInterval = max(maxSwapInterval, 0);} if (caps.PresentationIntervals & D3DPRESENT_INTERVAL_IMMEDIATE) {minSwapInterval = std::min(minSwapInterval, 0); maxSwapInterval = std::max(maxSwapInterval, 0);}
if (caps.PresentationIntervals & D3DPRESENT_INTERVAL_ONE) {minSwapInterval = min(minSwapInterval, 1); maxSwapInterval = max(maxSwapInterval, 1);} if (caps.PresentationIntervals & D3DPRESENT_INTERVAL_ONE) {minSwapInterval = std::min(minSwapInterval, 1); maxSwapInterval = std::max(maxSwapInterval, 1);}
if (caps.PresentationIntervals & D3DPRESENT_INTERVAL_TWO) {minSwapInterval = min(minSwapInterval, 2); maxSwapInterval = max(maxSwapInterval, 2);} if (caps.PresentationIntervals & D3DPRESENT_INTERVAL_TWO) {minSwapInterval = std::min(minSwapInterval, 2); maxSwapInterval = std::max(maxSwapInterval, 2);}
if (caps.PresentationIntervals & D3DPRESENT_INTERVAL_THREE) {minSwapInterval = min(minSwapInterval, 3); maxSwapInterval = max(maxSwapInterval, 3);} if (caps.PresentationIntervals & D3DPRESENT_INTERVAL_THREE) {minSwapInterval = std::min(minSwapInterval, 3); maxSwapInterval = std::max(maxSwapInterval, 3);}
if (caps.PresentationIntervals & D3DPRESENT_INTERVAL_FOUR) {minSwapInterval = min(minSwapInterval, 4); maxSwapInterval = max(maxSwapInterval, 4);} if (caps.PresentationIntervals & D3DPRESENT_INTERVAL_FOUR) {minSwapInterval = std::min(minSwapInterval, 4); maxSwapInterval = std::max(maxSwapInterval, 4);}
const D3DFORMAT adapterFormats[] = const D3DFORMAT adapterFormats[] =
{ {
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
Optimization="0" Optimization="0"
AdditionalIncludeDirectories="../Include/" AdditionalIncludeDirectories="../Include/"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBEGL_EXPORTS;_CRT_SECURE_NO_DEPRECATE" PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBEGL_EXPORTS;_CRT_SECURE_NO_DEPRECATE;NOMINMAX"
MinimalRebuild="true" MinimalRebuild="true"
BasicRuntimeChecks="3" BasicRuntimeChecks="3"
RuntimeLibrary="1" RuntimeLibrary="1"
...@@ -119,7 +119,7 @@ ...@@ -119,7 +119,7 @@
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
AdditionalIncludeDirectories="../Include/" AdditionalIncludeDirectories="../Include/"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBEGL_EXPORTS;_CRT_SECURE_NO_DEPRECATE" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBEGL_EXPORTS;_CRT_SECURE_NO_DEPRECATE;NOMINMAX"
RuntimeLibrary="0" RuntimeLibrary="0"
UsePrecompiledHeader="0" UsePrecompiledHeader="0"
WarningLevel="3" WarningLevel="3"
......
...@@ -8,6 +8,9 @@ ...@@ -8,6 +8,9 @@
// rendering operations. It is the GLES2 specific implementation of EGLContext. // rendering operations. It is the GLES2 specific implementation of EGLContext.
#include "Context.h" #include "Context.h"
#include <algorithm>
#include "main.h" #include "main.h"
#include "Display.h" #include "Display.h"
#include "Buffer.h" #include "Buffer.h"
...@@ -750,10 +753,10 @@ bool Context::applyRenderTarget(bool ignoreViewport) ...@@ -750,10 +753,10 @@ bool Context::applyRenderTarget(bool ignoreViewport)
} }
else else
{ {
viewport.X = max(viewportX, 0); viewport.X = std::max(viewportX, 0);
viewport.Y = max(viewportY, 0); viewport.Y = std::max(viewportY, 0);
viewport.Width = min(viewportWidth, (int)desc.Width - (int)viewport.X); viewport.Width = std::min(viewportWidth, (int)desc.Width - (int)viewport.X);
viewport.Height = min(viewportHeight, (int)desc.Height - (int)viewport.Y); viewport.Height = std::min(viewportHeight, (int)desc.Height - (int)viewport.Y);
viewport.MinZ = clamp01(zNear); viewport.MinZ = clamp01(zNear);
viewport.MaxZ = clamp01(zFar); viewport.MaxZ = clamp01(zFar);
} }
...@@ -1212,10 +1215,10 @@ void Context::readPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum ...@@ -1212,10 +1215,10 @@ void Context::readPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum
} }
D3DLOCKED_RECT lock; D3DLOCKED_RECT lock;
RECT rect = {max(x, 0), RECT rect = {std::max(x, 0),
max(y, 0), std::max(y, 0),
min(x + width, (int)desc.Width), std::min(x + width, (int)desc.Width),
min(y + height, (int)desc.Height)}; std::min(y + height, (int)desc.Height)};
result = systemSurface->LockRect(&lock, &rect, D3DLOCK_READONLY); result = systemSurface->LockRect(&lock, &rect, D3DLOCK_READONLY);
......
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
#include "Texture.h" #include "Texture.h"
#include <algorithm>
#include "main.h" #include "main.h"
#include "mathutil.h" #include "mathutil.h"
#include "debug.h" #include "debug.h"
...@@ -347,7 +349,7 @@ bool Texture2D::isComplete() ...@@ -347,7 +349,7 @@ bool Texture2D::isComplete()
if (mipmapping) if (mipmapping)
{ {
int q = log2(max(mWidth, mHeight)); int q = log2(std::max(mWidth, mHeight));
for (int level = 1; level <= q; level++) for (int level = 1; level <= q; level++)
{ {
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
Optimization="0" Optimization="0"
AdditionalIncludeDirectories="../Include/; ../Compiler/" AdditionalIncludeDirectories="../Include/; ../Compiler/"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBGLESV2_EXPORTS;_CRT_SECURE_NO_DEPRECATE" PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBGLESV2_EXPORTS;_CRT_SECURE_NO_DEPRECATE;NOMINMAX"
MinimalRebuild="true" MinimalRebuild="true"
BasicRuntimeChecks="3" BasicRuntimeChecks="3"
RuntimeLibrary="1" RuntimeLibrary="1"
...@@ -119,7 +119,7 @@ ...@@ -119,7 +119,7 @@
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
AdditionalIncludeDirectories="../Include/; ../Compiler/" AdditionalIncludeDirectories="../Include/; ../Compiler/"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBGLESV2_EXPORTS;_CRT_SECURE_NO_DEPRECATE" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBGLESV2_EXPORTS;_CRT_SECURE_NO_DEPRECATE;NOMINMAX"
RuntimeLibrary="0" RuntimeLibrary="0"
UsePrecompiledHeader="0" UsePrecompiledHeader="0"
WarningLevel="3" WarningLevel="3"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment