OpenGL support through GLEW. Only active if compiled with SLIC3R_GUI=1.

This commit is contained in:
bubnikv 2016-09-14 16:31:26 +02:00
parent 266e1c4be1
commit 2a5095a1ea
8 changed files with 58 additions and 12 deletions

View File

@ -1083,6 +1083,10 @@ sub load_object {
$color_idx = $obj_idx;
}
# Using the colors 'yellowish', 'greenish', 'blueish' for both the extrusion paths
# and the volumes of a single multi-color object.
#FIXME so for 4 or more color print, there will be only 3 colors displayed, which will
# not correspond to the color of the filament.
my $color = [ @{COLORS->[ $color_idx % scalar(@{&COLORS}) ]} ];
$color->[3] = $volume->modifier ? 0.5 : 1;
push @{$self->volumes}, my $v = Slic3r::GUI::3DScene::Volume->new(
@ -1114,6 +1118,7 @@ sub load_object {
return @volumes_idx;
}
# Called possibly by utils/view-toolpaths.pl, likely broken.
sub load_print_object_slices {
my ($self, $object) = @_;
@ -1168,6 +1173,8 @@ sub load_print_object_slices {
);
}
# Create 3D thick extrusion lines for a skirt and brim.
# Adds a new Slic3r::GUI::3DScene::Volume to $self->volumes.
sub load_print_toolpaths {
my ($self, $print) = @_;
@ -1221,6 +1228,9 @@ sub load_print_toolpaths {
);
}
# Create 3D thick extrusion lines for object forming extrusions.
# Adds a new Slic3r::GUI::3DScene::Volume to $self->volumes,
# one for perimeters, one for infill and one for supports.
sub load_print_object_toolpaths {
my ($self, $object) = @_;
@ -1319,6 +1329,7 @@ sub set_toolpaths_range {
}
}
# called by load_print_object_slices, probably not used.
sub _expolygons_to_verts {
my ($self, $expolygons, $z, $verts, $norms) = @_;

View File

@ -14,7 +14,7 @@ my $mswin = $^O eq 'MSWin32';
# HAS_BOOL : stops Perl/lib/CORE/handy.h from doing "# define bool char" for MSVC
# NOGDI : prevents inclusion of wingdi.h which defines functions Polygon() and Polyline() in global namespace
# BOOST_ASIO_DISABLE_KQUEUE : prevents a Boost ASIO bug on OS X: https://svn.boost.org/trac/boost/ticket/5339
my @cflags = qw(-D_GLIBCXX_USE_C99 -DHAS_BOOL -DNOGDI -DSLIC3RXS -DBOOST_ASIO_DISABLE_KQUEUE);
my @cflags = qw(-D_GLIBCXX_USE_C99 -DHAS_BOOL -DNOGDI -DSLIC3RXS -DBOOST_ASIO_DISABLE_KQUEUE -DGLEW_STATIC);
my @ldflags = ();
if ($^O eq 'darwin') {
push @ldflags, qw(-framework IOKit -framework CoreFoundation);
@ -22,14 +22,14 @@ if ($^O eq 'darwin') {
if ($mswin) {
# In case windows.h is included, we don't want the min / max macros to be active.
# If <math.h> is included, we want the #defines to be active (M_PI etc.)
push @cflags, qw(-DNOMINMAX -D_USE_MATH_DEFINES);
push @cflags, qw(-D_WIN32 -DNOMINMAX -D_USE_MATH_DEFINES);
}
my @early_includes = ();
my @INC = qw(-Isrc/libslic3r);
my @INC = qw(-Isrc/libslic3r -Isrc/glew/include);
my @LIBS = $cpp_guess->is_msvc ? qw(-LIBPATH:src/libslic3r) : qw(-Lsrc/libslic3r);
#if ($ENV{SLIC3R_GUI})
if ($ENV{SLIC3R_GUI})
{
print "Slic3r will be built with GUI support\n";
require Alien::wxWidgets;
@ -163,6 +163,19 @@ is handy, if you have built Boost libraries with mutliple settings.
EOF
# Add the OpenGL and GLU libraries.
if ($ENV{SLIC3R_GUI}) {
if ($mswin) {
if ($cpp_guess->is_msvc) {
push @LIBS, qw(OpenGL32.Lib GlU32.Lib);
} else {
push @LIBS, qw(-lopengl32);
}
} else {
push @LIBS, qw(-lgl -lglu);
}
}
if ($ENV{SLIC3R_DEBUG}) {
# only on newer GCCs: -ftemplate-backtrace-limit=0
push @cflags, '-DSLIC3R_DEBUG';

View File

@ -18,6 +18,8 @@ src/libslic3r/ClipperUtils.cpp
src/libslic3r/ClipperUtils.hpp
src/libslic3r/Config.cpp
src/libslic3r/Config.hpp
src/libslic3r/EdgeGrid.cpp
src/libslic3r/EdgeGrid.hpp
src/libslic3r/ExPolygon.cpp
src/libslic3r/ExPolygon.hpp
src/libslic3r/ExPolygonCollection.cpp
@ -136,6 +138,8 @@ src/Shiny/ShinyNodeState.c
src/Shiny/ShinyOutput.c
src/Shiny/ShinyTools.c
src/Shiny/ShinyZone.c
src/glew/LICENSE.txt
src/glew/README.md
src/glew/src/glew.c
src/glew/include/GL/glew.h
src/glew/include/GL/glxew.h

View File

@ -67,6 +67,9 @@
# ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN 1
# endif
# ifdef NOGDI
# undef NOGDI
# endif
#include <windows.h>
# undef WIN32_LEAN_AND_MEAN
#endif

View File

@ -30,6 +30,8 @@
** THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef SLIC3R_GUI
#include <GL/glew.h>
#if defined(_WIN32)
@ -18605,3 +18607,5 @@ GLboolean glxewIsSupported (const char* name)
}
#endif /* _WIN32 */
#endif /* SLIC3R_GUI */

View File

@ -2,7 +2,9 @@
#include <vector>
#include <float.h>
#ifdef SLIC3R_GUI
#include <wx/image.h>
#endif /* SLIC3R_GUI */
#include "libslic3r.h"
#include "EdgeGrid.hpp"
@ -551,7 +553,8 @@ void EdgeGrid::Grid::calculate_sdf()
}
}
#if 1
#if 0
//#ifdef SLIC3R_GUI
{
wxImage img(ncols, nrows);
unsigned char *data = img.GetData();
@ -609,7 +612,7 @@ void EdgeGrid::Grid::calculate_sdf()
}
img.SaveFile("out\\signed_df.png", wxBITMAP_TYPE_PNG);
}
#endif
#endif /* SLIC3R_GUI */
// 2) Propagate the signum.
#define PROPAGATE_SIGNUM_SINGLE_STEP(DELTA) do { \
@ -681,7 +684,8 @@ void EdgeGrid::Grid::calculate_sdf()
}
}
#if 1
#if 0
//#ifdef SLIC3R_GUI
{
wxImage img(ncols, nrows);
unsigned char *data = img.GetData();
@ -733,9 +737,10 @@ void EdgeGrid::Grid::calculate_sdf()
}
img.SaveFile("out\\signed_df-signs.png", wxBITMAP_TYPE_PNG);
}
#endif
#endif /* SLIC3R_GUI */
#if 1
#if 0
//#ifdef SLIC3R_GUI
{
wxImage img(ncols, nrows);
unsigned char *data = img.GetData();
@ -761,7 +766,7 @@ void EdgeGrid::Grid::calculate_sdf()
}
img.SaveFile("out\\signed_df2.png", wxBITMAP_TYPE_PNG);
}
#endif
#endif /* SLIC3R_GUI */
}
float EdgeGrid::Grid::signed_distance_bilinear(const Point &pt) const
@ -932,6 +937,7 @@ bool EdgeGrid::Grid::signed_distance(const Point &pt, coord_t search_radius, coo
return true;
}
#ifdef SLIC3R_GUI
void EdgeGrid::save_png(const EdgeGrid::Grid &grid, const BoundingBox &bbox, coord_t resolution, const char *path)
{
unsigned int w = (bbox.max.x - bbox.min.x + resolution - 1) / resolution;
@ -1022,5 +1028,6 @@ void EdgeGrid::save_png(const EdgeGrid::Grid &grid, const BoundingBox &bbox, coo
img.SaveFile(path, wxBITMAP_TYPE_PNG);
}
#endif /* SLIC3R_GUI */
} // namespace Slic3r

View File

@ -72,8 +72,10 @@ protected:
std::vector<float> m_signed_distance_field;
};
#ifdef SLIC3R_GUI
// Debugging utility. Save the signed distance field.
extern void save_png(const Grid &grid, const BoundingBox &bbox, coord_t resolution, const char *path);
#endif /* SLIC3R_GUI */
} // namespace EdgeGrid
} // namespace Slic3r

View File

@ -235,7 +235,9 @@ Print::invalidate_state_by_config_options(const std::vector<t_config_option_key>
|| *opt_key == "use_relative_e_distances"
|| *opt_key == "vibration_limit"
|| *opt_key == "wipe"
|| *opt_key == "z_offset") {
|| *opt_key == "z_offset"
|| *opt_key == "max_volumetric_extrusion_rate_slope_negative"
|| *opt_key == "max_volumetric_extrusion_rate_slope_positive") {
// these options only affect G-code export, so nothing to invalidate
} else if (*opt_key == "first_layer_extrusion_width") {
osteps.insert(posPerimeters);