Add a CMake buildsystem.
Additionally, update build tools so that no stdio redirection is necessary.pull/3/head
parent
c5364fe7a8
commit
5db5f1e152
|
@ -1,8 +1,2 @@
|
|||
Makefile.in
|
||||
/ac-aux/
|
||||
/aclocal.m4
|
||||
/autom4te.cache/
|
||||
/config.h.in
|
||||
/config.h.in~
|
||||
/configure
|
||||
/m4/
|
||||
/CMakeCache.txt
|
||||
/cbuild/
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
# cmake configuration
|
||||
|
||||
cmake_minimum_required(VERSION 2.8.12)
|
||||
cmake_policy(VERSION 2.8.12)
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
|
||||
"${CMAKE_SOURCE_DIR}/cmake/")
|
||||
|
||||
include(CheckIncludeFile)
|
||||
|
||||
# for /MT on MSVC
|
||||
set(CMAKE_USER_MAKE_RULES_OVERRIDE
|
||||
"${CMAKE_SOURCE_DIR}/cmake/c_flag_overrides.cmake")
|
||||
set(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX
|
||||
"${CMAKE_SOURCE_DIR}/cmake/cxx_flag_overrides.cmake")
|
||||
|
||||
# project
|
||||
|
||||
project(solvespace)
|
||||
set(solvespace_VERSION_MAJOR 2)
|
||||
set(solvespace_VERSION_MINOR 1)
|
||||
|
||||
# compiler
|
||||
|
||||
if(WIN32)
|
||||
add_definitions(
|
||||
-D_CRT_SECURE_NO_DEPRECATE=1
|
||||
-D_CRT_SECURE_NO_WARNINGS=1
|
||||
-D_WIN32_WINNT=0x500
|
||||
-D_WIN32_IE=_WIN32_WINNT
|
||||
-DISOLATION_AWARE_ENABLED=1
|
||||
-DWIN32=1
|
||||
-DWIN32_LEAN_AND_MEAN=1)
|
||||
endif()
|
||||
|
||||
# dependencies
|
||||
|
||||
CHECK_INCLUDE_FILE("stdint.h" HAVE_STDINT_H)
|
||||
|
||||
find_package(OpenGL REQUIRED)
|
||||
|
||||
find_package(Perl)
|
||||
find_package(PerlModules COMPONENTS GD)
|
||||
if(NOT (PERL_FOUND AND PERLMODULES_FOUND))
|
||||
message(STATUS "Perl with GD not found; icons will not be regenerated if modified")
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
find_package(PNG)
|
||||
|
||||
if(NOT PNG_FOUND)
|
||||
message(STATUS "Using prebuilt libpng")
|
||||
|
||||
set(PNG_FOUND TRUE)
|
||||
set(PNG_LIBRARIES
|
||||
"${CMAKE_SOURCE_DIR}/extlib/libpng/libpng.lib"
|
||||
"${CMAKE_SOURCE_DIR}/extlib/zlib/zlib.lib")
|
||||
set(PNG_INCLUDE_DIRS
|
||||
"${CMAKE_SOURCE_DIR}/extlib/libpng")
|
||||
endif()
|
||||
|
||||
message(STATUS "Using prebuilt SpaceWare")
|
||||
set(SPACEWARE_FOUND TRUE)
|
||||
set(SPACEWARE_INCLUDE_DIR
|
||||
"${CMAKE_SOURCE_DIR}/extlib/si")
|
||||
set(SPACEWARE_LIBRARIES
|
||||
"${CMAKE_SOURCE_DIR}/extlib/si/siapp.lib")
|
||||
else()
|
||||
find_package(PNG REQUIRED)
|
||||
find_package(SpaceWare)
|
||||
|
||||
find_package(FLTK REQUIRED)
|
||||
CHECK_INCLUDE_FILE("fontconfig/fontconfig.h" HAVE_FONTCONFIG)
|
||||
endif()
|
||||
|
||||
# components
|
||||
|
||||
if(WIN32)
|
||||
add_subdirectory(tools)
|
||||
endif()
|
||||
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(exposed)
|
|
@ -0,0 +1,77 @@
|
|||
# - try to find perl modules, passed as COMPONENTS
|
||||
#
|
||||
# Non-cache variable you might use in your CMakeLists.txt:
|
||||
# PERLMODULES_FOUND
|
||||
#
|
||||
# Requires these CMake modules:
|
||||
# FindPackageHandleStandardArgs (known included with CMake >=2.6.2)
|
||||
#
|
||||
# Original Author:
|
||||
# 2012 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
|
||||
# http://academic.cleardefinition.com
|
||||
# Iowa State University HCI Graduate Program/VRAC
|
||||
#
|
||||
# Copyright Iowa State University 2012.
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
if(NOT PERL_FOUND)
|
||||
find_package(Perl QUIET)
|
||||
endif()
|
||||
|
||||
set(_deps_check)
|
||||
if(PERL_FOUND)
|
||||
foreach(module ${PerlModules_FIND_COMPONENTS})
|
||||
string(REPLACE "::" "/" modfilename "${module}.pm")
|
||||
string(REPLACE "::" "_" modvarname "PERLMODULES_${module}_MODULE")
|
||||
string(TOUPPER "${modvarname}" modvarname)
|
||||
list(APPEND _deps_check ${modvarname})
|
||||
if(NOT ${modvarname})
|
||||
if(NOT PerlModules_FIND_QUIETLY)
|
||||
message(STATUS "Checking for perl module ${module}")
|
||||
endif()
|
||||
execute_process(COMMAND
|
||||
"${PERL_EXECUTABLE}"
|
||||
"-e"
|
||||
"use ${module}; print \$INC{\"${modfilename}\"}"
|
||||
RESULT_VARIABLE result_code
|
||||
OUTPUT_VARIABLE filename
|
||||
ERROR_VARIABLE error_info
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if(result_code EQUAL 0)
|
||||
if(NOT PerlModules_FIND_QUIETLY)
|
||||
message(STATUS
|
||||
"Checking for perl module ${module} - found at ${filename}")
|
||||
endif()
|
||||
set(${modvarname}
|
||||
"${filename}"
|
||||
CACHE
|
||||
FILEPATH
|
||||
"Location found for module ${module}"
|
||||
FORCE)
|
||||
mark_as_advanced(${modvarname})
|
||||
else()
|
||||
if(NOT PerlModules_FIND_QUIETLY)
|
||||
message(STATUS "Checking for perl module ${module} - failed")
|
||||
endif()
|
||||
set(${modvarname}
|
||||
"NOTFOUND"
|
||||
CACHE
|
||||
FILEPATH
|
||||
"No location found for module ${module}"
|
||||
FORCE)
|
||||
file(APPEND
|
||||
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
|
||||
"Determining if the Perl module ${module} exists failed with the following error output:\n"
|
||||
"${error_info}\n\n")
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(PerlModules
|
||||
DEFAULT_MSG
|
||||
PERL_FOUND
|
||||
${_deps_check})
|
|
@ -0,0 +1,28 @@
|
|||
# Find the libspnav library and header.
|
||||
#
|
||||
# Sets the usual variables expected for find_package scripts:
|
||||
#
|
||||
# SPACEWARE_INCLUDE_DIR - header location
|
||||
# SPACEWARE_LIBRARIES - library to link against
|
||||
# SPACEWARE_FOUND - true if pugixml was found.
|
||||
|
||||
if(UNIX)
|
||||
|
||||
find_path(SPACEWARE_INCLUDE_DIR
|
||||
spnav.h)
|
||||
|
||||
find_library(SPACEWARE_LIBRARY
|
||||
NAMES spnav libspnav)
|
||||
|
||||
# Support the REQUIRED and QUIET arguments, and set SPACEWARE_FOUND if found.
|
||||
include(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SPACEWARE DEFAULT_MSG
|
||||
SPACEWARE_LIBRARY SPACEWARE_INCLUDE_DIR)
|
||||
|
||||
if(SPACEWARE_FOUND)
|
||||
set(SPACEWARE_LIBRARIES ${SPACEWARE_LIBRARY})
|
||||
endif()
|
||||
|
||||
mark_as_advanced(SPACEWARE_LIBRARY SPACEWARE_INCLUDE_DIR)
|
||||
|
||||
endif()
|
|
@ -0,0 +1,6 @@
|
|||
if(MSVC)
|
||||
set(CMAKE_C_FLAGS_DEBUG_INIT "/D_DEBUG /MTd /Zi /Ob0 /Od /RTC1")
|
||||
set(CMAKE_C_FLAGS_MINSIZEREL_INIT "/MT /O1 /Ob1 /D NDEBUG")
|
||||
set(CMAKE_C_FLAGS_RELEASE_INIT "/MT /O2 /Ob2 /D NDEBUG")
|
||||
set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "/MT /Zi /O2 /Ob1 /D NDEBUG")
|
||||
endif()
|
|
@ -0,0 +1,6 @@
|
|||
if(MSVC)
|
||||
set(CMAKE_CXX_FLAGS_DEBUG_INIT "/D_DEBUG /MTd /Zi /Ob0 /Od /RTC1")
|
||||
set(CMAKE_CXX_FLAGS_MINSIZEREL_INIT "/MT /O1 /Ob1 /D NDEBUG")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE_INIT "/MT /O2 /Ob2 /D NDEBUG")
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "/MT /Zi /O2 /Ob1 /D NDEBUG")
|
||||
endif()
|
|
@ -0,0 +1,8 @@
|
|||
include_directories(
|
||||
${CMAKE_SOURCE_DIR}/include)
|
||||
|
||||
add_executable(CDemo
|
||||
CDemo.c)
|
||||
|
||||
target_link_libraries(CDemo
|
||||
slvs)
|
|
@ -0,0 +1,238 @@
|
|||
# global
|
||||
|
||||
include_directories(
|
||||
${OPENGL_INCLUDE_DIR}
|
||||
${PNG_INCLUDE_DIRS})
|
||||
|
||||
link_directories(
|
||||
${PNG_LIBRARY_DIRS})
|
||||
|
||||
add_definitions(
|
||||
${PNG_CFLAGS_OTHER})
|
||||
|
||||
include_directories(
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/built"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}")
|
||||
|
||||
if(SPACEWARE_FOUND)
|
||||
include_directories(
|
||||
"${SPACEWARE_INCLUDE_DIR}")
|
||||
endif()
|
||||
|
||||
set(HAVE_FLTK ${FLTK_FOUND})
|
||||
set(HAVE_SPACEWARE ${SPACEWARE_FOUND})
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/config.h.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/config.h")
|
||||
|
||||
# platform utilities
|
||||
|
||||
if(WIN32)
|
||||
set(util_SOURCES
|
||||
win32/w32util.cpp)
|
||||
else()
|
||||
set(util_SOURCES
|
||||
fltk/fltkutil.cpp)
|
||||
endif()
|
||||
|
||||
# libslvs
|
||||
|
||||
set(libslvs_SOURCES
|
||||
util.cpp
|
||||
entity.cpp
|
||||
expr.cpp
|
||||
constraint.cpp
|
||||
constrainteq.cpp
|
||||
system.cpp)
|
||||
|
||||
set(libslvs_HEADERS
|
||||
solvespace.h)
|
||||
|
||||
add_library(slvs SHARED
|
||||
${libslvs_SOURCES}
|
||||
${libslvs_HEADERS}
|
||||
${util_SOURCES}
|
||||
lib.cpp)
|
||||
|
||||
target_compile_definitions(slvs
|
||||
PRIVATE -DLIBRARY)
|
||||
|
||||
target_include_directories(slvs
|
||||
PUBLIC "${CMAKE_SOURCE_DIR}/include")
|
||||
|
||||
set_target_properties(slvs PROPERTIES
|
||||
PUBLIC_HEADER "${CMAKE_SOURCE_DIR}/include/slvs.h"
|
||||
VERSION ${solvespace_VERSION_MAJOR}.${solvespace_VERSION_MINOR}
|
||||
SOVERSION 1)
|
||||
|
||||
if(NOT WIN32)
|
||||
install(TARGETS slvs
|
||||
LIBRARY DESTINATION lib
|
||||
PUBLIC_HEADER DESTINATION include)
|
||||
endif()
|
||||
|
||||
# generated files
|
||||
|
||||
file(GLOB icons "${CMAKE_CURRENT_SOURCE_DIR}/icons/*.png")
|
||||
|
||||
if(PERL_FOUND AND PERLMODULES_FOUND)
|
||||
add_custom_command(
|
||||
OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/built/icons.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/built/icons-proto.h"
|
||||
COMMAND "${PERL_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/png2c.pl"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/built/icons.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/built/icons-proto.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/png2c.pl"
|
||||
DEPENDENCIES ${icons})
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/built/bitmapextra.table.h"
|
||||
COMMAND "${PERL_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/pngchar2c.pl"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/built/bitmapextra.table.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/pngchar2c.pl"
|
||||
DEPENDENCIES ${icons})
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
add_custom_command(
|
||||
OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/built/bitmapfont.table.h"
|
||||
COMMAND ttf2c "${CMAKE_CURRENT_SOURCE_DIR}/built/bitmapfont.table.h")
|
||||
endif()
|
||||
|
||||
set(generated_HEADERS
|
||||
built/bitmapextra.table.h
|
||||
built/bitmapfont.table.h
|
||||
built/icons-proto.h
|
||||
built/icons.h)
|
||||
|
||||
set_source_files_properties(${generated_HEADERS}
|
||||
PROPERTIES GENERATED TRUE)
|
||||
|
||||
# platform dependencies
|
||||
|
||||
if(WIN32)
|
||||
set(platform_HEADERS
|
||||
win32/freeze.h)
|
||||
|
||||
set(platform_SOURCES
|
||||
win32/freeze.cpp
|
||||
win32/w32main.cpp
|
||||
win32/resource.rc)
|
||||
else()
|
||||
include_directories(
|
||||
"${FLTK_INCLUDE_DIR}")
|
||||
|
||||
set(platform_SOURCES
|
||||
fltk/fltkmain.cpp)
|
||||
|
||||
set(platform_LIBRARIES
|
||||
${CMAKE_DL_LIBS}
|
||||
"${FLTK_LIBRARIES}")
|
||||
endif()
|
||||
|
||||
# solvespace executable
|
||||
|
||||
set(solvespace_HEADERS
|
||||
config.h
|
||||
dsc.h
|
||||
expr.h
|
||||
font.table.h
|
||||
polygon.h
|
||||
sketch.h
|
||||
solvespace.h
|
||||
ui.h
|
||||
srf/surface.h)
|
||||
|
||||
set(solvespace_SOURCES
|
||||
bsp.cpp
|
||||
clipboard.cpp
|
||||
confscreen.cpp
|
||||
constraint.cpp
|
||||
constrainteq.cpp
|
||||
describescreen.cpp
|
||||
draw.cpp
|
||||
drawconstraint.cpp
|
||||
drawentity.cpp
|
||||
entity.cpp
|
||||
export.cpp
|
||||
exportstep.cpp
|
||||
exportvector.cpp
|
||||
expr.cpp
|
||||
file.cpp
|
||||
generate.cpp
|
||||
glhelper.cpp
|
||||
graphicswin.cpp
|
||||
group.cpp
|
||||
groupmesh.cpp
|
||||
mesh.cpp
|
||||
modify.cpp
|
||||
mouse.cpp
|
||||
polygon.cpp
|
||||
request.cpp
|
||||
solvespace.cpp
|
||||
style.cpp
|
||||
system.cpp
|
||||
textscreens.cpp
|
||||
textwin.cpp
|
||||
toolbar.cpp
|
||||
ttf.cpp
|
||||
undoredo.cpp
|
||||
util.cpp
|
||||
view.cpp
|
||||
srf/boolean.cpp
|
||||
srf/curve.cpp
|
||||
srf/merge.cpp
|
||||
srf/ratpoly.cpp
|
||||
srf/raycast.cpp
|
||||
srf/surface.cpp
|
||||
srf/surfinter.cpp
|
||||
srf/triangulate.cpp)
|
||||
|
||||
add_executable(solvespace WIN32
|
||||
${libslvs_HEADERS}
|
||||
${libslvs_SOURCES}
|
||||
${util_SOURCES}
|
||||
${platform_HEADERS}
|
||||
${platform_SOURCES}
|
||||
${generated_HEADERS}
|
||||
${solvespace_HEADERS}
|
||||
${solvespace_SOURCES})
|
||||
|
||||
target_link_libraries(solvespace
|
||||
"${OPENGL_LIBRARIES}"
|
||||
"${PNG_LIBRARIES}"
|
||||
"${platform_LIBRARIES}")
|
||||
|
||||
if(WIN32)
|
||||
set_target_properties(solvespace PROPERTIES
|
||||
LINK_FLAGS "/MANIFEST:NO /SAFESEH:NO")
|
||||
endif()
|
||||
|
||||
if(SPACEWARE_FOUND)
|
||||
target_link_libraries(solvespace
|
||||
"${SPACEWARE_LIBRARIES}")
|
||||
endif()
|
||||
|
||||
install(TARGETS solvespace
|
||||
RUNTIME DESTINATION bin)
|
||||
|
||||
# valgrind
|
||||
|
||||
add_custom_target(solvespace-valgrind
|
||||
valgrind
|
||||
--tool=memcheck
|
||||
--verbose
|
||||
--track-fds=yes
|
||||
--log-file=vg.%p.out
|
||||
--num-callers=50
|
||||
--error-limit=no
|
||||
--read-var-info=yes
|
||||
--leak-check=full
|
||||
--leak-resolution=high
|
||||
--show-reachable=yes
|
||||
--track-origins=yes
|
||||
--malloc-fill=0xac
|
||||
--free-fill=0xde
|
||||
$<TARGET_FILE:solvespace>)
|
|
@ -1,3 +1,5 @@
|
|||
/**** This is a generated file - do not edit ****/
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0,
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
#ifndef __CONFIG_H
|
||||
#define __CONFIG_H
|
||||
|
||||
#define PACKAGE_VERSION "@solvespace_VERSION_MAJOR@.@solvespace_VERSION_MINOR@"
|
||||
|
||||
#cmakedefine HAVE_STDINT_H
|
||||
#cmakedefine HAVE_FONTCONFIG_FONTCONFIG_H
|
||||
|
||||
#cmakedefine HAVE_FLTK
|
||||
#define HAVE_FLTK_FULLSCREEN
|
||||
|
||||
#cmakedefine HAVE_SPACEWARE
|
||||
|
||||
#endif
|
|
@ -6,20 +6,18 @@
|
|||
// Copyright 2008-2013 Jonathan Westhues.
|
||||
// Copyright 2013 Daniel Richard G. <skunk@iSKUNK.ORG>
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
#ifdef HAVE_FONTCONFIG_FONTCONFIG_H
|
||||
#ifdef HAVE_FONTCONFIG
|
||||
# include <fontconfig/fontconfig.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIBSPNAV
|
||||
#ifdef HAVE_SPACEWARE
|
||||
# include <spnav.h>
|
||||
# ifndef SI_APP_FIT_BUTTON
|
||||
# define SI_APP_FIT_BUTTON 31
|
||||
|
@ -402,7 +400,7 @@ public:
|
|||
{
|
||||
switch(event)
|
||||
{
|
||||
#ifdef HAVE_LIBSPNAV
|
||||
#ifdef HAVE_SPACEWARE
|
||||
case FL_NO_EVENT: {
|
||||
spnav_event sev;
|
||||
if(!spnav_x11_event(fl_xevent, &sev)) break;
|
||||
|
@ -426,7 +424,7 @@ public:
|
|||
}
|
||||
return 1;
|
||||
}
|
||||
#endif // HAVE_LIBSPNAV
|
||||
#endif // HAVE_SPACEWARE
|
||||
|
||||
case FL_PUSH: // mouse button click...
|
||||
case FL_RELEASE: // ...and release
|
||||
|
@ -1330,7 +1328,7 @@ int main(int argc, char **argv)
|
|||
GetAbsoluteFilename(file);
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBSPNAV
|
||||
#ifdef HAVE_SPACEWARE
|
||||
bool spacenavd_active =
|
||||
spnav_x11_open(fl_display, fl_xid(GraphicsWnd)) == 0;
|
||||
#endif
|
||||
|
@ -1355,7 +1353,7 @@ int main(int argc, char **argv)
|
|||
SS.DoLater();
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBSPNAV
|
||||
#ifdef HAVE_SPACEWARE
|
||||
if(spacenavd_active) {
|
||||
spnav_close();
|
||||
}
|
||||
|
|
|
@ -7,9 +7,7 @@
|
|||
// Copyright 2008-2013 Jonathan Westhues.
|
||||
// Copyright 2013 Daniel Richard G. <skunk@iSKUNK.ORG>
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
|
|
|
@ -5,11 +5,13 @@ use warnings;
|
|||
|
||||
use GD;
|
||||
|
||||
my ($srcdir) = @ARGV;
|
||||
my ($out, $srcdir) = @ARGV;
|
||||
defined($srcdir) or $srcdir = '.';
|
||||
-d "$srcdir/icons" || die "$srcdir/icons/: directory not found";
|
||||
|
||||
print "/**** This is a generated file - do not edit ****/\n\n";
|
||||
open(OUT, ">$out") or die "$out: $!";
|
||||
|
||||
print OUT "/**** This is a generated file - do not edit ****/\n\n";
|
||||
|
||||
for my $file (sort <$srcdir/icons/char-*.png>) {
|
||||
open(PNG, $file) or die "$file: $!\n";
|
||||
|
@ -25,13 +27,13 @@ for my $file (sort <$srcdir/icons/char-*.png>) {
|
|||
my $index = $img->getPixel($x, $y);
|
||||
my ($r, $g, $b) = $img->rgb($index);
|
||||
if($r + $g + $b < 11) {
|
||||
print " 0, ";
|
||||
print OUT " 0, ";
|
||||
} else {
|
||||
print "255, ";
|
||||
print OUT "255, ";
|
||||
}
|
||||
}
|
||||
print "\n";
|
||||
print OUT "\n";
|
||||
}
|
||||
print "\n";
|
||||
print OUT "\n";
|
||||
}
|
||||
|
||||
|
|
|
@ -7,9 +7,7 @@
|
|||
#ifndef __SOLVESPACE_H
|
||||
#define __SOLVESPACE_H
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
|
@ -95,7 +93,7 @@ inline double ffabs(double v) { return (v > 0) ? v : (-v); }
|
|||
|
||||
#define isforname(c) (isalnum(c) || (c) == '_' || (c) == '-' || (c) == '#')
|
||||
|
||||
#if defined(WIN32) && !defined(HAVE_C99_INTEGER_TYPES)
|
||||
#if defined(WIN32) && !defined(HAVE_STDINT_H)
|
||||
// Define some useful C99 integer types.
|
||||
typedef UINT64 uint64_t;
|
||||
typedef INT64 int64_t;
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include <commctrl.h>
|
||||
#include <commdlg.h>
|
||||
|
||||
#ifdef HAVE_SPACEWARE_INPUT
|
||||
#ifdef HAVE_SPACEWARE
|
||||
# include <si.h>
|
||||
# include <siapp.h>
|
||||
# undef uint32_t // thanks but no thanks
|
||||
|
@ -48,7 +48,7 @@ int ClientIsSmallerBy;
|
|||
|
||||
HFONT FixedFont;
|
||||
|
||||
#ifdef HAVE_SPACEWARE_INPUT
|
||||
#ifdef HAVE_SPACEWARE
|
||||
// The 6-DOF input device.
|
||||
SiHdl SpaceNavigator = SI_NO_HANDLE;
|
||||
#endif
|
||||
|
@ -1114,7 +1114,7 @@ static void CreateMainWindows(void)
|
|||
ClientIsSmallerBy = (r.bottom - r.top) - (rc.bottom - rc.top);
|
||||
}
|
||||
|
||||
#ifdef HAVE_SPACEWARE_INPUT
|
||||
#ifdef HAVE_SPACEWARE
|
||||
//-----------------------------------------------------------------------------
|
||||
// Test if a message comes from the SpaceNavigator device. If yes, dispatch
|
||||
// it appropriately and return true. Otherwise, do nothing and return false.
|
||||
|
@ -1150,7 +1150,7 @@ static bool ProcessSpaceNavigatorMsg(MSG *msg) {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
#endif // HAVE_SPACEWARE_INPUT
|
||||
#endif // HAVE_SPACEWARE
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Entry point into the program.
|
||||
|
@ -1204,7 +1204,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
|||
GetAbsoluteFilename(file);
|
||||
}
|
||||
|
||||
#ifdef HAVE_SPACEWARE_INPUT
|
||||
#ifdef HAVE_SPACEWARE
|
||||
// Initialize the SpaceBall, if present. Test if the driver is running
|
||||
// first, to avoid a long timeout if it's not.
|
||||
HWND swdc = FindWindow("SpaceWare Driver Class", NULL);
|
||||
|
@ -1226,7 +1226,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
|||
MSG msg;
|
||||
DWORD ret;
|
||||
while((ret = GetMessage(&msg, NULL, 0, 0)) != 0) {
|
||||
#ifdef HAVE_SPACEWARE_INPUT
|
||||
#ifdef HAVE_SPACEWARE
|
||||
// Is it a message from the six degree of freedom input device?
|
||||
if(ProcessSpaceNavigatorMsg(&msg)) goto done;
|
||||
#endif
|
||||
|
@ -1249,7 +1249,7 @@ done:
|
|||
SS.DoLater();
|
||||
}
|
||||
|
||||
#ifdef HAVE_SPACEWARE_INPUT
|
||||
#ifdef HAVE_SPACEWARE
|
||||
if(swdc != NULL) {
|
||||
if(SpaceNavigator != SI_NO_HANDLE) SiClose(SpaceNavigator);
|
||||
SiTerminate();
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
add_executable(ttf2c
|
||||
ttf2c.cpp)
|
|
@ -5,8 +5,13 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Entry point into the program.
|
||||
//-----------------------------------------------------------------------------
|
||||
int main(void)
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
if(argc != 2) {
|
||||
fprintf(stderr, "usage: ttf2c [output]");
|
||||
return 1;
|
||||
}
|
||||
|
||||
InitCommonControls();
|
||||
|
||||
// A monospaced font
|
||||
|
@ -20,7 +25,13 @@ int main(void)
|
|||
SelectObject(hdc, bitmap);
|
||||
SelectObject(hdc, font);
|
||||
|
||||
printf("static const uint8_t FontTexture[256*16*16] = {\n");
|
||||
FILE* out = fopen(argv[1], "w");
|
||||
if(!out) {
|
||||
fprintf(stderr, "cannot open output file %s", argv[1]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
fprintf(out, "static const uint8_t FontTexture[256*16*16] = {\n");
|
||||
|
||||
int c;
|
||||
for(c = 0; c < 128; c++) {
|
||||
|
@ -39,14 +50,16 @@ int main(void)
|
|||
for(i = 0; i < 16; i++) {
|
||||
for(j = 0; j < 16; j++) {
|
||||
COLORREF c = GetPixel(hdc, i, j);
|
||||
printf("%3d, ", c ? 255 : 0);
|
||||
fprintf(out, "%3d, ", c ? 255 : 0);
|
||||
}
|
||||
printf("\n");
|
||||
fprintf(out, "\n");
|
||||
}
|
||||
printf("\n");
|
||||
fprintf(out, "\n");
|
||||
}
|
||||
printf("#include \"bitmapextra.table.h\"\n");
|
||||
printf("};\n");
|
||||
fprintf(out, "#include \"bitmapextra.table.h\"\n");
|
||||
fprintf(out, "};\n");
|
||||
|
||||
fclose(out);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue