From 45b5751fb4013f2ab8db47c5fe4ac533ab324864 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Sun, 10 Jan 1999 12:04:02 +0000 Subject: [PATCH] Got Penguin sample running under Windows. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1362 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/latex/wx/image.tex | 33 +++++++-- docs/motif/todo.txt | 4 ++ docs/todo.txt | 7 ++ utils/glcanvas/distrib/glcanvas.rsp | 11 +++ utils/glcanvas/samples/penguin/Makefile | 4 +- .../glcanvas/samples/penguin/{lw.c => lw.cpp} | 19 ++--- utils/glcanvas/samples/penguin/lw.h | 7 ++ utils/glcanvas/samples/penguin/makefile.nt | 71 +++++++++++++++++++ utils/glcanvas/samples/penguin/penguin.cpp | 9 +-- utils/glcanvas/samples/penguin/penguin.h | 3 +- utils/glcanvas/samples/penguin/penguin.rc | 3 + 11 files changed, 148 insertions(+), 23 deletions(-) rename utils/glcanvas/samples/penguin/{lw.c => lw.cpp} (93%) create mode 100644 utils/glcanvas/samples/penguin/makefile.nt create mode 100644 utils/glcanvas/samples/penguin/penguin.rc diff --git a/docs/latex/wx/image.tex b/docs/latex/wx/image.tex index 281fd8a7e1..a3a15b6010 100644 --- a/docs/latex/wx/image.tex +++ b/docs/latex/wx/image.tex @@ -46,6 +46,10 @@ Creates an image with the given width and height. Loads an image from a file. +\func{}{wxImage}{\param{wxInputStream\& }{stream}, \param{long}{ type = wxIMAGE\_TYPE\_PNG}} + +Loads an image from an input stream. + \wxheading{Parameters} \docparam{width}{Specifies the width of the image.} @@ -54,6 +58,8 @@ Loads an image from a file. \docparam{name}{This refers to an image filename. Its meaning is determined by the {\it type} parameter.} +\docparam{stream}{This refers to an input stream. Its meaning is determined by the {\it type} parameter. It is equal to loading from file except that you provide opened stream (file, HTTP or any other custom class).} + \docparam{type}{May be one of the following: \twocolwidtha{5cm} @@ -269,11 +275,18 @@ of a given handler class in an application session.} Loads an image from a file. +\func{bool}{LoadFile}{\param{wxInputStream\&}{ stream}, \param{long}{ type}} + +Loads an image from an input stream. + \wxheading{Parameters} \docparam{name}{A filename. The meaning of {\it name} is determined by the {\it type} parameter.} +\docparam{stream}{An input stream. +The meaning of {\it stream} data is determined by the {\it type} parameter.} + \docparam{type}{One of the following values: \twocolwidtha{5cm} @@ -321,10 +334,16 @@ TRUE if the handler was found and removed, FALSE otherwise. Saves a image in the named file. +\func{bool}{SaveFile}{\param{wxOutputStream\& }{stream}, \param{int}{ type}} + +Saves a image in the given stream. + \wxheading{Parameters} \docparam{name}{A filename. The meaning of {\it name} is determined by the {\it type} parameter.} +\docparam{stream}{An output stream. The meaning of {\it stream} is determined by the {\it type} parameter.} + \docparam{type}{Currently only one type can be used: \twocolwidtha{5cm} @@ -484,16 +503,16 @@ Gets the image type associated with this handler. \membersection{wxImageHandler::LoadFile}\label{wximagehandlerloadfile} -\func{bool}{LoadFile}{\param{wxImage* }{image}, \param{const wxString\&}{ name}} +\func{bool}{LoadFile}{\param{wxImage* }{image}, \param{wxInputStream\&}{ stream}} -Loads a image from a file or resource, putting the resulting data into {\it image}. +Loads a image from a stream, putting the resulting data into {\it image}. \wxheading{Parameters} \docparam{image}{The image object which is to be affected by this operation.} -\docparam{name}{Either a filename or a Windows resource name. -The meaning of {\it name} is determined by the {\it type} parameter.} +\docparam{stream}{Opened input stream. +The meaning of {\it stream} is determined by the {\it type} parameter.} \wxheading{Return value} @@ -507,15 +526,15 @@ TRUE if the operation succeeded, FALSE otherwise. \membersection{wxImageHandler::SaveFile}\label{wximagehandlersavefile} -\func{bool}{SaveFile}{\param{wxImage* }{image}, \param{const wxString\& }{name}} +\func{bool}{SaveFile}{\param{wxImage* }{image}, \param{wxOutputStream\& }{stream}} -Saves a image in the named file. +Saves a image in the output stream. \wxheading{Parameters} \docparam{image}{The image object which is to be affected by this operation.} -\docparam{name}{A filename. The meaning of {\it name} is determined by the {\it type} parameter.} +\docparam{stream}{A stream. The meaning of {\it stream} is determined by the {\it type} parameter.} \wxheading{Return value} diff --git a/docs/motif/todo.txt b/docs/motif/todo.txt index c319bc30db..639beb44aa 100644 --- a/docs/motif/todo.txt +++ b/docs/motif/todo.txt @@ -42,9 +42,13 @@ High Priority - Miscellaneous events. +- Get wxGLCanvas from 1.68 working. + Low Priority ------------ +- Visuals: how to select an appropriate one? + - Work out why XFreeFont in font.cpp produces a segv. This is currently commented out, which presumably causes a memory leak. diff --git a/docs/todo.txt b/docs/todo.txt index 4d1f0aef26..23dd3dd552 100644 --- a/docs/todo.txt +++ b/docs/todo.txt @@ -16,6 +16,13 @@ Please see also: - Documentation: mention include files with each class. +- Get Karsten to remove trashed CVS files: + + utils/glcanvas/isosurf/isosurf.dat.gz + src/msw/ctl3d/* + + and re-add them. + - Complete this ToDo list :-) diff --git a/utils/glcanvas/distrib/glcanvas.rsp b/utils/glcanvas/distrib/glcanvas.rsp index c16e2c560e..045fa083bd 100644 --- a/utils/glcanvas/distrib/glcanvas.rsp +++ b/utils/glcanvas/distrib/glcanvas.rsp @@ -19,4 +19,15 @@ samples/isosurf/*.xbm samples/isosurf/*.dat samples/isosurf/*.dat.gz samples/isosurf/make*.* +samples/penguin/*.cpp +samples/penguin/*.c +samples/penguin/*.h +samples/penguin/*.rc +samples/penguin/*.ico +samples/penguin/*.xbm +samples/penguin/*.xpm +samples/penguin/make*.* +samples/penguin/penguin.lwo + + diff --git a/utils/glcanvas/samples/penguin/Makefile b/utils/glcanvas/samples/penguin/Makefile index 5a3cfc9a81..fd005b951d 100644 --- a/utils/glcanvas/samples/penguin/Makefile +++ b/utils/glcanvas/samples/penguin/Makefile @@ -10,8 +10,8 @@ Penguin: penguin.o trackball.o lw.o glcanvas.o penguin.o: penguin.cpp $(CPP) `wx-config --cflags` -I../../src -c penguin.cpp -lw.o: lw.c - $(CC) `wx-config --cflags` -I../../src -c lw.c +lw.o: lw.cpp + $(CPP) `wx-config --cflags` -I../../src -c lw.cpp trackball.o: trackball.c $(CC) `wx-config --cflags` -I../../src -c trackball.c diff --git a/utils/glcanvas/samples/penguin/lw.c b/utils/glcanvas/samples/penguin/lw.cpp similarity index 93% rename from utils/glcanvas/samples/penguin/lw.c rename to utils/glcanvas/samples/penguin/lw.cpp index 01decb7845..e7bfe17843 100644 --- a/utils/glcanvas/samples/penguin/lw.c +++ b/utils/glcanvas/samples/penguin/lw.cpp @@ -16,8 +16,9 @@ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - - +#ifdef __WXMSW__ +#include +#endif #include "lw.h" #include @@ -100,7 +101,7 @@ static void read_srfs(FILE *f, int nbytes, lwObject *lwo) /* allocate more memory for materials if needed */ if (guess_cnt <= lwo->material_cnt) { guess_cnt += guess_cnt/2 + 4; - lwo->material = realloc(lwo->material, sizeof(lwMaterial)*guess_cnt); + lwo->material = (lwMaterial*) realloc(lwo->material, sizeof(lwMaterial)*guess_cnt); } material = lwo->material + lwo->material_cnt++; @@ -112,7 +113,7 @@ static void read_srfs(FILE *f, int nbytes, lwObject *lwo) material->g = 0.7; material->b = 0.7; } - lwo->material = realloc(lwo->material, sizeof(lwMaterial)*lwo->material_cnt); + lwo->material = (lwMaterial*) realloc(lwo->material, sizeof(lwMaterial)*lwo->material_cnt); } @@ -164,7 +165,7 @@ static void read_pols(FILE *f, int nbytes, lwObject *lwo) /* allocate more memory for polygons if necessary */ if (guess_cnt <= lwo->face_cnt) { guess_cnt += guess_cnt + 4; - lwo->face = realloc(lwo->face, sizeof(lwFace)*guess_cnt); + lwo->face = (lwFace*) realloc((void*) lwo->face, sizeof(lwFace)*guess_cnt); } face = lwo->face + lwo->face_cnt++; @@ -173,7 +174,7 @@ static void read_pols(FILE *f, int nbytes, lwObject *lwo) nbytes -= 2; /* allocate space for points */ - face->index = calloc(sizeof(int)*face->index_cnt,1); + face->index = (int*) calloc(sizeof(int)*face->index_cnt,1); /* read points in */ for (i=0; iindex_cnt; i++) { @@ -200,7 +201,7 @@ static void read_pols(FILE *f, int nbytes, lwObject *lwo) face->material -= 1; } /* readjust to true size */ - lwo->face = realloc(lwo->face, sizeof(lwFace)*lwo->face_cnt); + lwo->face = (lwFace*) realloc(lwo->face, sizeof(lwFace)*lwo->face_cnt); } @@ -209,7 +210,7 @@ static void read_pnts(FILE *f, int nbytes, lwObject *lwo) { int i; lwo->vertex_cnt = nbytes / 12; - lwo->vertex = calloc(sizeof(GLfloat)*lwo->vertex_cnt*3, 1); + lwo->vertex = (float*) calloc(sizeof(GLfloat)*lwo->vertex_cnt*3, 1); for (i=0; ivertex_cnt; i++) { lwo->vertex[i*3+0] = read_float(f); lwo->vertex[i*3+1] = read_float(f); @@ -265,7 +266,7 @@ lwObject *lw_object_read(const char *lw_file) } /* create new lwObject */ - lw_object = calloc(sizeof(lwObject),1); + lw_object = (lwObject*) calloc(sizeof(lwObject),1); /* read chunks */ while (read_bytes < form_bytes) { diff --git a/utils/glcanvas/samples/penguin/lw.h b/utils/glcanvas/samples/penguin/lw.h index 9202019222..b49e8ffc91 100644 --- a/utils/glcanvas/samples/penguin/lw.h +++ b/utils/glcanvas/samples/penguin/lw.h @@ -49,6 +49,9 @@ typedef struct { } lwObject; +#ifdef __cplusplus +extern "C" { +#endif int lw_is_lwobject(const char *lw_file); lwObject *lw_object_read(const char *lw_file); @@ -58,5 +61,9 @@ void lw_object_show(const lwObject *lw_object); GLfloat lw_object_radius(const lwObject *lw_object); void lw_object_scale (lwObject *lw_object, GLfloat scale); +#ifdef __cplusplus +} +#endif + #endif /* LW_H */ diff --git a/utils/glcanvas/samples/penguin/makefile.nt b/utils/glcanvas/samples/penguin/makefile.nt new file mode 100644 index 0000000000..86d751466b --- /dev/null +++ b/utils/glcanvas/samples/penguin/makefile.nt @@ -0,0 +1,71 @@ +# +# File: makefile.nt +# Author: Julian Smart +# Created: 1997 +# Updated: +# +# "%W% %G%" +# +# Makefile : Builds penguin example (MS VC++). +# Use FINAL=1 argument to nmake to build final version with no debugging +# info + +# Set WXDIR for your system +WXDIR = $(WXWIN) + +WXUSINGDLL=0 + +EXTRAINC=-I..\..\win +EXTRALIBS=$(WXDIR)\lib\glcanvas.lib glu32.lib opengl32.lib + +!include $(WXDIR)\src\ntwxwin.mak + +THISDIR = $(WXDIR)\utils\glcanvas\samples\penguin +PROGRAM=penguin + +OBJECTS = $(PROGRAM).obj trackball.obj lw.obj + +$(PROGRAM): $(PROGRAM).exe + +all: wx $(PROGRAM).exe + +wx: + cd $(WXDIR)\src\msw + nmake -f makefile.nt FINAL=$(FINAL) + cd $(THISDIR) + +wxclean: + cd $(WXDIR)\src\msw + nmake -f makefile.nt clean + cd $(THISDIR) + +$(PROGRAM).exe: $(DUMMYOBJ) $(WXLIB) $(OBJECTS) $(PROGRAM).res + $(link) @<< +-out:$(PROGRAM).exe +$(LINKFLAGS) +$(DUMMYOBJ) $(OBJECTS) $(PROGRAM).res +$(LIBS) +<< + + +$(PROGRAM).obj: $(PROGRAM).$(SRCSUFF) $(PROGRAM).h $(DUMMYOBJ) + $(cc) @<< +$(CPPFLAGS2) /c /Tp $*.$(SRCSUFF) +<< + +lw.obj: lw.c lw.h + $(cc) @<< +$(CPPFLAGS2) /c $*.$(SRCSUFF) +<< + +$(PROGRAM).res : $(PROGRAM).rc $(WXDIR)\include\wx\msw\wx.rc + $(rc) -r /i$(WXDIR)\include -fo$@ $(PROGRAM).rc + + +clean: + -erase *.obj + -erase *.exe + -erase *.res + -erase *.map + -erase *.sbr + -erase *.pdb diff --git a/utils/glcanvas/samples/penguin/penguin.cpp b/utils/glcanvas/samples/penguin/penguin.cpp index 9444b7ec08..e1100c508c 100644 --- a/utils/glcanvas/samples/penguin/penguin.cpp +++ b/utils/glcanvas/samples/penguin/penguin.cpp @@ -183,15 +183,16 @@ void TestGLCanvas::LoadLWO(const wxString &filename) void TestGLCanvas::OnMouse( wxMouseEvent& event ) { + wxSize sz(GetClientSize()); if (event.Dragging()) { /* drag in progress, simulate trackball */ float spin_quat[4]; trackball(spin_quat, - (2.0*info.beginx - m_width) / m_width, - ( m_height - 2.0*info.beginy) / m_height, - ( 2.0*event.GetX() - m_width) / m_width, - ( m_height - 2.0*event.GetY()) / m_height); + (2.0*info.beginx - sz.x) / sz.x, + ( sz.y - 2.0*info.beginy) / sz.y, + ( 2.0*event.GetX() - sz.x) / sz.x, + ( sz.y - 2.0*event.GetY()) / sz.y); add_quats( spin_quat, info.quat, info.quat ); diff --git a/utils/glcanvas/samples/penguin/penguin.h b/utils/glcanvas/samples/penguin/penguin.h index 83b0708e1c..5f17311513 100644 --- a/utils/glcanvas/samples/penguin/penguin.h +++ b/utils/glcanvas/samples/penguin/penguin.h @@ -28,7 +28,8 @@ extern "C" { /* information needed to display lightwave mesh */ typedef struct { - gint do_init; /* true if initgl not yet called */ +// gint do_init; /* true if initgl not yet called */ + int do_init; lwObject *lwobject; /* lightwave object mesh */ float beginx,beginy; /* position of mouse */ float quat[4]; /* orientation of object */ diff --git a/utils/glcanvas/samples/penguin/penguin.rc b/utils/glcanvas/samples/penguin/penguin.rc new file mode 100644 index 0000000000..626b82f58a --- /dev/null +++ b/utils/glcanvas/samples/penguin/penguin.rc @@ -0,0 +1,3 @@ +/* mondrian ICON "mondrian.ico" */ +#include "wx/msw/wx.rc" + -- 2.45.2