Replaced part of the auto config with glib.

This commit is contained in:
leo 2012-10-20 01:14:12 +00:00
parent 37cbe23a63
commit d52d9c5a18
26 changed files with 81 additions and 1452 deletions

View file

@ -5,7 +5,7 @@ include config.mk
MODULES := $(OSDIR) common
### Look for include files in each of the modules
CPPFLAGS += $(patsubst %,-I%,$(MODULES)) $(OS)
CPPFLAGS += $(patsubst %,-I%,$(MODULES))
CPPFLAGS += -g
### Extra libraries if required
@ -51,12 +51,12 @@ ifeq ($(findstring $(MAKECMDGOALS), help config-help config clean veryclean sour
endif
### Calculate C/C++ include dependencies
%.d: %.cpp $(OSDIR)/config.h $(OSDIR)/config.mk
%.d: %.cpp $(OSDIR)/config.mk
@$(CXX) -MM -MT '$(patsubst %.d,%.o, $@)' $(CXXFLAGS) $(CPPFLAGS) -w $< > $@
@[ -s $@ ] || rm -f $@
### Main compiler rule
%.o: %.cpp $(OSDIR)/config.h $(OSDIR)/config.mk
%.o: %.cpp $(OSDIR)/config.mk
@echo $<
@$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -o '$(patsubst %.cpp,%.o, $@)' $<
@[ -s $@ ] || rm -f $@
@ -70,7 +70,7 @@ clean:
veryclean: clean
find $(MODULES) -name \*.d | xargs rm -f
rm -rf bin
rm -rf arch $(OSDIR)/config.mk $(OSDIR)/config.h
rm -rf arch $(OSDIR)/config.mk
### Dependency stuff is done automatically, so these do nothing.

View file

@ -183,7 +183,7 @@ bool lcApplication::Initialize(int argc, char* argv[], const char* LibraryInstal
ImageHighlight = true;
else if ((strcmp(Param, "-v") == 0) || (strcmp(Param, "--version") == 0))
{
printf("LeoCAD version " LC_VERSION_TEXT LC_VERSION_TAG " for "LC_VERSION_OSNAME"\n");
printf("LeoCAD Version " LC_VERSION_TEXT "\n");
printf("Copyright (c) 1996-2006, BT Software\n");
printf("Compiled "__DATE__"\n");

View file

@ -1,9 +1,15 @@
#ifndef _LC_GLOBAL_H_
#define _LC_GLOBAL_H_
#include "config.h"
#include "lc_config.h"
#include "defines.h"
// Version number.
#define LC_VERSION_MAJOR 0
#define LC_VERSION_MINOR 79
#define LC_VERSION_PATCH 0
#define LC_VERSION_TEXT "0.79.0"
// Check for supported platforms.
#if !defined(LC_WINDOWS) && !defined(LC_LINUX)
#error No OS defined.

View file

@ -797,7 +797,6 @@ static const unsigned char sDefaultSettings[] =
static int lcGetMinifigSettings(lcMemFile& File)
{
#ifdef LC_HAVE_ZLIB
const size_t CHUNK = 16384;
int ret;
unsigned have;
@ -852,7 +851,6 @@ static int lcGetMinifigSettings(lcMemFile& File)
(void)inflateEnd(&strm);
return ret == Z_STREAM_END ? Z_OK : Z_DATA_ERROR;
#endif // LC_HAVE_ZLIB
}
// =============================================================================

View file

@ -1,7 +1,7 @@
SRC += common/camera.cpp common/console.cpp common/curve.cpp common/lc_colors.cpp common/lc_file.cpp \
common/lc_mesh.cpp common/globals.cpp common/group.cpp common/image.cpp common/im_bmp.cpp common/im_gif.cpp \
common/lc_application.cpp common/lc_library.cpp common/light.cpp common/mainwnd.cpp \
common/matrix.cpp common/message.cpp common/minifig.cpp common/object.cpp common/opengl.cpp \
common/message.cpp common/minifig.cpp common/object.cpp common/opengl.cpp \
common/piece.cpp common/pieceinf.cpp common/preview.cpp common/project.cpp common/quant.cpp \
common/str.cpp common/terrain.cpp common/texfont.cpp common/lc_texture.cpp common/tr.cpp \
common/view.cpp common/lc_zipfile.cpp
@ -11,12 +11,10 @@ ifeq ($(HAVE_JPEGLIB), yes)
SRC += common/im_jpg.cpp
endif
ifeq ($(HAVE_ZLIB), yes)
ifeq ($(HAVE_PNGLIB), yes)
LIBS += -lpng -lz
LIBS += -lpng
SRC += common/im_png.cpp
endif
endif
LIBS += -lm
LIBS += -lm -lz

339
config.mk
View file

@ -6,112 +6,17 @@ ERROR_SETTING=2> /dev/null
default: all
CC := gcc
CXX := g++
CC := gcc
CXX := g++
OSDIR := linux
# (Add a -g for debugging)
CPPFLAGS += -O2 -Wall
# Add compile options, such as -I option to include jpeglib's headers
# CPPFLAGS += -I/home/fred/jpeglib
# Add linker options, such as -L option to include jpeglib's libraries
# LDFLAGS += -L/home/fred/jpeglib
### Linux configuration
ifeq ($(shell uname), Linux)
OS := -DLC_LINUX
OSDIR := linux
TEST_GTK := 1
endif
### FreeBSD configuration
ifeq ($(shell uname), FreeBSD)
OS := -DLC_LINUX
OSDIR := linux
TEST_GTK := 1
CPPFLAGS += -L/usr/local/lib
endif
### Macintosh configuration
ifeq ($(shell uname), Darwin)
OS := -DLC_MACOSX
OSDIR := macosx
TEST_GTK := 0
CPPFLAGS += -funsigned-char -I/Developer/Headers/FlatCarbon/
LDFLAGS += -framework AGL -framework Carbon
# The directory tree for the generated bundle
BUNDLEDIR = bin/LeoCAD.app
CONTDIR = $(BUNDLEDIR)/Contents
BINDIR = $(CONTDIR)/MacOS
RSRCDIR = $(CONTDIR)/Resources
EN_RSRCDIR = $(RSRCDIR)/English.lproj
NIBS = main.nib
all: bundletree exec bnibs pkginfo infoplist infopliststr
bundletree: $(BINDIR) $(BUNDLEDIR) $(CONTDIR) $(RSRCDIR) $(EN_RSRCDIR)
$(BUNDLEDIR):
mkdir bin
mkdir $(BUNDLEDIR)
$(CONTDIR): $(BUNDLEDIR)
mkdir $(CONTDIR)
$(BINDIR): $(CONTDIR)
mkdir $(BINDIR)
$(RSRCDIR): $(CONTDIR)
mkdir $(RSRCDIR)
$(EN_RSRCDIR): $(RSRCDIR)
mkdir $(EN_RSRCDIR)
# The binary executable
exec: $(BINDIR)/leocad
$(BINDIR)/leocad: bin/leocad
cp bin/leocad $(BINDIR)
# The nib's
BNIBS = $(NIBS:%=$(EN_RSRCDIR)/%)
bnibs: $(BNIBS)
$(BNIBS) : $(EN_RSRCDIR)/%: macosx/English.lproj/%
rm -rf $@
cp -R $< $@
touch $@
# Info.plist
infoplist : $(CONTDIR)/Info.plist
$(CONTDIR)/Info.plist : macosx/Info.plist
cp macosx/Info.plist $@
# PkgInfo
pkginfo : $(CONTDIR)/PkgInfo
$(CONTDIR)/PkgInfo : macosx/PkgInfo
cp macosx/PkgInfo $@
# InfoPlist.strings - this goes inside English.lproj
infopliststr : $(EN_RSRCDIR)/InfoPlist.strings
$(EN_RSRCDIR)/InfoPlist.strings: macosx/English.lproj/InfoPlist.strings
cp $< $@
CPPFLAGS += -L/usr/local/lib
endif
### Default directory
@ -123,8 +28,7 @@ endif
.PHONY: config config-help
config-help:
@echo "This target attempts to detect your system settings,"
@echo "it will create $(OSDIR)/config.mk and $(OSDIR)/config.h"
@echo "This target attempts to detect your system settings and create $(OSDIR)/config.mk"
@echo "Valid parameters and their default values are:"
@echo " PREFIX=/usr/local"
@echo " DESTDIR="
@ -135,7 +39,7 @@ config-help:
CONFTEST="\#include <stdio.h>\nint main() { FILE *f=fopen(\"conftestval\", \"w\");\n\
if (!f) return 1; fprintf(f, \"%%d\\\n\", (int)sizeof(%s)); return 0; }\n"
$(OSDIR)/config.h $(OSDIR)/config.mk:
$(OSDIR)/config.mk: config.mk version.mk
make config
config:
@ -147,194 +51,20 @@ config:
@echo "PREFIX := $(PREFIX)" >> $(OSDIR)/config.mk;
@echo "DESTDIR := $(DESTDIR)" >> $(OSDIR)/config.mk;
@echo "" >> $(OSDIR)/config.mk
@echo "//" > $(OSDIR)/config.h
@echo "// LeoCAD configuration" >> $(OSDIR)/config.h
@echo "//" >> $(OSDIR)/config.h
@echo "// Auto-generated file, DO NOT EDIT" >> $(OSDIR)/config.h
@echo "//" >> $(OSDIR)/config.h
@echo "" >> $(OSDIR)/config.h
@echo "#ifndef _CONFIG_H_" >> $(OSDIR)/config.h
@echo "#define _CONFIG_H_" >> $(OSDIR)/config.h
@echo "" >> $(OSDIR)/config.h
### Version information
@echo "#define LC_VERSION_MAJOR $(MAJOR)" >> $(OSDIR)/config.h
@echo "#define LC_VERSION_MINOR $(MINOR)" >> $(OSDIR)/config.h
@echo "#define LC_VERSION_PATCH $(PATCHLVL)" >> $(OSDIR)/config.h
@echo "#define LC_VERSION_OSNAME \"$(shell uname)\"" >> $(OSDIR)/config.h
@echo "#define LC_VERSION_TEXT \"$(MAJOR).$(MINOR).$(PATCHLVL)\"" >> $(OSDIR)/config.h
@echo "#define LC_VERSION_TAG \"$(VERSIONTAG)\"" >> $(OSDIR)/config.h
@echo "#define LC_INSTALL_PREFIX \"$(PREFIX)\"" >> $(OSDIR)/config.h
@echo "" >> $(OSDIR)/config.h
### Determine variable sizes
@echo -n "checking size of char... "; \
printf ${CONFTEST} "char" > conftest.c; \
if { (eval $(CC) conftest.c -o conftest); } && \
(test -s conftest && (./conftest; exit)); then \
ac_cv_sizeof_char=`cat conftestval`; \
echo "$$ac_cv_sizeof_char"; \
else \
echo "failed to get size of char"; \
ac_cv_sizeof_char=0; \
fi; \
echo "#define LC_SIZEOF_CHAR $$ac_cv_sizeof_char" >> $(OSDIR)/config.h; \
rm -f conftest.c conftest conftestval; \
\
echo -n "checking size of short... "; \
printf ${CONFTEST} "short" > conftest.c; \
if { (eval $(CC) conftest.c -o conftest); } && \
(test -s conftest && (./conftest; exit)); then \
ac_cv_sizeof_short=`cat conftestval`; \
echo "$$ac_cv_sizeof_short"; \
else \
echo "failed to get size of short"; \
ac_cv_sizeof_short=0; \
fi; \
echo "#define LC_SIZEOF_SHORT $$ac_cv_sizeof_short" >> $(OSDIR)/config.h; \
rm -f conftest.c conftest conftestval; \
\
echo -n "checking size of long... "; \
printf ${CONFTEST} "long" > conftest.c; \
if { (eval $(CC) conftest.c -o conftest); } && \
(test -s conftest && (./conftest; exit)); then \
ac_cv_sizeof_long=`cat conftestval`; \
echo "$$ac_cv_sizeof_long"; \
else \
echo "failed to get size of long"; \
ac_cv_sizeof_long=0; \
fi; \
echo "#define LC_SIZEOF_LONG $$ac_cv_sizeof_long" >> $(OSDIR)/config.h; \
rm -f conftest.c conftest conftestval; \
\
echo -n "checking size of int... "; \
printf ${CONFTEST} "int" > conftest.c; \
if { (eval $(CC) conftest.c -o conftest); } && \
(test -s conftest && (./conftest; exit)); then \
ac_cv_sizeof_int=`cat conftestval`; \
echo "$$ac_cv_sizeof_int"; \
else \
echo "failed to get size of int"; \
ac_cv_sizeof_int=0; \
fi; \
echo "#define LC_SIZEOF_INT $$ac_cv_sizeof_int" >> $(OSDIR)/config.h; \
rm -f conftest.c conftest conftestval; \
\
echo -n "checking size of void *... "; \
printf ${CONFTEST} "void *" > conftest.c; \
if { (eval $(CC) conftest.c -o conftest); } && \
(test -s conftest && (./conftest; exit)); then \
ac_cv_sizeof_void_p=`cat conftestval`; \
echo "$$ac_cv_sizeof_void_p"; \
else \
echo "failed to get size of void *"; \
ac_cv_sizeof_void_p=0; \
fi; \
echo "#define LC_SIZEOF_VOID_P $$ac_cv_sizeof_void_p" >> $(OSDIR)/config.h; \
rm -f conftest.c conftest conftestval; \
\
echo -n "checking size of long long... "; \
printf ${CONFTEST} "long long" > conftest.c; \
if { (eval $(CC) conftest.c -o conftest); } && \
(test -s conftest && (./conftest; exit)); then \
ac_cv_sizeof_long_long=`cat conftestval`; \
echo "$$ac_cv_sizeof_long_long"; \
else \
echo "failed to get size of long long"; \
ac_cv_sizeof_long_long=0; \
fi; \
echo "#define LC_SIZEOF_LONG_LONG $$ac_cv_sizeof_long_long" >> $(OSDIR)/config.h; \
rm -f conftest.c conftest conftestval; \
case 2 in \
$$ac_cv_sizeof_short) lcint16=short;; \
$$ac_cv_sizeof_int) lcint16=int;; \
esac; \
case 4 in \
$$ac_cv_sizeof_short) lcint32=short;; \
$$ac_cv_sizeof_int) lcint32=int;; \
$$ac_cv_sizeof_long) lcint32=long;; \
esac; \
case 8 in \
$$ac_cv_sizeof_long_long) lcint64="long long";; \
esac; \
if test "$$ac_cv_sizeof_void_p" -eq "8"; then \
echo "#define LC_POINTER_TO_INT(p) ((lcint32)(lcint64)(p))" >> $(OSDIR)/config.h; \
else \
echo "#define LC_POINTER_TO_INT(p) ((lcint32)(p))" >> $(OSDIR)/config.h; \
fi; \
echo "" >> $(OSDIR)/config.h; \
echo "typedef signed char lcint8;" >> $(OSDIR)/config.h; \
echo "typedef unsigned char lcuint8;" >> $(OSDIR)/config.h; \
if test -n "$$lcint16"; then \
echo "typedef signed $$lcint16 lcint16;" >> $(OSDIR)/config.h; \
echo "typedef unsigned $$lcint16 lcuint16;" >> $(OSDIR)/config.h; \
else \
echo "#error need to define lcint16 and lcuint16" >> $(OSDIR)/config.h; \
fi; \
if test -n "$$lcint32"; then \
echo "typedef signed $$lcint32 lcint32;" >> $(OSDIR)/config.h; \
echo "typedef unsigned $$lcint32 lcuint32;" >> $(OSDIR)/config.h; \
else \
echo "#error need to define lcint32 and lcuint32" >> $(OSDIR)/config.h; \
fi; \
if test -n "$$lcint64"; then \
echo "typedef signed $$lcint64 lcint64;" >> $(OSDIR)/config.h; \
echo "typedef unsigned $$lcint64 lcuint64;" >> $(OSDIR)/config.h; \
else \
echo "#error need to define lcint64 and lcuint64" >> $(OSDIR)/config.h; \
fi; \
echo "" >> $(OSDIR)/config.h
### Check if machine is little or big endian
@echo -n "Determining endianess... "
@echo "int main () { union { long l; char c[sizeof (long)]; } u;" > endiantest.c
@echo "u.l = 1; return (u.c[sizeof (long) - 1] == 1); }" >> endiantest.c
@if { (eval $(CC) endiantest.c -o endiantest); } && \
(test -s endiantest && (./endiantest; exit)); then \
echo "little endian"; \
echo "#define LC_LITTLE_ENDIAN" >> $(OSDIR)/config.h; \
echo "#define LCUINT16(val) val" >> $(OSDIR)/config.h; \
echo "#define LCUINT32(val) val" >> $(OSDIR)/config.h; \
echo "#define LCINT16(val) val" >> $(OSDIR)/config.h; \
echo "#define LCINT32(val) val" >> $(OSDIR)/config.h; \
echo "#define LCFLOAT(val) val" >> $(OSDIR)/config.h; \
else \
echo "big endian"; \
echo "#define LC_BIG_ENDIAN" >> $(OSDIR)/config.h; \
echo "#define LCUINT16(val) ((lcuint16) ( \\" >> $(OSDIR)/config.h; \
echo " (((lcuint16) (val) & (lcuint16) 0x00ffU) << 8) | \\" >> $(OSDIR)/config.h; \
echo " (((lcuint16) (val) & (lcuint16) 0xff00U) >> 8)))" >> $(OSDIR)/config.h; \
echo "#define LCUINT32(val) ((lcuint32) ( \\" >> $(OSDIR)/config.h; \
echo " (((lcuint32) (val) & (lcuint32) 0x000000ffU) << 24) | \\" >> $(OSDIR)/config.h; \
echo " (((lcuint32) (val) & (lcuint32) 0x0000ff00U) << 8) | \\" >> $(OSDIR)/config.h; \
echo " (((lcuint32) (val) & (lcuint32) 0x00ff0000U) >> 8) | \\" >> $(OSDIR)/config.h; \
echo " (((lcuint32) (val) & (lcuint32) 0xff000000U) >> 24)))" >> $(OSDIR)/config.h; \
echo "#define LCINT16(val) ((lcint16)LCUINT16(val))" >> $(OSDIR)/config.h; \
echo "#define LCINT32(val) ((lcint32)LCUINT32(val))" >> $(OSDIR)/config.h; \
echo -e "inline float LCFLOAT (float l)\n{" >> $(OSDIR)/config.h; \
echo -e " union { unsigned char b[4]; float f; } in, out;\n" >> $(OSDIR)/config.h; \
echo -e " in.f = l;\n out.b[0] = in.b[3];\n out.b[1] = in.b[2];" >> $(OSDIR)/config.h; \
echo -e " out.b[2] = in.b[1];\n out.b[3] = in.b[0];\n" >> $(OSDIR)/config.h; \
echo -e " return out.f;\n}" >> $(OSDIR)/config.h; \
fi; \
echo "" >> $(OSDIR)/config.h
@rm -f endiantest.c endiantest
@echo "CPPFLAGS += -DLC_INSTALL_PREFIX=\\\"$(PREFIX)\\\"" >> $(OSDIR)/config.mk
@echo "" >> $(OSDIR)/config.mk
#### Check if the user has GTK+ and GLIB installed.
ifeq ($(TEST_GTK), 1)
@echo -n "Checking if GLIB and GTK+ are installed... "
@if (pkg-config --atleast-version=2.0.0 glib-2.0) && (pkg-config --atleast-version=2.0.0 gtk+-2.0); then \
echo "ok"; \
echo "CFLAGS += \$$(shell pkg-config gtk+-2.0 --cflags)" >> $(OSDIR)/config.mk; \
echo "CXXFLAGS += \$$(shell pkg-config gtk+-2.0 --cflags)" >> $(OSDIR)/config.mk; \
echo "CPPFLAGS += \$$(shell pkg-config gtk+-2.0 --cflags)" >> $(OSDIR)/config.mk; \
echo "LIBS += \$$(shell pkg-config gtk+-2.0 --libs)" >> $(OSDIR)/config.mk; \
else \
echo "failed"; \
rm -rf $(OSDIR)/config.mk $(OSDIR)/config.h; \
rm -rf $(OSDIR)/config.mk; \
exit 1; \
fi
endif
## Check if the user has OpenGL installed
@echo -n "Checking for OpenGL support... "
@ -346,27 +76,11 @@ endif
else \
rm -f gltest.c gltest; \
echo "failed"; \
rm -rf $(OSDIR)/config.mk $(OSDIR)/config.h; \
rm -rf $(OSDIR)/config.mk; \
exit 1; \
fi
@rm -f gltest.c gltest
## Check if the user has libjpeg installed
@echo -n "Checking for jpeg support... "
@echo "char jpeg_read_header();" > jpegtest.c
@echo "int main() { jpeg_read_header(); return 0; }" >> jpegtest.c
@if { (eval $(CC) jpegtest.c -ljpeg -o jpegtest $(CPPFLAGS) $(LDFLAGS)); } && \
(test -s jpegtest); then \
echo "ok"; \
echo "HAVE_JPEGLIB = yes" >> $(OSDIR)/config.mk; \
echo "#define LC_HAVE_JPEGLIB" >> $(OSDIR)/config.h; \
else \
echo "no (libjpeg optional)"; \
echo "HAVE_JPEGLIB = no" >> $(OSDIR)/config.mk; \
echo "#undef LC_HAVE_JPEGLIB" >> $(OSDIR)/config.h; \
fi
@rm -f jpegtest.c jpegtest
### Check if the user has zlib installed
@echo -n "Checking for zlib support... "
@echo "char gzread();" > ztest.c
@ -374,15 +88,30 @@ endif
@if { (eval $(CC) ztest.c -lz -o ztest $(CPPFLAGS) $(LDFLAGS)); } && \
(test -s ztest); then \
echo "ok"; \
echo "HAVE_ZLIB = yes" >> $(OSDIR)/config.mk; \
echo "#define LC_HAVE_ZLIB" >> $(OSDIR)/config.h; \
else \
echo "no (zlib optional)"; \
echo "HAVE_ZLIB = no" >> $(OSDIR)/config.mk; \
echo "#undef LC_HAVE_ZLIB" >> $(OSDIR)/config.h; \
rm -f ztest.c ztest \
echo "failed"; \
rm -rf $(OSDIR)/config.mk; \
exit 1; \
fi
@rm -f ztest.c ztest
## Check if the user has libjpeg installed
@echo -n "Checking for jpeg support... "
@echo "char jpeg_read_header();" > jpegtest.c
@echo "int main() { jpeg_read_header(); return 0; }" >> jpegtest.c
@if { (eval $(CC) jpegtest.c -ljpeg -o jpegtest $(CPPFLAGS) $(LDFLAGS)); } && \
(test -s jpegtest); then \
echo "ok"; \
echo "" >> $(OSDIR)/config.mk; \
echo "HAVE_JPEGLIB = yes" >> $(OSDIR)/config.mk; \
echo "CPPFLAGS += -DLC_HAVE_JPEGLIB" >> $(OSDIR)/config.mk; \
else \
echo "no (libjpeg optional)"; \
echo "HAVE_JPEGLIB = no" >> $(OSDIR)/config.mk; \
fi
@rm -f jpegtest.c jpegtest
### Check if the user has libpng installed
@echo -n "Checking for png support... "
@echo "char png_read_info();" > pngtest.c
@ -390,14 +119,12 @@ endif
@if { (eval $(CC) pngtest.c -lm -lz -lpng -o pngtest $(CPPFLAGS) $(LDFLAGS)); } && \
(test -s pngtest); then \
echo "ok"; \
echo "" >> $(OSDIR)/config.mk; \
echo "HAVE_PNGLIB = yes" >> $(OSDIR)/config.mk; \
echo "#define LC_HAVE_PNGLIB" >> $(OSDIR)/config.h; \
echo "CPPFLAGS += -DLC_HAVE_PNGLIB" >> $(OSDIR)/config.mk; \
else \
echo "no (libpng optional)"; \
echo "HAVE_PNGLIB = no" >> $(OSDIR)/config.mk; \
echo "#undef LC_HAVE_PNGLIB" >> $(OSDIR)/config.h; \
fi
@rm -f pngtest.c pngtest
@echo "" >> $(OSDIR)/config.h
@echo "#endif // _CONFIG_H_" >> $(OSDIR)/config.h

View file

@ -573,7 +573,7 @@ int aboutdlg_execute(void* param)
gtk_widget_show(vbox2);
gtk_box_pack_start(GTK_BOX(hbox), vbox2, TRUE, TRUE, 10);
w = gtk_label_new("LeoCAD for "LC_VERSION_OSNAME" Version "LC_VERSION_TEXT);
w = gtk_label_new("LeoCAD Version "LC_VERSION_TEXT);
gtk_widget_show(w);
gtk_box_pack_start(GTK_BOX(vbox2), w, FALSE, FALSE, 5);

View file

@ -20,7 +20,6 @@
#include "typedefs.h"
#include "globals.h"
#include "dialogs.h"
#include "matrix.h"
#include "pieceinf.h"
#include "main.h"
#include "minifig.h"

26
linux/lc_config.h Normal file
View file

@ -0,0 +1,26 @@
#ifndef _LC_CONFIG_H_
#define _LC_CONFIG_H_
#include <glib.h>
#define LC_LINUX
#define LC_POINTER_TO_INT GPOINTER_TO_INT
typedef gint8 lcint8;
typedef guint8 lcuint8;
typedef gint16 lcint16;
typedef guint16 lcuint16;
typedef gint32 lcint32;
typedef guint32 lcuint32;
typedef gint64 lcint64;
typedef guint64 lcuint64;
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
#define LC_LITTLE_ENDIAN
#else
#define LC_BIG_ENDIAN
#endif
#endif // _LC_CONFIG_H_

View file

@ -4,6 +4,7 @@
#include <dlfcn.h>
#include <stdio.h>
#include "lc_global.h"
#include "opengl.h"
static void* gl_module;

View file

@ -1,4 +0,0 @@
{
IBClasses = ();
IBVersion = 1;
}

View file

@ -1,25 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IBDocumentLocation</key>
<string>60 139 356 240 0 0 1152 848 </string>
<key>IBEditorPositions</key>
<dict>
<key>29</key>
<string>418 578 235 44 0 0 1152 848 </string>
</dict>
<key>IBFramework Version</key>
<string>437.0</string>
<key>IBOldestOS</key>
<integer>3</integer>
<key>IBOpenObjects</key>
<array>
<integer>166</integer>
</array>
<key>IBSystem Version</key>
<string>8G32</string>
<key>targetFramework</key>
<string>IBCarbonFramework</string>
</dict>
</plist>

View file

@ -1,327 +0,0 @@
<?xml version="1.0" standalone="yes"?>
<object class="NSIBObjectData">
<string name="targetFramework">IBCarbonFramework</string>
<object name="rootObject" class="NSCustomObject" id="1">
<string name="customClass">NSApplication</string>
</object>
<array count="43" name="allObjects">
<object class="IBCarbonMenu" id="29">
<string name="title">main</string>
<array count="4" name="items">
<object class="IBCarbonMenuItem" id="185">
<string name="title">LeoCAD</string>
<object name="submenu" class="IBCarbonMenu" id="184">
<string name="title">LeoCAD</string>
<array count="1" name="items">
<object class="IBCarbonMenuItem" id="187">
<string name="title">About LeoCAD</string>
<int name="keyEquivalentModifier">0</int>
<ostype name="command">abou</ostype>
</object>
</array>
<string name="name">_NSAppleMenu</string>
</object>
</object>
<object class="IBCarbonMenuItem" id="127">
<string name="title">File</string>
<object name="submenu" class="IBCarbonMenu" id="131">
<string name="title">File</string>
<array count="10" name="items">
<object class="IBCarbonMenuItem" id="139">
<string name="title">New</string>
<string name="keyEquivalent">n</string>
<ostype name="command">new </ostype>
</object>
<object class="IBCarbonMenuItem" id="134">
<string name="title">Open…</string>
<string name="keyEquivalent">o</string>
<ostype name="command">open</ostype>
</object>
<object class="IBCarbonMenuItem" id="133">
<boolean name="separator">TRUE</boolean>
</object>
<object class="IBCarbonMenuItem" id="130">
<string name="title">Close</string>
<string name="keyEquivalent">w</string>
<ostype name="command">clos</ostype>
</object>
<object class="IBCarbonMenuItem" id="138">
<string name="title">Save</string>
<string name="keyEquivalent">s</string>
<ostype name="command">save</ostype>
</object>
<object class="IBCarbonMenuItem" id="137">
<string name="title">Save As…</string>
<string name="keyEquivalent">S</string>
<ostype name="command">svas</ostype>
</object>
<object class="IBCarbonMenuItem" id="132">
<string name="title">Revert</string>
<string name="keyEquivalent">r</string>
<ostype name="command">rvrt</ostype>
</object>
<object class="IBCarbonMenuItem" id="128">
<boolean name="separator">TRUE</boolean>
</object>
<object class="IBCarbonMenuItem" id="135">
<string name="title">Page Setup…</string>
<string name="keyEquivalent">P</string>
<ostype name="command">page</ostype>
</object>
<object class="IBCarbonMenuItem" id="136">
<string name="title">Print…</string>
<string name="keyEquivalent">p</string>
<ostype name="command">prnt</ostype>
</object>
</array>
</object>
</object>
<object class="IBCarbonMenuItem" id="152">
<string name="title">Edit</string>
<object name="submenu" class="IBCarbonMenu" id="147">
<string name="title">Edit</string>
<array count="8" name="items">
<object class="IBCarbonMenuItem" id="141">
<string name="title">Undo</string>
<string name="keyEquivalent">z</string>
<ostype name="command">undo</ostype>
</object>
<object class="IBCarbonMenuItem" id="146">
<string name="title">Redo</string>
<string name="keyEquivalent">Z</string>
<ostype name="command">redo</ostype>
</object>
<object class="IBCarbonMenuItem" id="142">
<boolean name="separator">TRUE</boolean>
</object>
<object class="IBCarbonMenuItem" id="143">
<string name="title">Cut</string>
<string name="keyEquivalent">x</string>
<ostype name="command">cut </ostype>
</object>
<object class="IBCarbonMenuItem" id="149">
<string name="title">Copy</string>
<string name="keyEquivalent">c</string>
<ostype name="command">copy</ostype>
</object>
<object class="IBCarbonMenuItem" id="144">
<string name="title">Paste</string>
<string name="keyEquivalent">v</string>
<ostype name="command">past</ostype>
</object>
<object class="IBCarbonMenuItem" id="151">
<string name="title">Delete</string>
<ostype name="command">clea</ostype>
</object>
<object class="IBCarbonMenuItem" id="148">
<string name="title">Select All</string>
<string name="keyEquivalent">a</string>
<ostype name="command">sall</ostype>
</object>
</array>
</object>
</object>
<object class="IBCarbonMenuItem" id="192">
<string name="title">Window</string>
<object name="submenu" class="IBCarbonMenu" id="195">
<string name="title">Window</string>
<array count="6" name="items">
<object class="IBCarbonMenuItem" id="190">
<boolean name="dynamic">TRUE</boolean>
<string name="title">Minimize</string>
<string name="keyEquivalent">m</string>
<ostype name="command">mini</ostype>
</object>
<object class="IBCarbonMenuItem" id="191">
<boolean name="dynamic">TRUE</boolean>
<string name="title">Minimize All</string>
<string name="keyEquivalent">m</string>
<int name="keyEquivalentModifier">1572864</int>
<ostype name="command">mina</ostype>
</object>
<object class="IBCarbonMenuItem" id="197">
<string name="title">Zoom</string>
<ostype name="command">zoom</ostype>
</object>
<object class="IBCarbonMenuItem" id="194">
<boolean name="separator">TRUE</boolean>
</object>
<object class="IBCarbonMenuItem" id="196">
<boolean name="dynamic">TRUE</boolean>
<string name="title">Bring All to Front</string>
<ostype name="command">bfrt</ostype>
</object>
<object class="IBCarbonMenuItem" id="193">
<boolean name="dynamic">TRUE</boolean>
<string name="title">Arrange in Front</string>
<int name="keyEquivalentModifier">1572864</int>
<ostype name="command">frnt</ostype>
</object>
</array>
<string name="name">_NSWindowsMenu</string>
</object>
</object>
</array>
<string name="name">_NSMainMenu</string>
</object>
<reference idRef="127"/>
<reference idRef="128"/>
<reference idRef="130"/>
<reference idRef="131"/>
<reference idRef="132"/>
<reference idRef="133"/>
<reference idRef="134"/>
<reference idRef="135"/>
<reference idRef="136"/>
<reference idRef="137"/>
<reference idRef="138"/>
<reference idRef="139"/>
<reference idRef="141"/>
<reference idRef="142"/>
<reference idRef="143"/>
<reference idRef="144"/>
<reference idRef="146"/>
<reference idRef="147"/>
<reference idRef="148"/>
<reference idRef="149"/>
<reference idRef="151"/>
<reference idRef="152"/>
<object class="IBCarbonWindow" id="166">
<string name="windowRect">355 545 703 1019 </string>
<string name="title">LeoCAD</string>
<object name="rootControl" class="IBCarbonRootControl" id="167">
<string name="bounds">0 0 348 474 </string>
<array count="2" name="subviews">
<object class="IBCarbonHIView" id="202">
<string name="bounds">0 0 332 474 </string>
<ostype name="controlSignature">Moof</ostype>
<int name="controlID">127</int>
</object>
<object class="IBCarbonPlacard" id="208">
<string name="bounds">332 0 348 474 </string>
</object>
</array>
</object>
<boolean name="liveResize">TRUE</boolean>
</object>
<reference idRef="167"/>
<reference idRef="184"/>
<reference idRef="185"/>
<reference idRef="187"/>
<reference idRef="190"/>
<reference idRef="191"/>
<reference idRef="192"/>
<reference idRef="193"/>
<reference idRef="194"/>
<reference idRef="195"/>
<reference idRef="196"/>
<reference idRef="197"/>
<reference idRef="202"/>
<object class="IBCarbonWindow" id="205">
<string name="windowRect">153 486 554 707 </string>
<string name="title">Pieces</string>
<object name="rootControl" class="IBCarbonRootControl" id="206">
<string name="bounds">0 0 401 221 </string>
<array count="3" name="subviews">
<object class="IBCarbonSearchField" id="209">
<string name="bounds">359 20 381 201 </string>
<object name="layoutInfo" class="IBCarbonHILayoutInfo">
<int name="bindingLeftKind">1</int>
<int name="bindingBottomKind">2</int>
<int name="bindingRightKind">2</int>
</object>
</object>
<object class="IBCarbonHIView" id="210">
<string name="bounds">20 20 156 201 </string>
</object>
<object class="IBCarbonDBListView" id="211">
<string name="bounds">164 20 351 201 </string>
<boolean name="horzScrollBar">FALSE</boolean>
<int name="selectionFlags">10</int>
<int name="listViewHeaderBtnHeight">0</int>
<array count="1" name="listViewColumns">
<object class="IBCarbonDBListViewColumn">
<ostype name="propertyID">????</ostype>
<int name="sortOrder">1</int>
</object>
</array>
</object>
</array>
</object>
<boolean name="hasCollapseBox">FALSE</boolean>
<boolean name="hasHorizontalZoom">FALSE</boolean>
<boolean name="hasVerticalZoom">FALSE</boolean>
<boolean name="liveResize">TRUE</boolean>
<int name="carbonWindowClass">8</int>
<boolean name="isConstrained">FALSE</boolean>
<boolean name="hideOnFullScreen">TRUE</boolean>
</object>
<reference idRef="206"/>
<reference idRef="208"/>
<reference idRef="209"/>
<reference idRef="210"/>
<reference idRef="211"/>
</array>
<array count="43" name="allParents">
<reference idRef="1"/>
<reference idRef="29"/>
<reference idRef="131"/>
<reference idRef="131"/>
<reference idRef="127"/>
<reference idRef="131"/>
<reference idRef="131"/>
<reference idRef="131"/>
<reference idRef="131"/>
<reference idRef="131"/>
<reference idRef="131"/>
<reference idRef="131"/>
<reference idRef="131"/>
<reference idRef="147"/>
<reference idRef="147"/>
<reference idRef="147"/>
<reference idRef="147"/>
<reference idRef="147"/>
<reference idRef="152"/>
<reference idRef="147"/>
<reference idRef="147"/>
<reference idRef="147"/>
<reference idRef="29"/>
<reference idRef="1"/>
<reference idRef="166"/>
<reference idRef="185"/>
<reference idRef="29"/>
<reference idRef="184"/>
<reference idRef="195"/>
<reference idRef="195"/>
<reference idRef="29"/>
<reference idRef="195"/>
<reference idRef="195"/>
<reference idRef="192"/>
<reference idRef="195"/>
<reference idRef="195"/>
<reference idRef="167"/>
<reference idRef="1"/>
<reference idRef="205"/>
<reference idRef="167"/>
<reference idRef="206"/>
<reference idRef="206"/>
<reference idRef="206"/>
</array>
<dictionary count="7" name="nameTable">
<string>Files Owner</string>
<reference idRef="1"/>
<string>ListView</string>
<reference idRef="211"/>
<string>MainMenu</string>
<reference idRef="29"/>
<string>MainWindow</string>
<reference idRef="166"/>
<string>PiecesBar</string>
<reference idRef="205"/>
<string>View1</string>
<reference idRef="202"/>
<string>View11</string>
<reference idRef="210"/>
</dictionary>
<unsigned_int name="nextObjectID">213</unsigned_int>
</object>

View file

@ -1,24 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>LeoCAD</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>com.apple.myCarbonApp</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>CSResourcesFileMapped</key>
<true/>
</dict>
</plist>

View file

@ -1 +0,0 @@
include ../generic.mk

View file

@ -1 +0,0 @@
APPL????

View file

@ -1,41 +0,0 @@
#include <stdlib.h>
#include "basewnd.h"
BaseWnd::BaseWnd (BaseWnd *parent, int menu_count)
{
m_pParent = parent;
}
BaseWnd::~BaseWnd ()
{
}
void BaseWnd::BeginWait ()
{
}
void BaseWnd::EndWait ()
{
}
int BaseWnd::MessageBox (const char* text, const char* caption, int flags)
{
return 0;
}
void BaseWnd::ShowMenuItem (int id, bool show)
{
}
void BaseWnd::EnableMenuItem (int id, bool enable)
{
}
void BaseWnd::CheckMenuItem (int id, bool check)
{
}
void BaseWnd::SetMenuItemText (int id, const char *text)
{
}

View file

@ -1,9 +0,0 @@
### LeoCAD configuration
### Auto-generated file, DO NOT EDIT
PREFIX := /usr/local
DESTDIR :=
HAVE_JPEGLIB = no
HAVE_ZLIB = yes
HAVE_PNGLIB = no

View file

@ -1,282 +0,0 @@
#include <OpenGL/gl.h>
#include <AGL/agl.h>
#include <Carbon.h>
#include <stdlib.h>
#include <string.h>
#include "glwindow.h"
#include "opengl.h"
typedef struct
{
AGLContext Context;
WindowPtr Window;
DMExtendedNotificationUPP WindowEDMUPP;
HIViewRef View;
} GLWindowPrivate;
static void SetWindowSize(GLWindow* glw)
{
GLWindowPrivate* Priv = (GLWindowPrivate*)glw->GetData();
Rect r;
GetWindowPortBounds(Priv->Window, &r);
HIRect bounds;
HIViewGetBounds(Priv->View, &bounds);
GLint bufferRect[4];
bufferRect[0] = (int)bounds.origin.x;
bufferRect[1] = (int)((r.bottom - r.top) - bounds.origin.y - bounds.size.height);
bufferRect[2] = (int)bounds.size.width;
bufferRect[3] = (int)bounds.size.height;
aglSetInteger(Priv->Context, AGL_BUFFER_RECT, bufferRect);
aglEnable(Priv->Context, AGL_BUFFER_RECT);
glw->OnSize(bufferRect[2], bufferRect[3]);
}
static pascal OSStatus GLWindowEventHandler(EventHandlerCallRef Handler, EventRef Event, void* UserData)
{
OSStatus result = eventNotHandledErr;
GLWindow* glw = (GLWindow*)UserData;
GLWindowPrivate* Priv = (GLWindowPrivate*)glw->GetData();
UInt32 EventKind;
WindowRef wnd = NULL;
SInt16 WindowPart;
EventKind = GetEventKind(Event);
switch (EventKind)
{
case kEventWindowActivated:
break;
case kEventWindowShown:
if (Priv->Window == FrontWindow())
SetUserFocusWindow(Priv->Window);
break;
case kEventWindowDrawContent:
glw->OnDraw();
result = noErr;
break;
case kEventMouseDown:
{
EventMouseButton button;
UInt32 modifiers;
Point pt;
GetEventParameter(Event, kEventParamMouseButton, typeMouseButton, NULL, sizeof(EventMouseButton), NULL, &button);
GetEventParameter(Event, kEventParamMouseLocation, typeQDPoint, NULL, sizeof(Point), NULL, &pt);
GetEventParameter(Event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers);
bool Control = (modifiers & controlKey) != 0;
bool Shift = (modifiers & shiftKey) != 0;
WindowPart = FindWindow(pt, &wnd);
if (wnd != NULL)
SelectWindow(wnd);
switch (WindowPart)
{
case inDrag:
{
BitMap bits;
DragWindow(wnd, pt, &GetQDGlobalsScreenBits(&bits)->bounds);
aglUpdateContext(Priv->Context);
result = noErr;
} break;
case inContent:
{
SetPort(GetWindowPort(Priv->Window));
GlobalToLocal(&pt);
int x = pt.h;
int y = glw->GetHeight() - pt.v;
if (button == kEventMouseButtonPrimary)
glw->OnLeftButtonDown(x, y, Control, Shift);
else if (button == kEventMouseButtonSecondary)
glw->OnRightButtonDown(x, y, Control, Shift);
result = noErr;
} break;
}
} break;
case kEventWindowBoundsChanged:
{
SetWindowSize(glw);
result = noErr;
} break;
}
return result;
}
// handle display config changes meaing we need to update the GL context via the resize function and check for windwo dimension changes
// also note we redraw the content here as it could be lost in a display config change
void HandleWindowDMEvent (void* UserData, short Message, void* NotifyData)
{
// Post change notifications only.
if (Message == kDMNotifyEvent)
{
GLWindow* glw = (GLWindow*)UserData;
if (glw)
{
GLWindowPrivate* Priv = (GLWindowPrivate*)glw->GetData();
// have a valid OpenGl window
Rect rectPort;
CGRect viewRect = {{0.0f, 0.0f}, {0.0f, 0.0f}};
GetWindowPortBounds (Priv->Window, &rectPort);
viewRect.size.width = (float) (rectPort.right - rectPort.left);
viewRect.size.height = (float) (rectPort.bottom - rectPort.top);
// resizeGL (pContextInfo->aglContext, &pContextInfo->camera, pContextInfo->shapeSize, viewRect);
InvalWindowRect (Priv->Window, &rectPort); // force redrow
}
}
}
// ============================================================================
// GLWindow class
GLWindow::GLWindow(GLWindow* Share)
{
m_nRef = 0;
m_pShare = Share;
m_pData = (GLWindowPrivate*)malloc(sizeof(GLWindowPrivate));
memset(m_pData, 0, sizeof(GLWindowPrivate));
}
GLWindow::~GLWindow()
{
free(m_pData);
}
bool GLWindow::Create(void* Data)
{
GLWindowPrivate* Priv = (GLWindowPrivate*)m_pData;
GLint attrib[] = { AGL_RGBA, AGL_DOUBLEBUFFER, AGL_DEPTH_SIZE, 16, AGL_NONE };
AGLPixelFormat fmt;
AGLContext ctx;
WindowPtr wnd = (WindowPtr)HIViewGetWindow((HIViewRef)Data);
// Check for existance of OpenGL.
if ((Ptr)aglChoosePixelFormat == (Ptr)kUnresolvedCFragSymbolAddress)
return false;
// Get an appropriate pixel format.
fmt = aglChoosePixelFormat(NULL, 0, attrib);
if (fmt == NULL)
return false;
// Create an AGL context.
ctx = aglCreateContext(fmt, NULL);
if (ctx == NULL)
return false;
GrafPtr port = NULL; GetPort(&port); SetPort((GrafPtr)GetWindowPort(wnd));
// Attach the CGrafPtr to the context.
if (aglSetDrawable(ctx, GetWindowPort(wnd)))
{
if (!aglSetCurrentContext(ctx))
{
aglSetDrawable(ctx, NULL);
return false;
}
}
else
return false;
// Pixel format is no longer needed.
aglDestroyPixelFormat(fmt);
// Install event handler.
EventHandlerUPP myHandlerUPP = NewEventHandlerUPP(GLWindowEventHandler);
EventTypeSpec EventList[] =
{
{ kEventClassWindow, kEventWindowShown },
{ kEventClassWindow, kEventWindowActivated },
{ kEventClassWindow, kEventWindowDrawContent },
{ kEventClassWindow, kEventWindowBoundsChanged },
{ kEventClassMouse, kEventMouseDown },
};
InstallStandardEventHandler(GetWindowEventTarget(wnd));
InstallWindowEventHandler(wnd, myHandlerUPP, GetEventTypeCount(EventList), EventList, this, NULL);
// Ensure we know when display configs are changed
ProcessSerialNumber psn = { 0, kCurrentProcess };
Priv->WindowEDMUPP = NewDMExtendedNotificationUPP(HandleWindowDMEvent);
DMRegisterExtendedNotifyProc(Priv->WindowEDMUPP, this, 0, &psn);
// Save context information.
Priv->Context = ctx;
Priv->Window = wnd;
Priv->View = (HIViewRef)Data;
SetPort(port);
// Since we're attaching to an existing window, force the first update here.
SetWindowSize(this);
OnInitialUpdate();
Redraw();
return true;
}
void GLWindow::DestroyContext()
{
GLWindowPrivate* Priv = (GLWindowPrivate*)m_pData;
DisposeDMExtendedNotificationUPP(Priv->WindowEDMUPP);
Priv->WindowEDMUPP = NULL;
aglSetCurrentContext(Priv->Context);
aglSetDrawable(Priv->Context, NULL);
aglSetCurrentContext(NULL);
aglDestroyContext(Priv->Context);
Priv->Context = NULL;
Priv->Window = NULL;
}
void GLWindow::OnInitialUpdate()
{
}
bool GLWindow::MakeCurrent()
{
GLWindowPrivate* Priv = (GLWindowPrivate*)m_pData;
return aglSetCurrentContext(Priv->Context);
}
void GLWindow::SwapBuffers()
{
GLWindowPrivate* Priv = (GLWindowPrivate*)m_pData;
aglSwapBuffers(Priv->Context);
}
void GLWindow::Redraw()
{
GLWindowPrivate* Priv = (GLWindowPrivate*)m_pData;
Rect r;
GetWindowPortBounds(Priv->Window, &r);
InvalWindowRect(Priv->Window, &r);
}
void GLWindow::CaptureMouse()
{
}
void GLWindow::ReleaseMouse()
{
}

View file

@ -1,143 +0,0 @@
#include "glwindow.h"
#include "project.h"
#include "view.h"
#include "globals.h"
#include "opengl.h"
#include "mainwnd.h"
#include "lc_application.h"
#include <Carbon.h>
View* view;
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <OpenGL/glext.h>
Boolean SetUp();
pascal void IdleTimer (EventLoopTimerRef inTimer, void* userData);
EventLoopTimerUPP GetTimerUPP();
void CleanUp();
EventLoopTimerRef gTimer = NULL;
Boolean SetUp()
{
InitCursor();
DrawMenuBar();
InstallEventLoopTimer(GetCurrentEventLoop(), 0, 0.01, GetTimerUPP(), 0, &gTimer);
return true;
}
pascal void IdleTimer(EventLoopTimerRef inTimer, void* userData)
{
// view->Redraw();
}
EventLoopTimerUPP GetTimerUPP()
{
static EventLoopTimerUPP sTimerUPP = NULL;
if (sTimerUPP == NULL)
sTimerUPP = NewEventLoopTimerUPP (IdleTimer);
return sTimerUPP;
}
void CleanUp()
{
RemoveEventLoopTimer(gTimer);
gTimer = NULL;
}
// --------------------------------------------------------------------------
pascal OSStatus lcAppEventHandler(EventHandlerCallRef inHandlerCallRef, EventRef Event, void* UserData)
{
return eventNotHandledErr;
}
DEFINE_ONE_SHOT_HANDLER_GETTER(lcAppEventHandler);
int main(int argc, char* argv[])
{
UInt32 response;
// Check the Mac OS version.
if ((Gestalt (gestaltSystemVersion, (SInt32 *) &response) == noErr) && (response < 0x01020))
{
printf("Must have Mac OS v10.2 or later.\n");
return 1;
}
// Initialize the application.
g_App = new lcApplication();
main_window = new MainWnd();
// Get the pieces library path (bundle/Contents/Resources/).
CFBundleRef Bundle = CFBundleGetMainBundle();
if (Bundle == NULL)
return 1;
CFURLRef BundleURL = CFBundleCopyResourcesDirectoryURL(Bundle);
if (BundleURL == NULL)
return 1;
UInt8 ResourcesPath[LC_MAXPATH];
CFURLGetFileSystemRepresentation(BundleURL, true, ResourcesPath, LC_MAXPATH);
if (!g_App->Initialize(argc, argv, (char*)ResourcesPath))
return 1;
// Install the application event handler.
EventTypeSpec AppEventList[] = { { kEventClassCommand, kEventProcessCommand } };
InstallApplicationEventHandler(GetlcAppEventHandlerUPP(), GetEventTypeCount(AppEventList), AppEventList, NULL, NULL);
IBNibRef nib = NULL;
CreateNibReference(CFSTR("main"), &nib);
WindowRef win = NULL;
CreateWindowFromNib(nib, CFSTR("MainWindow"), &win);
ShowWindow(win);
SetMenuBarFromNib(nib, CFSTR("MainMenu"));
if (SetUp())
{
view = new View(lcGetActiveProject(), NULL);
HIViewRef userPane;
static const HIViewID userPaneID = { 'Moof', 127 };
HIViewFindByID(HIViewGetRoot(win), userPaneID, &userPane);
if (!view->Create(userPane))
{
delete main_window;
main_window = NULL;
delete view;
g_App->Shutdown();
delete g_App;
return 1;
}
RunApplicationEventLoop();
view->DestroyContext();
DisposeWindow(win);
}
CleanUp();
delete main_window;
main_window = NULL;
delete view;
g_App->Shutdown();
delete g_App;
DisposeNibReference(nib);
return 0;
}

View file

@ -1,2 +0,0 @@
SRC += macosx/system.cpp macosx/main.cpp macosx/glwindow.cpp macosx/osx_gl.cpp \
macosx/basewnd.cpp

View file

@ -1,34 +0,0 @@
#include <mach-o/dyld.h>
#include <stdlib.h>
#include <string.h>
bool Sys_GLOpenLibrary(const char* LibName)
{
return true;
}
void Sys_GLCloseLibrary()
{
}
void* Sys_GLGetProc(const char* ProcName)
{
NSSymbol Symbol = NULL;
char* SymbolName;
// Prepend a '_' for the Unix C symbol mangling convention.
SymbolName = (char*)malloc(strlen(ProcName) + 2);
strcpy(SymbolName + 1, ProcName);
SymbolName[0] = '_';
if (NSIsSymbolNameDefined(SymbolName))
Symbol = NSLookupAndBindSymbol(SymbolName);
free(SymbolName);
return Symbol ? NSAddressOfSymbol(Symbol) : NULL;
}
void* Sys_GLGetExtension(const char* ProcName)
{
return Sys_GLGetProc(ProcName);
}

View file

@ -1,233 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "camera.h"
#include "str.h"
int Sys_MessageBox (const char* text, const char* caption, int type)
{
return 0;
}
// =============================================================================
// Memory rendering
void* Sys_StartMemoryRender(int width, int height)
{
return NULL;
}
void Sys_FinishMemoryRender(void* param)
{
}
// =============================================================================
// Misc stuff
// FIXME: should have a table of LC_KEY_* defined
bool Sys_KeyDown (int key)
{
return false;
}
// String
char* strupr(char* string)
{
char *cp;
for (cp=string; *cp; ++cp)
{
if ('a' <= *cp && *cp <= 'z')
*cp += 'A' - 'a';
}
return string;
}
char* strlwr(char* string)
{
char *cp;
for (cp = string; *cp; ++cp)
{
if ('A' <= *cp && *cp <= 'Z')
*cp += 'a' - 'A';
}
return string;
}
int stricmp(const char* str1, const char* str2)
{
return strcmp(str1, str2);
}
// Profile functions
bool Sys_ProfileSaveInt (const char *section, const char *key, int value)
{
return true;
}
bool Sys_ProfileSaveString (const char *section, const char *key, const char *value)
{
return true;
}
int Sys_ProfileLoadInt (const char *section, const char *key, int default_value)
{
return default_value;
}
char* Sys_ProfileLoadString (const char *section, const char *key, const char *default_value)
{
return (char*)default_value;
}
void SystemPumpMessages()
{
}
long SystemGetTicks()
{
return 0;
}
// User Interface
void SystemUpdateViewport(int new_vp, int old_vp)
{
}
void SystemUpdateCategories(bool SearchOnly)
{
}
void SystemUpdateAction(int new_action, int old_action)
{
}
void SystemUpdateColorList(int new_color)
{
}
void SystemUpdateRenderingMode(bool bBackground, bool bFast)
{
}
void SystemUpdateUndoRedo(char* undo, char* redo)
{
}
void SystemUpdateSnap(const unsigned long snap)
{
}
void SystemUpdateCurrentCamera(Camera* pOld, Camera* pNew, Camera* pCamera)
{
}
void SystemUpdateCameraMenu(Camera* pCamera)
{
}
void SystemUpdateTime(bool bAnimation, int nTime, int nTotal)
{
}
void SystemUpdateAnimation(bool bAnimation, bool bAddKeys)
{
}
void SystemUpdateSnap(unsigned short move_snap, unsigned short RotateSnap)
{
}
void SystemUpdateSelected(unsigned long flags, int SelectedCount, class Object* Focus)
{
}
void SystemUpdateRecentMenu (String names[4])
{
}
void SystemUpdatePaste(bool enable)
{
}
void SystemUpdatePlay(bool play, bool stop)
{
}
void SystemInit()
{
}
void SystemFinish()
{
}
// FIXME: remove
int SystemDoMessageBox(char* prompt, int mode)
{
return 0;
}
bool SystemDoDialog(int mode, void* param)
{
return false;
}
void SystemDoPopupMenu(int nMenu, int x, int y)
{
}
void SystemDoWaitCursor(int code)
{
}
void SystemExportClipboard(File* clip)
{
}
File* SystemImportClipboard()
{
return NULL;
}
void SystemSetWindowCaption(char* caption)
{
}
void SystemRedrawView()
{
}
void SystemPieceComboAdd(char* name)
{
}
void SystemCaptureMouse()
{
}
void SystemReleaseMouse()
{
}
void SystemSwapBuffers()
{
}
void SystemStartProgressBar(int nLower, int nUpper, int nStep, const char* Text)
{
}
void SytemEndProgressBar()
{
}
void SytemStepProgressBar()
{
}

View file

@ -1,5 +1,5 @@
MAJOR := 0
MINOR := 78
MINOR := 79
PATCHLVL := 0
VERSIONTAG :=
VERSION := $(MAJOR).$(MINOR).$(PATCHLVL)

View file

@ -6,15 +6,15 @@
#define _CONFIG_H_
#define LC_VERSION_MAJOR 0
#define LC_VERSION_MINOR 78
#define LC_VERSION_MINOR 79
#define LC_VERSION_PATCH 0
#define LC_VERSION_OSNAME "Windows"
#define LC_VERSION_TEXT "0.78"
#define LC_VERSION_TEXT "0.79"
#define LC_VERSION_TAG ""
#define LC_INSTALL_PREFIX "C:\\leocad"
#define LC_POINTER_TO_INT(p) ((lcint32)(p))
typedef __int8 lcint8;
typedef signed __int8 lcint8;
typedef unsigned __int8 lcuint8;
typedef signed __int16 lcint16;
typedef unsigned __int16 lcuint16;
@ -32,7 +32,7 @@ typedef unsigned __int64 lcuint64;
#define LC_HAVE_3DSFTK
#define LC_HAVE_JPEGLIB
#define LC_HAVE_ZLIB
#define LC_HAVE_PNGLIB
#endif // _CONFIG_H_