Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: solvespace/solvespace
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 7bad19d7d38a
Choose a base ref
...
head repository: solvespace/solvespace
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 1df5de038cdd
Choose a head ref

Commits on May 21, 2019

  1. Fix an edge case with fps measured as infinite.

    If the timer is not sufficiently high resolution but the graphics
    card is fast, we can get renderTime.count() == 0.
    whitequark committed May 21, 2019
    Copy the full SHA
    9500487 View commit details
  2. Copy the full SHA
    25b6eba View commit details

Commits on May 23, 2019

  1. Update copyright statement in about box.

    Also, make sure it's localized properly.
    whitequark committed May 23, 2019
    Copy the full SHA
    0921296 View commit details
  2. Win32: use native OpenGL drivers, if available.

    After this commit, if the target system does have modern OpenGL
    drivers installed, ANGLE is configured to use them, bypassing most
    translation (shaders still have to be translated from ESSL to GLSL).
    
    If there are no OpenGL drivers, such as if the graphics drivers were
    installed via Windows Update, DirectX translation is still used. This
    results in a very noticeable startup delay and minor performance
    degradation.
    
    In addition it is no longer necessary to build with -DOPENGL=1 to be
    able to run the binary in wine; everything works out of the box.
    Before, wine's incomplete HLSL translator would crash.
    
    This change required renaming the variable `texture` in shaders,
    since it shadows the Core GLSL function with the same name, and ANGLE
    translates texture2D() calls to texture() calls.
    whitequark committed May 23, 2019
    Copy the full SHA
    e9b9dca View commit details
  3. Copy the full SHA
    f6484c7 View commit details
  4. Rework tooltip implementation to track tip area.

    This fixes an elusive GTK issue where tooltips would be spuriously
    displayed, and makes tooltips behave nicer on Windows.
    
    Unfortunately the macOS code is unchanged as the macOS tooltip
    implementation seems seriously broken in ways I do not understand.
    whitequark committed May 23, 2019
    Copy the full SHA
    3296474 View commit details
  5. Make help text for image and TTF request creation reflect reality.

    Before this commit it would prompt for top left and bottom left
    corner, neither of which was what in fact was being used. Those two
    specific points cannot be used because of the way equations are
    written, so instead change that to top left and bottom right, which
    is more convenient anyway.
    Evil-Spirit authored and whitequark committed May 23, 2019
    Copy the full SHA
    c9397ea View commit details
  6. Add a .clang-format file - not for bulk use!

    This would add a lot of noise to the history, etc. if applied all
    over now. Use git clang-format to apply it solely to your changes.
    rpavlik authored and whitequark committed May 23, 2019
    Copy the full SHA
    ffef006 View commit details
  7. Copy the full SHA
    e243396 View commit details
  8. Add a few asserts. NFC.

    rpavlik authored and whitequark committed May 23, 2019
    Copy the full SHA
    31f5873 View commit details
  9. Win32: Restore Windows XP Compatibility

    By setting WINVER=0x0501 (Windows XP) in CMakeLists.txt and adding a few
    missing defines in guiwin.cpp and configuring OPENGL=1 in CMake
    Solvespace (3.0~25b6eba1) compiles and works perfectly on Windows XP.
    Tested with MinGW GCC-6.3.0-1
    Ruevski authored and whitequark committed May 23, 2019
    Copy the full SHA
    260769c View commit details
  10. Make minor errors visible at a glance in the group list.

    If a sketch has a "minor" problem, such as being self-intersecting,
    this can cause considerably confusion in subsequent groups, yet is
    not indicated in the group list.
    
    This commit makes the "err" yellow in such cases. Note that the
    indication may not change immediately when a change leading to
    trouble is made, since the dependent groups are not recalculated
    on all changes.
    wpwrak authored and whitequark committed May 23, 2019
    Copy the full SHA
    c2c26e9 View commit details
  11. Copy the full SHA
    e67f967 View commit details
  12. Add a button to hide construction entities.

    Also, mark not just curves, but also points and normals derived from
    construction requests as construction.
    
    Also, don't always mark arc center point as construction just to
    exclude it from chord tolerance bounding box calculation; instead,
    special-case it there.
    whitequark committed May 23, 2019
    Copy the full SHA
    50c004b View commit details
  13. CLI: accept --chord-tol as an option to regenerate.

    This is currently necessary to get repeatable results when exporting
    assemblies as a part of a batch process, since the mesh geometry in
    imported files is not regenerated for export.
    whitequark committed May 23, 2019
    Copy the full SHA
    d01f715 View commit details
  14. Allow configuring the amount of digits displayed after decimal point.

    This is useful in niche cases, like making angular measurement tools.
    
    Also, use simpler and more principled code for numeric precision
    while editing constraints: don't special-case angles, but use up to
    10 digits after the decimal point for everything.
    whitequark committed May 23, 2019
    Copy the full SHA
    ac7b82d View commit details
  15. Get rid of FreeTemporary. NFC.

    Its only use was in a context where it was completely equivalent to
    MemFree, so just use that instead, and keep the temporary heap as
    purely an arena allocator, that could use something like bump
    pointer.
    whitequark committed May 23, 2019
    Copy the full SHA
    fabffba View commit details
  16. Remove the last use of memmove. NFC.

    Much clearer!
    whitequark committed May 23, 2019
    7
    Copy the full SHA
    cc10788 View commit details
  17. Copy the full SHA
    9f2077b View commit details
  18. Work around MSVC bug 746973.

    MSVC has a long history of value initialization bugs, and this one is
    no exception. In this case, when some MSVC versions (at least up to
    2013) are instructed to value-initialize a non-POD class with
    a compiler generated non-trivial constructor, it does not zero out
    the POD members.
    whitequark committed May 23, 2019
    Copy the full SHA
    43a59e2 View commit details
  19. Warn on broken extrusions, like on broken polygons.

    It's not very obvious if the extrusion failed because in a later
    group, the solid (by default) uses a very dark gray color that blends
    into the black background.
    
    This needs to be done separately because, while we already warn on
    broken polygons in workplanes, many more groups can be extruded, e.g.
    the canonical way (for now) to mirror a group is to use a rotation,
    and that doesn't get checked for closed contour, since most rotations
    won't get extruded.
    whitequark committed May 23, 2019
    Copy the full SHA
    df6777a View commit details

Commits on May 24, 2019

  1. Add an explicit mirror checkbox for Paste Transformed.

    This has always been possible by using negative scale, so this just
    adds a checkbox controlling the sign.
    whitequark committed May 24, 2019
    Copy the full SHA
    6c167db View commit details
  2. Fix commit cc10788.

    whitequark committed May 24, 2019
    Copy the full SHA
    9faa7cb View commit details
  3. Add a setting to format constraint labels using SI prefixes.

    Supported metric units: km, m, cm, mm, µm, nm.
    Supported USCS units: in, mil, µin.
    
    Also, use the newly introduced unit formatting machinery in tools for
    measuring perimeter, area and volume, so that e.g. volume is not
    displayed in millions of cubic millimeters.
    Evil-Spirit authored and whitequark committed May 24, 2019
    Copy the full SHA
    9d1c295 View commit details
  4. Show Degrees of Freedom → Show Underconstrained Points

    Clarify the name of the command, as the old name is not strictly
    correct. E.g. consider a vertical line with a midpoint constraint to
    origin has 1 DOF, but 2 highlights are shown. Conversely, a single
    datum point has 2 DOF, but 1 highlight is shown.
    whitequark committed May 24, 2019
    Copy the full SHA
    88879d3 View commit details
  5. Remove forceDofCheck parameter from SolveRank(). NFC.

    It makes no sense to solve by substitution (therefore weakening rank
    check) in SolveRank(), since that's the whole point of SolveRank().
    
    In addition, because SolveRank() is currently always called right
    after AddConstraint(), forceDofCheck would always be true anyway.
    
    In addition, it makes no sense to have TestRankForGroup() dependent
    on the result of the previous solve. (For SolveGroup(), solving by
    substitution after we know that rank test succeeds makes dragging
    points much faster.)
    whitequark committed May 24, 2019
    Copy the full SHA
    394c1f6 View commit details
  6. Skip creating an automatic H/V constraint if it would be redundant.

    This means that automatically added H/V constraints now will never
    cause the sketch to become overconstrained, which currently makes
    that feature almost unusable.
    whitequark committed May 24, 2019
    Copy the full SHA
    5495659 View commit details
  7. In TryConstrain(), reject redundant constraints in overconstrained gr…

    …oups.
    
    This keeps groups with allowed redundant constraints cleaner when
    they are used together with automatic constraints.
    whitequark committed May 24, 2019
    Copy the full SHA
    cf2f0e5 View commit details
  8. Copy the full SHA
    beea444 View commit details
  9. Make sure file from a recent menu exists before using it.

    Otherwise it can result in a very confusing error that does not
    suggest at all that the file is missing.
    whitequark committed May 24, 2019
    Copy the full SHA
    eb7e12b View commit details
  10. Copy the full SHA
    09ca442 View commit details
  11. 2
    Copy the full SHA
    406c55e View commit details
  12. Replace entity map implementation with std::unordered_map.

    On a single load benchmark this provides about 25% speedup.
    whitequark committed May 24, 2019
    Copy the full SHA
    bd84bc1 View commit details
  13. Deselect entities with Ctrl-LMB.

    In other words, Ctrl inverts the normal action of LMB. It is already
    possible to deselect entities through the context menu, but that
    can be very awkward on laptop touchpads with a crowded sketch; with
    Ctrl, a misclick is easily corrected without moving cursor at all.
    whitequark committed May 24, 2019
    Copy the full SHA
    6352405 View commit details

Commits on May 29, 2019

  1. Win32: fix build with -DOPENGL=1.

    ruevs authored and whitequark committed May 29, 2019
    Copy the full SHA
    9ac55f3 View commit details

Commits on May 31, 2019

  1. Update q3d submodule.

    whitequark committed May 31, 2019
    Copy the full SHA
    3596979 View commit details
  2. GTK: delete all gtkmm objects before destrying Gtk::Main.

    Otherwise this results in harmless but annoying spam on applciation
    shutdown.
    
    See https://gitlab.gnome.org/GNOME/gtkmm/issues/22.
    whitequark committed May 31, 2019
    Copy the full SHA
    3d80062 View commit details

Commits on Jun 3, 2019

  1. Implement revolve groups.

    phkahler authored and whitequark committed Jun 3, 2019
    Copy the full SHA
    5df53fc View commit details

Commits on Jun 14, 2019

  1. Freedesktop: add scalable SVG icon.

    ppd authored and whitequark committed Jun 14, 2019
    Copy the full SHA
    cb0fdb1 View commit details

Commits on Jun 24, 2019

  1. Fix off-by-1 in Group::Remap.

    This was introduced in bd84bc1 and caused crashes with:
      Assertion failed: hm.v != t->h.v.
    whitequark committed Jun 24, 2019
    5
    Copy the full SHA
    49a7f86 View commit details

Commits on Jun 25, 2019

  1. Copy the full SHA
    02d7f0c View commit details

Commits on Jul 2, 2019

  1. Copy the full SHA
    1df5de0 View commit details
Showing with 2,917 additions and 435 deletions.
  1. +43 −0 .clang-format
  2. +11 −1 CHANGELOG.md
  3. +17 −8 CMakeLists.txt
  4. +5 −0 CONTRIBUTING.md
  5. +32 −0 README.md
  6. +9 −0 cmake/Platform/Emscripten.cmake
  7. +10 −0 cmake/Toolchain-emscripten.cmake
  8. +5 −1 cmake/c_flag_overrides.cmake
  9. +4 −0 cmake/cxx_flag_overrides.cmake
  10. +5 −0 exposed/CMakeLists.txt
  11. +1 −1 extlib/q3d
  12. +38 −3 res/CMakeLists.txt
  13. +12 −0 res/freedesktop/solvespace-scalable.svg
  14. BIN res/icons/text-window/construction.png
  15. +2 −2 res/shaders/imesh.frag
  16. +2 −2 res/shaders/imesh_tex.frag
  17. +2 −2 res/shaders/imesh_texa.frag
  18. +2 −2 res/shaders/mesh_fill.frag
  19. +30 −0 res/threejs/SolveSpaceControls.js
  20. +45 −2 src/CMakeLists.txt
  21. +10 −3 src/clipboard.cpp
  22. +46 −7 src/confscreen.cpp
  23. +30 −9 src/constraint.cpp
  24. +2 −2 src/draw.cpp
  25. +7 −11 src/drawconstraint.cpp
  26. +1 −0 src/drawentity.cpp
  27. +2 −2 src/export.cpp
  28. +29 −20 src/file.cpp
  29. +5 −5 src/generate.cpp
  30. +33 −4 src/graphicswin.cpp
  31. +90 −27 src/group.cpp
  32. +23 −1 src/groupmesh.cpp
  33. +1 −1 src/lib.cpp
  34. +8 −10 src/mesh.cpp
  35. +59 −50 src/mouse.cpp
  36. +8 −2 src/platform/entrycli.cpp
  37. +1 −1 src/platform/entrygui.cpp
  38. +4 −1 src/platform/gui.h
  39. +42 −7 src/platform/guigtk.cpp
  40. +924 −0 src/platform/guihtml.cpp
  41. +5 −3 src/platform/guimac.mm
  42. +2 −0 src/platform/guinone.cpp
  43. +74 −23 src/platform/guiwin.cpp
  44. +82 −0 src/platform/html/emshell.html
  45. +277 −0 src/platform/html/solvespaceui.css
  46. +346 −0 src/platform/html/solvespaceui.js
  47. +13 −0 src/platform/platform.cpp
  48. +1 −0 src/platform/platform.h
  49. +0 −12 src/platform/utilunix.cpp
  50. +0 −3 src/platform/utilwin.cpp
  51. +10 −3 src/render/gl3shader.cpp
  52. +1 −1 src/render/gl3shader.h
  53. +2 −1 src/render/rendergl1.cpp
  54. +2 −1 src/render/rendergl3.cpp
  55. +2 −6 src/request.cpp
  56. +34 −18 src/sketch.h
  57. +86 −28 src/solvespace.cpp
  58. +15 −9 src/solvespace.h
  59. +226 −49 src/srf/surface.cpp
  60. +6 −3 src/srf/surface.h
  61. +14 −21 src/system.cpp
  62. +18 −15 src/textscreens.cpp
  63. +16 −10 src/textwin.cpp
  64. +23 −18 src/toolbar.cpp
  65. +18 −11 src/ui.h
  66. +2 −3 src/undoredo.cpp
  67. BIN test/constraint/angle/free_in_3d.png
  68. BIN test/constraint/angle/normal.png
  69. BIN test/constraint/angle/reference.png
  70. BIN test/constraint/angle/reference_free_in_3d.png
  71. +1 −1 test/constraint/arc_line_tangent/normal.slvs
  72. +2 −2 test/constraint/curve_curve_tangent/arc_arc.slvs
  73. +2 −2 test/constraint/curve_curve_tangent/arc_cubic.slvs
  74. +1 −1 test/constraint/equal_line_arc_len/normal.slvs
  75. BIN test/constraint/pt_face_distance/normal.png
  76. +17 −1 test/constraint/pt_face_distance/normal.slvs
  77. BIN test/constraint/pt_face_distance/reference.png
  78. +17 −1 test/constraint/pt_face_distance/reference.slvs
  79. +1 −1 test/constraint/pt_on_face/normal.slvs
  80. +1 −1 test/request/arc_of_circle/normal.slvs
43 changes: 43 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
# Things explicitly enumerated in CONTRIBUTING.md
IndentWidth: 4
UseTab: Never
SpaceBeforeParens: Never
BreakBeforeBraces: Attach
ColumnLimit: 100
# Docs say 100, but some places look more like 80.
#ColumnLimit: 80

# Based on minimizing diff when applying clang-format
AccessModifierOffset: -4
DerivePointerAlignment: true
AlignConsecutiveAssignments: true
FixNamespaceComments: true
NamespaceIndentation: Inner
AllowShortLoopsOnASingleLine: true
AlwaysBreakTemplateDeclarations: Yes # MultiLine
SpaceAfterTemplateKeyword: false
MaxEmptyLinesToKeep: 2
IndentPPDirectives: AfterHash
AlignEscapedNewlines: DontAlign
BreakConstructorInitializers: BeforeColon
AllowShortCaseLabelsOnASingleLine: true

# This one is mixed in its effect: it permits some single-line functions,
# but also tends to put, e.g., enums on a single line.
AllowShortBlocksOnASingleLine: true

# No way to remove all space around operators as seen in much of the code I looked at.
#SpaceBeforeAssignmentOperators: false

# Only seen some of the time (mostly just variables, not functions)
# but clang-format only has a true/false
#AlignConsecutiveDeclarations: true


# Would be nice to turn on eventually, maybe?
SortIncludes: false
SortUsingDeclarations: false

# Hard to tell what the desired config here was.
# AllowShortFunctionsOnASingleLine: Inline
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ Changelog
---

New sketch features:
* New group, revolve.
* Extrude, lathe, translate and rotate groups can use the "assembly"
boolean operation, to increase performance.
* The solid model of extrude and lathe groups can be suppressed,
@@ -33,8 +34,14 @@ New constraint features:
in the text window.
* When selecting an entity, the constraints applied to it can be selected
in the text window.
* Distance constraint labels can now be formatted to use SI prefixes.
Values are edited in the configured unit regardless of label format.
* When creating a constraint, if an exactly identical constraint already
exists, it is now selected instead of adding a redundant constraint.
* It is now possible to turn off automatic creation of horizontal/vertical
constraints on line segments.
* Automatic creation of constraints no longer happens if the constraint
would have been redundant with other ones.

New export/import features:
* Three.js: allow configuring projection for exported model, and initially
@@ -46,7 +53,7 @@ New export/import features:
exported. This format allows to easily hack on triangle mesh data created
in SolveSpace, supports colour information and is more space efficient than
most other formats.
* Export 2d section: custom styled entities that lie in the same
* Export 2d section: custom styled entities that lie in the same
plane as the exported section are included.

New rendering features:
@@ -68,9 +75,12 @@ New measurement/analysis features:
Other new features:
* New command-line interface, for batch exporting and more.
* The graphical interface now supports HiDPI screens on every OS.
* New option to lock Z axis to be always vertical, like in SketchUp.
* New button to hide all construction entities.
* New link to match the on-screen size of the sketch with its actual size,
"view → set to full scale".
* When zooming to fit, constraints are also considered.
* Ctrl-clicking entities now deselects them, as the inverse of clicking.
* When clicking on an entity that shares a place with other entities,
the entity from the current group is selected.
* When dragging an entity that shares a place with other entities,
25 changes: 17 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -112,7 +112,14 @@ add_subdirectory(extlib/libdxfrw)

message(STATUS "Using in-tree flatbuffers")
set(FLATBUFFERS_BUILD_FLATLIB ON CACHE BOOL "")
set(FLATBUFFERS_BUILD_FLATC ON CACHE BOOL "")
if(EMSCRIPTEN)
set(FLATBUFFERS_BUILD_FLATC OFF CACHE BOOL "")
if(NOT FLATC)
message(FATAL_ERROR "Emscripten build requires specifying the flatc binary explicitly")
endif()
else()
set(FLATBUFFERS_BUILD_FLATC ON CACHE BOOL "")
endif()
set(FLATBUFFERS_BUILD_FLATHASH OFF CACHE BOOL "")
set(FLATBUFFERS_BUILD_TESTS OFF CACHE BOOL "")
add_subdirectory(extlib/flatbuffers EXCLUDE_FROM_ALL)
@@ -121,7 +128,7 @@ message(STATUS "Using in-tree q3d")
add_subdirectory(extlib/q3d)
set(Q3D_INCLUDE_DIR ${CMAKE_BINARY_DIR}/extlib/q3d)

if(WIN32 OR APPLE)
if(WIN32 OR APPLE OR EMSCRIPTEN)
# On Win32 and macOS we use vendored packages, since there is little to no benefit
# to trying to find system versions. In particular, trying to link to libraries from
# Homebrew or macOS system libraries into the .app file is highly likely to result
@@ -187,9 +194,9 @@ if(ENABLE_GUI)
set(ANGLE_STATIC ON CACHE INTERNAL "")
set(ANGLE_ENABLE_D3D9 ON CACHE INTERNAL "")
set(ANGLE_ENABLE_D3D11 ON CACHE INTERNAL "")
set(ANGLE_ENABLE_OPENGL OFF CACHE INTERNAL "")
set(ANGLE_ENABLE_ESSL OFF CACHE INTERNAL "")
set(ANGLE_ENABLE_GLSL OFF CACHE INTERNAL "")
set(ANGLE_ENABLE_OPENGL ON CACHE INTERNAL "")
set(ANGLE_ENABLE_ESSL ON CACHE INTERNAL "")
set(ANGLE_ENABLE_GLSL ON CACHE INTERNAL "")
set(ANGLE_ENABLE_HLSL ON CACHE INTERNAL "")
add_vendored_subdirectory(extlib/angle)
set(OPENGL_LIBRARIES EGL GLESv2)
@@ -209,6 +216,8 @@ if(ENABLE_GUI)
elseif(APPLE)
find_package(OpenGL REQUIRED)
find_library(APPKIT_LIBRARY AppKit REQUIRED)
elseif(EMSCRIPTEN)
# Everything is built in
else()
find_package(OpenGL REQUIRED)
find_package(SpaceWare)
@@ -259,8 +268,8 @@ if(WIN32)
-D_CRT_SECURE_NO_DEPRECATE
-D_CRT_SECURE_NO_WARNINGS
-D_SCL_SECURE_NO_WARNINGS
-DWINVER=0x0601
-D_WIN32_WINNT=0x0601
-DWINVER=0x0501
-D_WIN32_WINNT=0x0501
-D_WIN32_IE=_WIN32_WINNT
-DISOLATION_AWARE_ENABLED
-DWIN32
@@ -285,7 +294,7 @@ if(MSVC)
endif()

if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(WARNING_FLAGS "-Wall -Wextra -Wno-unused-parameter")
set(WARNING_FLAGS "-Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers")
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(WARNING_FLAGS "${WARNING_FLAGS} -Wfloat-conversion")
endif()
5 changes: 5 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -186,6 +186,11 @@ std::string SolveSpace::Dirname(std::string filename) {
}
```
If you install [clang-format][], this style can be automatically applied by staging your changes
with `git add -u`, running `git clang-format`, and staging any changes it made again.
[clang-format]: https://clang.llvm.org/docs/ClangFormat.html
Debugging code
--------------
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -120,6 +120,38 @@ Space Navigator support will not be available.
If using Ubuntu to cross-compile, Ubuntu 17.10 or newer (or, alternatively, MinGW from the Ubuntu
17.10 repositories) is required.

## Building for web

You will need [Emscripten][]. First, install and prepare `emsdk`:

git clone https://github.com/juj/emsdk.git
cd emsdk
./emsdk install upstream-latest
./emsdk update upstream-latest
source ./emsdk_env.sh
cd ..

Before building, check out the project and the necessary submodules:

git clone https://github.com/solvespace/solvespace
cd solvespace
git submodule update

After that, build SolveSpace as following:

mkdir build
cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-emscripten.cmake \
-DCMAKE_BUILD_TYPE=Release
make

The graphical interface is built as multiple files in the `build/bin` directory with names
starting with `solvespace`. It can be run locally with `emrun build/bin/solvespace.html`.

The command-line interface is not available.

[emscripten]: https://kripken.github.io/emscripten-site/

Building on macOS
-----------------

9 changes: 9 additions & 0 deletions cmake/Platform/Emscripten.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
set(EMSCRIPTEN 1)

set(CMAKE_C_OUTPUT_EXTENSION ".o")
set(CMAKE_CXX_OUTPUT_EXTENSION ".o")
set(CMAKE_EXECUTABLE_SUFFIX ".html")

set(CMAKE_SIZEOF_VOID_P 4)

set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE)
10 changes: 10 additions & 0 deletions cmake/Toolchain-emscripten.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
set(CMAKE_SYSTEM_NAME Emscripten)

set(TRIPLE wasm-unknown-emscripten)

set(CMAKE_C_COMPILER emcc)
set(CMAKE_CXX_COMPILER em++)
set(CMAKE_AR emar)
set(CMAKE_RANLIB emranlib)

set(M_LIBRARY m)
6 changes: 5 additions & 1 deletion cmake/c_flag_overrides.cmake
Original file line number Diff line number Diff line change
@@ -3,4 +3,8 @@ if(MSVC)
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()
endif()

if(EMSCRIPTEN)
set(CMAKE_C_FLAGS_DEBUG_INIT "-g4")
endif()
4 changes: 4 additions & 0 deletions cmake/cxx_flag_overrides.cmake
Original file line number Diff line number Diff line change
@@ -4,3 +4,7 @@ if(MSVC)
set(CMAKE_CXX_FLAGS_RELEASE_INIT "/MT /O2 /Ob2 /D NDEBUG")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "/MT /Zi /O2 /Ob1 /D NDEBUG")
endif()

if(EMSCRIPTEN)
set(CMAKE_CXX_FLAGS_DEBUG_INIT "-g4")
endif()
5 changes: 5 additions & 0 deletions exposed/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -6,3 +6,8 @@ add_executable(CDemo

target_link_libraries(CDemo
slvs)

if(EMSCRIPTEN)
set_target_properties(CDemo PROPERTIES
LINK_FLAGS "-s TOTAL_MEMORY=134217728")
endif()
2 changes: 1 addition & 1 deletion extlib/q3d
Submodule q3d updated 3 files
+16 −8 CMakeLists.txt
+8 −0 README.md
+0 −0 q3d_object.fbs
41 changes: 38 additions & 3 deletions res/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# First, set up registration functions for the kinds of resources we handle.
set(resource_root ${CMAKE_CURRENT_SOURCE_DIR}/)
set(resource_list)
set(resource_names)
if(WIN32)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/win32/versioninfo.rc.in
${CMAKE_CURRENT_BINARY_DIR}/win32/versioninfo.rc)
@@ -83,6 +84,23 @@ elseif(APPLE)
DEPENDS ${source}
VERBATIM)
endfunction()
elseif(EMSCRIPTEN)
set(resource_dir ${CMAKE_BINARY_DIR}/src/res)

function(add_resource name)
set(source ${CMAKE_CURRENT_SOURCE_DIR}/${name})
set(target ${resource_dir}/${name})
set(resource_list "${resource_list};${target}" PARENT_SCOPE)
set(resource_names "${resource_names};res/${name}" PARENT_SCOPE)

add_custom_command(
OUTPUT ${target}
COMMAND ${CMAKE_COMMAND} -E make_directory ${resource_dir}
COMMAND ${CMAKE_COMMAND} -E copy ${source} ${target}
COMMENT "Copying resource ${name}"
DEPENDS ${source}
VERBATIM)
endfunction()
else() # Unix
include(GNUInstallDirs)

@@ -93,10 +111,9 @@ else() # Unix
set(target ${app_resource_dir}/${name})
set(resource_list "${resource_list};${target}" PARENT_SCOPE)

get_filename_component(target_dir ${target} DIRECTORY)
add_custom_command(
OUTPUT ${target}
COMMAND ${CMAKE_COMMAND} -E make_directory ${target_dir}
COMMAND ${CMAKE_COMMAND} -E make_directory ${app_resource_dir}
COMMAND ${CMAKE_COMMAND} -E copy ${source} ${target}
COMMENT "Copying resource ${name}"
DEPENDS ${source}
@@ -111,7 +128,8 @@ endif()
function(add_resources)
foreach(name ${ARGN})
add_resource(${name})
set(resource_list "${resource_list}" PARENT_SCOPE)
set(resource_list "${resource_list}" PARENT_SCOPE)
set(resource_names "${resource_names}" PARENT_SCOPE)
endforeach()
endfunction()

@@ -138,6 +156,13 @@ else()
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/mime/packages
RENAME com.solvespace.SolveSpace-slvs.xml)

install(FILES freedesktop/solvespace-scalable.svg
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/scalable/apps
RENAME com.solvespace.SolveSpace.svg)
install(FILES freedesktop/solvespace-scalable.svg
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/scalable/mimetypes
RENAME com.solvespace.SolveSpace.svg)

foreach(SIZE 16x16 24x24 32x32 48x48)
install(FILES freedesktop/solvespace-${SIZE}.png
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/${SIZE}/apps
@@ -156,6 +181,13 @@ else()
install(FILES freedesktop/solvespace-mime.xml
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/mime/packages
RENAME solvespace-slvs.xml)

install(FILES freedesktop/solvespace-scalable.svg
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/scalable/apps
RENAME solvespace.svg)
install(FILES freedesktop/solvespace-scalable.svg
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/scalable/mimetypes
RENAME application.x-solvespace.svg)

foreach(SIZE 16x16 24x24 32x32 48x48)
install(FILES freedesktop/solvespace-${SIZE}.png
@@ -208,6 +240,7 @@ add_resources(
icons/graphics-window/trim.png
icons/graphics-window/vert.png
icons/text-window/constraint.png
icons/text-window/construction.png
icons/text-window/edges.png
icons/text-window/faces.png
icons/text-window/occluded-visible.png
@@ -259,4 +292,6 @@ add_custom_target(resources
DEPENDS ${resource_list})
if(WIN32)
set_property(TARGET resources PROPERTY EXTRA_SOURCES ${rc_file})
elseif(EMSCRIPTEN)
set_property(TARGET resources PROPERTY NAMES ${resource_names})
endif()
12 changes: 12 additions & 0 deletions res/freedesktop/solvespace-scalable.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/icons/text-window/construction.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions res/shaders/imesh.frag
Original file line number Diff line number Diff line change
@@ -4,9 +4,9 @@
// Copyright 2016 Aleksey Egorov
//-----------------------------------------------------------------------------
uniform vec4 color;
uniform sampler2D texture;
uniform sampler2D texture_;

void main() {
if(texture2D(texture, gl_FragCoord.xy / 32.0).a < 0.5) discard;
if(texture2D(texture_, gl_FragCoord.xy / 32.0).a < 0.5) discard;
gl_FragColor = color;
}
4 changes: 2 additions & 2 deletions res/shaders/imesh_tex.frag
Original file line number Diff line number Diff line change
@@ -4,12 +4,12 @@
// Copyright 2016 Aleksey Egorov
//-----------------------------------------------------------------------------
uniform vec4 color;
uniform sampler2D texture;
uniform sampler2D texture_;

varying vec2 fragTex;

void main() {
vec4 texColor = texture2D(texture, fragTex);
vec4 texColor = texture2D(texture_, fragTex);
if(texColor.a == 0.0) discard;
gl_FragColor = texColor * color;
}
Loading