Commit 052a7244 authored by TheNumbat's avatar TheNumbat
Browse files

improve build system

parent 2c6a0968
......@@ -45,7 +45,7 @@ if(APPLE)
set(CLANG_CXX_FLAGS "-std=c++11 -m64")
if(CMU462_BUILD_DEBUG)
if(CMU462_BUILD_DEBUG OR CMAKE_BUILD_TYPE MATCHES "Debug")
set(CMAKE_BUILD_TYPE Debug)
else(CMU462_BUILD_DEBUG)
set(CLANG_CXX_FLAGS "${CLANG_CXX_FLAGS} -O3")
......@@ -63,7 +63,7 @@ if(APPLE)
set(GCC_CXX_FLAGS "-std=gnu++11 -m64")
if(CMU462_BUILD_DEBUG)
if(CMU462_BUILD_DEBUG OR CMAKE_BUILD_TYPE MATCHES "Debug")
set(CMAKE_BUILD_TYPE Debug)
else(CMU462_BUILD_DEBUG)
set(GCC_CXX_FLAGS "${GCC_CXX_FLAGS} -O3")
......@@ -81,7 +81,10 @@ endif(APPLE)
##################
# Build on Linux #
##################
set(LINUX UNIX AND NOT APPLE)
if(UNIX AND NOT APPLE)
set(LINUX)
endif()
if(LINUX)
# GCC only
......@@ -126,8 +129,6 @@ if(WIN32)
if(MSVC)
set(MSVC_CXX_FLAGS "-std=gnu++11")
if(CMU462_BUILD_DEBUG)
set(CMAKE_BUILD_TYPE Debug)
else(CMU462_BUILD_DEBUG)
......@@ -141,8 +142,6 @@ if(WIN32)
if(MINGW)
set(MSVC_CXX_FLAGS "-std=gnu++11")
if(CMU462_BUILD_DEBUG)
set(CMAKE_BUILD_TYPE Debug)
else(CMU462_BUILD_DEBUG)
......
......@@ -7,8 +7,7 @@ include_directories(${GLEW_HEADER_DIR})
add_library(glew
${GLEW_SOURCE_DIR}/glew.c
${GLEW_SOURCE_DIR}/glewinfo.c
${GLEW_SOURCE_DIR}/visualinfo.c)
${GLEW_SOURCE_DIR}/glewinfo.c)
set(GLEW_LIBRARIES glew PARENT_SCOPE)
set(GLEW_INCLUDE_DIRS ${GLEW_HEADER_DIR} PARENT_SCOPE)
......
......@@ -21,10 +21,10 @@ set(LIB_SUFFIX "" CACHE STRING "Takes an empty string or 64. Directory where lib
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
option(GLFW_BUILD_EXAMPLES "Build the GLFW example programs" ON)
option(GLFW_BUILD_TESTS "Build the GLFW test programs" ON)
option(GLFW_BUILD_DOCS "Build the GLFW documentation" ON)
option(GLFW_INSTALL "Generate installation target" ON)
option(GLFW_BUILD_EXAMPLES "Build the GLFW example programs" OFF)
option(GLFW_BUILD_TESTS "Build the GLFW test programs" OFF)
option(GLFW_BUILD_DOCS "Build the GLFW documentation" OFF)
option(GLFW_INSTALL "Generate installation target" OFF)
option(GLFW_VULKAN_STATIC "Use the Vulkan loader statically linked into application" OFF)
option(GLFW_DOCUMENT_INTERNALS "Include internals in documentation" OFF)
......
......@@ -14,11 +14,11 @@ const Color Color::White = Color(1,1,1,1);
const Color Color::Black = Color(0,0,0,1);
Color::Color( const unsigned char* arr ) {
float inv = 1.0 / 255.0;
float inv = 1.0f / 255.0f;
r = arr[0] * inv;
g = arr[1] * inv;
b = arr[2] * inv;
a = 1.0;
a = 1.0f;
}
Color Color::fromHex( const char* s ) {
......@@ -44,18 +44,18 @@ Color Color::fromHex( const char* s ) {
// Extract 8-byte chunks and normalize.
Color c;
c.r = (float)( ( rgb & 0xFF0000 ) >> 16 ) / 255.0;
c.g = (float)( ( rgb & 0x00FF00 ) >> 8 ) / 255.0;
c.b = (float)( ( rgb & 0x0000FF ) >> 0 ) / 255.0;
c.r = (float)( ( rgb & 0xFF0000 ) >> 16 ) / 255.0f;
c.g = (float)( ( rgb & 0x00FF00 ) >> 8 ) / 255.0f;
c.b = (float)( ( rgb & 0x0000FF ) >> 0 ) / 255.0f;
c.a = 1.0; // set alpha to 1 (opaque) by default
return c;
}
string Color::toHex( void ) const {
int R = (unsigned char) max( 0., min( 255.0, 255.0 * r ));
int G = (unsigned char) max( 0., min( 255.0, 255.0 * g ));
int B = (unsigned char) max( 0., min( 255.0, 255.0 * b ));
int R = (unsigned char) max( 0.f, min( 255.0f, 255.0f * r ));
int G = (unsigned char) max( 0.f, min( 255.0f, 255.0f * g ));
int B = (unsigned char) max( 0.f, min( 255.0f, 255.0f * b ));
stringstream ss;
ss << hex;
......
......@@ -33,7 +33,7 @@ if(APPLE)
set(CLANG_CXX_FLAGS "-std=c++11 -m64")
if(BUILD_DEBUG)
if(BUILD_DEBUG OR CMAKE_BUILD_TYPE MATCHES "Debug")
set(CMAKE_BUILD_TYPE Debug)
else(BUILD_DEBUG)
set(CLANG_CXX_FLAGS "${CLANG_CXX_FLAGS} -O3")
......@@ -67,7 +67,9 @@ endif(APPLE)
##################
# Build on Linux #
##################
set(LINUX UNIX AND NOT APPLE)
if(UNIX AND NOT APPLE)
set(LINUX)
endif()
if(LINUX)
# GCC only
......@@ -112,7 +114,6 @@ if(WIN32)
if(MSVC)
set(MSVC_CXX_FLAGS "-std=gnu++11")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MD")
......
@echo off
if exist "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat" (
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat" > NUL 2> NUL
) else if exist "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvars64.bat" (
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvars64.bat" > NUL 2> NUL
) else (
rem "Could not find visual studio C++ build environment."
)
mkdir build
pushd build
cmake ..
cmake -A x64 ..
if "%1"=="configure" exit
if [%1]==[] (cmake --build . --config RelWithDebInfo)
if not [%1]==[] (cmake --build . --config %1)
......
......@@ -83,7 +83,19 @@ if (APPLE) # Frameworks required on osx
${IOKIT_LIBRARIES}
${COREVIDEO_LIBRARIES}
)
else(UNIX) #LINUX
endif()
if(WIN32)
target_link_libraries( drawsvg drawsvg_hdwr drawsvg_ref
${CMU462_LIBRARIES}
${GLEW_LIBRARIES}
${GLFW_LIBRARIES}
${FREETYPE_LIBRARIES}
${OPENGL_LIBRARIES}
)
endif()
if(UNIX AND NOT APPLE) #LINUX
target_link_libraries( drawsvg drawsvg_hdwr drawsvg_ref
${CMU462_LIBRARIES}
${GLEW_LIBRARIES}
......
......@@ -63,16 +63,12 @@ void HardwareRenderer::draw_svg( SVG& svg ) {
Vector2D c = transform(Vector2D( 0 ,svg.height)); c.x--; c.y++;
Vector2D d = transform(Vector2D(svg.width,svg.height)); d.x++; d.y++;
rasterize_line(a.x, a.y, b.x, b.y, Color::Black);
rasterize_line(a.x, a.y, c.x, c.y, Color::Black);
rasterize_line(d.x, d.y, b.x, b.y, Color::Black);
rasterize_line(d.x, d.y, c.x, c.y, Color::Black);
// resolve and send to render target
// resolve();
rasterize_line((float)a.x, (float)a.y, (float)b.x, (float)b.y, Color::Black);
rasterize_line((float)a.x, (float)a.y, (float)c.x, (float)c.y, Color::Black);
rasterize_line((float)d.x, (float)d.y, (float)b.x, (float)b.y, Color::Black);
rasterize_line((float)d.x, (float)d.y, (float)c.x, (float)c.y, Color::Black);
leave2DDrawing();
}
void HardwareRenderer::draw_element( SVGElement* element ) {
......
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