Removed old wxGLCanvas stuff; moved wxTreeLayout to wxWindows; corrected some doc errors
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6330 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
@@ -1035,6 +1035,44 @@ samples/rotate/*.xpm
|
||||
samples/rotate/*.txt
|
||||
samples/rotate/*.bmp
|
||||
|
||||
samples/treelay/*.cpp
|
||||
samples/treelay/*.h
|
||||
samples/treelay/makefile*
|
||||
samples/treelay/*.rc
|
||||
samples/treelay/*.def
|
||||
samples/treelay/*.ico
|
||||
samples/treelay/*.xpm
|
||||
samples/treelay/*.txt
|
||||
samples/treelay/*.bmp
|
||||
|
||||
samples/opengl/cube/*.cpp
|
||||
samples/opengl/cube/*.h
|
||||
samples/opengl/cube/*.rc
|
||||
samples/opengl/cube/*.ico
|
||||
samples/opengl/cube/*.xbm
|
||||
samples/opengl/cube/make*.*
|
||||
samples/opengl/cube/Makefile
|
||||
|
||||
samples/opengl/isosurf/*.cpp
|
||||
samples/opengl/isosurf/*.h
|
||||
samples/opengl/isosurf/*.rc
|
||||
samples/opengl/isosurf/*.ico
|
||||
samples/opengl/isosurf/*.xbm
|
||||
samples/opengl/isosurf/*.dat.gz
|
||||
samples/opengl/isosurf/make*.*
|
||||
samples/opengl/isosurf/Makefile
|
||||
|
||||
samples/opengl/penguin/*.cpp
|
||||
samples/opengl/penguin/*.c
|
||||
samples/opengl/penguin/*.h
|
||||
samples/opengl/penguin/*.rc
|
||||
samples/opengl/penguin/*.ico
|
||||
samples/opengl/penguin/*.xbm
|
||||
samples/opengl/penguin/*.xpm
|
||||
samples/opengl/penguin/make*.*
|
||||
samples/opengl/penguin/Makefile
|
||||
samples/opengl/penguin/penguin.lwo
|
||||
|
||||
demos/makefile*
|
||||
demos/configure
|
||||
demos/configure.in
|
||||
|
@@ -52,6 +52,12 @@ samples/socket/Makefile.in
|
||||
samples/dialup/Makefile.in
|
||||
samples/font/Makefile.in
|
||||
samples/menu/Makefile.in
|
||||
samples/treelay/Makefile.in
|
||||
samples/opengl/cube/Makefile.in
|
||||
samples/opengl/penguin/Makefile.in
|
||||
samples/opengl/isosurf/Makefile.in
|
||||
samples/ogl/ogledit/Makefile.in
|
||||
samples/ogl/studio/Makefile.in
|
||||
demos/bombs/Makefile.in
|
||||
demos/forty/Makefile.in
|
||||
demos/fractal/Makefile.in
|
||||
|
@@ -98,6 +98,7 @@ tbarsmpl.cpp G
|
||||
textdlgg.cpp G
|
||||
tipdlg.cpp G
|
||||
treectrl.cpp G 16
|
||||
treelay.cpp G
|
||||
wizard.cpp G
|
||||
|
||||
appcmn.cpp C B
|
||||
|
@@ -3,9 +3,15 @@ src/wxvc.dsw
|
||||
src/wxvc_dll.dsp
|
||||
src/wxvc_dll.dsw
|
||||
|
||||
src/ogl/OglVC.dsp
|
||||
src/ogl/OglVC.dsw
|
||||
|
||||
src/jpeg/jpeg.dsp
|
||||
src/jpeg/jpeg.dsw
|
||||
|
||||
src/tiff/tiff.dsp
|
||||
src/tiff/tiff.dsw
|
||||
|
||||
samples/calendar/CalendarVC.dsp
|
||||
samples/calendar/CalendarVC.dsw
|
||||
|
||||
@@ -187,6 +193,21 @@ samples/validate/ValidateVC.dsw
|
||||
samples/wizard/WizardVC.dsp
|
||||
samples/wizard/WizardVC.dsw
|
||||
|
||||
samples/opengl/cube/CubeVC.dsp
|
||||
samples/opengl/cube/CubeVC.dsw
|
||||
samples/opengl/isosurf/IsosurfVC.dsp
|
||||
samples/opengl/isosurf/IsosurfVC.dsw
|
||||
samples/opengl/penguin/PenguinVC.dsp
|
||||
samples/opengl/penguin/PenguinVC.dsw
|
||||
|
||||
samples/ogl/ogledit/OgleditVC.dsp
|
||||
samples/ogl/ogledit/OgleditVC.dsw
|
||||
samples/ogl/studio/StudioVC.dsp
|
||||
samples/ogl/studio/StudioVC.dsw
|
||||
|
||||
samples/treelay/TreeSampleVC.dsp
|
||||
samples/treelay/TreeSampleVC.dsw
|
||||
|
||||
demos/bombs/BombsVC.dsp
|
||||
demos/bombs/BombsVC.dsw
|
||||
|
||||
@@ -211,24 +232,4 @@ utils/dialoged/src/DialogEdVC.dsw
|
||||
utils/tex2rtf/src/Tex2RTFVC.dsp
|
||||
utils/tex2rtf/src/Tex2RTFVC.dsw
|
||||
|
||||
utils/glcanvas/win/Glcanvas*.dsp
|
||||
utils/glcanvas/win/Glcanvas*.dsw
|
||||
utils/glcanvas/samples/cube/CubeVC.dsp
|
||||
utils/glcanvas/samples/cube/CubeVC.dsw
|
||||
utils/glcanvas/samples/isosurf/IsosurfVC.dsp
|
||||
utils/glcanvas/samples/isosurf/IsosurfVC.dsw
|
||||
utils/glcanvas/samples/penguin/PenguinVC.dsp
|
||||
utils/glcanvas/samples/penguin/PenguinVC.dsw
|
||||
|
||||
utils/ogl/src/OglVC.dsp
|
||||
utils/ogl/src/OglVC.dsw
|
||||
utils/ogl/samples/ogledit/OgleditVC.dsp
|
||||
utils/ogl/samples/ogledit/OgleditVC.dsw
|
||||
utils/ogl/samples/studio/StudioVC.dsp
|
||||
utils/ogl/samples/studio/StudioVC.dsw
|
||||
|
||||
utils/wxtree/src/TreeVC.dsp
|
||||
utils/wxtree/src/TreeVC.dsw
|
||||
utils/wxtree/src/TreeSampleVC.dsp
|
||||
utils/wxtree/src/TreeSampleVC.dsw
|
||||
|
||||
|
@@ -22,7 +22,6 @@ echo CTRL-C if this is not correct.
|
||||
pause
|
||||
|
||||
erase %dest\wx*.zip
|
||||
erase %dest\glcanvas.zip
|
||||
erase %dest\ogl3.zip
|
||||
erase %dest\tex2rtf2.zip
|
||||
erase %dest\jpeg.zip
|
||||
@@ -62,8 +61,8 @@ zip32 -@ %dest\wx%version%_cw.zip < %src\distrib\msw\cw.rsp
|
||||
rem OGL 3
|
||||
zip32 -@ %dest\ogl3.zip < %src\distrib\msw\ogl.rsp
|
||||
|
||||
rem GLCanvas
|
||||
zip32 -@ %dest\glcanvas.zip < %src\distrib\msw\glcanvas.rsp
|
||||
rem GLCanvas: obsolete, now in main library
|
||||
rem zip32 -@ %dest\glcanvas.zip < %src\distrib\msw\glcanvas.rsp
|
||||
|
||||
rem Tex2RTF
|
||||
zip32 -@ %dest\tex2rtf2.zip < %src\distrib\msw\tex2rtf.rsp
|
||||
@@ -107,7 +106,6 @@ unzip32 -o ..\wx%version%_bc.zip
|
||||
unzip32 -o ..\wx%version%_hlp.zip
|
||||
Rem Need Word file, for Remstar DB classes
|
||||
unzip32 -o ..\wx%version%_wrd.zip
|
||||
unzip32 -o ..\glcanvas.zip
|
||||
unzip32 -o ..\treedraw.zip
|
||||
unzip32 -o ..\ogl3.zip
|
||||
unzip32 -o ..\jpeg.zip
|
||||
|
@@ -125,7 +125,7 @@ WX_DEFINE_SORTED_ARRAY(MyFile *, ArrayOfFiles);
|
||||
|
||||
\helpref{Container classes overview}{wxcontaineroverview}, \helpref{wxList}{wxlist}
|
||||
|
||||
\wxheading{Required headers:}
|
||||
\wxheading{Include files}
|
||||
|
||||
<wx/dynarray.h> for wxArray and wxSortedArray and additionally <wx/arrimpl.cpp>
|
||||
for wxObjArray.
|
||||
|
@@ -284,6 +284,7 @@
|
||||
\input toolbar.tex
|
||||
\input treectrl.tex
|
||||
\input treeevt.tex
|
||||
\input treelay.tex
|
||||
\input upduievt.tex
|
||||
\input url.tex
|
||||
\input validatr.tex
|
||||
|
@@ -3,10 +3,8 @@
|
||||
% /home/guilhem/PROJECTS/wxWindows/utils/wxMMedia2/lib/sndaiff.h at 26/Feb/00 14:52:29
|
||||
%
|
||||
|
||||
|
||||
\section{\class{wxSoundAiff}}\label{wxsoundaiff}
|
||||
|
||||
|
||||
AIFF codec
|
||||
|
||||
\wxheading{Derived from}
|
||||
|
@@ -16,9 +16,9 @@ Base class for sound streams
|
||||
|
||||
No base class
|
||||
|
||||
\wxheading{Include file}
|
||||
\wxheading{Include files}
|
||||
|
||||
wx/mmedia/sndbase.h
|
||||
<wx/mmedia/sndbase.h>
|
||||
|
||||
\wxheading{Data structures}
|
||||
|
||||
@@ -56,6 +56,7 @@ may happen when you call wxSoundRouterStream::SetSoundFormat().}
|
||||
|
||||
When a sound event is generated, it may either call the internal sound event
|
||||
processor (which can be inherited) or call a C function. Its definition is:
|
||||
|
||||
\begin{verbatim}
|
||||
typedef void (*wxSoundCallback)(wxSoundStream *stream, int evt,
|
||||
void *cdata);
|
||||
@@ -63,13 +64,13 @@ processor (which can be inherited) or call a C function. Its definition is:
|
||||
|
||||
The {\bf stream} parameter represents the current wxSoundStream.
|
||||
|
||||
The {\bf evt} parameter represents the sound event which is the cause of the calling. (See \helpref{wxSound events}{wxsoundstreamevents})
|
||||
The {\bf evt} parameter represents the sound event which is the cause of the calling. (See \helpref{wxSound events}{wxsoundstreamevents}).
|
||||
|
||||
The {\bf cdata} parameter represents the user callback data which were specified
|
||||
when the user called \helpref{wxSoundStream::Register}{wxsoundstreamregister}.
|
||||
|
||||
{\bf\it Note:} There is two other ways to catch sound events: you can inherit the
|
||||
sound stream and redefine \helpref{wxSoundStream::OnSoundEvent}{wxsoundstreamonsoundevent}, or you can reroute the events to another sound stream using \helpref{wxSoundStream::SetEventHandler}{wxsoundstreameventhandler}
|
||||
{\it Note:} There are two other ways to catch sound events: you can inherit the
|
||||
sound stream and redefine \helpref{wxSoundStream::OnSoundEvent}{wxsoundstreamonsoundevent}, or you can reroute the events to another sound stream using \helpref{wxSoundStream::SetEventHandler}{wxsoundstreameventhandler}.
|
||||
|
||||
%%
|
||||
%% wxSoundStream streaming mode
|
||||
@@ -88,8 +89,8 @@ events and you cannot use wxSoundStream::Write().
|
||||
The {\bf wxSOUND\_OUTPUT} mode is the playing mode. It generates {\bf wxSOUND\_OUTPUT}
|
||||
events and you cannot use wxSoundStream::Read().
|
||||
|
||||
The {\bf wxSOUND\_DUPLEX} mode activates the full duplex mode. The full duplex needs
|
||||
you make synchronous call to \helpref{wxSoundStream::Read}{wxsoundstreamread} and
|
||||
The {\bf wxSOUND\_DUPLEX} mode activates the full duplex mode. The full duplex requires
|
||||
you to make synchronous call to \helpref{wxSoundStream::Read}{wxsoundstreamread} and
|
||||
\helpref{wxSoundStream::Write}{wxsoundstreamwrite}. This means that you must be
|
||||
careful with realtime problems. Each time you call Read you must call Write.
|
||||
|
||||
@@ -136,30 +137,29 @@ any temporary buffer.
|
||||
|
||||
\func{wxSoundStream\&}{Read}{\param{void* }{buffer}, \param{wxUint32 }{len}}
|
||||
|
||||
Reads \it{len} bytes from the sound stream. This call may block the user so
|
||||
Reads {\it len} bytes from the sound stream. This call may block the user so
|
||||
use it carefully when you need to intensively refresh the GUI. You may be
|
||||
interested by sound events: see
|
||||
\helpref{wxSoundStream::OnSoundEvent}{wxsoundstreamonsoundevent}.
|
||||
interested by sound events: see \helpref{wxSoundStream::OnSoundEvent}{wxsoundstreamonsoundevent}.
|
||||
|
||||
It is better to use the size returned by \helpref{wxSoundStream::GetBestSize}{wxsoundstreamgetbestsize}: this may improve performance or accuracy of the
|
||||
sound event system.
|
||||
|
||||
\wxheading{Note on \it{len}}
|
||||
\wxheading{Parameters}
|
||||
|
||||
\it{len} is expressed in bytes. If you need to do conversions between bytes
|
||||
\docparam{len}{{\it len} is expressed in bytes. If you need to do conversions between bytes
|
||||
and seconds use wxSoundFormat.
|
||||
See \helpref{wxSoundFormatBase}{wxsoundformatbase}, \helpref{wxSoundStream::GetSoundFormat}{wxsoundstreamgetsoundformat}.
|
||||
See \helpref{wxSoundFormatBase}{wxsoundformatbase}, \helpref{wxSoundStream::GetSoundFormat}{wxsoundstreamgetsoundformat}.}
|
||||
|
||||
\wxheading{Note on data}
|
||||
|
||||
Data in \it{buffer} are coded using the sound format attached to this sound
|
||||
\docparam{data}{Data in \it{buffer} are coded using the sound format attached to this sound
|
||||
stream. The format is specified with
|
||||
\helpref{SetSoundFormat}{wxsoundstreamsetsoundformat}
|
||||
\helpref{SetSoundFormat}{wxsoundstreamsetsoundformat}.}
|
||||
|
||||
%%
|
||||
%% Write
|
||||
%%
|
||||
|
||||
\membersection{wxSoundStream::Write}\label{wxsoundstreamwrite}
|
||||
|
||||
\func{wxSoundStream\&}{Write}{\param{const void* }{buffer}, \param{wxUint32 }{len}}
|
||||
|
||||
Writes \it{len} bytes to the sound stream. This call may block the user so
|
||||
@@ -169,17 +169,15 @@ use it carefully. You may be interested by sound events: see
|
||||
It is better to use the size returned by \helpref{wxSoundStream::GetBestSize}{wxsoundstreamgetbestsize}: this may improve performance or accuracy of the
|
||||
sound event system.
|
||||
|
||||
\wxheading{Note on \it{len}}
|
||||
\wxheading{Parameters}
|
||||
|
||||
\it{len} is expressed in bytes. If you need to do conversions between bytes
|
||||
\docparam{len}{This is expressed in bytes. If you need to do conversions between bytes
|
||||
and seconds use wxSoundFormat.
|
||||
See \helpref{wxSoundFormatBase}{wxsoundformatbase}, \helpref{wxSoundStream::GetSoundFormat}{wxsoundstreamgetsoundformat}.
|
||||
See \helpref{wxSoundFormatBase}{wxsoundformatbase}, \helpref{wxSoundStream::GetSoundFormat}{wxsoundstreamgetsoundformat}.}
|
||||
|
||||
\wxheading{Note on data}
|
||||
|
||||
Data in \it{buffer} are coded using the sound format attached to this sound
|
||||
\docparam{buffer}{Data in \it{buffer} are coded using the sound format attached to this sound
|
||||
stream. The format is specified with
|
||||
\helpref{SetSoundFormat}{wxsoundstreamsetsoundformat}
|
||||
\helpref{SetSoundFormat}{wxsoundstreamsetsoundformat}.}
|
||||
|
||||
%%
|
||||
%% GetBestSize
|
||||
@@ -199,6 +197,7 @@ will not block for this buffer size.
|
||||
%%
|
||||
|
||||
\membersection{wxSoundStream::SetSoundFormat}\label{wxsoundstreamsetsoundformat}
|
||||
|
||||
\func{bool}{SetSoundFormat}{\param{const wxSoundFormatBase\& }{format}}
|
||||
|
||||
SetSoundFormat is one of the key function of the wxSoundStream object. It specifies
|
||||
@@ -227,6 +226,7 @@ the stream itself.
|
||||
%% SetCallback
|
||||
%%
|
||||
\membersection{wxSoundStream::SetCallback}\label{wxsoundstreamregister}
|
||||
|
||||
\func{void}{Register}{\param{int }{evt}, \param{wxSoundCallback }{cbk}, \param{void* }{cdata}}
|
||||
|
||||
It installs a C callback for wxSoundStream events. The C callbacks are still useful
|
||||
@@ -249,29 +249,29 @@ recording or playing or the two at the same time.
|
||||
|
||||
Stops the async notifier.
|
||||
|
||||
|
||||
\membersection{wxSoundStream::SetEventHandler}\label{wxsoundstreamseteventhandler}
|
||||
|
||||
\func{void}{SetEventHandler}{\param{wxSoundStream* }{handler}}
|
||||
|
||||
Sets the event handler: if it is non-null, all events are routed to it.
|
||||
|
||||
|
||||
\membersection{wxSoundStream::GetError}\label{wxsoundstreamgeterror}
|
||||
|
||||
\constfunc{wxSoundError}{GetError}{\void}
|
||||
|
||||
|
||||
\membersection{wxSoundStream::GetLastAccess}\label{wxsoundstreamgetlastaccess}
|
||||
|
||||
\constfunc{wxUint32}{GetLastAccess}{\void}
|
||||
|
||||
|
||||
\membersection{wxSoundStream::QueueFilled}\label{wxsoundstreamqueuefilled}
|
||||
|
||||
\constfunc{bool}{QueueFilled}{\void}
|
||||
|
||||
This is only useful for device (I think).
|
||||
|
||||
|
||||
\membersection{wxSoundStream::OnSoundEvent}\label{wxsoundstreamonsoundevent}
|
||||
|
||||
\func{void}{OnSoundEvent}{\param{int }{evt}}
|
||||
|
||||
Handles event
|
||||
Handles event.
|
||||
|
||||
|
@@ -3,7 +3,6 @@
|
||||
% /home/guilhem/PROJECTS/wxWindows/utils/wxMMedia2/lib/sndcodec.h at 26/Feb/00 14:26:29
|
||||
%
|
||||
|
||||
|
||||
\section{\class{wxSoundStreamCodec}}\label{wxsoundstreamcodec}
|
||||
|
||||
\wxheading{Derived from}
|
||||
@@ -14,7 +13,6 @@
|
||||
|
||||
\latexignore{\rtfignore{\wxheading{Members}}}
|
||||
|
||||
|
||||
\membersection{wxSoundStreamCodec::wxSoundStreamCodec}\label{wxsoundstreamcodecwxsoundstreamcodec}
|
||||
|
||||
\func{}{wxSoundStreamCodec}{\param{wxSoundStream\& }{snd\_io}}
|
||||
|
@@ -3,10 +3,8 @@
|
||||
% /home/guilhem/PROJECTS/wxWindows/utils/wxMMedia2/lib/sndesd.h at 26/Feb/00 14:26:56
|
||||
%
|
||||
|
||||
|
||||
\section{\class{wxSoundStreamESD}}\label{wxsoundstreamesd}
|
||||
|
||||
|
||||
ESD output class
|
||||
|
||||
\wxheading{Derived from}
|
||||
@@ -20,7 +18,7 @@ ESD output class
|
||||
|
||||
\membersection{wxSoundStreamESD::wxSoundStreamESD}\label{wxsoundstreamesdwxsoundstreamesd}
|
||||
|
||||
\func{}{wxSoundStreamESD}{\param{const wxString\& }{hostname = \_T("localhost")}}
|
||||
\func{}{wxSoundStreamESD}{\param{const wxString\& }{hostname = "localhost"}}
|
||||
|
||||
|
||||
\membersection{wxSoundStreamESD::\destruct{wxSoundStreamESD}}\label{wxsoundstreamesddtor}
|
||||
|
@@ -26,9 +26,10 @@ typedef enum {
|
||||
{\small \begin{verbatim}
|
||||
typedef struct g72x\_state g72state
|
||||
\end{verbatim}}
|
||||
This fixes a bug in Mingw95
|
||||
\latexignore{\rtfignore{\wxheading{Members}}}
|
||||
|
||||
This fixes a bug in Mingw95
|
||||
|
||||
\latexignore{\rtfignore{\wxheading{Members}}}
|
||||
|
||||
\membersection{wxSoundFormatG72X::wxSoundFormatG72X}\label{wxsoundformatg72xwxsoundformatg72x}
|
||||
|
||||
@@ -80,7 +81,7 @@ This fixes a bug in Mingw95
|
||||
\constfunc{wxUint32}{GetBytesFromTime}{\param{wxUint32 }{time}}
|
||||
|
||||
|
||||
\membersection{wxSoundFormatG72X::operator!=}\label{wxsoundformatg72xoperator!=}
|
||||
\membersection{wxSoundFormatG72X::operator!=}\label{wxsoundformatg72xoperatorneq}
|
||||
|
||||
\constfunc{bool}{operator!=}{\param{const wxSoundFormatBase\& }{frmt2}}
|
||||
|
||||
|
@@ -98,7 +98,7 @@ PCM specification class
|
||||
\constfunc{wxUint32}{GetBytesFromTime}{\param{wxUint32 }{time}}
|
||||
|
||||
|
||||
\membersection{wxSoundFormatPcm::operator!}\label{wxsoundformatpcmoperator!}
|
||||
\membersection{wxSoundFormatPcm::operator!}\label{wxsoundformatpcmoperatornot}
|
||||
|
||||
\constfunc{bool}{operator!}{\param{const wxSoundFormatBase\& }{frmt2}}
|
||||
|
||||
|
@@ -64,6 +64,6 @@ It clones the current format.
|
||||
\constfunc{wxUint32}{GetBytesFromTime}{\param{wxUint32 }{time}}
|
||||
|
||||
|
||||
\membersection{wxSoundFormatBase::operator!=}\label{wxsoundformatbaseoperator!=}
|
||||
\membersection{wxSoundFormatBase::operator!=}\label{wxsoundformatbaseoperatorneq}
|
||||
|
||||
\constfunc{bool}{operator!=}{\param{const wxSoundFormatBase\& }{frmt2}
|
||||
\constfunc{bool}{operator!=}{\param{const wxSoundFormatBase\& }{frmt2}}
|
||||
|
@@ -68,7 +68,7 @@ ULAW format
|
||||
\constfunc{wxUint32}{GetBytesFromTime}{\param{wxUint32 }{time}}
|
||||
|
||||
|
||||
\membersection{wxSoundFormatUlaw::operator!=}\label{wxsoundformatulawoperator!=}
|
||||
\membersection{wxSoundFormatUlaw::operator!=}\label{wxsoundformatulawoperatorneq}
|
||||
|
||||
\constfunc{bool}{operator!=}{\param{const wxSoundFormatBase\& }{frmt2}}
|
||||
|
||||
|
@@ -1,20 +1,20 @@
|
||||
\chapter{wxTreeLayout Class Reference}
|
||||
\setheader{{\it CHAPTER \thechapter}}{}{}{}{}{{\it CHAPTER \thechapter}}%
|
||||
\setfooter{\thepage}{}{}{}{}{\thepage}
|
||||
|
||||
\section{\class{wxTreeLayout}}\label{wxtreelayout}
|
||||
|
||||
This abstract class is used for drawing a tree. You must derive a new
|
||||
class from this, and define member functions to access the data that
|
||||
wxTreeLayout needs.
|
||||
wxTreeLayout provides layout of simple trees with one root node, drawn left-to-right,
|
||||
with user-defined spacing between nodes.
|
||||
|
||||
wxTreeLayout is an abstract class that must be subclassed. The programmer
|
||||
defines various member functions which will access whatever data structures
|
||||
are appropriate for the application, and wxTreeLayout uses these when laying
|
||||
out the tree.
|
||||
|
||||
Nodes are identified by long integer identifiers. The derived class
|
||||
communicates the actual tree structure to wxTreeLayout by defining \helprefn{wxTreeLayout::GetChildren}{getchildren}\rtfsp
|
||||
and \helprefn{wxTreeLayout::GetNodeParent}{getnodeparent} functions.
|
||||
communicates the actual tree structure to wxTreeLayout by defining \helpref{wxTreeLayout::GetChildren}{wxtreelayoutgetchildren}\rtfsp
|
||||
and \helpref{wxTreeLayout::GetNodeParent}{wxtreelayoutgetnodeparent} functions.
|
||||
|
||||
The application should call \helprefn{DoLayout}{dolayout} to do the tree
|
||||
The application should call \helpref{wxTreeLayout::DoLayout}{wxtreelayoutdolayout} to do the tree
|
||||
layout. Depending on how the derived class has been defined, either
|
||||
\rtfsp\helprefn{wxTreeLayout::Draw}{draw} must be called (for example by the OnPaint member
|
||||
\rtfsp\helprefn{wxTreeLayout::Draw}{wxtreelayoutdraw} must be called (for example by the OnPaint member
|
||||
of a wxScrolledWindow) or the application-defined drawing code should be called
|
||||
as normal.
|
||||
|
||||
@@ -24,10 +24,29 @@ just need a way for wxTreeLayout to set the node image positions according to
|
||||
the layout algorithm, and the rest will be done by your own image drawing
|
||||
system.
|
||||
|
||||
The algorithm is due to Gabriel Robins \cite{robins87}, a linear-time
|
||||
algorithm originally implemented in LISP for AI applications.
|
||||
|
||||
The original algorithm has been modified so that both X and Y planes
|
||||
are calculated simultaneously, increasing efficiency slightly. The basic
|
||||
code is only a page or so long.
|
||||
|
||||
\helponly{Below is the example tree generated by the program test.cc.
|
||||
|
||||
\begin{figure}
|
||||
$$\image{11cm;0cm}{treetst.ps}$$
|
||||
\caption{Example tree}\label{exampletree}
|
||||
\end{figure}
|
||||
}
|
||||
|
||||
\wxheading{Derived from}
|
||||
|
||||
wxObject
|
||||
|
||||
\wxheading{See also}
|
||||
|
||||
\helpref{wxLayoutTreeStored}{wxlayouttreestored}
|
||||
|
||||
\latexignore{\rtfignore{\wxheading{Members}}}
|
||||
|
||||
\membersection{wxTreeLayout::wxTreeLayout}
|
||||
@@ -36,7 +55,7 @@ wxObject
|
||||
|
||||
Constructor.
|
||||
|
||||
\membersection{wxTreeLayout::ActivateNode}\label{activatenode}
|
||||
\membersection{wxTreeLayout::ActivateNode}\label{wxtreelayoutactivatenode}
|
||||
|
||||
\func{void}{ActivateNode}{\param{long}{ id}, \param{bool }{active}}
|
||||
|
||||
@@ -49,13 +68,13 @@ Define this so wxTreeLayout can turn nodes on and off for drawing purposes
|
||||
|
||||
Private function for laying out a branch.
|
||||
|
||||
\membersection{wxTreeLayout::DoLayout}\label{dolayout}
|
||||
\membersection{wxTreeLayout::DoLayout}\label{wxtreelayoutdolayout}
|
||||
|
||||
\func{void}{DoLayout}{\param{wxDC\&}{ dc}, \param{long}{ topNode = -1}}
|
||||
|
||||
Calculates the layout for the tree, optionally specifying the top node.
|
||||
|
||||
\membersection{wxTreeLayout::Draw}\label{draw}
|
||||
\membersection{wxTreeLayout::Draw}\label{wxtreelayoutdraw}
|
||||
|
||||
\func{void}{Draw}{\param{wxDC\&}{ dc}}
|
||||
|
||||
@@ -86,14 +105,14 @@ Defined by wxTreeLayout to draw a node.
|
||||
|
||||
Defined by wxTreeLayout to draw the nodes.
|
||||
|
||||
\membersection{wxTreeLayout::GetChildren}\label{getchildren}
|
||||
\membersection{wxTreeLayout::GetChildren}\label{wxtreelayoutgetchildren}
|
||||
|
||||
\func{void}{GetChildren}{\param{long}{ id}, \param{wxList \&}{list}}
|
||||
|
||||
Must be defined to return the children of node {\it id} in the given list
|
||||
of integers.
|
||||
|
||||
\membersection{wxTreeLayout::GetNextNode}\label{getnextnode}
|
||||
\membersection{wxTreeLayout::GetNextNode}\label{wxtreelayoutgetnextnode}
|
||||
|
||||
\func{long}{GetNextNode}{\param{long}{ id}}
|
||||
|
||||
@@ -115,7 +134,7 @@ the drawing to wxTreeLayout).
|
||||
Can be defined to indicate a node's size, or left to wxTreeLayout to use the
|
||||
name as an indication of size.
|
||||
|
||||
\membersection{wxTreeLayout::GetNodeParent}\label{getnodeparent}
|
||||
\membersection{wxTreeLayout::GetNodeParent}\label{wxtreelayoutgetnodeparent}
|
||||
|
||||
\constfunc{long}{GetNodeParent}{\param{long}{ id}}
|
||||
|
||||
@@ -182,7 +201,7 @@ Gets the vertical spacing between nodes.
|
||||
Initializes wxTreeLayout. Call from application or overridden {\bf Initialize}
|
||||
or constructor.
|
||||
|
||||
\membersection{wxTreeLayout::NodeActive}\label{nodeactive}
|
||||
\membersection{wxTreeLayout::NodeActive}\label{wxtreelayoutnodeactive}
|
||||
|
||||
\func{bool}{NodeActive}{\param{long}{ id}}
|
||||
|
||||
@@ -217,7 +236,7 @@ may be necessary for your application.
|
||||
|
||||
Sets the tree orientation: TRUE means top-to-bottom, FALSE means left-to-right (the default).
|
||||
|
||||
\membersection{wxTreeLayout::SetTopNode}\label{settopnode}
|
||||
\membersection{wxTreeLayout::SetTopNode}\label{wxtreelayoutsettopnode}
|
||||
|
||||
\func{void}{SetTopNode}{\param{long}{ id}}
|
||||
|
||||
@@ -229,76 +248,80 @@ Call this to identify the top of the tree to wxTreeLayout.
|
||||
|
||||
Sets the horizontal and vertical spacing between nodes in the tree.
|
||||
|
||||
\membersection{wxTreeLayout::SetMargins}\label{setmargins}
|
||||
\membersection{wxTreeLayout::SetMargins}\label{wxtreelayoutsetmargins}
|
||||
|
||||
\func{void}{SetMargins}{\param{long}{ x}, \param{long}{ y}}
|
||||
|
||||
Sets the left and top margins of the whole tree.
|
||||
|
||||
\section{\class{wxStoredTree}}\label{wxstoredtree}
|
||||
\section{\class{wxLayoutTreeStored}}\label{wxlayouttreestored}
|
||||
|
||||
wxStoredTree provides storage for node labels, position and client data. It also provides hit-testing
|
||||
wxLayoutTreeStored provides storage for node labels, position and client data. It also provides hit-testing
|
||||
(which node a mouse event occurred on). It is usually a more convenient class to use than wxTreeLayout.
|
||||
|
||||
\wxheading{Derived from}
|
||||
|
||||
\helpref{wxTreeLayout}{wxtreelayout}
|
||||
\helpref{wxTreeLayout}{wxtreelayout}\\
|
||||
\helpref{wxObject}{wxobject}
|
||||
|
||||
\wxheading{See also}
|
||||
|
||||
\helpref{wxLayoutTree}{wxlayouttree}
|
||||
|
||||
\latexignore{\rtfignore{\wxheading{Members}}}
|
||||
|
||||
\membersection{wxStoredTree::wxStoredTree}
|
||||
\membersection{wxLayoutTreeStored::wxLayoutTreeStored}
|
||||
|
||||
\func{}{wxStoredTree}{\param{int }{noNodes = 200}}
|
||||
\func{}{wxLayoutTreeStored}{\param{int }{noNodes = 200}}
|
||||
|
||||
Constructor. Specify the maximum number of nodes to be allocated.
|
||||
|
||||
\membersection{wxStoredTree::AddChild}\label{wxstoredtreeaddchild}
|
||||
\membersection{wxLayoutTreeStored::AddChild}\label{wxlayouttreestoredaddchild}
|
||||
|
||||
\func{long}{AddChild}{\param{const wxString\&}{ name}, \param{const wxString\&}{ parent = ""}}
|
||||
|
||||
Adds a child with a given parent, returning the node id.
|
||||
|
||||
\membersection{wxStoredTree::GetClientData}\label{wxstoredtreegetclientdata}
|
||||
\membersection{wxLayoutTreeStored::GetClientData}\label{wxlayouttreestoredgetclientdata}
|
||||
|
||||
\constfunc{long}{GetClientData}{\param{long}{ id}}
|
||||
|
||||
Gets the client data for the given node.
|
||||
|
||||
\membersection{wxStoredTree::GetNode}\label{wxstoredtreegetnode}
|
||||
\membersection{wxLayoutTreeStored::GetNode}\label{wxlayouttreestoredgetnode}
|
||||
|
||||
\constfunc{wxStoredNode*}{GetNode}{\param{long}{ id}}
|
||||
|
||||
Returns the wxStoredNode object for the given node id.
|
||||
|
||||
\membersection{wxStoredTree::GetNodeCount}\label{wxstoredtreegetnodecount}
|
||||
\membersection{wxLayoutTreeStored::GetNodeCount}\label{wxlayouttreestoredgetnodecount}
|
||||
|
||||
\constfunc{int}{GetNodeCount}{\void}
|
||||
|
||||
Returns the current number of nodes.
|
||||
|
||||
\membersection{wxStoredTree::GetNumNodes}\label{wxstoredtreegetnumnodes}
|
||||
\membersection{wxLayoutTreeStored::GetNumNodes}\label{wxlayouttreestoredgetnumnodes}
|
||||
|
||||
\constfunc{int}{GetNumNodes}{\void}
|
||||
|
||||
Returns the maximum number of nodes.
|
||||
|
||||
\membersection{wxStoredTree::HitTest}\label{wxstoredtreehittest}
|
||||
\membersection{wxLayoutTreeStored::HitTest}\label{wxlayouttreestoredhittest}
|
||||
|
||||
\func{wxString}{HitTest}{\param{wxMouseEvent\&}{ event}, \param{wxDC\& }{dc}}
|
||||
|
||||
Returns a string with the node name corresponding to the position of the mouse event, or the empty string if no node
|
||||
was detected.
|
||||
|
||||
\membersection{wxStoredTree::NameToId}\label{wxstoredtreenametoid}
|
||||
\membersection{wxLayoutTreeStored::NameToId}\label{wxlayouttreestorednametoid}
|
||||
|
||||
\func{long}{NameToId}{\param{const wxString\&}{ name}}
|
||||
|
||||
Returns the id for the given node name, or -1 if there was no such node.
|
||||
|
||||
\membersection{wxStoredTree::SetClientData}\label{wxstoredtreesetclientdata}
|
||||
\membersection{wxLayoutTreeStored::SetClientData}\label{wxlayouttreestoredsetclientdata}
|
||||
|
||||
\func{void}{SetClientData}{\param{long}{ id}, \param{long}{ clientData}}
|
||||
|
||||
Sets client data for the given node.
|
||||
|
||||
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
@@ -3,11 +3,8 @@
|
||||
% /home/guilhem/PROJECTS/wxWindows/utils/wxMMedia2/lib/vidbase.h at 26/Feb/00 14:51:56
|
||||
%
|
||||
|
||||
|
||||
\section{\class{wxVideoBaseDriver}}\label{wxvideobasedriver}
|
||||
|
||||
|
||||
|
||||
Classes definition
|
||||
|
||||
\wxheading{Derived from}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
[OPTIONS]
|
||||
BMROOT=d:\wx2\wxWind~1\docs/latex/wx ; Assume that bitmaps are where the source is
|
||||
BMROOT=d:\wx2\wxWindows\docs\latex\wx ; Assume that bitmaps are where the source is
|
||||
TITLE=wxWindows Manual
|
||||
CONTENTS=Contents
|
||||
COMPRESS=HIGH
|
||||
|
138
include/wx/generic/treelay.h
Normal file
@@ -0,0 +1,138 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: treelay.h
|
||||
// Purpose: wxTreeLayout class
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 7/4/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 1998 Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_TREELAY_H_
|
||||
#define _WX_TREELAY_H_
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface "wxtree.h"
|
||||
#endif
|
||||
|
||||
#include <wx/string.h>
|
||||
|
||||
class WXDLLEXPORT wxTreeLayout: public wxObject
|
||||
{
|
||||
DECLARE_ABSTRACT_CLASS(wxTreeLayout)
|
||||
|
||||
public:
|
||||
wxTreeLayout();
|
||||
|
||||
// Redefine these
|
||||
virtual void GetChildren(long id, wxList& list) = 0;
|
||||
virtual long GetNextNode(long id) = 0;
|
||||
virtual long GetNodeParent(long id) = 0;
|
||||
virtual long GetNodeX(long id) = 0;
|
||||
virtual long GetNodeY(long id) = 0;
|
||||
virtual void SetNodeX(long id, long x) = 0;
|
||||
virtual void SetNodeY(long id, long y) = 0;
|
||||
virtual void ActivateNode(long id, bool active) = 0;
|
||||
virtual bool NodeActive(long id) = 0;
|
||||
|
||||
// Optional redefinition
|
||||
void Initialize(void);
|
||||
inline virtual void SetNodeName(long id, const wxString& name) {}
|
||||
inline virtual wxString GetNodeName(long id) { return wxString(""); }
|
||||
virtual void GetNodeSize(long id, long *x, long *y, wxDC& dc);
|
||||
virtual void Draw(wxDC& dc);
|
||||
virtual void DrawNodes(wxDC& dc);
|
||||
virtual void DrawBranches(wxDC& dc);
|
||||
virtual void DrawNode(long id, wxDC& dc);
|
||||
virtual void DrawBranch(long from, long to, wxDC& dc);
|
||||
|
||||
// Don't redefine
|
||||
virtual void DoLayout(wxDC& dc, long topNode = -1);
|
||||
|
||||
// Accessors -- don't redefine
|
||||
inline void SetTopNode(long id) { m_parentNode = id; }
|
||||
inline long GetTopNode(void) const { return m_parentNode; }
|
||||
inline void SetSpacing(long x, long y) { m_xSpacing = x; m_ySpacing = y; }
|
||||
inline long GetXSpacing(void) const { return m_xSpacing; }
|
||||
inline long GetYSpacing(void) const { return m_ySpacing; }
|
||||
inline void SetMargins(long x, long y) { m_leftMargin = x; m_topMargin = y; }
|
||||
inline long GetTopMargin(void) const { return m_topMargin; }
|
||||
inline long GetLeftMargin(void) const { return m_leftMargin; }
|
||||
|
||||
inline bool GetOrientation(void) const { return m_orientation; }
|
||||
inline void SetOrientation(bool or) { m_orientation = or; }
|
||||
|
||||
private:
|
||||
void CalcLayout(long node_id, int level, wxDC& dc);
|
||||
|
||||
// Members
|
||||
|
||||
protected:
|
||||
long m_parentNode;
|
||||
long m_lastY;
|
||||
long m_lastX;
|
||||
long m_xSpacing;
|
||||
long m_ySpacing;
|
||||
long m_topMargin;
|
||||
long m_leftMargin;
|
||||
bool m_orientation; // TRUE for top-to-bottom, FALSE for left-to-right
|
||||
};
|
||||
|
||||
class WXDLLEXPORT wxStoredNode
|
||||
{
|
||||
public:
|
||||
wxString m_name;
|
||||
long m_x, m_y;
|
||||
long m_parentId;
|
||||
bool m_active;
|
||||
long m_clientData;
|
||||
};
|
||||
|
||||
/*
|
||||
* A version of wxTreeLayout with storage for nodes
|
||||
*/
|
||||
|
||||
class WXDLLEXPORT wxLayoutTreeStored: public wxTreeLayout
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxLayoutTreeStored)
|
||||
public:
|
||||
wxLayoutTreeStored(int noNodes = 200);
|
||||
~wxLayoutTreeStored(void);
|
||||
void Initialize(int n);
|
||||
|
||||
wxString HitTest(wxMouseEvent& event, wxDC& dc);
|
||||
wxStoredNode* GetNode(long id) const;
|
||||
inline int GetNumNodes() const { return m_maxNodes; };
|
||||
inline int GetNodeCount() const { return m_num; };
|
||||
|
||||
virtual void GetChildren(long id, wxList& list);
|
||||
virtual long GetNextNode(long id);
|
||||
virtual long GetNodeParent(long id);
|
||||
virtual long GetNodeX(long id);
|
||||
virtual long GetNodeY(long id);
|
||||
virtual void SetNodeX(long id, long x);
|
||||
virtual void SetNodeY(long id, long y);
|
||||
virtual void SetNodeName(long id, const wxString& name);
|
||||
virtual wxString GetNodeName(long id);
|
||||
virtual void ActivateNode(long id, bool active);
|
||||
virtual bool NodeActive(long id);
|
||||
virtual void SetClientData(long id, long clientData);
|
||||
virtual long GetClientData(long id) const;
|
||||
|
||||
virtual long AddChild(const wxString& name, const wxString& parent = "");
|
||||
virtual long NameToId(const wxString& name);
|
||||
|
||||
// Data members
|
||||
private:
|
||||
wxStoredNode* m_nodes;
|
||||
int m_num;
|
||||
int m_maxNodes;
|
||||
};
|
||||
|
||||
// For backward compatibility
|
||||
#define wxStoredTree wxLayoutTreeStored
|
||||
|
||||
#endif
|
||||
// _WX_TREELAY_H_
|
||||
|
@@ -220,6 +220,9 @@
|
||||
// OpenGL canvas
|
||||
#define wxUSE_GLCANVAS 0
|
||||
|
||||
// wxTreeLayout class
|
||||
#define wxUSE_TREELAYOUT 1
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Postscript support settings
|
||||
// ----------------------------------------------------------------------------
|
||||
|
7
include/wx/treelay.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#ifndef _WX_TREELAY_H_BASE_
|
||||
#define _WX_TREELAY_H_BASE_
|
||||
|
||||
#include "wx/generic/treelay.h"
|
||||
|
||||
#endif
|
||||
// _WX_TREELAY_H_BASE_
|
21
samples/treelay/Makefile.in
Normal file
@@ -0,0 +1,21 @@
|
||||
#
|
||||
# File: makefile.unx
|
||||
# Author: Julian Smart
|
||||
# Created: 1998
|
||||
# Updated:
|
||||
# Copyright: (c) 1998 Julian Smart
|
||||
#
|
||||
# "%W% %G%"
|
||||
#
|
||||
# Makefile for test example (UNIX).
|
||||
|
||||
top_srcdir = @top_srcdir@/..
|
||||
top_builddir = ../..
|
||||
program_dir = samples/test
|
||||
|
||||
PROGRAM=test
|
||||
|
||||
OBJECTS=$(PROGRAM).o
|
||||
|
||||
include ../../src/makeprog.env
|
||||
|
@@ -9,9 +9,7 @@
|
||||
|
||||
WXDIR = $(WXWIN)
|
||||
|
||||
TARGET=cube
|
||||
EXTRALIBS=$(WXDIR)\lib\glcanvas.lib
|
||||
EXTRACPPFLAGS=-I$(WXDIR)\utils\glcanvas\win
|
||||
TARGET=test
|
||||
OBJECTS = $(TARGET).obj
|
||||
|
||||
!include $(WXDIR)\src\makeprog.b32
|
@@ -12,7 +12,7 @@
|
||||
|
||||
WXDIR = $(WXWIN)
|
||||
|
||||
TARGET=minimal
|
||||
TARGET=test
|
||||
OBJECTS=$(TARGET).obj
|
||||
|
||||
!include $(WXDIR)\src\makeprog.bcc
|
17
samples/treelay/makefile.dos
Normal file
@@ -0,0 +1,17 @@
|
||||
#
|
||||
# File: makefile.dos
|
||||
# Author: Julian Smart
|
||||
# Created: 1998
|
||||
# Updated:
|
||||
#
|
||||
# Makefile : Builds 16-bit sample, VC++ 1.5
|
||||
# Use FINAL=1 argument to nmake to build final version with no debugging
|
||||
# info
|
||||
|
||||
WXDIR = $(WXWIN)
|
||||
|
||||
TARGET=test
|
||||
OBJECTS=$(TARGET).obj
|
||||
|
||||
!include $(WXDIR)\src\makeprog.msc
|
||||
|
@@ -7,10 +7,10 @@
|
||||
#
|
||||
# Makefile for wxWindows sample (Cygwin/Mingw32).
|
||||
|
||||
WXDIR = $(WXWIN)
|
||||
WXDIR = ../..
|
||||
|
||||
TARGET=test
|
||||
OBJECTS = $(TARGET).o wxtree.o
|
||||
OBJECTS = $(TARGET).o
|
||||
|
||||
include $(WXDIR)/src/makeprog.g95
|
||||
|
35
samples/treelay/makefile.unx
Normal file
@@ -0,0 +1,35 @@
|
||||
#
|
||||
# File: Makefile for samples
|
||||
# Author: Robert Roebling
|
||||
# Created: 1999
|
||||
# Updated:
|
||||
# Copyright: (c) 1998 Robert Roebling
|
||||
#
|
||||
# This makefile requires a Unix version of wxWindows
|
||||
# to be installed on your system. This is most often
|
||||
# done typing "make install" when using the complete
|
||||
# sources of wxWindows or by installing the two
|
||||
# RPM packages wxGTK.XXX.rpm and wxGTK-devel.XXX.rpm
|
||||
# under Linux.
|
||||
#
|
||||
|
||||
CC = gcc
|
||||
|
||||
PROGRAM = test
|
||||
|
||||
OBJECTS = $(PROGRAM).o
|
||||
|
||||
# implementation
|
||||
|
||||
.SUFFIXES: .o .cpp
|
||||
|
||||
.cpp.o :
|
||||
$(CC) -c `wx-config --cflags` -o $@ $<
|
||||
|
||||
all: $(PROGRAM)
|
||||
|
||||
$(PROGRAM): $(OBJECTS)
|
||||
$(CC) -o $(PROGRAM) $(OBJECTS) `wx-config --libs`
|
||||
|
||||
clean:
|
||||
rm -f *.o $(PROGRAM)
|
@@ -11,15 +11,8 @@
|
||||
# Set WXDIR for your system
|
||||
WXDIR = $(WXWIN)
|
||||
|
||||
!if "$(FINAL)" == "1"
|
||||
!else
|
||||
LIBEXT=_d
|
||||
!endif
|
||||
|
||||
PROGRAM=cube
|
||||
PROGRAM=test
|
||||
OBJECTS = $(PROGRAM).obj
|
||||
EXTRAINC=-I..\..\win
|
||||
EXTRALIBS=$(WXDIR)\lib\glcanvas$(LIBEXT).lib glu32.lib opengl32.lib
|
||||
|
||||
!include $(WXDIR)\src\makeprog.vc
|
||||
|
@@ -7,10 +7,8 @@
|
||||
|
||||
WXDIR = $(%WXWIN)
|
||||
|
||||
PROGRAM = cube
|
||||
PROGRAM = test
|
||||
OBJECTS = $(PROGRAM).obj
|
||||
EXTRALIBS=$(WXDIR)\lib\glcanvas.lib
|
||||
EXTRACPPFLAGS=-I$(WXDIR)\utils\glcanvas\win
|
||||
|
||||
!include $(WXDIR)\src\makeprog.wat
|
||||
|
Before Width: | Height: | Size: 766 B After Width: | Height: | Size: 766 B |
@@ -20,7 +20,8 @@
|
||||
#include <wx/wx.h>
|
||||
#endif
|
||||
|
||||
#include "wxtree.h"
|
||||
#include <wx/treelay.h>
|
||||
|
||||
#include "test.h"
|
||||
|
||||
wxStoredTree *myTree = NULL;
|
446
src/generic/treelay.cpp
Normal file
@@ -0,0 +1,446 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: treelay.h
|
||||
// Purpose: wxTreeLayout class
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 7/4/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 1998 Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "wxtree.h"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include <wx/wxprec.h>
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include <wx/wx.h>
|
||||
#endif
|
||||
|
||||
#if wxUSE_TREELAYOUT
|
||||
|
||||
#include <wx/treelay.h>
|
||||
|
||||
/*
|
||||
* Abstract tree
|
||||
*
|
||||
*/
|
||||
|
||||
IMPLEMENT_ABSTRACT_CLASS(wxTreeLayout, wxObject)
|
||||
|
||||
wxTreeLayout::wxTreeLayout()
|
||||
{
|
||||
m_xSpacing = 16;
|
||||
m_ySpacing = 20;
|
||||
m_topMargin = 5;
|
||||
m_leftMargin = 5;
|
||||
m_orientation = FALSE;
|
||||
m_parentNode = 0;
|
||||
}
|
||||
|
||||
void wxTreeLayout::DoLayout(wxDC& dc, long topId)
|
||||
{
|
||||
if (topId != -1)
|
||||
SetTopNode(topId);
|
||||
|
||||
long actualTopId = GetTopNode();
|
||||
long id = actualTopId;
|
||||
while (id != -1)
|
||||
{
|
||||
SetNodeX(id, 0);
|
||||
SetNodeY(id, 0);
|
||||
ActivateNode(id, FALSE);
|
||||
id = GetNextNode(id);
|
||||
}
|
||||
m_lastY = m_topMargin;
|
||||
m_lastX = m_leftMargin;
|
||||
CalcLayout(actualTopId, 0, dc);
|
||||
}
|
||||
|
||||
void wxTreeLayout::Draw(wxDC& dc)
|
||||
{
|
||||
dc.Clear();
|
||||
DrawBranches(dc);
|
||||
DrawNodes(dc);
|
||||
}
|
||||
|
||||
void wxTreeLayout::DrawNodes(wxDC& dc)
|
||||
{
|
||||
long id = GetTopNode();
|
||||
while (id != -1)
|
||||
{
|
||||
if (NodeActive(id))
|
||||
DrawNode(id, dc);
|
||||
id = GetNextNode(id);
|
||||
}
|
||||
}
|
||||
|
||||
void wxTreeLayout::DrawBranches(wxDC& dc)
|
||||
{
|
||||
long id = GetTopNode();
|
||||
while (id != -1)
|
||||
{
|
||||
if (GetNodeParent(id) > -1)
|
||||
{
|
||||
long parent = GetNodeParent(id);
|
||||
if (NodeActive(parent))
|
||||
DrawBranch(parent, id, dc);
|
||||
}
|
||||
id = GetNextNode(id);
|
||||
}
|
||||
}
|
||||
|
||||
void wxTreeLayout::DrawNode(long id, wxDC& dc)
|
||||
{
|
||||
char buf[80];
|
||||
wxString name(GetNodeName(id));
|
||||
if (name != "")
|
||||
sprintf(buf, "%s", (const char*) name);
|
||||
else
|
||||
sprintf(buf, "<unnamed>");
|
||||
|
||||
long x = 80;
|
||||
long y = 20;
|
||||
dc.GetTextExtent(buf, &x, &y);
|
||||
dc.DrawText(buf, GetNodeX(id), (long)(GetNodeY(id) - (y/2.0)));
|
||||
}
|
||||
|
||||
void wxTreeLayout::DrawBranch(long from, long to, wxDC& dc)
|
||||
{
|
||||
long w, h;
|
||||
GetNodeSize(from, &w, &h, dc);
|
||||
dc.DrawLine(GetNodeX(from)+w, GetNodeY(from),
|
||||
GetNodeX(to), GetNodeY(to));
|
||||
}
|
||||
|
||||
void wxTreeLayout::Initialize(void)
|
||||
{
|
||||
}
|
||||
|
||||
void wxTreeLayout::GetNodeSize(long id, long *x, long *y, wxDC& dc)
|
||||
{
|
||||
wxString name(GetNodeName(id));
|
||||
if (name != "")
|
||||
dc.GetTextExtent(name, x, y);
|
||||
else
|
||||
{
|
||||
*x = 70; *y = 20;
|
||||
}
|
||||
}
|
||||
|
||||
void wxTreeLayout::CalcLayout(long nodeId, int level, wxDC& dc)
|
||||
{
|
||||
wxList children;
|
||||
GetChildren(nodeId, children);
|
||||
int n = children.Number();
|
||||
|
||||
if (m_orientation == FALSE)
|
||||
{
|
||||
// Left to right
|
||||
// X Calculations
|
||||
if (level == 0)
|
||||
SetNodeX(nodeId, m_leftMargin);
|
||||
else
|
||||
{
|
||||
long x = 0;
|
||||
long y = 0;
|
||||
long parentId = GetNodeParent(nodeId);
|
||||
if (parentId != -1)
|
||||
GetNodeSize(parentId, &x, &y, dc);
|
||||
SetNodeX(nodeId, (long)(GetNodeX(parentId) + m_xSpacing + x));
|
||||
}
|
||||
|
||||
wxNode *node = children.First();
|
||||
while (node)
|
||||
{
|
||||
CalcLayout((long)node->Data(), level+1, dc);
|
||||
node = node->Next();
|
||||
}
|
||||
|
||||
// Y Calculations
|
||||
long averageY;
|
||||
ActivateNode(nodeId, TRUE);
|
||||
|
||||
if (n > 0)
|
||||
{
|
||||
averageY = 0;
|
||||
node = children.First();
|
||||
while (node)
|
||||
{
|
||||
averageY += GetNodeY((long)node->Data());
|
||||
node = node->Next();
|
||||
}
|
||||
averageY = averageY / n;
|
||||
SetNodeY(nodeId, averageY);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetNodeY(nodeId, m_lastY);
|
||||
long x, y;
|
||||
GetNodeSize(nodeId, &x, &y, dc);
|
||||
|
||||
m_lastY = m_lastY + y + m_ySpacing;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Top to bottom
|
||||
|
||||
// Y Calculations
|
||||
if (level == 0)
|
||||
SetNodeY(nodeId, m_topMargin);
|
||||
else
|
||||
{
|
||||
long x = 0;
|
||||
long y = 0;
|
||||
long parentId = GetNodeParent(nodeId);
|
||||
if (parentId != -1)
|
||||
GetNodeSize(parentId, &x, &y, dc);
|
||||
SetNodeY(nodeId, (long)(GetNodeY(parentId) + m_ySpacing + y));
|
||||
}
|
||||
|
||||
wxNode *node = children.First();
|
||||
while (node)
|
||||
{
|
||||
CalcLayout((long)node->Data(), level+1, dc);
|
||||
node = node->Next();
|
||||
}
|
||||
|
||||
// X Calculations
|
||||
long averageX;
|
||||
ActivateNode(nodeId, TRUE);
|
||||
|
||||
if (n > 0)
|
||||
{
|
||||
averageX = 0;
|
||||
node = children.First();
|
||||
while (node)
|
||||
{
|
||||
averageX += GetNodeX((long)node->Data());
|
||||
node = node->Next();
|
||||
}
|
||||
averageX = averageX / n;
|
||||
SetNodeX(nodeId, averageX);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetNodeX(nodeId, m_lastX);
|
||||
long x, y;
|
||||
GetNodeSize(nodeId, &x, &y, dc);
|
||||
|
||||
m_lastX = m_lastX + x + m_xSpacing;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Tree with storage
|
||||
*
|
||||
*/
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxLayoutTreeStored, wxTreeLayout)
|
||||
|
||||
wxLayoutTreeStored::wxLayoutTreeStored(int n):wxTreeLayout()
|
||||
{
|
||||
m_nodes = NULL;
|
||||
m_maxNodes = 0;
|
||||
Initialize(n);
|
||||
}
|
||||
|
||||
wxLayoutTreeStored::~wxLayoutTreeStored(void)
|
||||
{
|
||||
if (m_nodes)
|
||||
delete[] m_nodes;
|
||||
}
|
||||
|
||||
void wxLayoutTreeStored::Initialize(int n)
|
||||
{
|
||||
m_maxNodes = n;
|
||||
wxTreeLayout::Initialize();
|
||||
if (m_nodes) delete[] m_nodes;
|
||||
m_nodes = new wxStoredNode[m_maxNodes];
|
||||
int i;
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
m_nodes[i].m_name = "";
|
||||
m_nodes[i].m_active = FALSE;
|
||||
m_nodes[i].m_parentId = -1;
|
||||
m_nodes[i].m_x = 0;
|
||||
m_nodes[i].m_y = 0;
|
||||
}
|
||||
m_num = 0;
|
||||
}
|
||||
|
||||
long wxLayoutTreeStored::AddChild(const wxString& name, const wxString& parent)
|
||||
{
|
||||
if (m_num < (m_maxNodes -1 ))
|
||||
{
|
||||
long i = -1;
|
||||
if (parent != "")
|
||||
i = NameToId(parent);
|
||||
else m_parentNode = m_num;
|
||||
|
||||
m_nodes[m_num].m_parentId = i;
|
||||
m_nodes[m_num].m_name = name;
|
||||
m_nodes[m_num].m_x = m_nodes[m_num].m_y = 0;
|
||||
m_nodes[m_num].m_clientData = 0;
|
||||
m_num ++;
|
||||
|
||||
return (m_num - 1);
|
||||
}
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
long wxLayoutTreeStored::NameToId(const wxString& name)
|
||||
{
|
||||
long i;
|
||||
for (i = 0; i < m_num; i++)
|
||||
if (name == m_nodes[i].m_name)
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
void wxLayoutTreeStored::GetChildren(long id, wxList& list)
|
||||
{
|
||||
long currentId = GetTopNode();
|
||||
while (currentId != -1)
|
||||
{
|
||||
if (id == GetNodeParent(currentId))
|
||||
list.Append((wxObject *)currentId);
|
||||
currentId = GetNextNode(currentId);
|
||||
}
|
||||
}
|
||||
|
||||
wxStoredNode* wxLayoutTreeStored::GetNode(long idx) const
|
||||
{
|
||||
wxASSERT(idx < m_num);
|
||||
|
||||
return &m_nodes[idx];
|
||||
};
|
||||
|
||||
long wxLayoutTreeStored::GetNodeX(long id)
|
||||
{
|
||||
wxASSERT(id < m_num);
|
||||
|
||||
return (long)m_nodes[id].m_x;
|
||||
}
|
||||
|
||||
long wxLayoutTreeStored::GetNodeY(long id)
|
||||
{
|
||||
wxASSERT(id < m_num);
|
||||
|
||||
return (long)m_nodes[id].m_y;
|
||||
}
|
||||
|
||||
void wxLayoutTreeStored::SetNodeX(long id, long x)
|
||||
{
|
||||
wxASSERT(id < m_num);
|
||||
|
||||
m_nodes[id].m_x = (int)x;
|
||||
}
|
||||
|
||||
void wxLayoutTreeStored::SetNodeY(long id, long y)
|
||||
{
|
||||
wxASSERT(id < m_num);
|
||||
|
||||
m_nodes[id].m_y = (int)y;
|
||||
}
|
||||
|
||||
void wxLayoutTreeStored::SetNodeName(long id, const wxString& name)
|
||||
{
|
||||
wxASSERT(id < m_num);
|
||||
|
||||
m_nodes[id].m_name = name;
|
||||
}
|
||||
|
||||
wxString wxLayoutTreeStored::GetNodeName(long id)
|
||||
{
|
||||
wxASSERT(id < m_num);
|
||||
|
||||
return m_nodes[id].m_name;
|
||||
}
|
||||
|
||||
long wxLayoutTreeStored::GetNodeParent(long id)
|
||||
{
|
||||
if (id != -1)
|
||||
{
|
||||
wxASSERT(id < m_num);
|
||||
|
||||
return m_nodes[id].m_parentId;
|
||||
}
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
long wxLayoutTreeStored::GetNextNode(long id)
|
||||
{
|
||||
wxASSERT(id < m_num);
|
||||
|
||||
if ((id != -1) && (id < (m_num - 1)))
|
||||
return id + 1;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
void wxLayoutTreeStored::SetClientData(long id, long clientData)
|
||||
{
|
||||
wxASSERT(id < m_num);
|
||||
|
||||
m_nodes[id].m_clientData = clientData;
|
||||
}
|
||||
|
||||
long wxLayoutTreeStored::GetClientData(long id) const
|
||||
{
|
||||
wxASSERT(id < m_num);
|
||||
|
||||
return m_nodes[id].m_clientData;
|
||||
}
|
||||
|
||||
void wxLayoutTreeStored::ActivateNode(long id, bool active)
|
||||
{
|
||||
wxASSERT(id < m_num);
|
||||
|
||||
m_nodes[id].m_active = active;
|
||||
}
|
||||
|
||||
bool wxLayoutTreeStored::NodeActive(long id)
|
||||
{
|
||||
wxASSERT(id < m_num);
|
||||
|
||||
return m_nodes[id].m_active;
|
||||
}
|
||||
|
||||
wxString wxLayoutTreeStored::HitTest(wxMouseEvent& event, wxDC& dc)
|
||||
{
|
||||
wxPoint pt = event.GetPosition();
|
||||
wxCoord x = pt.x;
|
||||
wxCoord y = pt.y;
|
||||
|
||||
int i;
|
||||
for (i = 0; i < m_maxNodes; i++)
|
||||
{
|
||||
wxStoredNode* item = &m_nodes[i];
|
||||
|
||||
long width, height;
|
||||
dc.GetTextExtent(m_nodes[i].m_name, &width, &height);
|
||||
|
||||
if ( (x >= (m_nodes[i].m_x-10)) && (x < (m_nodes[i].m_x + width+10)) &&
|
||||
(y >= m_nodes[i].m_y-10) && (y < (m_nodes[i].m_y + height+10)) )
|
||||
{
|
||||
return m_nodes[i].m_name;
|
||||
}
|
||||
}
|
||||
|
||||
return wxString("");
|
||||
}
|
||||
|
||||
#endif
|
||||
// wxUSE_TREELAYOUT
|
@@ -1,6 +1,6 @@
|
||||
|
||||
|
||||
# This file was automatically generated by tmake at 15:17, 2000/02/27
|
||||
# This file was automatically generated by tmake at 12:24, 2000/02/28
|
||||
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE B32.T!
|
||||
|
||||
#
|
||||
@@ -98,6 +98,7 @@ GENERICOBJS= $(MSWDIR)\busyinfo.obj \
|
||||
$(MSWDIR)\tbarsmpl.obj \
|
||||
$(MSWDIR)\textdlgg.obj \
|
||||
$(MSWDIR)\tipdlg.obj \
|
||||
$(MSWDIR)\treelay.obj \
|
||||
$(MSWDIR)\wizard.obj
|
||||
|
||||
# Not needed:
|
||||
@@ -827,6 +828,8 @@ $(MSWDIR)\textdlgg.obj: $(GENDIR)\textdlgg.$(SRCSUFF)
|
||||
|
||||
$(MSWDIR)\tipdlg.obj: $(GENDIR)\tipdlg.$(SRCSUFF)
|
||||
|
||||
$(MSWDIR)\treelay.obj: $(GENDIR)\treelay.$(SRCSUFF)
|
||||
|
||||
$(MSWDIR)\wizard.obj: $(GENDIR)\wizard.$(SRCSUFF)
|
||||
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
|
||||
|
||||
# This file was automatically generated by tmake at 15:18, 2000/02/27
|
||||
# This file was automatically generated by tmake at 12:24, 2000/02/28
|
||||
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE BCC.T!
|
||||
|
||||
#
|
||||
@@ -99,6 +99,7 @@ GENERICOBJS= $(MSWDIR)\busyinfo.obj \
|
||||
$(MSWDIR)\textdlgg.obj \
|
||||
$(MSWDIR)\tipdlg.obj \
|
||||
$(MSWDIR)\treectrl.obj \
|
||||
$(MSWDIR)\treelay.obj \
|
||||
$(MSWDIR)\wizard.obj
|
||||
|
||||
COMMONOBJS = \
|
||||
@@ -692,6 +693,8 @@ $(MSWDIR)\tipdlg.obj: $(GENDIR)\tipdlg.$(SRCSUFF)
|
||||
|
||||
$(MSWDIR)\treectrl.obj: $(GENDIR)\treectrl.$(SRCSUFF)
|
||||
|
||||
$(MSWDIR)\treelay.obj: $(GENDIR)\treelay.$(SRCSUFF)
|
||||
|
||||
$(MSWDIR)\wizard.obj: $(GENDIR)\wizard.$(SRCSUFF)
|
||||
|
||||
|
||||
|
@@ -84,6 +84,7 @@ GENERICOBJS= $(GENDIR)\busyinfo.obj \
|
||||
$(GENDIR)\textdlgg.obj \
|
||||
$(GENDIR)\tipdlg.obj \
|
||||
$(GENDIR)\treectrl.obj \
|
||||
$(GENDIR)\treelay.obj \
|
||||
$(GENDIR)\wizard.obj
|
||||
|
||||
# we can't have all objects in one list because the library becomes too big
|
||||
|
@@ -89,6 +89,7 @@ GENERICOBJS = \
|
||||
$(GENDIR)/tbarsmpl.$(OBJSUFF) \
|
||||
$(GENDIR)/textdlgg.$(OBJSUFF) \
|
||||
$(GENDIR)/tipdlg.$(OBJSUFF) \
|
||||
$(GENDIR)/treelay.$(OBJSUFF) \
|
||||
$(GENDIR)/wizard.$(OBJSUFF)
|
||||
|
||||
COMMONOBJS = \
|
||||
|
@@ -1,4 +1,4 @@
|
||||
# This file was automatically generated by tmake at 15:17, 2000/02/27
|
||||
# This file was automatically generated by tmake at 12:24, 2000/02/28
|
||||
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE VC.T!
|
||||
|
||||
# File: makefile.vc
|
||||
@@ -103,6 +103,7 @@ GENERICOBJS= ..\generic\$D\busyinfo.obj \
|
||||
..\generic\$D\tbarsmpl.obj \
|
||||
..\generic\$D\textdlgg.obj \
|
||||
..\generic\$D\tipdlg.obj \
|
||||
..\generic\$D\treelay.obj \
|
||||
..\generic\$D\wizard.obj
|
||||
|
||||
# These are generic things that don't need to be compiled on MSW,
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#!/binb/wmake.exe
|
||||
|
||||
# This file was automatically generated by tmake at 15:18, 2000/02/27
|
||||
# This file was automatically generated by tmake at 12:25, 2000/02/28
|
||||
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE WAT.T!
|
||||
|
||||
#
|
||||
@@ -59,6 +59,7 @@ GENERICOBJS= busyinfo.obj &
|
||||
tbarsmpl.obj &
|
||||
textdlgg.obj &
|
||||
tipdlg.obj &
|
||||
treelay.obj &
|
||||
wizard.obj
|
||||
|
||||
# These are generic things that don't need to be compiled on MSW,
|
||||
@@ -998,6 +999,9 @@ textdlgg.obj: $(GENDIR)\textdlgg.cpp
|
||||
tipdlg.obj: $(GENDIR)\tipdlg.cpp
|
||||
*$(CCC) $(CPPFLAGS) $(IFLAGS) $<
|
||||
|
||||
treelay.obj: $(GENDIR)\treelay.cpp
|
||||
*$(CCC) $(CPPFLAGS) $(IFLAGS) $<
|
||||
|
||||
wizard.obj: $(GENDIR)\wizard.cpp
|
||||
*$(CCC) $(CPPFLAGS) $(IFLAGS) $<
|
||||
|
||||
|
@@ -592,6 +592,10 @@ SOURCE=.\generic\tipdlg.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\generic\treelay.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\generic\wizard.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
|
@@ -592,6 +592,14 @@ SOURCE=.\generic\textdlgg.cpp
|
||||
|
||||
SOURCE=.\generic\tipdlg.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\generic\treelay.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\generic\wizard.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "wxHTML Files"
|
||||
|
||||
|
@@ -1,3 +0,0 @@
|
||||
all:
|
||||
cd @GL_TOOLKIT_DIR@; make
|
||||
cd samples; make
|
@@ -1,40 +0,0 @@
|
||||
docs/*.*
|
||||
win/*.cpp
|
||||
win/*.h
|
||||
win/make*.*
|
||||
gtk/*.cpp
|
||||
gtk/*.h
|
||||
gtk/make*.*
|
||||
motif/*.cpp
|
||||
motif/*.h
|
||||
motif/*.txt
|
||||
motif/make*.*
|
||||
samples/cube/*.cpp
|
||||
samples/cube/*.h
|
||||
samples/cube/*.rc
|
||||
samples/cube/*.ico
|
||||
samples/cube/*.xbm
|
||||
samples/cube/make*.*
|
||||
samples/cube/Makefile
|
||||
samples/isosurf/*.cpp
|
||||
samples/isosurf/*.h
|
||||
samples/isosurf/*.rc
|
||||
samples/isosurf/*.ico
|
||||
samples/isosurf/*.xbm
|
||||
samples/isosurf/*.dat
|
||||
samples/isosurf/*.dat.gz
|
||||
samples/isosurf/make*.*
|
||||
samples/isosurf/Makefile
|
||||
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
|
||||
samples/penguin/Makefile
|
||||
|
||||
|
||||
|
@@ -1,27 +0,0 @@
|
||||
@echo off
|
||||
rem Zip up an external source distribution of GLCanvas
|
||||
set src=%1
|
||||
set dest=%2
|
||||
if "%src" == "" set src=%WXWIN\utils\glcanvas
|
||||
if "%dest" == "" set dest=%WXWIN\utils\glcanvas\deliver
|
||||
echo About to archive an external GLCanvas distribution:
|
||||
echo From %src
|
||||
echo To %dest\glcanvas.zip
|
||||
echo CTRL-C if this is not correct.
|
||||
inkey /W10 `Press any key to continue...` %%input
|
||||
|
||||
erase %dest\glcanvas.zip
|
||||
cd %src
|
||||
|
||||
zip32 -@ %dest\glcanvas.zip < %src\distrib\glcanvas.rsp
|
||||
|
||||
echo GLCanvas archived.
|
||||
goto end
|
||||
|
||||
:usage
|
||||
echo GLCanvas distribution.
|
||||
echo Usage: zipsrc source destination
|
||||
|
||||
:end
|
||||
|
||||
|
@@ -1,5 +0,0 @@
|
||||
wxGLCanvas
|
||||
----------
|
||||
|
||||
No known issues, though probably palettes aren't correctly
|
||||
handled under Windows. They are ignored under GTK.
|
@@ -1,3 +0,0 @@
|
||||
Linux
|
||||
linux-gnu
|
||||
linux
|
@@ -1,22 +0,0 @@
|
||||
#
|
||||
# File: Makefile
|
||||
# Author: Robert Roebling
|
||||
# Created: 1999
|
||||
# Updated:
|
||||
# Copyright: (c) 1998 Robert Roebling
|
||||
#
|
||||
# "%W% %G%"
|
||||
#
|
||||
# Makefile for wxMultiMedia (UNIX).
|
||||
|
||||
top_srcdir = @top_srcdir@/..
|
||||
top_builddir = ../../..
|
||||
|
||||
VPATH= $(top_srcdir)/utils/glcanvas/gtk
|
||||
|
||||
LIBTARGET=libwxglcanvas
|
||||
|
||||
OBJECTS=glcanvas.o
|
||||
|
||||
include $(top_builddir)/src/makelib.env
|
||||
|
@@ -1,424 +0,0 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: glcanvas.cpp
|
||||
// Purpose: wxGLCanvas, for using OpenGL/Mesa with wxWindows and GTK
|
||||
// Author: Robert Roebling
|
||||
// Modified by:
|
||||
// Created: 17/08/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Robert Roebling
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "glcanvas.h"
|
||||
#endif
|
||||
|
||||
#include "glcanvas.h"
|
||||
|
||||
#include "wx/frame.h"
|
||||
#include "wx/colour.h"
|
||||
#include "wx/module.h"
|
||||
#include "wx/app.h"
|
||||
|
||||
extern "C" {
|
||||
#include "gtk/gtk.h"
|
||||
#include "gdk/gdk.h"
|
||||
#include "gdk/gdkx.h"
|
||||
}
|
||||
|
||||
#include "wx/gtk/win_gtk.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// global data
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
XVisualInfo *g_vi = (XVisualInfo*) NULL;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// idle system
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
extern void wxapp_install_idle_handler();
|
||||
extern bool g_isIdle;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// wxGLContext
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
IMPLEMENT_CLASS(wxGLContext,wxObject)
|
||||
|
||||
wxGLContext::wxGLContext( bool WXUNUSED(isRGB), wxWindow *win, const wxPalette& WXUNUSED(palette) )
|
||||
{
|
||||
m_window = win;
|
||||
m_widget = win->m_wxwindow;
|
||||
|
||||
wxGLCanvas *gc = (wxGLCanvas*) win;
|
||||
XVisualInfo *vi = (XVisualInfo *) gc->m_vi;
|
||||
|
||||
wxCHECK_RET( vi, "invalid visual for OpenGl" );
|
||||
|
||||
m_glContext = glXCreateContext( GDK_DISPLAY(), vi, None, GL_TRUE );
|
||||
|
||||
wxCHECK_RET( m_glContext, "Couldn't create OpenGl context" );
|
||||
}
|
||||
|
||||
wxGLContext::wxGLContext(
|
||||
bool WXUNUSED(isRGB), wxWindow *win,
|
||||
const wxPalette& WXUNUSED(palette),
|
||||
const wxGLContext *other /* for sharing display lists */
|
||||
)
|
||||
{
|
||||
m_window = win;
|
||||
m_widget = win->m_wxwindow;
|
||||
|
||||
wxGLCanvas *gc = (wxGLCanvas*) win;
|
||||
XVisualInfo *vi = (XVisualInfo *) gc->m_vi;
|
||||
|
||||
wxCHECK_RET( vi, "invalid visual for OpenGl" );
|
||||
|
||||
if( other != 0 )
|
||||
m_glContext = glXCreateContext( GDK_DISPLAY(), vi, other->m_glContext, GL_TRUE );
|
||||
else
|
||||
m_glContext = glXCreateContext( GDK_DISPLAY(), vi, None, GL_TRUE );
|
||||
|
||||
wxCHECK_RET( m_glContext, "Couldn't create OpenGl context" );
|
||||
}
|
||||
|
||||
wxGLContext::~wxGLContext()
|
||||
{
|
||||
if (!m_glContext) return;
|
||||
|
||||
if (m_glContext == glXGetCurrentContext())
|
||||
{
|
||||
glXMakeCurrent( GDK_DISPLAY(), None, NULL);
|
||||
}
|
||||
|
||||
glXDestroyContext( GDK_DISPLAY(), m_glContext );
|
||||
}
|
||||
|
||||
void wxGLContext::SwapBuffers()
|
||||
{
|
||||
if (m_glContext)
|
||||
{
|
||||
GdkWindow *window = GTK_PIZZA(m_widget)->bin_window;
|
||||
glXSwapBuffers( GDK_DISPLAY(), GDK_WINDOW_XWINDOW( window ) );
|
||||
}
|
||||
}
|
||||
|
||||
void wxGLContext::SetCurrent()
|
||||
{
|
||||
if (m_glContext)
|
||||
{
|
||||
GdkWindow *window = GTK_PIZZA(m_widget)->bin_window;
|
||||
glXMakeCurrent( GDK_DISPLAY(), GDK_WINDOW_XWINDOW(window), m_glContext );
|
||||
}
|
||||
}
|
||||
|
||||
void wxGLContext::SetColour(const char *colour)
|
||||
{
|
||||
float r = 0.0;
|
||||
float g = 0.0;
|
||||
float b = 0.0;
|
||||
wxColour *col = wxTheColourDatabase->FindColour(colour);
|
||||
if (col)
|
||||
{
|
||||
r = (float)(col->Red()/256.0);
|
||||
g = (float)(col->Green()/256.0);
|
||||
b = (float)(col->Blue()/256.0);
|
||||
glColor3f( r, g, b);
|
||||
}
|
||||
}
|
||||
|
||||
void wxGLContext::SetupPixelFormat()
|
||||
{
|
||||
}
|
||||
|
||||
void wxGLContext::SetupPalette( const wxPalette& WXUNUSED(palette) )
|
||||
{
|
||||
}
|
||||
|
||||
wxPalette wxGLContext::CreateDefaultPalette()
|
||||
{
|
||||
return wxNullPalette;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "realize" from m_wxwindow
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static gint
|
||||
gtk_glwindow_realized_callback( GtkWidget * WXUNUSED(widget), wxGLCanvas *win )
|
||||
{
|
||||
wxGLContext *share= win->m_sharedContext;
|
||||
if (share==NULL && win->m_sharedContextOf) share=win->m_sharedContextOf->GetContext();
|
||||
|
||||
win->m_glContext = new wxGLContext( TRUE, win, wxNullPalette, share );
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "map" from m_wxwindow
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static gint
|
||||
gtk_glwindow_map_callback( GtkWidget * WXUNUSED(widget), wxGLCanvas *win )
|
||||
{
|
||||
if (win->m_glContext/* && win->m_exposed*/)
|
||||
{
|
||||
wxPaintEvent event( win->GetId() );
|
||||
event.SetEventObject( win );
|
||||
win->GetEventHandler()->ProcessEvent( event );
|
||||
|
||||
win->m_exposed = FALSE;
|
||||
win->GetUpdateRegion().Clear();
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "expose_event" of m_wxwindow
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static void
|
||||
gtk_glwindow_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExpose *gdk_event, wxGLCanvas *win )
|
||||
{
|
||||
if (g_isIdle)
|
||||
wxapp_install_idle_handler();
|
||||
|
||||
win->m_exposed = TRUE;
|
||||
|
||||
win->GetUpdateRegion().Union( gdk_event->area.x,
|
||||
gdk_event->area.y,
|
||||
gdk_event->area.width,
|
||||
gdk_event->area.height );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "draw" of m_wxwindow
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static void
|
||||
gtk_glwindow_draw_callback( GtkWidget *WXUNUSED(widget), GdkRectangle *rect, wxGLCanvas *win )
|
||||
{
|
||||
if (g_isIdle)
|
||||
wxapp_install_idle_handler();
|
||||
|
||||
win->m_exposed = TRUE;
|
||||
|
||||
win->GetUpdateRegion().Union( rect->x, rect->y,
|
||||
rect->width, rect->height );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "size_allocate" of m_wxwindow
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static void
|
||||
gtk_glcanvas_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxGLCanvas *win )
|
||||
{
|
||||
if (g_isIdle)
|
||||
wxapp_install_idle_handler();
|
||||
|
||||
if (!win->m_hasVMT)
|
||||
return;
|
||||
|
||||
wxSizeEvent event( wxSize(win->m_width,win->m_height), win->GetId() );
|
||||
event.SetEventObject( win );
|
||||
win->GetEventHandler()->ProcessEvent( event );
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// wxGlCanvas
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
IMPLEMENT_CLASS(wxGLCanvas, wxScrolledWindow)
|
||||
|
||||
BEGIN_EVENT_TABLE(wxGLCanvas, wxScrolledWindow)
|
||||
EVT_SIZE(wxGLCanvas::OnSize)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
wxGLCanvas::wxGLCanvas( wxWindow *parent, wxWindowID id,
|
||||
const wxPoint& pos, const wxSize& size,
|
||||
long style, const wxString& name,
|
||||
int *attribList,
|
||||
const wxPalette& palette )
|
||||
{
|
||||
Create( parent, NULL, NULL, id, pos, size, style, name, attribList, palette );
|
||||
}
|
||||
|
||||
wxGLCanvas::wxGLCanvas( wxWindow *parent,
|
||||
const wxGLContext *shared,
|
||||
wxWindowID id,
|
||||
const wxPoint& pos, const wxSize& size,
|
||||
long style, const wxString& name,
|
||||
int *attribList,
|
||||
const wxPalette& palette )
|
||||
{
|
||||
Create( parent, shared, NULL, id, pos, size, style, name, attribList, palette );
|
||||
}
|
||||
|
||||
wxGLCanvas::wxGLCanvas( wxWindow *parent,
|
||||
const wxGLCanvas *shared,
|
||||
wxWindowID id,
|
||||
const wxPoint& pos, const wxSize& size,
|
||||
long style, const wxString& name,
|
||||
int *attribList,
|
||||
const wxPalette& palette )
|
||||
{
|
||||
Create( parent, NULL, shared, id, pos, size, style, name, attribList, palette );
|
||||
}
|
||||
|
||||
bool wxGLCanvas::Create( wxWindow *parent,
|
||||
const wxGLContext *shared,
|
||||
const wxGLCanvas *shared_context_of,
|
||||
wxWindowID id,
|
||||
const wxPoint& pos, const wxSize& size,
|
||||
long style, const wxString& name,
|
||||
int *attribList,
|
||||
const wxPalette& palette)
|
||||
{
|
||||
m_sharedContext = (wxGLContext*)shared; // const_cast
|
||||
m_sharedContextOf = (wxGLCanvas*)shared_context_of; // const_cast
|
||||
m_glContext = (wxGLContext*) NULL;
|
||||
|
||||
m_exposed = FALSE;
|
||||
m_noExpose = TRUE;
|
||||
m_nativeSizeEvent = TRUE;
|
||||
|
||||
if (!attribList)
|
||||
{
|
||||
int data[] = { GLX_RGBA,
|
||||
GLX_DOUBLEBUFFER,
|
||||
GLX_DEPTH_SIZE, 1, // use largest available depth buffer
|
||||
GLX_RED_SIZE, 1,
|
||||
GLX_GREEN_SIZE, 1,
|
||||
GLX_BLUE_SIZE, 1,
|
||||
GLX_ALPHA_SIZE, 0,
|
||||
None };
|
||||
attribList = (int*) data;
|
||||
}
|
||||
else
|
||||
{
|
||||
int data[512], arg=0, p=0;
|
||||
|
||||
while( (attribList[arg]!=0) && (p<512) )
|
||||
{
|
||||
switch( attribList[arg++] )
|
||||
{
|
||||
case WX_GL_RGBA: data[p++] = GLX_RGBA; break;
|
||||
case WX_GL_DOUBLEBUFFER: data[p++] = GLX_DOUBLEBUFFER; break;
|
||||
case WX_GL_DEPTH_SIZE:
|
||||
data[p++]=GLX_DEPTH_SIZE; data[p++]=attribList[arg++]; break;
|
||||
case WX_GL_MIN_RED:
|
||||
data[p++]=GLX_RED_SIZE; data[p++]=attribList[arg++]; break;
|
||||
case WX_GL_MIN_GREEN:
|
||||
data[p++]=GLX_GREEN_SIZE; data[p++]=attribList[arg++]; break;
|
||||
case WX_GL_MIN_BLUE:
|
||||
data[p++]=GLX_BLUE_SIZE; data[p++]=attribList[arg++]; break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
data[p] = 0;
|
||||
|
||||
attribList = (int*) data;
|
||||
}
|
||||
|
||||
|
||||
Display *dpy = GDK_DISPLAY();
|
||||
|
||||
XVisualInfo *vi = glXChooseVisual( dpy, DefaultScreen(dpy), attribList );
|
||||
|
||||
m_vi = vi; // safe for later use
|
||||
|
||||
wxCHECK_MSG( m_vi, FALSE, "required visual couldn't be found" );
|
||||
|
||||
GdkVisual *visual = gdkx_visual_get( vi->visualid );
|
||||
GdkColormap *colormap = gdk_colormap_new( gdkx_visual_get(vi->visualid), TRUE );
|
||||
|
||||
gtk_widget_push_colormap( colormap );
|
||||
gtk_widget_push_visual( visual );
|
||||
|
||||
wxScrolledWindow::Create( parent, id, pos, size, style, name );
|
||||
|
||||
m_glWidget = m_wxwindow;
|
||||
|
||||
gtk_pizza_set_clear( GTK_PIZZA(m_wxwindow), FALSE );
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT(m_wxwindow), "realize",
|
||||
GTK_SIGNAL_FUNC(gtk_glwindow_realized_callback), (gpointer) this );
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT(m_wxwindow), "map",
|
||||
GTK_SIGNAL_FUNC(gtk_glwindow_map_callback), (gpointer) this );
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT(m_wxwindow), "expose_event",
|
||||
GTK_SIGNAL_FUNC(gtk_glwindow_expose_callback), (gpointer)this );
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT(m_wxwindow), "draw",
|
||||
GTK_SIGNAL_FUNC(gtk_glwindow_draw_callback), (gpointer)this );
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
|
||||
GTK_SIGNAL_FUNC(gtk_glcanvas_size_callback), (gpointer)this );
|
||||
|
||||
gtk_widget_pop_visual();
|
||||
gtk_widget_pop_colormap();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
wxGLCanvas::~wxGLCanvas()
|
||||
{
|
||||
XVisualInfo *vi = (XVisualInfo *) m_vi;
|
||||
|
||||
if (vi) XFree( vi );
|
||||
if (m_glContext) delete m_glContext;
|
||||
}
|
||||
|
||||
void wxGLCanvas::SwapBuffers()
|
||||
{
|
||||
if (m_glContext) m_glContext->SwapBuffers();
|
||||
}
|
||||
|
||||
void wxGLCanvas::OnSize(wxSizeEvent& WXUNUSED(event))
|
||||
{
|
||||
int width, height;
|
||||
GetClientSize( &width, &height );
|
||||
|
||||
if (m_glContext && GTK_WIDGET_REALIZED(m_glWidget) )
|
||||
{
|
||||
SetCurrent();
|
||||
|
||||
glViewport(0, 0, (GLint)width, (GLint)height );
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glFrustum( -1.0, 1.0, -1.0, 1.0, 5.0, 15.0 );
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
}
|
||||
|
||||
void wxGLCanvas::SetCurrent()
|
||||
{
|
||||
if (m_glContext) m_glContext->SetCurrent();
|
||||
}
|
||||
|
||||
void wxGLCanvas::SetColour( const char *colour )
|
||||
{
|
||||
if (m_glContext) m_glContext->SetColour( colour );
|
||||
}
|
||||
|
||||
void wxGLCanvas::OnInternalIdle()
|
||||
{
|
||||
if (m_glContext && m_exposed)
|
||||
{
|
||||
wxPaintEvent event( GetId() );
|
||||
event.SetEventObject( this );
|
||||
GetEventHandler()->ProcessEvent( event );
|
||||
|
||||
m_exposed = FALSE;
|
||||
GetUpdateRegion().Clear();
|
||||
}
|
||||
|
||||
wxWindow::OnInternalIdle();
|
||||
}
|
@@ -1,161 +0,0 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: glcanvas.h
|
||||
// Purpose: wxGLCanvas, for using OpenGL/Mesa with wxWindows and GTK
|
||||
// Author: Robert Roebling
|
||||
// Modified by:
|
||||
// Created: 17/8/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Robert Roebling
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface "glcanvas.h"
|
||||
#endif
|
||||
|
||||
#ifndef _WX_GLCANVAS_H_
|
||||
#define _WX_GLCANVAS_H_
|
||||
|
||||
#include "wx/defs.h"
|
||||
#include "wx/scrolwin.h"
|
||||
|
||||
extern "C" {
|
||||
#include "GL/gl.h"
|
||||
#include "GL/glx.h"
|
||||
#include "GL/glu.h"
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Constants for attriblist
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
enum
|
||||
{
|
||||
WX_GL_RGBA=1, /* use true color palette */
|
||||
WX_GL_DEPTH_SIZE, /* bits for Z-buffer (0,16,32) */
|
||||
WX_GL_DOUBLEBUFFER, /* use doublebuffer */
|
||||
WX_GL_MIN_RED, /* use red buffer with most bits (> MIN_RED bits) */
|
||||
WX_GL_MIN_GREEN, /* use green buffer with most bits (> MIN_GREEN bits) */
|
||||
WX_GL_MIN_BLUE /* use blue buffer with most bits (> MIN_BLUE bits) */
|
||||
/* these are enough constants for now, the remaining will be added later */
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// classes
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
class wxGLContext;
|
||||
class wxGLCanvas;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// wxGLContext
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
|
||||
class wxGLContext: public wxObject
|
||||
{
|
||||
public:
|
||||
wxGLContext( bool isRGB, wxWindow *win, const wxPalette& palette = wxNullPalette );
|
||||
wxGLContext(
|
||||
bool WXUNUSED(isRGB), wxWindow *win,
|
||||
const wxPalette& WXUNUSED(palette),
|
||||
const wxGLContext *other /* for sharing display lists */
|
||||
);
|
||||
~wxGLContext();
|
||||
|
||||
void SetCurrent();
|
||||
void SetColour(const char *colour);
|
||||
void SwapBuffers();
|
||||
|
||||
void SetupPixelFormat();
|
||||
void SetupPalette(const wxPalette& palette);
|
||||
wxPalette CreateDefaultPalette();
|
||||
|
||||
inline wxPalette* GetPalette() const { return (wxPalette*) & m_palette; }
|
||||
inline wxWindow* GetWindow() const { return m_window; }
|
||||
inline GtkWidget* GetWidget() const { return m_widget; }
|
||||
inline GLXContext GetContext() const { return m_glContext; }
|
||||
|
||||
public:
|
||||
GLXContext m_glContext;
|
||||
|
||||
GtkWidget *m_widget;
|
||||
wxPalette m_palette;
|
||||
wxWindow* m_window;
|
||||
|
||||
private:
|
||||
DECLARE_CLASS(wxGLContext)
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// wxGLContext
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
class wxGLCanvas: public wxScrolledWindow
|
||||
{
|
||||
public:
|
||||
inline wxGLCanvas() {
|
||||
m_glContext = (wxGLContext*) NULL;
|
||||
m_sharedContext = (wxGLContext*) NULL;
|
||||
m_glWidget = (GtkWidget*) NULL;
|
||||
m_vi = (void*) NULL;
|
||||
m_exposed = FALSE;
|
||||
}
|
||||
wxGLCanvas( wxWindow *parent, wxWindowID id = -1,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = 0, const wxString& name = "GLCanvas",
|
||||
int *attribList = (int*) NULL,
|
||||
const wxPalette& palette = wxNullPalette );
|
||||
wxGLCanvas( wxWindow *parent, const wxGLContext *shared = (wxGLContext *)NULL,
|
||||
wxWindowID id = -1,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = 0, const wxString& name = "GLCanvas",
|
||||
int *attribList = (int*) NULL,
|
||||
const wxPalette& palette = wxNullPalette );
|
||||
wxGLCanvas( wxWindow *parent, const wxGLCanvas *shared = (wxGLCanvas *)NULL,
|
||||
wxWindowID id = -1,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = 0, const wxString& name = "GLCanvas",
|
||||
int *attribList = (int*) NULL,
|
||||
const wxPalette& palette = wxNullPalette );
|
||||
|
||||
bool Create( wxWindow *parent,
|
||||
const wxGLContext *shared = (wxGLContext*)NULL,
|
||||
const wxGLCanvas *shared_context_of = (wxGLCanvas*)NULL,
|
||||
wxWindowID id = -1,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = 0, const wxString& name = "GLCanvas",
|
||||
int *attribList = (int*) NULL,
|
||||
const wxPalette& palette = wxNullPalette );
|
||||
|
||||
~wxGLCanvas();
|
||||
|
||||
void SetCurrent();
|
||||
void SetColour(const char *colour);
|
||||
void SwapBuffers();
|
||||
|
||||
void OnSize(wxSizeEvent& event);
|
||||
|
||||
void OnInternalIdle();
|
||||
|
||||
inline wxGLContext* GetContext() const { return m_glContext; }
|
||||
|
||||
// implementation
|
||||
|
||||
wxGLContext *m_glContext,
|
||||
*m_sharedContext;
|
||||
wxGLCanvas *m_sharedContextOf;
|
||||
void *m_vi;
|
||||
GtkWidget *m_glWidget;
|
||||
bool m_exposed;
|
||||
|
||||
private:
|
||||
DECLARE_EVENT_TABLE()
|
||||
DECLARE_CLASS(wxGLCanvas)
|
||||
};
|
||||
|
||||
#endif
|
@@ -1,161 +0,0 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: glcanvas.cpp
|
||||
// Purpose: wxGLCanvas, for using OpenGL with wxWindows 2.0 for Motif.
|
||||
// Uses the GLX extension.
|
||||
// Author: Julian Smart and Wolfram Gloger
|
||||
// Modified by:
|
||||
// Created: 1995, 1999
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart, Wolfram Gloger
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "glcanvas.h"
|
||||
#endif
|
||||
|
||||
#include "glcanvas.h"
|
||||
#include "wx/utils.h"
|
||||
#include "wx/app.h"
|
||||
|
||||
#include <Xm/Xm.h>
|
||||
#include "wx/motif/private.h"
|
||||
|
||||
#ifdef OLD_MESA
|
||||
// workaround for bug in Mesa's glx.c
|
||||
static int bitcount( unsigned long n )
|
||||
{
|
||||
int bits;
|
||||
for (bits=0; n>0;) {
|
||||
if(n & 1) bits++;
|
||||
n = n >> 1;
|
||||
}
|
||||
return bits;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* GLCanvas implementation
|
||||
*/
|
||||
|
||||
IMPLEMENT_CLASS(wxGLCanvas, wxScrolledWindow)
|
||||
|
||||
wxGLCanvas::wxGLCanvas(wxWindow *parent, wxWindowID id = -1, const wxPoint& pos,
|
||||
const wxSize& size, long style,
|
||||
const wxString& name, int *attrib_list, const wxPalette& palette):
|
||||
wxScrolledWindow(parent, id, pos, size, style, name)
|
||||
{
|
||||
XVisualInfo *vi, vi_templ;
|
||||
XWindowAttributes xwa;
|
||||
int val, n;
|
||||
|
||||
Display* display = (Display*) GetXDisplay();
|
||||
|
||||
glx_cx = 0;
|
||||
// Check for the presence of the GLX extension
|
||||
if(!glXQueryExtension(display, NULL, NULL)) {
|
||||
wxDebugMsg("wxGLCanvas: GLX extension is missing\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if(attrib_list) {
|
||||
// Get an appropriate visual
|
||||
vi = glXChooseVisual(display, DefaultScreen(display), attrib_list);
|
||||
if(!vi) return;
|
||||
|
||||
// Here we should make sure that vi is the same visual as the
|
||||
// one used by the xwindow drawable in wxCanvas. However,
|
||||
// there is currently no mechanism for this in wx_canvs.cc.
|
||||
} else {
|
||||
// By default, we use the visual of xwindow
|
||||
XGetWindowAttributes(display, (Window) GetXWindow(), &xwa);
|
||||
vi_templ.visualid = XVisualIDFromVisual(xwa.visual);
|
||||
vi = XGetVisualInfo(display, VisualIDMask, &vi_templ, &n);
|
||||
if(!vi) return;
|
||||
glXGetConfig(display, vi, GLX_USE_GL, &val);
|
||||
if(!val) return;
|
||||
// Basically, this is it. It should be possible to use vi
|
||||
// in glXCreateContext() below. But this fails with Mesa.
|
||||
// I notified the Mesa author about it; there may be a fix.
|
||||
#ifdef OLD_MESA
|
||||
// Construct an attribute list matching the visual
|
||||
int a_list[32];
|
||||
n = 0;
|
||||
if(vi->c_class==TrueColor || vi->c_class==DirectColor) { // RGBA visual
|
||||
a_list[n++] = GLX_RGBA;
|
||||
a_list[n++] = GLX_RED_SIZE;
|
||||
a_list[n++] = bitcount(vi->red_mask);
|
||||
a_list[n++] = GLX_GREEN_SIZE;
|
||||
a_list[n++] = bitcount(vi->green_mask);
|
||||
a_list[n++] = GLX_BLUE_SIZE;
|
||||
a_list[n++] = bitcount(vi->blue_mask);
|
||||
glXGetConfig(display, vi, GLX_ALPHA_SIZE, &val);
|
||||
a_list[n++] = GLX_ALPHA_SIZE;
|
||||
a_list[n++] = val;
|
||||
} else { // Color index visual
|
||||
glXGetConfig(display, vi, GLX_BUFFER_SIZE, &val);
|
||||
a_list[n++] = GLX_BUFFER_SIZE;
|
||||
a_list[n++] = val;
|
||||
}
|
||||
a_list[n] = None;
|
||||
XFree(vi);
|
||||
vi = glXChooseVisual(display, DefaultScreen(display), a_list);
|
||||
if(!vi) return;
|
||||
#endif /* OLD_MESA */
|
||||
}
|
||||
|
||||
// Create the GLX context and make it current
|
||||
glx_cx = glXCreateContext(display, vi, 0, GL_TRUE);
|
||||
#ifndef OLD_MESA
|
||||
XFree(vi);
|
||||
#endif
|
||||
SetCurrent();
|
||||
}
|
||||
|
||||
wxGLCanvas::~wxGLCanvas(void)
|
||||
{
|
||||
Display* display = (Display*) GetXDisplay();
|
||||
if(glx_cx) glXDestroyContext(display, glx_cx);
|
||||
}
|
||||
|
||||
void wxGLCanvas::SwapBuffers()
|
||||
{
|
||||
Display* display = (Display*) GetXDisplay();
|
||||
if(glx_cx) glXSwapBuffers(display, (Window) GetXWindow());
|
||||
}
|
||||
|
||||
void wxGLCanvas::SetCurrent()
|
||||
{
|
||||
Display* display = (Display*) GetXDisplay();
|
||||
if(glx_cx) glXMakeCurrent(display, (Window) GetXWindow(), glx_cx);
|
||||
}
|
||||
|
||||
void wxGLCanvas::SetColour(const char *col)
|
||||
{
|
||||
wxColour *the_colour = wxTheColourDatabase->FindColour(col);
|
||||
if(the_colour) {
|
||||
GLboolean b;
|
||||
glGetBooleanv(GL_RGBA_MODE, &b);
|
||||
if(b) {
|
||||
glColor3ub(the_colour->Red(),
|
||||
the_colour->Green(),
|
||||
the_colour->Blue());
|
||||
} else {
|
||||
GLint pix = (GLint)the_colour->m_pixel;
|
||||
if(pix == -1) {
|
||||
XColor exact_def;
|
||||
exact_def.red = (unsigned short)the_colour->Red() << 8;
|
||||
exact_def.green = (unsigned short)the_colour->Green() << 8;
|
||||
exact_def.blue = (unsigned short)the_colour->Blue() << 8;
|
||||
exact_def.flags = DoRed | DoGreen | DoBlue;
|
||||
if(!XAllocColor((Display*) GetXDisplay(), (Colormap) wxTheApp->GetMainColormap(GetXDisplay()), &exact_def)) {
|
||||
wxDebugMsg("wxGLCanvas: cannot allocate color\n");
|
||||
return;
|
||||
}
|
||||
pix = the_colour->m_pixel = exact_def.pixel;
|
||||
}
|
||||
glIndexi(pix);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,46 +0,0 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: glcanvas.h
|
||||
// Purpose: wxGLCanvas, for using OpenGL with wxWindows 2.0 for Motif.
|
||||
// Uses the GLX extension.
|
||||
// Author: Julian Smart and Wolfram Gloger
|
||||
// Modified by:
|
||||
// Created: 1995, 1999
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart, Wolfram Gloger
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface "glcanvas.h"
|
||||
#endif
|
||||
|
||||
#ifndef _WX_GLCANVAS_H_
|
||||
#define _WX_GLCANVAS_H_
|
||||
|
||||
#include "wx/setup.h"
|
||||
#include "wx/gdicmn.h"
|
||||
#include "wx/palette.h"
|
||||
#include "wx/scrolwin.h"
|
||||
|
||||
#include <GL/glx.h>
|
||||
|
||||
class wxGLCanvas: public wxScrolledWindow
|
||||
{
|
||||
DECLARE_CLASS(wxGLCanvas)
|
||||
public:
|
||||
GLXContext glx_cx;
|
||||
|
||||
inline wxGLCanvas() { glx_cx = 0; }
|
||||
|
||||
wxGLCanvas(wxWindow *parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize, long style = 0,
|
||||
const wxString& name = "GLCanvas", int *attribList = 0, const wxPalette& palette = wxNullPalette);
|
||||
~wxGLCanvas(void);
|
||||
|
||||
void SetCurrent();
|
||||
void SwapBuffers();
|
||||
void SetColour(const char *col);
|
||||
};
|
||||
|
||||
#endif
|
||||
// _WX_GLCANVAS_H_
|
@@ -1,20 +0,0 @@
|
||||
#
|
||||
# File: makefile.unx
|
||||
# Author: Julian Smart
|
||||
# Created: 1998
|
||||
# Updated:
|
||||
# Copyright: (c) 1998 Julia`n Smart
|
||||
#
|
||||
# "%W% %G%"
|
||||
#
|
||||
# Makefile for wxGLCanvas (Unix)
|
||||
|
||||
LIBTARGET=$(WXWIN)/lib/libglcanvas
|
||||
OPENGLHOME=/home/jacs/mesa/Mesa-2.3
|
||||
|
||||
EXTRACPPFLAGS=-I$(OPENGLHOME)/include
|
||||
|
||||
OBJECTS=glcanvas.o
|
||||
|
||||
include ../../../src/makelib.env
|
||||
|
@@ -1,52 +0,0 @@
|
||||
GLCanvas class for wxWindows 1.66 using the GLX protocol extension
|
||||
==================================================================
|
||||
|
||||
I have just uploaded a file 'wx166glx.tar.gz' to the wxWindows
|
||||
incoming directory. It contains an implementation of a GLCanvas class
|
||||
(interfacing an ordinary wxCanvas with OpenGL calls) for X11 (I tested
|
||||
with Motif, maybe it works with XView as well). I tried to imitate
|
||||
what Julian did in 'wxmesa1.zip' for MS Windows in conjunction with
|
||||
the Mesa library.
|
||||
|
||||
Of the several possibilities to use OpenGL under X11, I chose the GLX
|
||||
server extension, because it is the most efficient method on machines
|
||||
with graphics hardware support (I expect wxWindows/OpenGL applications
|
||||
to _fly_ on my Indy :-). However, you don't need a 'real' OpenGL
|
||||
implementation to use GLCanvas -- the free Mesa library has a
|
||||
simulated GLX interface built-in. Just link in libMesaGLU and
|
||||
libMesaGL along with libwx_motif and everything should work fine.
|
||||
|
||||
Installation:
|
||||
|
||||
Untar wx166glx.tar.gz from your main wxWindows directory (i.e. where
|
||||
the `include' and `src' subdirectories are). Then apply the small
|
||||
patch file which has appeared in the `glx' subdirectory:
|
||||
|
||||
% patch -p0 < glx/wx166-glx.diff
|
||||
|
||||
Recompile the wx_motif library in the standard way. The inclusion of
|
||||
the GLCanvas class in libwx_motif is protected with a new 'USE_GLX'
|
||||
flag in wx_setup.h, so it could maybe be included in a future
|
||||
wxWindows release (with USE_GLX turned off by default).
|
||||
|
||||
Two new samples (bounce and prim) are included. I adapted them from
|
||||
wxmesa1.zip -- they should compile under both MS Windows (with wxMesa)
|
||||
and X11. The makefile.unx's are set up for the Mesa libraries; if you
|
||||
have original libGLU/libGL's just change the GLLIBS = ... line.
|
||||
|
||||
Problems:
|
||||
|
||||
One more or less serious problem remains: the visual generated by the
|
||||
GLCanvas class must match the visual of wxCanvas.xwindow (which
|
||||
currently is always the screen's default visual). The end result is
|
||||
that you will get a nice RGB mode for OpenGL only if your display's
|
||||
default visual is TrueColor or DirectColor (the XFree86 S3 servers for
|
||||
PCs with the '-bpp 16/32' option are examples). I'm contemplating a
|
||||
solution where the wxCanvas drawingarea widget is destroyed and then
|
||||
re-created from within the GLCanvas constructor. I would welcome
|
||||
suggestions on this and discussions of the GLCanvas 'API'.
|
||||
|
||||
Regards,
|
||||
|
||||
Wolfram Gloger.
|
||||
(Gloger@lrz.uni-muenchen.de)
|
@@ -1,31 +0,0 @@
|
||||
#
|
||||
# File: Makefile
|
||||
# Author: Robert Roebling
|
||||
# Created: 1999
|
||||
# Updated:
|
||||
# Copyright: (c) 1998 Robert Roebling
|
||||
#
|
||||
# Makefile for OpenGl demo (GTK version)
|
||||
#
|
||||
# This makefile requires wxWindows/GTK to be
|
||||
# installed (possibly using "make install")
|
||||
# on your system.
|
||||
#
|
||||
|
||||
CC = gcc
|
||||
WXCONFIG=../../../../wx-config
|
||||
WXINCLUDE=-I../../../../include
|
||||
WXLIB=-L../../../../lib
|
||||
|
||||
cube: cube.o glcanvas.o
|
||||
$(CC) -o cube cube.o glcanvas.o `$(WXCONFIG) --libs` $(WXLIB) -lMesaGL -lMesaGLU
|
||||
|
||||
cube.o: cube.cpp
|
||||
$(CC) `$(WXCONFIG) --cflags` -I../../gtk $(WXINCLUDE) -c cube.cpp
|
||||
|
||||
glcanvas.o: ../../gtk/glcanvas.cpp
|
||||
$(CC) `$(WXCONFIG) --cflags` `gtk-config --cflags` -I../../gtk $(WXINCLUDE) -c ../../gtk/glcanvas.cpp
|
||||
|
||||
clean:
|
||||
rm -f *.o cube
|
||||
|
@@ -1,505 +0,0 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: cube.cpp
|
||||
// Purpose: wxGLCanvas demo program
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 04/01/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#endif
|
||||
|
||||
#include "wx/log.h"
|
||||
|
||||
#include "cube.h"
|
||||
|
||||
#ifndef __WXMSW__ // for wxStopWatch, see remark below
|
||||
#include <sys/time.h>
|
||||
#include <sys/unistd.h>
|
||||
#else
|
||||
#include <sys/timeb.h>
|
||||
#endif
|
||||
|
||||
#define ID_NEW_WINDOW 10000
|
||||
#define ID_DEF_ROTATE_LEFT_KEY 10001
|
||||
#define ID_DEF_ROTATE_RIGHT_KEY 10002
|
||||
|
||||
/*----------------------------------------------------------
|
||||
Control to get a keycode
|
||||
----------------------------------------------------------*/
|
||||
class ScanCodeCtrl : public wxTextCtrl
|
||||
{
|
||||
public:
|
||||
ScanCodeCtrl( wxWindow* parent, wxWindowID id, int code,
|
||||
const wxPoint& pos, const wxSize& size );
|
||||
void OnChar( wxKeyEvent& event ) { } /* do nothing */
|
||||
void OnKeyDown(wxKeyEvent& event);
|
||||
private:
|
||||
// any class wishing to process wxWindows events must use this macro
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
BEGIN_EVENT_TABLE( ScanCodeCtrl, wxTextCtrl )
|
||||
EVT_CHAR( ScanCodeCtrl::OnChar )
|
||||
EVT_KEY_DOWN( ScanCodeCtrl::OnKeyDown )
|
||||
END_EVENT_TABLE()
|
||||
|
||||
ScanCodeCtrl::ScanCodeCtrl( wxWindow* parent, wxWindowID id, int code,
|
||||
const wxPoint& pos, const wxSize& size )
|
||||
: wxTextCtrl( parent, id, "", pos, size )
|
||||
{ wxString buf;
|
||||
buf.Printf( "0x%04x", code );
|
||||
SetValue( buf );
|
||||
}
|
||||
|
||||
void ScanCodeCtrl::OnKeyDown( wxKeyEvent& event )
|
||||
{ wxString buf;
|
||||
buf.Printf( "0x%04x", event.KeyCode() );
|
||||
SetValue( buf );
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------
|
||||
Dialog for defining a keypress
|
||||
-------------------------------------------------------------------*/
|
||||
|
||||
class ScanCodeDialog : public wxDialog
|
||||
{
|
||||
public:
|
||||
ScanCodeDialog( wxWindow* parent, wxWindowID id, const int code,
|
||||
const wxString &descr, const wxString& title );
|
||||
int GetValue();
|
||||
private:
|
||||
ScanCodeCtrl *m_ScanCode;
|
||||
wxTextCtrl *m_Description;
|
||||
};
|
||||
|
||||
ScanCodeDialog::ScanCodeDialog( wxWindow* parent, wxWindowID id,
|
||||
const int code, const wxString &descr, const wxString& title )
|
||||
: wxDialog( parent, id, title, wxPoint(-1, -1), wxSize(96*2,76*2) )
|
||||
{
|
||||
new wxStaticText( this, -1, "Scancode", wxPoint(4*2,3*2),
|
||||
wxSize(31*2,12*2) );
|
||||
m_ScanCode = new ScanCodeCtrl( this, -1, code, wxPoint(37*2,6*2),
|
||||
wxSize(53*2,14*2) );
|
||||
|
||||
new wxStaticText( this, -1, "Description", wxPoint(4*2,24*2),
|
||||
wxSize(32*2,12*2) );
|
||||
m_Description = new wxTextCtrl( this, -1, descr, wxPoint(37*2,27*2),
|
||||
wxSize(53*2,14*2) );
|
||||
|
||||
new wxButton( this, wxID_OK, "Ok", wxPoint(20*2,50*2), wxSize(20*2,13*2) );
|
||||
new wxButton( this, wxID_CANCEL, "Cancel", wxPoint(44*2,50*2),
|
||||
wxSize(25*2,13*2) );
|
||||
}
|
||||
|
||||
int ScanCodeDialog::GetValue()
|
||||
{
|
||||
int code;
|
||||
wxString buf = m_ScanCode->GetValue();
|
||||
sscanf( buf.c_str(), "%i", &code );
|
||||
return( code );
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Utility function to get the elapsed time (in msec) since a given point
|
||||
in time (in sec) (because current version of wxGetElapsedTime doesn<73>t
|
||||
works right with glibc-2.1 and linux, at least for me)
|
||||
-----------------------------------------------------------------------*/
|
||||
unsigned long wxStopWatch( unsigned long *sec_base )
|
||||
{
|
||||
unsigned long secs,msec;
|
||||
|
||||
#ifndef __WXMSW__ // think every unice has gettimeofday
|
||||
struct timeval tv;
|
||||
gettimeofday( &tv, (struct timezone *)NULL );
|
||||
secs = tv.tv_sec;
|
||||
msec = tv.tv_usec/1000;
|
||||
#else
|
||||
struct timeb tb;
|
||||
ftime( &tb );
|
||||
secs = tb.time;
|
||||
msec = tb.millitm;
|
||||
#endif
|
||||
|
||||
if( *sec_base == 0 )
|
||||
*sec_base = secs;
|
||||
|
||||
return( (secs-*sec_base)*1000 + msec );
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------
|
||||
Implementation of Test-GLCanvas
|
||||
-----------------------------------------------------------------*/
|
||||
|
||||
BEGIN_EVENT_TABLE(TestGLCanvas, wxGLCanvas)
|
||||
EVT_SIZE(TestGLCanvas::OnSize)
|
||||
EVT_PAINT(TestGLCanvas::OnPaint)
|
||||
EVT_ERASE_BACKGROUND(TestGLCanvas::OnEraseBackground)
|
||||
EVT_KEY_DOWN( TestGLCanvas::OnKeyDown )
|
||||
EVT_KEY_UP( TestGLCanvas::OnKeyUp )
|
||||
EVT_ENTER_WINDOW( TestGLCanvas::OnEnterWindow )
|
||||
END_EVENT_TABLE()
|
||||
|
||||
unsigned long TestGLCanvas::m_secbase = 0;
|
||||
int TestGLCanvas::m_TimeInitialized = 0;
|
||||
unsigned long TestGLCanvas::m_xsynct;
|
||||
unsigned long TestGLCanvas::m_gsynct;
|
||||
|
||||
|
||||
TestGLCanvas::TestGLCanvas(wxWindow *parent, wxWindowID id,
|
||||
const wxPoint& pos, const wxSize& size, long style, const wxString& name):
|
||||
wxGLCanvas(parent, NULL, id, pos, size, style, name )
|
||||
{
|
||||
m_init = FALSE;
|
||||
m_gllist = 0;
|
||||
m_rleft = WXK_LEFT;
|
||||
m_rright = WXK_RIGHT;
|
||||
}
|
||||
|
||||
TestGLCanvas::TestGLCanvas(wxWindow *parent, const TestGLCanvas &other,
|
||||
wxWindowID id, const wxPoint& pos, const wxSize& size, long style,
|
||||
const wxString& name ) :
|
||||
wxGLCanvas(parent, other.GetContext(), id, pos, size, style, name )
|
||||
{
|
||||
m_init = FALSE;
|
||||
m_gllist = other.m_gllist; /* share display list */
|
||||
m_rleft = WXK_LEFT;
|
||||
m_rright = WXK_RIGHT;
|
||||
}
|
||||
|
||||
TestGLCanvas::~TestGLCanvas()
|
||||
{
|
||||
}
|
||||
|
||||
void TestGLCanvas::Render()
|
||||
{
|
||||
wxPaintDC dc(this);
|
||||
|
||||
#ifndef __WXMOTIF__
|
||||
if (!GetContext()) return;
|
||||
#endif
|
||||
|
||||
SetCurrent();
|
||||
/* init OpenGL once, but after SetCurrent */
|
||||
if (!m_init)
|
||||
{
|
||||
InitGL();
|
||||
m_init = TRUE;
|
||||
}
|
||||
|
||||
/* clear color and depth buffers */
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
if( m_gllist == 0 )
|
||||
{
|
||||
m_gllist = glGenLists( 1 );
|
||||
glNewList( m_gllist, GL_COMPILE_AND_EXECUTE );
|
||||
/* draw six faces of a cube */
|
||||
glBegin(GL_QUADS);
|
||||
glNormal3f( 0.0F, 0.0F, 1.0F);
|
||||
glVertex3f( 0.5F, 0.5F, 0.5F); glVertex3f(-0.5F, 0.5F, 0.5F);
|
||||
glVertex3f(-0.5F,-0.5F, 0.5F); glVertex3f( 0.5F,-0.5F, 0.5F);
|
||||
|
||||
glNormal3f( 0.0F, 0.0F,-1.0F);
|
||||
glVertex3f(-0.5F,-0.5F,-0.5F); glVertex3f(-0.5F, 0.5F,-0.5F);
|
||||
glVertex3f( 0.5F, 0.5F,-0.5F); glVertex3f( 0.5F,-0.5F,-0.5F);
|
||||
|
||||
glNormal3f( 0.0F, 1.0F, 0.0F);
|
||||
glVertex3f( 0.5F, 0.5F, 0.5F); glVertex3f( 0.5F, 0.5F,-0.5F);
|
||||
glVertex3f(-0.5F, 0.5F,-0.5F); glVertex3f(-0.5F, 0.5F, 0.5F);
|
||||
|
||||
glNormal3f( 0.0F,-1.0F, 0.0F);
|
||||
glVertex3f(-0.5F,-0.5F,-0.5F); glVertex3f( 0.5F,-0.5F,-0.5F);
|
||||
glVertex3f( 0.5F,-0.5F, 0.5F); glVertex3f(-0.5F,-0.5F, 0.5F);
|
||||
|
||||
glNormal3f( 1.0F, 0.0F, 0.0F);
|
||||
glVertex3f( 0.5F, 0.5F, 0.5F); glVertex3f( 0.5F,-0.5F, 0.5F);
|
||||
glVertex3f( 0.5F,-0.5F,-0.5F); glVertex3f( 0.5F, 0.5F,-0.5F);
|
||||
|
||||
glNormal3f(-1.0F, 0.0F, 0.0F);
|
||||
glVertex3f(-0.5F,-0.5F,-0.5F); glVertex3f(-0.5F,-0.5F, 0.5F);
|
||||
glVertex3f(-0.5F, 0.5F, 0.5F); glVertex3f(-0.5F, 0.5F,-0.5F);
|
||||
glEnd();
|
||||
|
||||
glEndList();
|
||||
}
|
||||
else
|
||||
glCallList( m_gllist );
|
||||
|
||||
glFlush();
|
||||
SwapBuffers();
|
||||
}
|
||||
|
||||
void TestGLCanvas::OnEnterWindow( wxMouseEvent& event )
|
||||
{
|
||||
SetFocus();
|
||||
}
|
||||
|
||||
void TestGLCanvas::OnPaint( wxPaintEvent& event )
|
||||
{
|
||||
Render();
|
||||
}
|
||||
|
||||
void TestGLCanvas::OnSize(wxSizeEvent& event)
|
||||
{
|
||||
int width, height;
|
||||
GetClientSize(& width, & height);
|
||||
|
||||
#ifndef __WXMOTIF__
|
||||
if (GetContext())
|
||||
#endif
|
||||
{
|
||||
SetCurrent();
|
||||
glViewport(0, 0, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
void TestGLCanvas::OnEraseBackground(wxEraseEvent& event)
|
||||
{
|
||||
// Do nothing, to avoid flashing.
|
||||
}
|
||||
|
||||
void TestGLCanvas::InitGL()
|
||||
{
|
||||
SetCurrent();
|
||||
|
||||
/* set viewing projection */
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glFrustum(-0.5F, 0.5F, -0.5F, 0.5F, 1.0F, 3.0F);
|
||||
|
||||
/* position viewer */
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glTranslatef(0.0F, 0.0F, -2.0F);
|
||||
|
||||
/* position object */
|
||||
glRotatef(30.0F, 1.0F, 0.0F, 0.0F);
|
||||
glRotatef(30.0F, 0.0F, 1.0F, 0.0F);
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glEnable(GL_LIGHTING);
|
||||
glEnable(GL_LIGHT0);
|
||||
}
|
||||
|
||||
GLfloat TestGLCanvas::CalcRotateSpeed( unsigned long acceltime )
|
||||
{
|
||||
GLfloat t,v;
|
||||
|
||||
t = ((GLfloat)acceltime) / 1000.0f;
|
||||
|
||||
if( t < 0.5f )
|
||||
v = t;
|
||||
else if( t < 1.0f )
|
||||
v = t * (2.0f - t);
|
||||
else
|
||||
v = 0.75f;
|
||||
|
||||
return(v);
|
||||
}
|
||||
|
||||
GLfloat TestGLCanvas::CalcRotateAngle( unsigned long lasttime,
|
||||
unsigned long acceltime )
|
||||
{
|
||||
GLfloat t,s1,s2;
|
||||
|
||||
t = ((GLfloat)(acceltime - lasttime)) / 1000.0f;
|
||||
s1 = CalcRotateSpeed( lasttime );
|
||||
s2 = CalcRotateSpeed( acceltime );
|
||||
|
||||
return( t * (s1 + s2) * 135.0f );
|
||||
}
|
||||
|
||||
void TestGLCanvas::Action( long code, unsigned long lasttime,
|
||||
unsigned long acceltime )
|
||||
{
|
||||
GLfloat angle = CalcRotateAngle( lasttime, acceltime );
|
||||
|
||||
if (code == m_rleft)
|
||||
Rotate( angle );
|
||||
else if (code == m_rright)
|
||||
Rotate( -angle );
|
||||
}
|
||||
|
||||
void TestGLCanvas::OnKeyDown( wxKeyEvent& event )
|
||||
{
|
||||
long evkey = event.KeyCode();
|
||||
if (evkey == 0) return;
|
||||
|
||||
if (!m_TimeInitialized)
|
||||
{
|
||||
m_TimeInitialized = 1;
|
||||
m_xsynct = event.m_timeStamp;
|
||||
m_gsynct = wxStopWatch(&m_secbase);
|
||||
|
||||
m_Key = evkey;
|
||||
m_StartTime = 0;
|
||||
m_LastTime = 0;
|
||||
m_LastRedraw = 0;
|
||||
}
|
||||
|
||||
unsigned long currTime = event.m_timeStamp - m_xsynct;
|
||||
|
||||
if (evkey != m_Key)
|
||||
{
|
||||
m_Key = evkey;
|
||||
m_LastRedraw = m_StartTime = m_LastTime = currTime;
|
||||
}
|
||||
|
||||
if (currTime >= m_LastRedraw) // Redraw:
|
||||
{
|
||||
Action( m_Key, m_LastTime-m_StartTime, currTime-m_StartTime );
|
||||
|
||||
m_LastRedraw = wxStopWatch(&m_secbase) - m_gsynct;
|
||||
m_LastTime = currTime;
|
||||
}
|
||||
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
void TestGLCanvas::OnKeyUp( wxKeyEvent& event )
|
||||
{
|
||||
m_Key = 0;
|
||||
m_StartTime = 0;
|
||||
m_LastTime = 0;
|
||||
m_LastRedraw = 0;
|
||||
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
void TestGLCanvas::Rotate( GLfloat deg )
|
||||
{
|
||||
SetCurrent();
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glRotatef((GLfloat)deg, 0.0F, 0.0F, 1.0F);
|
||||
Refresh(FALSE);
|
||||
}
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------------
|
||||
Main Window
|
||||
-------------------------------------------------------------------------*/
|
||||
|
||||
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
||||
EVT_MENU(wxID_EXIT, MyFrame::OnExit)
|
||||
EVT_MENU( ID_NEW_WINDOW, MyFrame::OnNewWindow)
|
||||
EVT_MENU( ID_DEF_ROTATE_LEFT_KEY, MyFrame::OnDefRotateLeftKey)
|
||||
EVT_MENU( ID_DEF_ROTATE_RIGHT_KEY, MyFrame::OnDefRotateRightKey)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
// My frame constructor
|
||||
MyFrame::MyFrame(wxFrame *frame, const wxString& title, const wxPoint& pos,
|
||||
const wxSize& size, long style)
|
||||
: wxFrame(frame, -1, title, pos, size, style)
|
||||
{
|
||||
m_canvas = NULL;
|
||||
}
|
||||
|
||||
// Intercept menu commands
|
||||
void MyFrame::OnExit(wxCommandEvent& event)
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
void MyFrame::OnNewWindow()
|
||||
{
|
||||
MyFrame *frame = new MyFrame(NULL, "Cube OpenGL Demo Clone",
|
||||
wxPoint(50, 50), wxSize(400, 300));
|
||||
// Give it an icon
|
||||
#ifdef wx_msw
|
||||
frame->SetIcon(wxIcon("mondrian"));
|
||||
#endif
|
||||
|
||||
// Make a menubar
|
||||
wxMenu *winMenu = new wxMenu;
|
||||
|
||||
winMenu->Append(wxID_EXIT, "&Close");
|
||||
winMenu->Append(ID_NEW_WINDOW, "&New" );
|
||||
wxMenuBar *menuBar = new wxMenuBar;
|
||||
menuBar->Append(winMenu, "&Window");
|
||||
|
||||
winMenu = new wxMenu;
|
||||
winMenu->Append(ID_DEF_ROTATE_LEFT_KEY, "Rotate &left");
|
||||
winMenu->Append(ID_DEF_ROTATE_RIGHT_KEY, "Rotate &right");
|
||||
menuBar->Append(winMenu, "&Key");
|
||||
|
||||
frame->SetMenuBar(menuBar);
|
||||
|
||||
frame->m_canvas = new TestGLCanvas( frame, *m_canvas, -1,
|
||||
wxPoint(0, 0), wxSize(200, 200) );
|
||||
|
||||
// Show the frame
|
||||
frame->Show(TRUE);
|
||||
}
|
||||
|
||||
void MyFrame::OnDefRotateLeftKey()
|
||||
{
|
||||
ScanCodeDialog dial( this, -1, m_canvas->m_rleft,
|
||||
wxString("Left"), "Define key" );
|
||||
int result = dial.ShowModal();
|
||||
if( result == wxID_OK )
|
||||
m_canvas->m_rleft = dial.GetValue();
|
||||
}
|
||||
void MyFrame::OnDefRotateRightKey()
|
||||
{
|
||||
ScanCodeDialog dial( this, -1, m_canvas->m_rright,
|
||||
wxString("Right"), "Define key" );
|
||||
int result = dial.ShowModal();
|
||||
if( result == wxID_OK )
|
||||
m_canvas->m_rright = dial.GetValue();
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------
|
||||
Application object ( equivalent to main() )
|
||||
------------------------------------------------------------------ */
|
||||
|
||||
IMPLEMENT_APP(MyApp)
|
||||
|
||||
bool MyApp::OnInit(void)
|
||||
{
|
||||
wxLog::SetTraceMask(wxTraceMessages);
|
||||
|
||||
// Create the main frame window
|
||||
MyFrame *frame = new MyFrame(NULL, "Cube OpenGL Demo", wxPoint(50, 50),
|
||||
wxSize(400, 300));
|
||||
// Give it an icon
|
||||
#ifdef wx_msw
|
||||
frame->SetIcon(wxIcon("mondrian"));
|
||||
#endif
|
||||
|
||||
// Make a menubar
|
||||
wxMenu *winMenu = new wxMenu;
|
||||
|
||||
winMenu->Append(wxID_EXIT, "&Close");
|
||||
winMenu->Append(ID_NEW_WINDOW, "&New" );
|
||||
wxMenuBar *menuBar = new wxMenuBar;
|
||||
menuBar->Append(winMenu, "&Window");
|
||||
|
||||
winMenu = new wxMenu;
|
||||
winMenu->Append(ID_DEF_ROTATE_LEFT_KEY, "Rotate &left");
|
||||
winMenu->Append(ID_DEF_ROTATE_RIGHT_KEY, "Rotate &right");
|
||||
menuBar->Append(winMenu, "&Key");
|
||||
|
||||
frame->SetMenuBar(menuBar);
|
||||
|
||||
frame->m_canvas = new TestGLCanvas(frame, -1, wxPoint(0, 0), wxSize(200, 200));
|
||||
|
||||
// Show the frame
|
||||
frame->Show(TRUE);
|
||||
|
||||
return TRUE;
|
||||
}
|
@@ -1,93 +0,0 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: cube.h
|
||||
// Purpose: wxGLCanvas demo program
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 04/01/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_CUBE_H_
|
||||
#define _WX_CUBE_H_
|
||||
|
||||
#include "glcanvas.h"
|
||||
|
||||
// Define a new application type
|
||||
class MyApp: public wxApp
|
||||
{
|
||||
public:
|
||||
bool OnInit(void);
|
||||
};
|
||||
|
||||
// Define a new frame type
|
||||
class TestGLCanvas;
|
||||
class MyFrame: public wxFrame
|
||||
{
|
||||
public:
|
||||
MyFrame(wxFrame *frame, const wxString& title, const wxPoint& pos,
|
||||
const wxSize& size, long style = wxDEFAULT_FRAME_STYLE);
|
||||
|
||||
void OnExit(wxCommandEvent& event);
|
||||
void OnNewWindow();
|
||||
void OnDefRotateLeftKey();
|
||||
void OnDefRotateRightKey();
|
||||
|
||||
public:
|
||||
TestGLCanvas* m_canvas;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
class TestGLCanvas: public wxGLCanvas
|
||||
{
|
||||
friend class MyFrame;
|
||||
public:
|
||||
TestGLCanvas(wxWindow *parent, const wxWindowID id = -1,
|
||||
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
|
||||
long style = 0, const wxString& name = "TestGLCanvas");
|
||||
TestGLCanvas(wxWindow *parent, const TestGLCanvas &other,
|
||||
const wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize, long style = 0,
|
||||
const wxString& name = "TestGLCanvas" );
|
||||
|
||||
~TestGLCanvas(void);
|
||||
|
||||
void OnPaint(wxPaintEvent& event);
|
||||
void OnSize(wxSizeEvent& event);
|
||||
void OnEraseBackground(wxEraseEvent& event);
|
||||
void OnKeyDown(wxKeyEvent& event);
|
||||
void OnKeyUp(wxKeyEvent& event);
|
||||
void OnEnterWindow( wxMouseEvent& event );
|
||||
|
||||
void Render( void );
|
||||
void InitGL(void);
|
||||
void Rotate( GLfloat deg );
|
||||
static GLfloat CalcRotateSpeed( unsigned long acceltime );
|
||||
static GLfloat CalcRotateAngle( unsigned long lasttime,
|
||||
unsigned long acceltime );
|
||||
void Action( long code, unsigned long lasttime,
|
||||
unsigned long acceltime );
|
||||
|
||||
private:
|
||||
bool m_init;
|
||||
GLuint m_gllist;
|
||||
long m_rleft;
|
||||
long m_rright;
|
||||
|
||||
static unsigned long m_secbase;
|
||||
static int m_TimeInitialized;
|
||||
static unsigned long m_xsynct;
|
||||
static unsigned long m_gsynct;
|
||||
|
||||
long m_Key;
|
||||
unsigned long m_StartTime;
|
||||
unsigned long m_LastTime;
|
||||
unsigned long m_LastRedraw;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -1,3 +0,0 @@
|
||||
mondrian ICON "mondrian.ico"
|
||||
#include "wx/msw/wx.rc"
|
||||
|
@@ -1,21 +0,0 @@
|
||||
#
|
||||
# File: makefile.bcc
|
||||
# Author: Julian Smart
|
||||
# Created: 1998
|
||||
# Updated:
|
||||
#
|
||||
# Builds a BC++ 16-bit sample
|
||||
|
||||
!if "$(WXWIN)" == ""
|
||||
!error You must define the WXWIN variable in autoexec.bat, e.g. WXWIN=c:\wx
|
||||
!endif
|
||||
|
||||
WXDIR = $(WXWIN)
|
||||
|
||||
TARGET=cube
|
||||
EXTRALIBS=$(WXDIR)\lib\glcanvas.lib
|
||||
EXTRACPPFLAGS=-I$(WXDIR)\utils\glcanvas\win
|
||||
OBJECTS = $(TARGET).obj
|
||||
|
||||
!include $(WXDIR)\src\makeprog.bcc
|
||||
|
@@ -1,18 +0,0 @@
|
||||
#
|
||||
# File: makefile.g95
|
||||
# Author: Julian Smart
|
||||
# Created: 1999
|
||||
# Updated:
|
||||
# Copyright: (c) Julian Smart, 1999
|
||||
#
|
||||
# Makefile for wxWindows sample (Cygwin/Mingw32).
|
||||
|
||||
WXDIR = ../../../..
|
||||
|
||||
TARGET=cube
|
||||
EXTRACPPFLAGS=-I../../win
|
||||
EXTRALIBS=-lglcanvas -lopengl32 -lglu32
|
||||
OBJECTS = $(TARGET).o
|
||||
|
||||
include $(WXDIR)/src/makeprog.g95
|
||||
|
@@ -1,23 +0,0 @@
|
||||
#
|
||||
# File: makefile.unx
|
||||
# Author: Julian Smart
|
||||
# Created: 1998
|
||||
# Updated:
|
||||
# Copyright: (c) 1998 Julian Smart
|
||||
#
|
||||
# "%W% %G%"
|
||||
#
|
||||
# Makefile for cube example (UNIX).
|
||||
|
||||
PROGRAM=cube
|
||||
|
||||
OPENGLHOME=/home/jacs/mesa/Mesa-2.3
|
||||
|
||||
EXTRACPPFLAGS=-I$(OPENGLHOME)/include -I../../motif
|
||||
EXTRALDFLAGS=-L$(OPENGLHOME)/lib
|
||||
EXTRALDLIBS=-lglcanvas_motif -lMesaGL -lMesaGLU
|
||||
|
||||
OBJECTS=$(PROGRAM).o
|
||||
|
||||
include ../../../../src/makeprog.env
|
||||
|
@@ -1,32 +0,0 @@
|
||||
#
|
||||
# File: Makefile
|
||||
# Author: Robert Roebling
|
||||
# Created: 1999
|
||||
# Updated:
|
||||
# Copyright: (c) 1998 Robert Roebling
|
||||
#
|
||||
# Makefile for OpenGl demo (GTK version)
|
||||
#
|
||||
# This makefile requires wxWindows/GTK to be
|
||||
# installed (possibly using "make install")
|
||||
# on your system.
|
||||
#
|
||||
|
||||
CC = g++
|
||||
WXCONFIG=../../../../wx-config
|
||||
WXINCLUDE=-I../../../../include
|
||||
WXLIB=-L../../../../lib
|
||||
|
||||
isosurf: isosurf.o glcanvas.o
|
||||
$(CC) -o isosurf \
|
||||
isosurf.o glcanvas.o \
|
||||
`$(WXCONFIG) --libs` $(WXLIB) -lMesaGL -lMesaGLU
|
||||
|
||||
isosurf.o: isosurf.cpp
|
||||
$(CC) `$(WXCONFIG) --cflags` -I../../gtk $(WXINCLUDE) -c isosurf.cpp
|
||||
|
||||
glcanvas.o: ../../gtk/glcanvas.cpp
|
||||
$(CC) `$(WXCONFIG) --cflags` `gtk-config --cflags` -I../../gtk -c $(WXINCLUDE) ../../gtk/glcanvas.cpp
|
||||
|
||||
clean:
|
||||
rm -f *.o isosurf
|
@@ -1,412 +0,0 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: isosurf.cpp
|
||||
// Purpose: wxGLCanvas demo program
|
||||
// Author: Brian Paul (original gltk version), Wolfram Gloger
|
||||
// Modified by: Julian Smart
|
||||
// Created: 04/01/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#endif
|
||||
|
||||
#include "wx/timer.h"
|
||||
#include "glcanvas.h"
|
||||
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
|
||||
#include "isosurf.h"
|
||||
|
||||
// The following part is taken largely unchanged from the original C Version
|
||||
|
||||
#include <math.h>
|
||||
|
||||
GLboolean speed_test = GL_FALSE;
|
||||
GLboolean use_vertex_arrays = GL_FALSE;
|
||||
|
||||
GLboolean doubleBuffer = GL_TRUE;
|
||||
|
||||
GLboolean smooth = GL_TRUE;
|
||||
GLboolean lighting = GL_TRUE;
|
||||
|
||||
|
||||
#define MAXVERTS 10000
|
||||
|
||||
static GLfloat verts[MAXVERTS][3];
|
||||
static GLfloat norms[MAXVERTS][3];
|
||||
static GLint numverts;
|
||||
|
||||
static GLfloat xrot;
|
||||
static GLfloat yrot;
|
||||
|
||||
|
||||
static void read_surface( char *filename )
|
||||
{
|
||||
FILE *f;
|
||||
|
||||
f = fopen(filename,"r");
|
||||
if (!f) {
|
||||
wxString msg("Couldn't read ");
|
||||
msg += filename;
|
||||
wxMessageBox(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
numverts = 0;
|
||||
while (!feof(f) && numverts<MAXVERTS) {
|
||||
fscanf( f, "%f %f %f %f %f %f",
|
||||
&verts[numverts][0], &verts[numverts][1], &verts[numverts][2],
|
||||
&norms[numverts][0], &norms[numverts][1], &norms[numverts][2] );
|
||||
numverts++;
|
||||
}
|
||||
numverts--;
|
||||
|
||||
printf("%d vertices, %d triangles\n", numverts, numverts-2);
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
|
||||
static void draw_surface( void )
|
||||
{
|
||||
GLint i;
|
||||
|
||||
#ifdef GL_EXT_vertex_array
|
||||
if (use_vertex_arrays) {
|
||||
glDrawArraysEXT( GL_TRIANGLE_STRIP, 0, numverts );
|
||||
}
|
||||
else {
|
||||
#endif
|
||||
glBegin( GL_TRIANGLE_STRIP );
|
||||
for (i=0;i<numverts;i++) {
|
||||
glNormal3fv( norms[i] );
|
||||
glVertex3fv( verts[i] );
|
||||
}
|
||||
glEnd();
|
||||
#ifdef GL_EXT_vertex_array
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
static void draw1(void)
|
||||
{
|
||||
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
|
||||
glPushMatrix();
|
||||
glRotatef( yrot, 0.0, 1.0, 0.0 );
|
||||
glRotatef( xrot, 1.0, 0.0, 0.0 );
|
||||
|
||||
draw_surface();
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
glFlush();
|
||||
}
|
||||
|
||||
|
||||
static void InitMaterials(void)
|
||||
{
|
||||
static float ambient[] = {0.1, 0.1, 0.1, 1.0};
|
||||
static float diffuse[] = {0.5, 1.0, 1.0, 1.0};
|
||||
static float position0[] = {0.0, 0.0, 20.0, 0.0};
|
||||
static float position1[] = {0.0, 0.0, -20.0, 0.0};
|
||||
static float front_mat_shininess[] = {60.0};
|
||||
static float front_mat_specular[] = {0.2, 0.2, 0.2, 1.0};
|
||||
static float front_mat_diffuse[] = {0.5, 0.28, 0.38, 1.0};
|
||||
/*
|
||||
static float back_mat_shininess[] = {60.0};
|
||||
static float back_mat_specular[] = {0.5, 0.5, 0.2, 1.0};
|
||||
static float back_mat_diffuse[] = {1.0, 1.0, 0.2, 1.0};
|
||||
*/
|
||||
static float lmodel_ambient[] = {1.0, 1.0, 1.0, 1.0};
|
||||
static float lmodel_twoside[] = {GL_FALSE};
|
||||
|
||||
glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
|
||||
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
|
||||
glLightfv(GL_LIGHT0, GL_POSITION, position0);
|
||||
glEnable(GL_LIGHT0);
|
||||
|
||||
glLightfv(GL_LIGHT1, GL_AMBIENT, ambient);
|
||||
glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuse);
|
||||
glLightfv(GL_LIGHT1, GL_POSITION, position1);
|
||||
glEnable(GL_LIGHT1);
|
||||
|
||||
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
|
||||
glLightModelfv(GL_LIGHT_MODEL_TWO_SIDE, lmodel_twoside);
|
||||
glEnable(GL_LIGHTING);
|
||||
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, front_mat_shininess);
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, front_mat_specular);
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, front_mat_diffuse);
|
||||
}
|
||||
|
||||
|
||||
static void Init(void)
|
||||
{
|
||||
glClearColor(0.0, 0.0, 0.0, 0.0);
|
||||
|
||||
glShadeModel(GL_SMOOTH);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
InitMaterials();
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glFrustum( -1.0, 1.0, -1.0, 1.0, 5, 25 );
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glTranslatef( 0.0, 0.0, -6.0 );
|
||||
|
||||
#ifdef GL_EXT_vertex_array
|
||||
if (use_vertex_arrays) {
|
||||
glVertexPointerEXT( 3, GL_FLOAT, 0, numverts, verts );
|
||||
glNormalPointerEXT( GL_FLOAT, 0, numverts, norms );
|
||||
glEnable( GL_VERTEX_ARRAY_EXT );
|
||||
glEnable( GL_NORMAL_ARRAY_EXT );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
static void Reshape(int width, int height)
|
||||
{
|
||||
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||
}
|
||||
|
||||
|
||||
static GLenum Args(int argc, char **argv)
|
||||
{
|
||||
GLint i;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-sb") == 0) {
|
||||
doubleBuffer = GL_FALSE;
|
||||
}
|
||||
else if (strcmp(argv[i], "-db") == 0) {
|
||||
doubleBuffer = GL_TRUE;
|
||||
}
|
||||
else if (strcmp(argv[i], "-speed") == 0) {
|
||||
speed_test = GL_TRUE;
|
||||
doubleBuffer = GL_TRUE;
|
||||
}
|
||||
else if (strcmp(argv[i], "-va") == 0) {
|
||||
use_vertex_arrays = GL_TRUE;
|
||||
}
|
||||
else {
|
||||
wxString msg("Bad option: ");
|
||||
msg += argv[i];
|
||||
wxMessageBox(msg);
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
// The following part was written for wxWindows 1.66
|
||||
MyFrame *frame = NULL;
|
||||
|
||||
IMPLEMENT_APP(MyApp)
|
||||
|
||||
// `Main program' equivalent, creating windows and returning main app frame
|
||||
bool MyApp::OnInit(void)
|
||||
{
|
||||
Args(argc, argv);
|
||||
|
||||
// Create the main frame window
|
||||
frame = new MyFrame(NULL, "Isosurf GL Sample", wxPoint(50, 50), wxSize(200, 200));
|
||||
|
||||
// Give it an icon
|
||||
frame->SetIcon(wxIcon("mondrian"));
|
||||
|
||||
// Make a menubar
|
||||
wxMenu *fileMenu = new wxMenu;
|
||||
|
||||
fileMenu->Append(wxID_EXIT, "E&xit");
|
||||
wxMenuBar *menuBar = new wxMenuBar;
|
||||
menuBar->Append(fileMenu, "&File");
|
||||
frame->SetMenuBar(menuBar);
|
||||
|
||||
// Make a TestGLCanvas
|
||||
|
||||
// JACS
|
||||
#ifdef __WXMSW__
|
||||
int *gl_attrib = NULL;
|
||||
#else
|
||||
int gl_attrib[20] = { GLX_RGBA, GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1,
|
||||
GLX_BLUE_SIZE, 1, GLX_DEPTH_SIZE, 1,
|
||||
GLX_DOUBLEBUFFER, None };
|
||||
#endif
|
||||
|
||||
if(!doubleBuffer)
|
||||
{
|
||||
printf("don't have double buffer, disabling\n");
|
||||
#ifdef __WXGTK__
|
||||
gl_attrib[9] = None;
|
||||
#endif
|
||||
doubleBuffer = GL_FALSE;
|
||||
}
|
||||
frame->m_canvas = new TestGLCanvas(frame, -1, wxPoint(0, 0), wxSize(200, 200), 0, "TestGLCanvas",
|
||||
gl_attrib);
|
||||
|
||||
// Show the frame
|
||||
frame->Show(TRUE);
|
||||
|
||||
frame->m_canvas->SetCurrent();
|
||||
read_surface( "isosurf.dat" );
|
||||
|
||||
Init();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
||||
EVT_MENU(wxID_EXIT, MyFrame::OnExit)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
// My frame constructor
|
||||
MyFrame::MyFrame(wxFrame *frame, const wxString& title, const wxPoint& pos,
|
||||
const wxSize& size, long style):
|
||||
wxFrame(frame, -1, title, pos, size, style)
|
||||
{
|
||||
m_canvas = NULL;
|
||||
}
|
||||
|
||||
// Intercept menu commands
|
||||
void MyFrame::OnExit(wxCommandEvent& event)
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
/*
|
||||
* TestGLCanvas implementation
|
||||
*/
|
||||
|
||||
BEGIN_EVENT_TABLE(TestGLCanvas, wxGLCanvas)
|
||||
EVT_SIZE(TestGLCanvas::OnSize)
|
||||
EVT_PAINT(TestGLCanvas::OnPaint)
|
||||
EVT_CHAR(TestGLCanvas::OnChar)
|
||||
EVT_MOUSE_EVENTS(TestGLCanvas::OnMouseEvent)
|
||||
EVT_ERASE_BACKGROUND(TestGLCanvas::OnEraseBackground)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
TestGLCanvas::TestGLCanvas(wxWindow *parent, wxWindowID id,
|
||||
const wxPoint& pos, const wxSize& size, long style, const wxString& name, int* gl_attrib):
|
||||
wxGLCanvas(parent, id, pos, size, style, name, gl_attrib)
|
||||
{
|
||||
parent->Show(TRUE);
|
||||
SetCurrent();
|
||||
/* Make sure server supports the vertex array extension */
|
||||
char* extensions = (char *) glGetString( GL_EXTENSIONS );
|
||||
if (!extensions || !strstr( extensions, "GL_EXT_vertex_array" )) {
|
||||
use_vertex_arrays = GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TestGLCanvas::~TestGLCanvas(void)
|
||||
{
|
||||
}
|
||||
|
||||
void TestGLCanvas::OnPaint( wxPaintEvent& event )
|
||||
{
|
||||
// This is a dummy, to avoid an endless succession of paint messages.
|
||||
// OnPaint handlers must always create a wxPaintDC.
|
||||
wxPaintDC dc(this);
|
||||
|
||||
draw1();
|
||||
SwapBuffers();
|
||||
}
|
||||
|
||||
void TestGLCanvas::OnSize(wxSizeEvent& event)
|
||||
{
|
||||
SetCurrent();
|
||||
int width, height;
|
||||
GetClientSize(& width, & height);
|
||||
Reshape(width, height);
|
||||
}
|
||||
|
||||
void TestGLCanvas::OnChar(wxKeyEvent& event)
|
||||
{
|
||||
switch(event.KeyCode()) {
|
||||
case WXK_ESCAPE:
|
||||
exit(0);
|
||||
case WXK_LEFT:
|
||||
yrot -= 15.0;
|
||||
break;
|
||||
case WXK_RIGHT:
|
||||
yrot += 15.0;
|
||||
break;
|
||||
case WXK_UP:
|
||||
xrot += 15.0;
|
||||
break;
|
||||
case WXK_DOWN:
|
||||
xrot -= 15.0;
|
||||
break;
|
||||
case 's': case 'S':
|
||||
smooth = !smooth;
|
||||
if (smooth) {
|
||||
glShadeModel(GL_SMOOTH);
|
||||
} else {
|
||||
glShadeModel(GL_FLAT);
|
||||
}
|
||||
break;
|
||||
case 'l': case 'L':
|
||||
lighting = !lighting;
|
||||
if (lighting) {
|
||||
glEnable(GL_LIGHTING);
|
||||
} else {
|
||||
glDisable(GL_LIGHTING);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
event.Skip();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Refresh(FALSE);
|
||||
}
|
||||
|
||||
void TestGLCanvas::OnMouseEvent(wxMouseEvent& event)
|
||||
{
|
||||
static int dragging = 0;
|
||||
static float last_x, last_y;
|
||||
|
||||
//printf("%f %f %d\n", event.GetX(), event.GetY(), (int)event.LeftIsDown());
|
||||
if(event.LeftIsDown()) {
|
||||
if(!dragging) {
|
||||
dragging = 1;
|
||||
} else {
|
||||
yrot += (event.GetX() - last_x)*1.0;
|
||||
xrot += (event.GetY() - last_y)*1.0;
|
||||
Refresh(FALSE);
|
||||
}
|
||||
last_x = event.GetX();
|
||||
last_y = event.GetY();
|
||||
} else
|
||||
dragging = 0;
|
||||
}
|
||||
|
||||
void TestGLCanvas::OnEraseBackground(wxEraseEvent& event)
|
||||
{
|
||||
// Do nothing, to avoid flashing.
|
||||
}
|
||||
|
@@ -1,52 +0,0 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: isosurf.h
|
||||
// Purpose: wxGLCanvas demo program
|
||||
// Author: Brian Paul (original gltk version), Wolfram Gloger
|
||||
// Modified by: Julian Smart
|
||||
// Created: 04/01/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_ISOSURF_H_
|
||||
#define _WX_ISOSURF_H_
|
||||
|
||||
// Define a new application type
|
||||
class MyApp: public wxApp
|
||||
{ public:
|
||||
bool OnInit(void);
|
||||
};
|
||||
|
||||
class TestGLCanvas: public wxGLCanvas
|
||||
{
|
||||
public:
|
||||
TestGLCanvas(wxWindow *parent, const wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = "TestGLCanvas",
|
||||
int* gl_attrib = NULL);
|
||||
~TestGLCanvas(void);
|
||||
|
||||
void OnPaint(wxPaintEvent& event);
|
||||
void OnSize(wxSizeEvent& event);
|
||||
void OnEraseBackground(wxEraseEvent& event);
|
||||
void OnChar(wxKeyEvent& event);
|
||||
void OnMouseEvent(wxMouseEvent& event);
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
class MyFrame: public wxFrame
|
||||
{
|
||||
public:
|
||||
MyFrame(wxFrame *frame, const wxString& title, const wxPoint& pos, const wxSize& size,
|
||||
long style = wxDEFAULT_FRAME_STYLE);
|
||||
|
||||
void OnExit(wxCommandEvent& event);
|
||||
public:
|
||||
TestGLCanvas* m_canvas;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -1,3 +0,0 @@
|
||||
mondrian ICON "mondrian.ico"
|
||||
#include "wx/msw/wx.rc"
|
||||
|
@@ -1,22 +0,0 @@
|
||||
#
|
||||
# File: makefile.b32
|
||||
# Author: Julian Smart
|
||||
# Created: 1999
|
||||
# Updated:
|
||||
# Copyright:
|
||||
#
|
||||
# Makefile : Builds sample for 32-bit BC++
|
||||
|
||||
WXDIR = $(WXWIN)
|
||||
|
||||
TARGET=isosurf
|
||||
EXTRALIBS=$(WXDIR)\lib\glcanvas.lib
|
||||
EXTRACPPFLAGS=-I$(WXDIR)\utils\glcanvas\win
|
||||
OBJECTS = $(TARGET).obj
|
||||
EXTRATARGETS=isosurf.dat
|
||||
|
||||
!include $(WXDIR)\src\makeprog.b32
|
||||
|
||||
isosurf.dat: isosurf.dat.gz
|
||||
gzip -c -d isosurf.dat.gz > isosurf.dat
|
||||
|
@@ -1,25 +0,0 @@
|
||||
#
|
||||
# File: makefile.bcc
|
||||
# Author: Julian Smart
|
||||
# Created: 1998
|
||||
# Updated:
|
||||
#
|
||||
# Builds a BC++ 16-bit sample
|
||||
|
||||
!if "$(WXWIN)" == ""
|
||||
!error You must define the WXWIN variable in autoexec.bat, e.g. WXWIN=c:\wx
|
||||
!endif
|
||||
|
||||
WXDIR = $(WXWIN)
|
||||
|
||||
TARGET=isosurf
|
||||
EXTRALIBS=$(WXDIR)\lib\glcanvas.lib
|
||||
EXTRACPPFLAGS=-I$(WXDIR)\utils\glcanvas\win
|
||||
OBJECTS = $(TARGET).obj
|
||||
EXTRATARGETS=isosurf.dat
|
||||
|
||||
!include $(WXDIR)\src\makeprog.bcc
|
||||
|
||||
isosurf.dat: isosurf.dat.gz
|
||||
gzip -c -d isosurf.dat.gz > isosurf.dat
|
||||
|
@@ -1,20 +0,0 @@
|
||||
#
|
||||
# File: makefile.g95
|
||||
# Author: Julian Smart
|
||||
# Created: 1999
|
||||
# Updated:
|
||||
# Copyright: (c) Julian Smart, 1999
|
||||
#
|
||||
# Makefile for wxWindows sample (Cygwin/Mingw32).
|
||||
|
||||
WXDIR = ../../../..
|
||||
|
||||
TARGET=isosurf
|
||||
EXTRACPPFLAGS=-I../../win
|
||||
EXTRALIBS=-lglcanvas -lopengl32 -lglu32
|
||||
OBJECTS = $(TARGET).o
|
||||
|
||||
include $(WXDIR)/src/makeprog.g95
|
||||
|
||||
isosurf.dat: isosurf.dat.gz
|
||||
gzip -c -d isosurf.dat.gz > isosurf.dat
|
@@ -1,27 +0,0 @@
|
||||
#
|
||||
# File: makefile.unx
|
||||
# Author: Julian Smart
|
||||
# Created: 1998
|
||||
# Updated:
|
||||
# Copyright: (c) 1998 Julian Smart
|
||||
#
|
||||
# "%W% %G%"
|
||||
#
|
||||
# Makefile for isosurf example (UNIX).
|
||||
|
||||
PROGRAM=isosurf
|
||||
|
||||
OPENGLHOME=/home/jacs/mesa/Mesa-2.3
|
||||
|
||||
EXTRACPPFLAGS=-I$(OPENGLHOME)/include -I../../motif
|
||||
EXTRALDFLAGS=-L$(OPENGLHOME)/lib
|
||||
EXTRALDLIBS=-lglcanvas_motif -lMesaGL -lMesaGLU
|
||||
|
||||
OBJECTS=$(PROGRAM).o
|
||||
EXTRATARGETS=isosurf.dat
|
||||
|
||||
include ../../../../src/makeprog.env
|
||||
|
||||
isosurf.dat: isosurf.dat.gz
|
||||
gzip -c -d isosurf.dat.gz > isosurf.dat
|
||||
|
@@ -1,30 +0,0 @@
|
||||
#
|
||||
# File: makefile.vc
|
||||
# Author: Julian Smart
|
||||
# Created: 1999
|
||||
# Updated:
|
||||
# Copyright: (c) Julian Smart
|
||||
#
|
||||
# Makefile : Builds sample (VC++, WIN32)
|
||||
# Use FINAL=1 argument to nmake to build final version with no debug info.
|
||||
|
||||
# Set WXDIR for your system
|
||||
WXDIR = $(WXWIN)
|
||||
|
||||
!if "$(FINAL)" == "1"
|
||||
!else
|
||||
LIBEXT=_d
|
||||
!endif
|
||||
|
||||
PROGRAM=isosurf
|
||||
OBJECTS = $(PROGRAM).obj
|
||||
EXTRAINC=-I..\..\win
|
||||
EXTRALIBS=$(WXDIR)\lib\glcanvas$(LIBEXT).lib glu32.lib opengl32.lib
|
||||
EXTRATARGETS=isosurf.dat
|
||||
|
||||
!include $(WXDIR)\src\makeprog.vc
|
||||
|
||||
isosurf.dat: isosurf.dat.gz
|
||||
gzip -c -d isosurf.dat.gz > isosurf.dat
|
||||
|
||||
|
@@ -1,20 +0,0 @@
|
||||
#
|
||||
# Makefile for WATCOM
|
||||
#
|
||||
# Created by Julian Smart, January 1999
|
||||
#
|
||||
#
|
||||
|
||||
WXDIR = $(%WXWIN)
|
||||
|
||||
PROGRAM = isosurf
|
||||
OBJECTS = $(PROGRAM).obj
|
||||
EXTRALIBS=$(WXDIR)\lib\glcanvas.lib
|
||||
EXTRACPPFLAGS=-I$(WXDIR)\utils\glcanvas\win
|
||||
EXTRATARGETS=isosurf.dat
|
||||
|
||||
!include $(WXDIR)\src\makeprog.wat
|
||||
|
||||
isosurf.dat: isosurf.dat.gz
|
||||
gzip -c -d isosurf.dat.gz > isosurf.dat
|
||||
|
Before Width: | Height: | Size: 766 B |
@@ -1,37 +0,0 @@
|
||||
#
|
||||
# File: Makefile
|
||||
# Author: Robert Roebling
|
||||
# Created: 1999
|
||||
# Updated:
|
||||
# Copyright: (c) 1998 Robert Roebling
|
||||
#
|
||||
# Makefile for OpenGL demo (GTK version)
|
||||
#
|
||||
# This makefile requires wxWindows/GTK to be
|
||||
# installed (possibly using "make install")
|
||||
# on your system.
|
||||
#
|
||||
|
||||
CPP = gcc
|
||||
CC = gcc
|
||||
WXCONFIG=../../../../wx-config
|
||||
WXINCLUDE=-I../../../../include
|
||||
WXLIB=-L../../../../lib
|
||||
|
||||
Penguin: penguin.o trackball.o lw.o glcanvas.o
|
||||
$(CPP) -o Penguin penguin.o trackball.o lw.o glcanvas.o `$(WXCONFIG) --libs` $(WXLIB) -lMesaGL -lMesaGLU
|
||||
|
||||
penguin.o: penguin.cpp
|
||||
$(CPP) `$(WXCONFIG) --cflags` -I../../gtk $(WXINCLUDE) -c penguin.cpp
|
||||
|
||||
lw.o: lw.cpp
|
||||
$(CPP) `$(WXCONFIG) --cflags` -I../../gtk $(WXINCLUDE) -c lw.cpp
|
||||
|
||||
trackball.o: trackball.c
|
||||
$(CC) `$(WXCONFIG) --cflags` -I../../gtk $(WXINCLUDE) -c trackball.c
|
||||
|
||||
glcanvas.o: ../../gtk/glcanvas.cpp
|
||||
$(CPP) `$(WXCONFIG) --cflags` `gtk-config --cflags` -g -I../../gtk $(WXINCLUDE) -c ../../gtk/glcanvas.cpp
|
||||
|
||||
clean:
|
||||
rm -f *.o Penguin
|
@@ -1,427 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 1998 Janne L<>f <jlof@mail.student.oulu.fi>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifdef __WXMSW__
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include "lw.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
#define wxInt32 int
|
||||
#define wxUint32 unsigned int
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
|
||||
#define MK_ID(a,b,c,d) ((((wxUint32)(a))<<24)| \
|
||||
(((wxUint32)(b))<<16)| \
|
||||
(((wxUint32)(c))<< 8)| \
|
||||
(((wxUint32)(d)) ))
|
||||
|
||||
#define ID_FORM MK_ID('F','O','R','M')
|
||||
#define ID_LWOB MK_ID('L','W','O','B')
|
||||
#define ID_PNTS MK_ID('P','N','T','S')
|
||||
#define ID_SRFS MK_ID('S','R','F','S')
|
||||
#define ID_SURF MK_ID('S','U','R','F')
|
||||
#define ID_POLS MK_ID('P','O','L','S')
|
||||
#define ID_COLR MK_ID('C','O','L','R')
|
||||
|
||||
static wxInt32 read_char(FILE *f)
|
||||
{
|
||||
int c = fgetc(f);
|
||||
return c;
|
||||
}
|
||||
|
||||
static wxInt32 read_short(FILE *f)
|
||||
{
|
||||
return (read_char(f)<<8) | read_char(f);
|
||||
}
|
||||
|
||||
static wxInt32 read_long(FILE *f)
|
||||
{
|
||||
return (read_char(f)<<24) | (read_char(f)<<16) | (read_char(f)<<8) | read_char(f);
|
||||
}
|
||||
|
||||
static GLfloat read_float(FILE *f)
|
||||
{
|
||||
wxInt32 x = read_long(f);
|
||||
return *(GLfloat*)&x;
|
||||
}
|
||||
|
||||
static int read_string(FILE *f, char *s)
|
||||
{
|
||||
int c;
|
||||
int cnt = 0;
|
||||
do {
|
||||
c = read_char(f);
|
||||
if (cnt < LW_MAX_NAME_LEN)
|
||||
s[cnt] = c;
|
||||
else
|
||||
s[LW_MAX_NAME_LEN-1] = 0;
|
||||
cnt++;
|
||||
} while (c != 0);
|
||||
/* if length of string (including \0) is odd skip another byte */
|
||||
if (cnt%2) {
|
||||
read_char(f);
|
||||
cnt++;
|
||||
}
|
||||
return cnt;
|
||||
}
|
||||
|
||||
static void read_srfs(FILE *f, int nbytes, lwObject *lwo)
|
||||
{
|
||||
int guess_cnt = lwo->material_cnt;
|
||||
|
||||
while (nbytes > 0) {
|
||||
lwMaterial *material;
|
||||
|
||||
/* allocate more memory for materials if needed */
|
||||
if (guess_cnt <= lwo->material_cnt) {
|
||||
guess_cnt += guess_cnt/2 + 4;
|
||||
lwo->material = (lwMaterial*) realloc(lwo->material, sizeof(lwMaterial)*guess_cnt);
|
||||
}
|
||||
material = lwo->material + lwo->material_cnt++;
|
||||
|
||||
/* read name */
|
||||
nbytes -= read_string(f,material->name);
|
||||
|
||||
/* defaults */
|
||||
material->r = 0.7;
|
||||
material->g = 0.7;
|
||||
material->b = 0.7;
|
||||
}
|
||||
lwo->material = (lwMaterial*) realloc(lwo->material, sizeof(lwMaterial)*lwo->material_cnt);
|
||||
}
|
||||
|
||||
|
||||
static void read_surf(FILE *f, int nbytes, lwObject *lwo)
|
||||
{
|
||||
int i;
|
||||
char name[LW_MAX_NAME_LEN];
|
||||
lwMaterial *material = NULL;
|
||||
|
||||
/* read surface name */
|
||||
nbytes -= read_string(f,name);
|
||||
|
||||
/* find material */
|
||||
for (i=0; i< lwo->material_cnt; i++) {
|
||||
if (strcmp(lwo->material[i].name,name) == 0) {
|
||||
material = &lwo->material[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* read values */
|
||||
while (nbytes > 0) {
|
||||
int id = read_long(f);
|
||||
int len = read_short(f);
|
||||
nbytes -= 6 + len + (len%2);
|
||||
|
||||
switch (id) {
|
||||
case ID_COLR:
|
||||
material->r = read_char(f) / 255.0;
|
||||
material->g = read_char(f) / 255.0;
|
||||
material->b = read_char(f) / 255.0;
|
||||
read_char(f); /* dummy */
|
||||
break;
|
||||
default:
|
||||
fseek(f, len+(len%2), SEEK_CUR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void read_pols(FILE *f, int nbytes, lwObject *lwo)
|
||||
{
|
||||
int guess_cnt = lwo->face_cnt;
|
||||
|
||||
while (nbytes > 0) {
|
||||
lwFace *face;
|
||||
int i;
|
||||
|
||||
/* allocate more memory for polygons if necessary */
|
||||
if (guess_cnt <= lwo->face_cnt) {
|
||||
guess_cnt += guess_cnt + 4;
|
||||
lwo->face = (lwFace*) realloc((void*) lwo->face, sizeof(lwFace)*guess_cnt);
|
||||
}
|
||||
face = lwo->face + lwo->face_cnt++;
|
||||
|
||||
/* number of points in this face */
|
||||
face->index_cnt = read_short(f);
|
||||
nbytes -= 2;
|
||||
|
||||
/* allocate space for points */
|
||||
face->index = (int*) calloc(sizeof(int)*face->index_cnt,1);
|
||||
|
||||
/* read points in */
|
||||
for (i=0; i<face->index_cnt; i++) {
|
||||
face->index[i] = read_short(f);
|
||||
nbytes -= 2;
|
||||
}
|
||||
|
||||
/* read surface material */
|
||||
face->material = read_short(f);
|
||||
nbytes -= 2;
|
||||
|
||||
/* skip over detail polygons */
|
||||
if (face->material < 0) {
|
||||
int det_cnt;
|
||||
face->material = -face->material;
|
||||
det_cnt = read_short(f);
|
||||
nbytes -= 2;
|
||||
while (det_cnt-- > 0) {
|
||||
int cnt = read_short(f);
|
||||
fseek(f, cnt*2+2, SEEK_CUR);
|
||||
nbytes -= cnt*2+2;
|
||||
}
|
||||
}
|
||||
face->material -= 1;
|
||||
}
|
||||
/* readjust to true size */
|
||||
lwo->face = (lwFace*) realloc(lwo->face, sizeof(lwFace)*lwo->face_cnt);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void read_pnts(FILE *f, int nbytes, lwObject *lwo)
|
||||
{
|
||||
int i;
|
||||
lwo->vertex_cnt = nbytes / 12;
|
||||
lwo->vertex = (float*) calloc(sizeof(GLfloat)*lwo->vertex_cnt*3, 1);
|
||||
for (i=0; i<lwo->vertex_cnt; i++) {
|
||||
lwo->vertex[i*3+0] = read_float(f);
|
||||
lwo->vertex[i*3+1] = read_float(f);
|
||||
lwo->vertex[i*3+2] = read_float(f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int lw_is_lwobject(const char *lw_file)
|
||||
{
|
||||
FILE *f = fopen(lw_file, "rb");
|
||||
if (f) {
|
||||
wxInt32 form = read_long(f);
|
||||
wxInt32 nlen = read_long(f);
|
||||
wxInt32 lwob = read_long(f);
|
||||
fclose(f);
|
||||
if (form == ID_FORM && nlen != 0 && lwob == ID_LWOB)
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
lwObject *lw_object_read(const char *lw_file)
|
||||
{
|
||||
FILE *f = NULL;
|
||||
lwObject *lw_object = NULL;
|
||||
|
||||
wxInt32 form_bytes = 0;
|
||||
wxInt32 read_bytes = 0;
|
||||
|
||||
/* open file */
|
||||
f = fopen(lw_file, "rb");
|
||||
if (f == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* check for headers */
|
||||
if (read_long(f) != ID_FORM) {
|
||||
fclose(f);
|
||||
return NULL;
|
||||
}
|
||||
form_bytes = read_long(f);
|
||||
read_bytes += 4;
|
||||
|
||||
if (read_long(f) != ID_LWOB) {
|
||||
fclose(f);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* create new lwObject */
|
||||
lw_object = (lwObject*) calloc(sizeof(lwObject),1);
|
||||
|
||||
/* read chunks */
|
||||
while (read_bytes < form_bytes) {
|
||||
wxInt32 id = read_long(f);
|
||||
wxInt32 nbytes = read_long(f);
|
||||
read_bytes += 8 + nbytes + (nbytes%2);
|
||||
|
||||
switch (id) {
|
||||
case ID_PNTS:
|
||||
read_pnts(f, nbytes, lw_object);
|
||||
break;
|
||||
case ID_POLS:
|
||||
read_pols(f, nbytes, lw_object);
|
||||
break;
|
||||
case ID_SRFS:
|
||||
read_srfs(f, nbytes, lw_object);
|
||||
break;
|
||||
case ID_SURF:
|
||||
read_surf(f, nbytes, lw_object);
|
||||
break;
|
||||
default:
|
||||
fseek(f, nbytes + (nbytes%2), SEEK_CUR);
|
||||
}
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
return lw_object;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void lw_object_free(lwObject *lw_object)
|
||||
{
|
||||
if (lw_object->face) {
|
||||
int i;
|
||||
for (i=0; i<lw_object->face_cnt; i++)
|
||||
free(lw_object->face[i].index);
|
||||
free(lw_object->face);
|
||||
}
|
||||
free(lw_object->material);
|
||||
free(lw_object->vertex);
|
||||
free(lw_object);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define PX(i) (lw_object->vertex[face->index[i]*3+0])
|
||||
#define PY(i) (lw_object->vertex[face->index[i]*3+1])
|
||||
#define PZ(i) (lw_object->vertex[face->index[i]*3+2])
|
||||
void lw_object_show(const lwObject *lw_object)
|
||||
{
|
||||
int i,j;
|
||||
int prev_index_cnt = -1;
|
||||
int prev_material = -1;
|
||||
GLfloat prev_nx = 0;
|
||||
GLfloat prev_ny = 0;
|
||||
GLfloat prev_nz = 0;
|
||||
|
||||
for (i=0; i<lw_object->face_cnt; i++) {
|
||||
GLfloat ax,ay,az,bx,by,bz,nx,ny,nz,r;
|
||||
const lwFace *face = lw_object->face+i;
|
||||
|
||||
/* ignore faces with less than 3 points */
|
||||
if (face->index_cnt < 3)
|
||||
continue;
|
||||
|
||||
/* calculate normal */
|
||||
ax = PX(1) - PX(0);
|
||||
ay = PY(1) - PY(0);
|
||||
az = PZ(1) - PZ(0);
|
||||
|
||||
bx = PX(face->index_cnt-1) - PX(0);
|
||||
by = PY(face->index_cnt-1) - PY(0);
|
||||
bz = PZ(face->index_cnt-1) - PZ(0);
|
||||
|
||||
nx = ay * bz - az * by;
|
||||
ny = az * bx - ax * bz;
|
||||
nz = ax * by - ay * bx;
|
||||
|
||||
r = sqrt(nx*nx + ny*ny + nz*nz);
|
||||
if (r < 0.000001) /* avoid division by zero */
|
||||
continue;
|
||||
nx /= r;
|
||||
ny /= r;
|
||||
nz /= r;
|
||||
|
||||
/* glBegin/glEnd */
|
||||
if (prev_index_cnt != face->index_cnt || prev_index_cnt > 4) {
|
||||
if (prev_index_cnt > 0) glEnd();
|
||||
prev_index_cnt = face->index_cnt;
|
||||
switch (face->index_cnt) {
|
||||
case 3:
|
||||
glBegin(GL_TRIANGLES);
|
||||
break;
|
||||
case 4:
|
||||
glBegin(GL_QUADS);
|
||||
break;
|
||||
default:
|
||||
glBegin(GL_POLYGON);
|
||||
}
|
||||
}
|
||||
|
||||
/* update material if necessary */
|
||||
if (prev_material != face->material) {
|
||||
prev_material = face->material;
|
||||
glColor3f(lw_object->material[face->material].r,
|
||||
lw_object->material[face->material].g,
|
||||
lw_object->material[face->material].b);
|
||||
}
|
||||
|
||||
/* update normal if necessary */
|
||||
if (nx != prev_nx || ny != prev_ny || nz != prev_nz) {
|
||||
prev_nx = nx;
|
||||
prev_ny = ny;
|
||||
prev_nz = nz;
|
||||
glNormal3f(nx,ny,nz);
|
||||
}
|
||||
|
||||
/* draw polygon/triangle/quad */
|
||||
for (j=0; j<face->index_cnt; j++)
|
||||
glVertex3f(PX(j),PY(j),PZ(j));
|
||||
|
||||
}
|
||||
|
||||
/* if glBegin was called call glEnd */
|
||||
if (prev_index_cnt > 0)
|
||||
glEnd();
|
||||
}
|
||||
|
||||
|
||||
GLfloat lw_object_radius(const lwObject *lwo)
|
||||
{
|
||||
int i;
|
||||
double max_radius = 0.0;
|
||||
|
||||
for (i=0; i<lwo->vertex_cnt; i++) {
|
||||
GLfloat *v = &lwo->vertex[i*3];
|
||||
double r = v[0]*v[0] + v[1]*v[1] + v[2]*v[2];
|
||||
if (r > max_radius)
|
||||
max_radius = r;
|
||||
}
|
||||
return sqrt(max_radius);
|
||||
}
|
||||
|
||||
void lw_object_scale(lwObject *lwo, GLfloat scale)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0; i<lwo->vertex_cnt; i++) {
|
||||
lwo->vertex[i*3+0] *= scale;
|
||||
lwo->vertex[i*3+1] *= scale;
|
||||
lwo->vertex[i*3+2] *= scale;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 1998 Janne L<>f <jlof@mail.student.oulu.fi>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef LW_H
|
||||
#define LW_H
|
||||
|
||||
#include <GL/gl.h>
|
||||
|
||||
#define LW_MAX_POINTS 200
|
||||
#define LW_MAX_NAME_LEN 500
|
||||
|
||||
typedef struct {
|
||||
char name[LW_MAX_NAME_LEN];
|
||||
GLfloat r,g,b;
|
||||
} lwMaterial;
|
||||
|
||||
typedef struct {
|
||||
int material; /* material of this face */
|
||||
int index_cnt; /* number of vertices */
|
||||
int *index; /* index to vertex */
|
||||
float *texcoord; /* u,v texture coordinates */
|
||||
} lwFace;
|
||||
|
||||
typedef struct {
|
||||
int face_cnt;
|
||||
lwFace *face;
|
||||
|
||||
int material_cnt;
|
||||
lwMaterial *material;
|
||||
|
||||
int vertex_cnt;
|
||||
GLfloat *vertex;
|
||||
|
||||
} lwObject;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int lw_is_lwobject(const char *lw_file);
|
||||
lwObject *lw_object_read(const char *lw_file);
|
||||
void lw_object_free( lwObject *lw_object);
|
||||
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 */
|
||||
|
@@ -1,18 +0,0 @@
|
||||
#
|
||||
# File: makefile.b32
|
||||
# Author: Julian Smart
|
||||
# Created: 1999
|
||||
# Updated:
|
||||
# Copyright:
|
||||
#
|
||||
# Makefile : Builds sample for 32-bit BC++
|
||||
|
||||
WXDIR = $(WXWIN)
|
||||
|
||||
TARGET=penguin
|
||||
EXTRALIBS=$(WXDIR)\lib\glcanvas.lib
|
||||
EXTRACPPFLAGS=-I$(WXDIR)\utils\glcanvas\win
|
||||
OBJECTS = $(TARGET).obj lw.obj trackball.obj
|
||||
|
||||
!include $(WXDIR)\src\makeprog.b32
|
||||
|
@@ -1,21 +0,0 @@
|
||||
#
|
||||
# File: makefile.bcc
|
||||
# Author: Julian Smart
|
||||
# Created: 1998
|
||||
# Updated:
|
||||
#
|
||||
# Builds a BC++ 16-bit sample
|
||||
|
||||
!if "$(WXWIN)" == ""
|
||||
!error You must define the WXWIN variable in autoexec.bat, e.g. WXWIN=c:\wx
|
||||
!endif
|
||||
|
||||
WXDIR = $(WXWIN)
|
||||
|
||||
TARGET=cube
|
||||
EXTRALIBS=$(WXDIR)\lib\glcanvas.lib
|
||||
EXTRACPPFLAGS=-I$(WXDIR)\utils\glcanvas\win
|
||||
OBJECTS = $(TARGET).obj
|
||||
|
||||
!include $(WXDIR)\src\makeprog.bcc
|
||||
|
@@ -1,18 +0,0 @@
|
||||
#
|
||||
# File: makefile.g95
|
||||
# Author: Julian Smart
|
||||
# Created: 1999
|
||||
# Updated:
|
||||
# Copyright: (c) Julian Smart, 1999
|
||||
#
|
||||
# Makefile for wxWindows sample (Cygwin/Mingw32).
|
||||
|
||||
WXDIR = ../../../..
|
||||
|
||||
TARGET=penguin
|
||||
EXTRACPPFLAGS=-I../../win
|
||||
EXTRALIBS=-lglcanvas -lopengl32 -lglu32
|
||||
OBJECTS = $(TARGET).o lw.o trackball.o
|
||||
|
||||
include $(WXDIR)/src/makeprog.g95
|
||||
|
@@ -1,21 +0,0 @@
|
||||
#
|
||||
# File: makefile.unx
|
||||
# Author: Julian Smart
|
||||
# Created: 1998
|
||||
# Updated:
|
||||
# Copyright: (c) 1998 Julian Smart
|
||||
#
|
||||
# Makefile for penguin example (UNIX).
|
||||
|
||||
PROGRAM=penguin
|
||||
|
||||
OPENGLHOME=/home/jacs/mesa/Mesa-2.3
|
||||
|
||||
EXTRACPPFLAGS=-I$(OPENGLHOME)/include -I../../motif
|
||||
EXTRALDFLAGS=-L$(OPENGLHOME)/lib
|
||||
EXTRALDLIBS=-lglcanvas_motif -lMesaGL -lMesaGLU
|
||||
|
||||
OBJECTS=$(PROGRAM).o trackball.o lw.o
|
||||
|
||||
include ../../../../src/makeprog.env
|
||||
|
@@ -1,30 +0,0 @@
|
||||
#
|
||||
# File: makefile.vc
|
||||
# Author: Julian Smart
|
||||
# Created: 1999
|
||||
# Updated:
|
||||
# Copyright: (c) Julian Smart
|
||||
#
|
||||
# Makefile : Builds sample (VC++, WIN32)
|
||||
# Use FINAL=1 argument to nmake to build final version with no debug info.
|
||||
|
||||
# Set WXDIR for your system
|
||||
WXDIR = $(WXWIN)
|
||||
|
||||
!if "$(FINAL)" == "1"
|
||||
!else
|
||||
LIBEXT=_d
|
||||
!endif
|
||||
|
||||
PROGRAM=penguin
|
||||
OBJECTS = $(PROGRAM).obj trackball.obj lw.obj
|
||||
EXTRAINC=-I..\..\win
|
||||
EXTRALIBS=$(WXDIR)\lib\glcanvas$(LIBEXT).lib glu32.lib opengl32.lib
|
||||
|
||||
!include $(WXDIR)\src\makeprog.vc
|
||||
|
||||
lw.obj: lw.cpp lw.h
|
||||
$(cc) @<<
|
||||
$(CPPFLAGS2) /c $*.$(SRCSUFF)
|
||||
<<
|
||||
|
@@ -1,17 +0,0 @@
|
||||
#
|
||||
# Makefile for WATCOM
|
||||
#
|
||||
# Created by Julian Smart, January 1999
|
||||
#
|
||||
#
|
||||
|
||||
WXDIR = $(%WXWIN)
|
||||
|
||||
PROGRAM = cube
|
||||
OBJECTS = $(PROGRAM).obj
|
||||
EXTRALIBS=$(WXDIR)\lib\glcanvas.lib
|
||||
EXTRACPPFLAGS=-I$(WXDIR)\utils\glcanvas\win
|
||||
|
||||
!include $(WXDIR)\src\makeprog.wat
|
||||
|
||||
|
@@ -1,236 +0,0 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: penguin.cpp
|
||||
// Purpose: wxGLCanvas demo program
|
||||
// Author: Robert Roebling
|
||||
// Modified by:
|
||||
// Created: 04/01/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Robert Roebling
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#endif
|
||||
|
||||
#include "penguin.h"
|
||||
#include <GL/glu.h>
|
||||
|
||||
#define VIEW_ASPECT 1.3
|
||||
|
||||
/* `Main program' equivalent, creating windows and returning main app frame */
|
||||
bool MyApp::OnInit(void)
|
||||
{
|
||||
|
||||
/* Create the main frame window */
|
||||
MyFrame *frame = new MyFrame(NULL, "wxWindows OpenGL Demo", wxPoint(50, 50), wxSize(400, 300));
|
||||
|
||||
/* Make a menubar */
|
||||
wxMenu *fileMenu = new wxMenu;
|
||||
|
||||
fileMenu->Append(wxID_EXIT, "E&xit");
|
||||
wxMenuBar *menuBar = new wxMenuBar;
|
||||
menuBar->Append(fileMenu, "&File");
|
||||
frame->SetMenuBar(menuBar);
|
||||
|
||||
frame->m_canvas = new TestGLCanvas(frame, -1, wxPoint(0, 0), wxSize(200, 200));
|
||||
|
||||
/* Load file wiht mesh data */
|
||||
frame->m_canvas->LoadLWO( "penguin.lwo" );
|
||||
|
||||
/* Show the frame */
|
||||
frame->Show(TRUE);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
IMPLEMENT_APP(MyApp)
|
||||
|
||||
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
||||
EVT_MENU(wxID_EXIT, MyFrame::OnExit)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
/* My frame constructor */
|
||||
MyFrame::MyFrame(wxFrame *frame, const wxString& title, const wxPoint& pos,
|
||||
const wxSize& size, long style):
|
||||
wxFrame(frame, -1, title, pos, size, style)
|
||||
{
|
||||
m_canvas = NULL;
|
||||
}
|
||||
|
||||
/* Intercept menu commands */
|
||||
void MyFrame::OnExit(wxCommandEvent& event)
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
BEGIN_EVENT_TABLE(TestGLCanvas, wxGLCanvas)
|
||||
EVT_SIZE(TestGLCanvas::OnSize)
|
||||
EVT_PAINT(TestGLCanvas::OnPaint)
|
||||
EVT_ERASE_BACKGROUND(TestGLCanvas::OnEraseBackground)
|
||||
EVT_MOUSE_EVENTS(TestGLCanvas::OnMouse)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
TestGLCanvas::TestGLCanvas(wxWindow *parent, wxWindowID id,
|
||||
const wxPoint& pos, const wxSize& size, long style, const wxString& name):
|
||||
wxGLCanvas(parent, id, pos, size, style, name)
|
||||
{
|
||||
block = FALSE;
|
||||
}
|
||||
|
||||
TestGLCanvas::~TestGLCanvas(void)
|
||||
{
|
||||
/* destroy mesh */
|
||||
lw_object_free(info.lwobject);
|
||||
}
|
||||
|
||||
void TestGLCanvas::OnPaint( wxPaintEvent& event )
|
||||
{
|
||||
/* must always be here */
|
||||
wxPaintDC dc(this);
|
||||
|
||||
#ifndef __WXMOTIF__
|
||||
if (!GetContext()) return;
|
||||
#endif
|
||||
|
||||
SetCurrent();
|
||||
|
||||
/* initialize OpenGL */
|
||||
if (info.do_init == TRUE)
|
||||
{
|
||||
InitGL();
|
||||
info.do_init = FALSE;
|
||||
}
|
||||
|
||||
/* view */
|
||||
glMatrixMode( GL_PROJECTION );
|
||||
glLoadIdentity();
|
||||
gluPerspective( info.zoom, VIEW_ASPECT, 1, 100 );
|
||||
glMatrixMode( GL_MODELVIEW );
|
||||
|
||||
/* clear */
|
||||
glClearColor( .3, .4, .6, 1 );
|
||||
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
|
||||
|
||||
/* transformations */
|
||||
GLfloat m[4][4];
|
||||
glLoadIdentity();
|
||||
glTranslatef( 0, 0, -30 );
|
||||
build_rotmatrix( m,info.quat );
|
||||
glMultMatrixf( &m[0][0] );
|
||||
|
||||
/* draw object */
|
||||
lw_object_show( info.lwobject );
|
||||
|
||||
/* flush */
|
||||
glFlush();
|
||||
|
||||
/* swap */
|
||||
SwapBuffers();
|
||||
}
|
||||
|
||||
void TestGLCanvas::OnSize(wxSizeEvent& event)
|
||||
{
|
||||
int width, height;
|
||||
GetClientSize(& width, & height);
|
||||
|
||||
#ifndef __WXMOTIF__
|
||||
if (GetContext())
|
||||
#endif
|
||||
{
|
||||
SetCurrent();
|
||||
glViewport(0, 0, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
void TestGLCanvas::OnEraseBackground(wxEraseEvent& event)
|
||||
{
|
||||
/* Do nothing, to avoid flashing on MSW */
|
||||
}
|
||||
|
||||
void TestGLCanvas::LoadLWO(const wxString &filename)
|
||||
{
|
||||
/* test if lightwave object */
|
||||
if (!lw_is_lwobject(filename)) return;
|
||||
|
||||
/* read lightwave object */
|
||||
lwObject *lwobject = lw_object_read(filename);
|
||||
|
||||
/* scale */
|
||||
lw_object_scale(lwobject, 10.0 / lw_object_radius(lwobject));
|
||||
|
||||
/* set up mesh info */
|
||||
info.do_init = TRUE;
|
||||
info.lwobject = lwobject;
|
||||
info.beginx = 0;
|
||||
info.beginy = 0;
|
||||
info.zoom = 45;
|
||||
trackball( info.quat, 0.0, 0.0, 0.0, 0.0 );
|
||||
}
|
||||
|
||||
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 - 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 );
|
||||
|
||||
/* orientation has changed, redraw mesh */
|
||||
Refresh(FALSE);
|
||||
}
|
||||
|
||||
info.beginx = event.GetX();
|
||||
info.beginy = event.GetY();
|
||||
}
|
||||
|
||||
void TestGLCanvas::InitGL(void)
|
||||
{
|
||||
GLfloat light0_pos[4] = { -50.0, 50.0, 0.0, 0.0 };
|
||||
GLfloat light0_color[4] = { .6, .6, .6, 1.0 }; /* white light */
|
||||
GLfloat light1_pos[4] = { 50.0, 50.0, 0.0, 0.0 };
|
||||
GLfloat light1_color[4] = { .4, .4, 1, 1.0 }; /* cold blue light */
|
||||
|
||||
/* remove back faces */
|
||||
glDisable(GL_CULL_FACE);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
/* speedups */
|
||||
glEnable(GL_DITHER);
|
||||
glShadeModel(GL_SMOOTH);
|
||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
|
||||
glHint(GL_POLYGON_SMOOTH_HINT, GL_FASTEST);
|
||||
|
||||
/* light */
|
||||
glLightfv(GL_LIGHT0, GL_POSITION, light0_pos);
|
||||
glLightfv(GL_LIGHT0, GL_DIFFUSE, light0_color);
|
||||
glLightfv(GL_LIGHT1, GL_POSITION, light1_pos);
|
||||
glLightfv(GL_LIGHT1, GL_DIFFUSE, light1_color);
|
||||
glEnable(GL_LIGHT0);
|
||||
glEnable(GL_LIGHT1);
|
||||
glEnable(GL_LIGHTING);
|
||||
|
||||
glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE);
|
||||
glEnable(GL_COLOR_MATERIAL);
|
||||
}
|
||||
|
||||
|
@@ -1,84 +0,0 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: penguin.h
|
||||
// Purpose: wxGLCanvas demo program
|
||||
// Author: Robert Roebling
|
||||
// Modified by:
|
||||
// Created: 04/01/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Robert Roebling
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_PENGUIN_H_
|
||||
#define _WX_PENGUIN_H_
|
||||
|
||||
|
||||
#include "wx/defs.h"
|
||||
#include "wx/app.h"
|
||||
#include "wx/menu.h"
|
||||
#include "wx/dcclient.h"
|
||||
|
||||
#include "glcanvas.h"
|
||||
|
||||
extern "C" {
|
||||
#include "lw.h"
|
||||
#include "trackball.h"
|
||||
}
|
||||
|
||||
/* information needed to display lightwave mesh */
|
||||
typedef struct
|
||||
{
|
||||
// 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 */
|
||||
float zoom; /* field of view in degrees */
|
||||
} mesh_info;
|
||||
|
||||
|
||||
/* Define a new application type */
|
||||
class MyApp: public wxApp
|
||||
{
|
||||
public:
|
||||
bool OnInit(void);
|
||||
};
|
||||
|
||||
/* Define a new frame type */
|
||||
class TestGLCanvas;
|
||||
class MyFrame: public wxFrame
|
||||
{
|
||||
public:
|
||||
MyFrame(wxFrame *frame, const wxString& title, const wxPoint& pos, const wxSize& size,
|
||||
long style = wxDEFAULT_FRAME_STYLE);
|
||||
|
||||
void OnExit(wxCommandEvent& event);
|
||||
public:
|
||||
TestGLCanvas* m_canvas;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
|
||||
class TestGLCanvas: public wxGLCanvas
|
||||
{
|
||||
public:
|
||||
TestGLCanvas(wxWindow *parent, const wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = "TestGLCanvas");
|
||||
~TestGLCanvas(void);
|
||||
|
||||
void OnPaint(wxPaintEvent& event);
|
||||
void OnSize(wxSizeEvent& event);
|
||||
void OnEraseBackground(wxEraseEvent& event);
|
||||
void LoadLWO( const wxString &filename);
|
||||
void OnMouse( wxMouseEvent& event );
|
||||
void InitGL(void);
|
||||
|
||||
mesh_info info;
|
||||
bool block;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -1,3 +0,0 @@
|
||||
/* mondrian ICON "mondrian.ico" */
|
||||
#include "wx/msw/wx.rc"
|
||||
|
@@ -1,324 +0,0 @@
|
||||
/*
|
||||
* (c) Copyright 1993, 1994, Silicon Graphics, Inc.
|
||||
* ALL RIGHTS RESERVED
|
||||
* Permission to use, copy, modify, and distribute this software for
|
||||
* any purpose and without fee is hereby granted, provided that the above
|
||||
* copyright notice appear in all copies and that both the copyright notice
|
||||
* and this permission notice appear in supporting documentation, and that
|
||||
* the name of Silicon Graphics, Inc. not be used in advertising
|
||||
* or publicity pertaining to distribution of the software without specific,
|
||||
* written prior permission.
|
||||
*
|
||||
* THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
|
||||
* AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
|
||||
* GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
|
||||
* SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
|
||||
* KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
|
||||
* LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
|
||||
* THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
|
||||
* POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* US Government Users Restricted Rights
|
||||
* Use, duplication, or disclosure by the Government is subject to
|
||||
* restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
|
||||
* (c)(1)(ii) of the Rights in Technical Data and Computer Software
|
||||
* clause at DFARS 252.227-7013 and/or in similar or successor
|
||||
* clauses in the FAR or the DOD or NASA FAR Supplement.
|
||||
* Unpublished-- rights reserved under the copyright laws of the
|
||||
* United States. Contractor/manufacturer is Silicon Graphics,
|
||||
* Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
|
||||
*
|
||||
* OpenGL(TM) is a trademark of Silicon Graphics, Inc.
|
||||
*/
|
||||
/*
|
||||
* Trackball code:
|
||||
*
|
||||
* Implementation of a virtual trackball.
|
||||
* Implemented by Gavin Bell, lots of ideas from Thant Tessman and
|
||||
* the August '88 issue of Siggraph's "Computer Graphics," pp. 121-129.
|
||||
*
|
||||
* Vector manip code:
|
||||
*
|
||||
* Original code from:
|
||||
* David M. Ciemiewicz, Mark Grossman, Henry Moreton, and Paul Haeberli
|
||||
*
|
||||
* Much mucking with by:
|
||||
* Gavin Bell
|
||||
*/
|
||||
#include <math.h>
|
||||
#include "trackball.h"
|
||||
|
||||
/*
|
||||
* This size should really be based on the distance from the center of
|
||||
* rotation to the point on the object underneath the mouse. That
|
||||
* point would then track the mouse as closely as possible. This is a
|
||||
* simple example, though, so that is left as an Exercise for the
|
||||
* Programmer.
|
||||
*/
|
||||
#define TRACKBALLSIZE (0.8)
|
||||
|
||||
/*
|
||||
* Local function prototypes (not defined in trackball.h)
|
||||
*/
|
||||
static float tb_project_to_sphere(float, float, float);
|
||||
static void normalize_quat(float [4]);
|
||||
|
||||
void
|
||||
vzero(float *v)
|
||||
{
|
||||
v[0] = 0.0;
|
||||
v[1] = 0.0;
|
||||
v[2] = 0.0;
|
||||
}
|
||||
|
||||
void
|
||||
vset(float *v, float x, float y, float z)
|
||||
{
|
||||
v[0] = x;
|
||||
v[1] = y;
|
||||
v[2] = z;
|
||||
}
|
||||
|
||||
void
|
||||
vsub(const float *src1, const float *src2, float *dst)
|
||||
{
|
||||
dst[0] = src1[0] - src2[0];
|
||||
dst[1] = src1[1] - src2[1];
|
||||
dst[2] = src1[2] - src2[2];
|
||||
}
|
||||
|
||||
void
|
||||
vcopy(const float *v1, float *v2)
|
||||
{
|
||||
register int i;
|
||||
for (i = 0 ; i < 3 ; i++)
|
||||
v2[i] = v1[i];
|
||||
}
|
||||
|
||||
void
|
||||
vcross(const float *v1, const float *v2, float *cross)
|
||||
{
|
||||
float temp[3];
|
||||
|
||||
temp[0] = (v1[1] * v2[2]) - (v1[2] * v2[1]);
|
||||
temp[1] = (v1[2] * v2[0]) - (v1[0] * v2[2]);
|
||||
temp[2] = (v1[0] * v2[1]) - (v1[1] * v2[0]);
|
||||
vcopy(temp, cross);
|
||||
}
|
||||
|
||||
float
|
||||
vlength(const float *v)
|
||||
{
|
||||
return sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
|
||||
}
|
||||
|
||||
void
|
||||
vscale(float *v, float div)
|
||||
{
|
||||
v[0] *= div;
|
||||
v[1] *= div;
|
||||
v[2] *= div;
|
||||
}
|
||||
|
||||
void
|
||||
vnormal(float *v)
|
||||
{
|
||||
vscale(v,1.0/vlength(v));
|
||||
}
|
||||
|
||||
float
|
||||
vdot(const float *v1, const float *v2)
|
||||
{
|
||||
return v1[0]*v2[0] + v1[1]*v2[1] + v1[2]*v2[2];
|
||||
}
|
||||
|
||||
void
|
||||
vadd(const float *src1, const float *src2, float *dst)
|
||||
{
|
||||
dst[0] = src1[0] + src2[0];
|
||||
dst[1] = src1[1] + src2[1];
|
||||
dst[2] = src1[2] + src2[2];
|
||||
}
|
||||
|
||||
/*
|
||||
* Ok, simulate a track-ball. Project the points onto the virtual
|
||||
* trackball, then figure out the axis of rotation, which is the cross
|
||||
* product of P1 P2 and O P1 (O is the center of the ball, 0,0,0)
|
||||
* Note: This is a deformed trackball-- is a trackball in the center,
|
||||
* but is deformed into a hyperbolic sheet of rotation away from the
|
||||
* center. This particular function was chosen after trying out
|
||||
* several variations.
|
||||
*
|
||||
* It is assumed that the arguments to this routine are in the range
|
||||
* (-1.0 ... 1.0)
|
||||
*/
|
||||
void
|
||||
trackball(float q[4], float p1x, float p1y, float p2x, float p2y)
|
||||
{
|
||||
float a[3]; /* Axis of rotation */
|
||||
float phi; /* how much to rotate about axis */
|
||||
float p1[3], p2[3], d[3];
|
||||
float t;
|
||||
|
||||
if (p1x == p2x && p1y == p2y) {
|
||||
/* Zero rotation */
|
||||
vzero(q);
|
||||
q[3] = 1.0;
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* First, figure out z-coordinates for projection of P1 and P2 to
|
||||
* deformed sphere
|
||||
*/
|
||||
vset(p1,p1x,p1y,tb_project_to_sphere(TRACKBALLSIZE,p1x,p1y));
|
||||
vset(p2,p2x,p2y,tb_project_to_sphere(TRACKBALLSIZE,p2x,p2y));
|
||||
|
||||
/*
|
||||
* Now, we want the cross product of P1 and P2
|
||||
*/
|
||||
vcross(p2,p1,a);
|
||||
|
||||
/*
|
||||
* Figure out how much to rotate around that axis.
|
||||
*/
|
||||
vsub(p1,p2,d);
|
||||
t = vlength(d) / (2.0*TRACKBALLSIZE);
|
||||
|
||||
/*
|
||||
* Avoid problems with out-of-control values...
|
||||
*/
|
||||
if (t > 1.0) t = 1.0;
|
||||
if (t < -1.0) t = -1.0;
|
||||
phi = 2.0 * asin(t);
|
||||
|
||||
axis_to_quat(a,phi,q);
|
||||
}
|
||||
|
||||
/*
|
||||
* Given an axis and angle, compute quaternion.
|
||||
*/
|
||||
void
|
||||
axis_to_quat(float a[3], float phi, float q[4])
|
||||
{
|
||||
vnormal(a);
|
||||
vcopy(a,q);
|
||||
vscale(q,sin(phi/2.0));
|
||||
q[3] = cos(phi/2.0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Project an x,y pair onto a sphere of radius r OR a hyperbolic sheet
|
||||
* if we are away from the center of the sphere.
|
||||
*/
|
||||
static float
|
||||
tb_project_to_sphere(float r, float x, float y)
|
||||
{
|
||||
float d, t, z;
|
||||
|
||||
d = sqrt(x*x + y*y);
|
||||
if (d < r * 0.70710678118654752440) { /* Inside sphere */
|
||||
z = sqrt(r*r - d*d);
|
||||
} else { /* On hyperbola */
|
||||
t = r / 1.41421356237309504880;
|
||||
z = t*t / d;
|
||||
}
|
||||
return z;
|
||||
}
|
||||
|
||||
/*
|
||||
* Given two rotations, e1 and e2, expressed as quaternion rotations,
|
||||
* figure out the equivalent single rotation and stuff it into dest.
|
||||
*
|
||||
* This routine also normalizes the result every RENORMCOUNT times it is
|
||||
* called, to keep error from creeping in.
|
||||
*
|
||||
* NOTE: This routine is written so that q1 or q2 may be the same
|
||||
* as dest (or each other).
|
||||
*/
|
||||
|
||||
#define RENORMCOUNT 97
|
||||
|
||||
void
|
||||
add_quats(float q1[4], float q2[4], float dest[4])
|
||||
{
|
||||
static int count=0;
|
||||
float t1[4], t2[4], t3[4];
|
||||
float tf[4];
|
||||
|
||||
vcopy(q1,t1);
|
||||
vscale(t1,q2[3]);
|
||||
|
||||
vcopy(q2,t2);
|
||||
vscale(t2,q1[3]);
|
||||
|
||||
vcross(q2,q1,t3);
|
||||
vadd(t1,t2,tf);
|
||||
vadd(t3,tf,tf);
|
||||
tf[3] = q1[3] * q2[3] - vdot(q1,q2);
|
||||
|
||||
dest[0] = tf[0];
|
||||
dest[1] = tf[1];
|
||||
dest[2] = tf[2];
|
||||
dest[3] = tf[3];
|
||||
|
||||
if (++count > RENORMCOUNT) {
|
||||
count = 0;
|
||||
normalize_quat(dest);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Quaternions always obey: a^2 + b^2 + c^2 + d^2 = 1.0
|
||||
* If they don't add up to 1.0, dividing by their magnitued will
|
||||
* renormalize them.
|
||||
*
|
||||
* Note: See the following for more information on quaternions:
|
||||
*
|
||||
* - Shoemake, K., Animating rotation with quaternion curves, Computer
|
||||
* Graphics 19, No 3 (Proc. SIGGRAPH'85), 245-254, 1985.
|
||||
* - Pletinckx, D., Quaternion calculus as a basic tool in computer
|
||||
* graphics, The Visual Computer 5, 2-13, 1989.
|
||||
*/
|
||||
static void
|
||||
normalize_quat(float q[4])
|
||||
{
|
||||
int i;
|
||||
float mag;
|
||||
|
||||
mag = (q[0]*q[0] + q[1]*q[1] + q[2]*q[2] + q[3]*q[3]);
|
||||
for (i = 0; i < 4; i++) q[i] /= mag;
|
||||
}
|
||||
|
||||
/*
|
||||
* Build a rotation matrix, given a quaternion rotation.
|
||||
*
|
||||
*/
|
||||
void
|
||||
build_rotmatrix(float m[4][4], float q[4])
|
||||
{
|
||||
m[0][0] = 1.0 - 2.0 * (q[1] * q[1] + q[2] * q[2]);
|
||||
m[0][1] = 2.0 * (q[0] * q[1] - q[2] * q[3]);
|
||||
m[0][2] = 2.0 * (q[2] * q[0] + q[1] * q[3]);
|
||||
m[0][3] = 0.0;
|
||||
|
||||
m[1][0] = 2.0 * (q[0] * q[1] + q[2] * q[3]);
|
||||
m[1][1]= 1.0 - 2.0 * (q[2] * q[2] + q[0] * q[0]);
|
||||
m[1][2] = 2.0 * (q[1] * q[2] - q[0] * q[3]);
|
||||
m[1][3] = 0.0;
|
||||
|
||||
m[2][0] = 2.0 * (q[2] * q[0] - q[1] * q[3]);
|
||||
m[2][1] = 2.0 * (q[1] * q[2] + q[0] * q[3]);
|
||||
m[2][2] = 1.0 - 2.0 * (q[1] * q[1] + q[0] * q[0]);
|
||||
m[2][3] = 0.0;
|
||||
|
||||
m[3][0] = 0.0;
|
||||
m[3][1] = 0.0;
|
||||
m[3][2] = 0.0;
|
||||
m[3][3] = 1.0;
|
||||
}
|
||||
|
@@ -1,78 +0,0 @@
|
||||
/*
|
||||
* (c) Copyright 1993, 1994, Silicon Graphics, Inc.
|
||||
* ALL RIGHTS RESERVED
|
||||
* Permission to use, copy, modify, and distribute this software for
|
||||
* any purpose and without fee is hereby granted, provided that the above
|
||||
* copyright notice appear in all copies and that both the copyright notice
|
||||
* and this permission notice appear in supporting documentation, and that
|
||||
* the name of Silicon Graphics, Inc. not be used in advertising
|
||||
* or publicity pertaining to distribution of the software without specific,
|
||||
* written prior permission.
|
||||
*
|
||||
* THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
|
||||
* AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
|
||||
* GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
|
||||
* SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
|
||||
* KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
|
||||
* LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
|
||||
* THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
|
||||
* POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* US Government Users Restricted Rights
|
||||
* Use, duplication, or disclosure by the Government is subject to
|
||||
* restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
|
||||
* (c)(1)(ii) of the Rights in Technical Data and Computer Software
|
||||
* clause at DFARS 252.227-7013 and/or in similar or successor
|
||||
* clauses in the FAR or the DOD or NASA FAR Supplement.
|
||||
* Unpublished-- rights reserved under the copyright laws of the
|
||||
* United States. Contractor/manufacturer is Silicon Graphics,
|
||||
* Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
|
||||
*
|
||||
* OpenGL(TM) is a trademark of Silicon Graphics, Inc.
|
||||
*/
|
||||
/*
|
||||
* trackball.h
|
||||
* A virtual trackball implementation
|
||||
* Written by Gavin Bell for Silicon Graphics, November 1988.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Pass the x and y coordinates of the last and current positions of
|
||||
* the mouse, scaled so they are from (-1.0 ... 1.0).
|
||||
*
|
||||
* The resulting rotation is returned as a quaternion rotation in the
|
||||
* first paramater.
|
||||
*/
|
||||
void
|
||||
trackball(float q[4], float p1x, float p1y, float p2x, float p2y);
|
||||
|
||||
/*
|
||||
* Given two quaternions, add them together to get a third quaternion.
|
||||
* Adding quaternions to get a compound rotation is analagous to adding
|
||||
* translations to get a compound translation. When incrementally
|
||||
* adding rotations, the first argument here should be the new
|
||||
* rotation, the second and third the total rotation (which will be
|
||||
* over-written with the resulting new total rotation).
|
||||
*/
|
||||
void
|
||||
add_quats(float *q1, float *q2, float *dest);
|
||||
|
||||
/*
|
||||
* A useful function, builds a rotation matrix in Matrix based on
|
||||
* given quaternion.
|
||||
*/
|
||||
void
|
||||
build_rotmatrix(float m[4][4], float q[4]);
|
||||
|
||||
/*
|
||||
* This function computes a quaternion based on an axis (defined by
|
||||
* the given vector) and an angle about which to rotate. The angle is
|
||||
* expressed in radians. The result is put into the third argument.
|
||||
*/
|
||||
void
|
||||
axis_to_quat(float a[3], float phi, float q[4]);
|
||||
|
@@ -1,21 +0,0 @@
|
||||
#
|
||||
# File: Makefile
|
||||
# Author: Robert Roebling
|
||||
# Created: 1999
|
||||
# Updated:
|
||||
# Copyright: (c) 1998 Robert Roebling
|
||||
#
|
||||
# "%W% %G%"
|
||||
#
|
||||
|
||||
top_srcdir = @top_srcdir@/..
|
||||
top_builddir = ../../..
|
||||
|
||||
VPATH= $(top_srcdir)/utils/glcanvas/win
|
||||
|
||||
LIBTARGET=libwxglcanvas
|
||||
|
||||
OBJECTS=glcanvas.o
|
||||
|
||||
include $(top_builddir)/src/makelib.env
|
||||
|
@@ -1,618 +0,0 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: glcanvas.cpp
|
||||
// Purpose: wxGLCanvas, for using OpenGL with wxWindows under MS Windows
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 04/01/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "glcanvas.h"
|
||||
#endif
|
||||
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#if defined(__BORLANDC__)
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include <wx/frame.h>
|
||||
#endif
|
||||
|
||||
#include <wx/msw/private.h>
|
||||
|
||||
#include "glcanvas.h"
|
||||
|
||||
wxChar wxGLCanvasClassName[] = wxT("wxGLCanvasClass");
|
||||
|
||||
LRESULT WXDLLEXPORT APIENTRY _EXPORT wxWndProc(HWND hWnd, UINT message,
|
||||
WPARAM wParam, LPARAM lParam);
|
||||
|
||||
/*
|
||||
* GLContext implementation
|
||||
*/
|
||||
|
||||
wxGLContext::wxGLContext(bool isRGB, wxGLCanvas *win, const wxPalette& palette)
|
||||
{
|
||||
m_window = win;
|
||||
|
||||
m_hDC = win->GetHDC();
|
||||
|
||||
m_glContext = wglCreateContext((HDC) m_hDC);
|
||||
wxCHECK_RET( m_glContext, "Couldn't create OpenGl context" );
|
||||
|
||||
wglMakeCurrent((HDC) m_hDC, m_glContext);
|
||||
}
|
||||
|
||||
wxGLContext::wxGLContext(
|
||||
bool isRGB, wxGLCanvas *win,
|
||||
const wxPalette& palette,
|
||||
const wxGLContext *other /* for sharing display lists */
|
||||
)
|
||||
{
|
||||
m_window = win;
|
||||
|
||||
m_hDC = win->GetHDC();
|
||||
|
||||
m_glContext = wglCreateContext((HDC) m_hDC);
|
||||
wxCHECK_RET( m_glContext, "Couldn't create OpenGl context" );
|
||||
|
||||
if( other != 0 )
|
||||
wglShareLists( other->m_glContext, m_glContext );
|
||||
|
||||
wglMakeCurrent((HDC) m_hDC, m_glContext);
|
||||
}
|
||||
|
||||
wxGLContext::~wxGLContext()
|
||||
{
|
||||
if (m_glContext)
|
||||
{
|
||||
wglMakeCurrent(NULL, NULL);
|
||||
wglDeleteContext(m_glContext);
|
||||
}
|
||||
}
|
||||
|
||||
void wxGLContext::SwapBuffers()
|
||||
{
|
||||
if (m_glContext)
|
||||
{
|
||||
wglMakeCurrent((HDC) m_hDC, m_glContext);
|
||||
::SwapBuffers((HDC) m_hDC); //blits the backbuffer into DC
|
||||
}
|
||||
}
|
||||
|
||||
void wxGLContext::SetCurrent()
|
||||
{
|
||||
if (m_glContext)
|
||||
{
|
||||
wglMakeCurrent((HDC) m_hDC, m_glContext);
|
||||
}
|
||||
|
||||
/*
|
||||
setupPixelFormat(hDC);
|
||||
setupPalette(hDC);
|
||||
*/
|
||||
}
|
||||
|
||||
void wxGLContext::SetColour(const char *colour)
|
||||
{
|
||||
float r = 0.0;
|
||||
float g = 0.0;
|
||||
float b = 0.0;
|
||||
wxColour *col = wxTheColourDatabase->FindColour(colour);
|
||||
if (col)
|
||||
{
|
||||
r = (float)(col->Red()/256.0);
|
||||
g = (float)(col->Green()/256.0);
|
||||
b = (float)(col->Blue()/256.0);
|
||||
glColor3f( r, g, b);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* wxGLCanvas implementation
|
||||
*/
|
||||
|
||||
IMPLEMENT_CLASS(wxGLCanvas, wxScrolledWindow)
|
||||
|
||||
BEGIN_EVENT_TABLE(wxGLCanvas, wxScrolledWindow)
|
||||
EVT_SIZE(wxGLCanvas::OnSize)
|
||||
EVT_PALETTE_CHANGED(wxGLCanvas::OnPaletteChanged)
|
||||
EVT_QUERY_NEW_PALETTE(wxGLCanvas::OnQueryNewPalette)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
wxGLCanvas::wxGLCanvas(wxWindow *parent, wxWindowID id,
|
||||
const wxPoint& pos, const wxSize& size, long style, const wxString& name,
|
||||
int *attribList /* not used yet! */, const wxPalette& palette):
|
||||
wxScrolledWindow()
|
||||
{
|
||||
m_glContext = (wxGLContext*) NULL;
|
||||
|
||||
bool ret = Create(parent, id, pos, size, style, name);
|
||||
|
||||
if ( ret )
|
||||
{
|
||||
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
|
||||
SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
|
||||
}
|
||||
|
||||
m_hDC = (WXHDC) ::GetDC((HWND) GetHWND());
|
||||
|
||||
SetupPixelFormat();
|
||||
SetupPalette(palette);
|
||||
|
||||
m_glContext = new wxGLContext(TRUE, this, palette);
|
||||
}
|
||||
|
||||
wxGLCanvas::wxGLCanvas( wxWindow *parent,
|
||||
const wxGLContext *shared, wxWindowID id,
|
||||
const wxPoint& pos, const wxSize& size, long style, const wxString& name,
|
||||
int *attribList, const wxPalette& palette )
|
||||
: wxScrolledWindow()
|
||||
{
|
||||
m_glContext = (wxGLContext*) NULL;
|
||||
|
||||
bool ret = Create(parent, id, pos, size, style, name);
|
||||
|
||||
if ( ret )
|
||||
{
|
||||
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
|
||||
SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
|
||||
}
|
||||
|
||||
m_hDC = (WXHDC) ::GetDC((HWND) GetHWND());
|
||||
|
||||
SetupPixelFormat();
|
||||
SetupPalette(palette);
|
||||
|
||||
m_glContext = new wxGLContext(TRUE, this, palette, shared );
|
||||
}
|
||||
|
||||
// Not very usefull for wxMSW, but this is to be wxGTK compliant
|
||||
|
||||
wxGLCanvas::wxGLCanvas( wxWindow *parent, const wxGLCanvas *shared, wxWindowID id,
|
||||
const wxPoint& pos, const wxSize& size, long style, const wxString& name,
|
||||
int *attribList, const wxPalette& palette ):
|
||||
wxScrolledWindow()
|
||||
{
|
||||
m_glContext = (wxGLContext*) NULL;
|
||||
|
||||
bool ret = Create(parent, id, pos, size, style, name);
|
||||
|
||||
if ( ret )
|
||||
{
|
||||
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
|
||||
SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
|
||||
}
|
||||
|
||||
m_hDC = (WXHDC) ::GetDC((HWND) GetHWND());
|
||||
|
||||
SetupPixelFormat();
|
||||
SetupPalette(palette);
|
||||
|
||||
wxGLContext *sharedContext=0;
|
||||
if (shared) sharedContext=shared->GetContext();
|
||||
m_glContext = new wxGLContext(TRUE, this, palette, sharedContext );
|
||||
}
|
||||
|
||||
wxGLCanvas::~wxGLCanvas()
|
||||
{
|
||||
if (m_glContext)
|
||||
delete m_glContext;
|
||||
|
||||
::ReleaseDC((HWND) GetHWND(), (HDC) m_hDC);
|
||||
}
|
||||
|
||||
// Replaces wxWindow::Create functionality, since we need to use a different window class
|
||||
bool wxGLCanvas::Create(wxWindow *parent, wxWindowID id,
|
||||
const wxPoint& pos, const wxSize& size, long style, const wxString& name)
|
||||
{
|
||||
static bool registeredGLCanvasClass = FALSE;
|
||||
|
||||
// We have to register a special window class because we need
|
||||
// the CS_OWNDC style for GLCanvas.
|
||||
|
||||
/*
|
||||
From Angel Popov <jumpo@bitex.com>
|
||||
|
||||
Here are two snips from a dicussion in the OpenGL Gamedev list that explains
|
||||
how this problem can be fixed:
|
||||
|
||||
"There are 5 common DCs available in Win95. These are aquired when you call
|
||||
GetDC or GetDCEx from a window that does _not_ have the OWNDC flag.
|
||||
OWNDC flagged windows do not get their DC from the common DC pool, the issue
|
||||
is they require 800 bytes each from the limited 64Kb local heap for GDI."
|
||||
|
||||
"The deal is, if you hold onto one of the 5 shared DC's too long (as GL apps
|
||||
do), Win95 will actually "steal" it from you. MakeCurrent fails,
|
||||
apparently, because Windows re-assigns the HDC to a different window. The
|
||||
only way to prevent this, the only reliable means, is to set CS_OWNDC."
|
||||
*/
|
||||
|
||||
if (!registeredGLCanvasClass)
|
||||
{
|
||||
WNDCLASS wndclass;
|
||||
|
||||
static const long styleNormal = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS | CS_OWNDC;
|
||||
|
||||
// the fields which are common to all classes
|
||||
wndclass.lpfnWndProc = (WNDPROC)wxWndProc;
|
||||
wndclass.cbClsExtra = 0;
|
||||
wndclass.cbWndExtra = sizeof( DWORD ); // VZ: what is this DWORD used for?
|
||||
wndclass.hInstance = wxhInstance;
|
||||
wndclass.hIcon = (HICON) NULL;
|
||||
wndclass.hCursor = ::LoadCursor((HINSTANCE)NULL, IDC_ARROW);
|
||||
wndclass.lpszMenuName = NULL;
|
||||
|
||||
// Register the GLCanvas class name
|
||||
wndclass.hbrBackground = (HBRUSH)NULL;
|
||||
wndclass.lpszClassName = wxGLCanvasClassName;
|
||||
wndclass.style = styleNormal;
|
||||
|
||||
if ( !RegisterClass(&wndclass) )
|
||||
{
|
||||
wxLogLastError("RegisterClass(wxGLCanvasClass)");
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
registeredGLCanvasClass = TRUE;
|
||||
}
|
||||
|
||||
wxCHECK_MSG( parent, FALSE, wxT("can't create wxWindow without parent") );
|
||||
|
||||
if ( !CreateBase(parent, id, pos, size, style, wxDefaultValidator, name) )
|
||||
return FALSE;
|
||||
|
||||
parent->AddChild(this);
|
||||
|
||||
DWORD msflags = 0;
|
||||
if ( style & wxBORDER )
|
||||
msflags |= WS_BORDER;
|
||||
if ( style & wxTHICK_FRAME )
|
||||
msflags |= WS_THICKFRAME;
|
||||
|
||||
msflags |= WS_CHILD | WS_VISIBLE;
|
||||
if ( style & wxCLIP_CHILDREN )
|
||||
msflags |= WS_CLIPCHILDREN;
|
||||
|
||||
bool want3D;
|
||||
WXDWORD exStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &want3D);
|
||||
|
||||
// Even with extended styles, need to combine with WS_BORDER
|
||||
// for them to look right.
|
||||
if ( want3D || (m_windowStyle & wxSIMPLE_BORDER) || (m_windowStyle & wxRAISED_BORDER ) ||
|
||||
(m_windowStyle & wxSUNKEN_BORDER) || (m_windowStyle & wxDOUBLE_BORDER))
|
||||
{
|
||||
msflags |= WS_BORDER;
|
||||
}
|
||||
|
||||
// calculate the value to return from WM_GETDLGCODE handler
|
||||
if ( GetWindowStyleFlag() & wxWANTS_CHARS )
|
||||
{
|
||||
// want everything: i.e. all keys and WM_CHAR message
|
||||
m_lDlgCode = DLGC_WANTARROWS | DLGC_WANTCHARS |
|
||||
DLGC_WANTTAB | DLGC_WANTMESSAGE;
|
||||
}
|
||||
|
||||
MSWCreate(m_windowId, parent, wxGLCanvasClassName, this, NULL,
|
||||
pos.x, pos.y,
|
||||
WidthDefault(size.x), HeightDefault(size.y),
|
||||
msflags, NULL, exStyle);
|
||||
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
|
||||
void wxGLCanvas::SetupPixelFormat() // (HDC hDC)
|
||||
{
|
||||
PIXELFORMATDESCRIPTOR pfd = {
|
||||
sizeof(PIXELFORMATDESCRIPTOR), /* size */
|
||||
1, /* version */
|
||||
PFD_SUPPORT_OPENGL |
|
||||
PFD_DRAW_TO_WINDOW |
|
||||
PFD_DOUBLEBUFFER, /* support double-buffering */
|
||||
PFD_TYPE_RGBA, /* color type */
|
||||
16, /* prefered color depth */
|
||||
0, 0, 0, 0, 0, 0, /* color bits (ignored) */
|
||||
0, /* no alpha buffer */
|
||||
0, /* alpha bits (ignored) */
|
||||
0, /* no accumulation buffer */
|
||||
0, 0, 0, 0, /* accum bits (ignored) */
|
||||
16, /* depth buffer */
|
||||
0, /* no stencil buffer */
|
||||
0, /* no auxiliary buffers */
|
||||
PFD_MAIN_PLANE, /* main layer */
|
||||
0, /* reserved */
|
||||
0, 0, 0, /* no layer, visible, damage masks */
|
||||
};
|
||||
int pixelFormat;
|
||||
|
||||
pixelFormat = ChoosePixelFormat((HDC) m_hDC, &pfd);
|
||||
if (pixelFormat == 0) {
|
||||
MessageBox(WindowFromDC((HDC) m_hDC), "ChoosePixelFormat failed.", "Error",
|
||||
MB_ICONERROR | MB_OK);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (SetPixelFormat((HDC) m_hDC, pixelFormat, &pfd) != TRUE) {
|
||||
MessageBox(WindowFromDC((HDC) m_hDC), "SetPixelFormat failed.", "Error",
|
||||
MB_ICONERROR | MB_OK);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
void wxGLCanvas::SetupPalette(const wxPalette& palette)
|
||||
{
|
||||
int pixelFormat = GetPixelFormat((HDC) m_hDC);
|
||||
PIXELFORMATDESCRIPTOR pfd;
|
||||
|
||||
DescribePixelFormat((HDC) m_hDC, pixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
|
||||
|
||||
if (pfd.dwFlags & PFD_NEED_PALETTE)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_palette = palette;
|
||||
|
||||
if ( !m_palette.Ok() )
|
||||
{
|
||||
m_palette = CreateDefaultPalette();
|
||||
}
|
||||
|
||||
if (m_palette.Ok())
|
||||
{
|
||||
SelectPalette((HDC) m_hDC, (HPALETTE) m_palette.GetHPALETTE(), FALSE);
|
||||
RealizePalette((HDC) m_hDC);
|
||||
}
|
||||
}
|
||||
|
||||
wxPalette wxGLCanvas::CreateDefaultPalette()
|
||||
{
|
||||
PIXELFORMATDESCRIPTOR pfd;
|
||||
int paletteSize;
|
||||
int pixelFormat = GetPixelFormat((HDC) m_hDC);
|
||||
|
||||
DescribePixelFormat((HDC) m_hDC, pixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
|
||||
|
||||
paletteSize = 1 << pfd.cColorBits;
|
||||
|
||||
LOGPALETTE* pPal =
|
||||
(LOGPALETTE*) malloc(sizeof(LOGPALETTE) + paletteSize * sizeof(PALETTEENTRY));
|
||||
pPal->palVersion = 0x300;
|
||||
pPal->palNumEntries = paletteSize;
|
||||
|
||||
/* build a simple RGB color palette */
|
||||
{
|
||||
int redMask = (1 << pfd.cRedBits) - 1;
|
||||
int greenMask = (1 << pfd.cGreenBits) - 1;
|
||||
int blueMask = (1 << pfd.cBlueBits) - 1;
|
||||
int i;
|
||||
|
||||
for (i=0; i<paletteSize; ++i) {
|
||||
pPal->palPalEntry[i].peRed =
|
||||
(((i >> pfd.cRedShift) & redMask) * 255) / redMask;
|
||||
pPal->palPalEntry[i].peGreen =
|
||||
(((i >> pfd.cGreenShift) & greenMask) * 255) / greenMask;
|
||||
pPal->palPalEntry[i].peBlue =
|
||||
(((i >> pfd.cBlueShift) & blueMask) * 255) / blueMask;
|
||||
pPal->palPalEntry[i].peFlags = 0;
|
||||
}
|
||||
}
|
||||
|
||||
HPALETTE hPalette = CreatePalette(pPal);
|
||||
free(pPal);
|
||||
|
||||
wxPalette palette;
|
||||
palette.SetHPALETTE((WXHPALETTE) hPalette);
|
||||
|
||||
return palette;
|
||||
}
|
||||
|
||||
void wxGLCanvas::SwapBuffers()
|
||||
{
|
||||
if (m_glContext)
|
||||
m_glContext->SwapBuffers();
|
||||
}
|
||||
|
||||
void wxGLCanvas::OnSize(wxSizeEvent& event)
|
||||
{
|
||||
int width, height;
|
||||
GetClientSize(& width, & height);
|
||||
|
||||
if (m_glContext)
|
||||
{
|
||||
m_glContext->SetCurrent();
|
||||
|
||||
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glFrustum( -1.0, 1.0, -1.0, 1.0, 5.0, 15.0 );
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
}
|
||||
|
||||
void wxGLCanvas::SetCurrent()
|
||||
{
|
||||
if (m_glContext)
|
||||
{
|
||||
m_glContext->SetCurrent();
|
||||
}
|
||||
}
|
||||
|
||||
void wxGLCanvas::SetColour(const char *colour)
|
||||
{
|
||||
if (m_glContext)
|
||||
m_glContext->SetColour(colour);
|
||||
}
|
||||
|
||||
// TODO: Have to have this called by parent frame (?)
|
||||
// So we need wxFrame to call OnQueryNewPalette for all children...
|
||||
void wxGLCanvas::OnQueryNewPalette(wxQueryNewPaletteEvent& event)
|
||||
{
|
||||
/* realize palette if this is the current window */
|
||||
if ( GetPalette()->Ok() ) {
|
||||
::UnrealizeObject((HPALETTE) GetPalette()->GetHPALETTE());
|
||||
::SelectPalette((HDC) GetHDC(), (HPALETTE) GetPalette()->GetHPALETTE(), FALSE);
|
||||
::RealizePalette((HDC) GetHDC());
|
||||
Refresh();
|
||||
event.SetPaletteRealized(TRUE);
|
||||
}
|
||||
else
|
||||
event.SetPaletteRealized(FALSE);
|
||||
}
|
||||
|
||||
// I think this doesn't have to be propagated to child windows.
|
||||
void wxGLCanvas::OnPaletteChanged(wxPaletteChangedEvent& event)
|
||||
{
|
||||
/* realize palette if this is *not* the current window */
|
||||
if ( GetPalette() &&
|
||||
GetPalette()->Ok() && (this != event.GetChangedWindow()) )
|
||||
{
|
||||
::UnrealizeObject((HPALETTE) GetPalette()->GetHPALETTE());
|
||||
::SelectPalette((HDC) GetHDC(), (HPALETTE) GetPalette()->GetHPALETTE(), FALSE);
|
||||
::RealizePalette((HDC) GetHDC());
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/* Give extensions proper function names. */
|
||||
|
||||
/* EXT_vertex_array */
|
||||
void glArrayElementEXT(GLint i)
|
||||
{
|
||||
}
|
||||
|
||||
void glColorPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer)
|
||||
{
|
||||
}
|
||||
|
||||
void glDrawArraysEXT(GLenum mode, GLint first, GLsizei count)
|
||||
{
|
||||
#ifdef GL_EXT_vertex_array
|
||||
static PFNGLDRAWARRAYSEXTPROC proc = 0;
|
||||
|
||||
if ( !proc )
|
||||
{
|
||||
proc = (PFNGLDRAWARRAYSEXTPROC) wglGetProcAddress("glDrawArraysEXT");
|
||||
}
|
||||
|
||||
if ( proc )
|
||||
(* proc) (mode, first, count);
|
||||
#endif
|
||||
}
|
||||
|
||||
void glEdgeFlagPointerEXT(GLsizei stride, GLsizei count, const GLboolean *pointer)
|
||||
{
|
||||
}
|
||||
|
||||
void glGetPointervEXT(GLenum pname, GLvoid* *params)
|
||||
{
|
||||
}
|
||||
|
||||
void glIndexPointerEXT(GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer)
|
||||
{
|
||||
}
|
||||
|
||||
void glNormalPointerEXT(GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer)
|
||||
{
|
||||
#ifdef GL_EXT_vertex_array
|
||||
static PFNGLNORMALPOINTEREXTPROC proc = 0;
|
||||
|
||||
if ( !proc )
|
||||
{
|
||||
proc = (PFNGLNORMALPOINTEREXTPROC) wglGetProcAddress("glNormalPointerEXT");
|
||||
}
|
||||
|
||||
if ( proc )
|
||||
(* proc) (type, stride, count, pointer);
|
||||
#endif
|
||||
}
|
||||
|
||||
void glTexCoordPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer)
|
||||
{
|
||||
}
|
||||
|
||||
void glVertexPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer)
|
||||
{
|
||||
#ifdef GL_EXT_vertex_array
|
||||
static PFNGLVERTEXPOINTEREXTPROC proc = 0;
|
||||
|
||||
if ( !proc )
|
||||
{
|
||||
proc = (PFNGLVERTEXPOINTEREXTPROC) wglGetProcAddress("glVertexPointerEXT");
|
||||
}
|
||||
|
||||
if ( proc )
|
||||
(* proc) (size, type, stride, count, pointer);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* EXT_color_subtable */
|
||||
void glColorSubtableEXT(GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *table)
|
||||
{
|
||||
}
|
||||
|
||||
/* EXT_color_table */
|
||||
void glColorTableEXT(GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table)
|
||||
{
|
||||
}
|
||||
|
||||
void glCopyColorTableEXT(GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width)
|
||||
{
|
||||
}
|
||||
|
||||
void glGetColorTableEXT(GLenum target, GLenum format, GLenum type, GLvoid *table)
|
||||
{
|
||||
}
|
||||
|
||||
void glGetColorTableParamaterfvEXT(GLenum target, GLenum pname, GLfloat *params)
|
||||
{
|
||||
}
|
||||
|
||||
void glGetColorTavleParameterivEXT(GLenum target, GLenum pname, GLint *params)
|
||||
{
|
||||
}
|
||||
|
||||
/* SGI_compiled_vertex_array */
|
||||
void glLockArraysSGI(GLint first, GLsizei count)
|
||||
{
|
||||
}
|
||||
|
||||
void glUnlockArraysSGI()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/* SGI_cull_vertex */
|
||||
void glCullParameterdvSGI(GLenum pname, GLdouble* params)
|
||||
{
|
||||
}
|
||||
|
||||
void glCullParameterfvSGI(GLenum pname, GLfloat* params)
|
||||
{
|
||||
}
|
||||
|
||||
/* SGI_index_func */
|
||||
void glIndexFuncSGI(GLenum func, GLclampf ref)
|
||||
{
|
||||
}
|
||||
|
||||
/* SGI_index_material */
|
||||
void glIndexMaterialSGI(GLenum face, GLenum mode)
|
||||
{
|
||||
}
|
||||
|
||||
/* WIN_swap_hint */
|
||||
void glAddSwapHintRectWin(GLint x, GLint y, GLsizei width, GLsizei height)
|
||||
{
|
||||
}
|
||||
|
@@ -1,165 +0,0 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: glcanvas.h
|
||||
// Purpose: wxGLCanvas, for using OpenGL with wxWindows under Windows
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 04/01/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface "glcanvas.h"
|
||||
#endif
|
||||
|
||||
#ifndef _WX_GLCANVAS_H_
|
||||
#define _WX_GLCANVAS_H_
|
||||
|
||||
#include <wx/scrolwin.h>
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include "gl/gl.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Constants for attriblist
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
enum
|
||||
{
|
||||
WX_GL_RGBA=1, /* use true color palette */
|
||||
WX_GL_DEPTH_SIZE, /* bits for Z-buffer (0,16,32) */
|
||||
WX_GL_DOUBLEBUFFER, /* use doublebuffer */
|
||||
WX_GL_MIN_RED, /* use red buffer with most bits (> MIN_RED bits) */
|
||||
WX_GL_MIN_GREEN, /* use green buffer with most bits (> MIN_GREEN bits) */
|
||||
WX_GL_MIN_BLUE /* use blue buffer with most bits (> MIN_BLUE bits) */
|
||||
/* these are enough constants for now, the remaining will be added later */
|
||||
};
|
||||
|
||||
class wxGLCanvas; /* forward reference */
|
||||
|
||||
class wxGLContext: public wxObject
|
||||
{
|
||||
public:
|
||||
wxGLContext(bool isRGB, wxGLCanvas *win, const wxPalette& palette = wxNullPalette);
|
||||
wxGLContext(
|
||||
bool isRGB, wxGLCanvas *win,
|
||||
const wxPalette& WXUNUSED(palette),
|
||||
const wxGLContext *other /* for sharing display lists */
|
||||
);
|
||||
~wxGLContext();
|
||||
|
||||
void SetCurrent();
|
||||
void SetColour(const char *colour);
|
||||
void SwapBuffers();
|
||||
|
||||
|
||||
inline wxWindow* GetWindow() const { return m_window; }
|
||||
inline WXHDC GetHDC() const { return m_hDC; }
|
||||
inline HGLRC GetGLRC() const { return m_glContext; }
|
||||
|
||||
public:
|
||||
HGLRC m_glContext;
|
||||
WXHDC m_hDC;
|
||||
wxWindow* m_window;
|
||||
};
|
||||
|
||||
class wxGLCanvas: public wxScrolledWindow
|
||||
{
|
||||
DECLARE_CLASS(wxGLCanvas)
|
||||
public:
|
||||
wxGLCanvas(wxWindow *parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize, long style = 0,
|
||||
const wxString& name = "GLCanvas", int *attribList = 0, const wxPalette& palette = wxNullPalette);
|
||||
wxGLCanvas( wxWindow *parent, const wxGLContext *shared = (wxGLContext *)NULL,
|
||||
wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = "GLCanvas",
|
||||
int *attribList = (int*) NULL, const wxPalette& palette = wxNullPalette );
|
||||
wxGLCanvas( wxWindow *parent, const wxGLCanvas *shared = (wxGLCanvas *)NULL, wxWindowID id = -1,
|
||||
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0,
|
||||
const wxString& name = "GLCanvas", int *attribList = 0, const wxPalette& palette = wxNullPalette );
|
||||
~wxGLCanvas();
|
||||
|
||||
// Replaces wxWindow::Create functionality, since we need to use a different window class
|
||||
bool Create(wxWindow *parent, wxWindowID id,
|
||||
const wxPoint& pos, const wxSize& size, long style, const wxString& name);
|
||||
|
||||
void SetCurrent();
|
||||
void SetColour(const char *colour);
|
||||
void SwapBuffers();
|
||||
|
||||
void OnSize(wxSizeEvent& event);
|
||||
|
||||
void OnQueryNewPalette(wxQueryNewPaletteEvent& event);
|
||||
void OnPaletteChanged(wxPaletteChangedEvent& event);
|
||||
|
||||
inline wxGLContext* GetContext() const { return m_glContext; }
|
||||
|
||||
|
||||
inline WXHDC GetHDC() const { return m_hDC; }
|
||||
void SetupPixelFormat();
|
||||
void SetupPalette(const wxPalette& palette);
|
||||
wxPalette CreateDefaultPalette();
|
||||
|
||||
inline wxPalette* GetPalette() const { return (wxPalette*) & m_palette; }
|
||||
|
||||
protected:
|
||||
wxGLContext* m_glContext; // this is typedef-ed ptr, in fact
|
||||
wxPalette m_palette;
|
||||
WXHDC m_hDC;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Give extensions proper function names. */
|
||||
|
||||
/* N.B. - this is not completely implemented as yet */
|
||||
|
||||
/* EXT_vertex_array */
|
||||
void glArrayElementEXT(GLint i);
|
||||
void glColorPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
|
||||
void glDrawArraysEXT(GLenum mode, GLint first, GLsizei count);
|
||||
void glEdgeFlagPointerEXT(GLsizei stride, GLsizei count, const GLboolean *pointer);
|
||||
void glGetPointervEXT(GLenum pname, GLvoid* *params);
|
||||
void glIndexPointerEXT(GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
|
||||
void glNormalPointerEXT(GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
|
||||
void glTexCoordPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
|
||||
void glVertexPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
|
||||
|
||||
/* EXT_color_subtable */
|
||||
void glColorSubtableEXT(GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *table);
|
||||
|
||||
/* EXT_color_table */
|
||||
void glColorTableEXT(GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table);
|
||||
void glCopyColorTableEXT(GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);
|
||||
void glGetColorTableEXT(GLenum target, GLenum format, GLenum type, GLvoid *table);
|
||||
void glGetColorTableParamaterfvEXT(GLenum target, GLenum pname, GLfloat *params);
|
||||
void glGetColorTavleParameterivEXT(GLenum target, GLenum pname, GLint *params);
|
||||
|
||||
/* SGI_compiled_vertex_array */
|
||||
void glLockArraysSGI(GLint first, GLsizei count);
|
||||
void glUnlockArraysSGI();
|
||||
|
||||
/* SGI_cull_vertex */
|
||||
void glCullParameterdvSGI(GLenum pname, GLdouble* params);
|
||||
void glCullParameterfvSGI(GLenum pname, GLfloat* params);
|
||||
|
||||
/* SGI_index_func */
|
||||
void glIndexFuncSGI(GLenum func, GLclampf ref);
|
||||
|
||||
/* SGI_index_material */
|
||||
void glIndexMaterialSGI(GLenum face, GLenum mode);
|
||||
|
||||
/* WIN_swap_hint */
|
||||
void glAddSwapHintRectWin(GLint x, GLint y, GLsizei width, GLsizei height);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@@ -1,17 +0,0 @@
|
||||
#
|
||||
# File: makefile.b32
|
||||
# Author: Julian Smart
|
||||
# Created: 1999
|
||||
# Updated:
|
||||
# Copyright:
|
||||
#
|
||||
# Makefile : Builds wxGLCanvas library for 32-bit BC++
|
||||
|
||||
WXDIR = $(WXWIN)
|
||||
|
||||
LIBTARGET=$(WXDIR)\lib\glcanvas.lib
|
||||
|
||||
OBJECTS = glcanvas.obj
|
||||
|
||||
!include $(WXDIR)\src\makelib.b32
|
||||
|
@@ -1,16 +0,0 @@
|
||||
#
|
||||
# File: makefile.g95
|
||||
# Author: Julian Smart
|
||||
# Created: 1999
|
||||
# Updated:
|
||||
# Copyright: (c) Julian Smart, 1999
|
||||
#
|
||||
# Makefile for wxWindows wxGLCanvas library Cygwin/Mingw32).
|
||||
|
||||
WXDIR = ../../..
|
||||
|
||||
LIBTARGET=$(WXDIR)/lib/libglcanvas.a
|
||||
OBJECTS = glcanvas.o
|
||||
|
||||
include $(WXDIR)/src/makelib.g95
|
||||
|
@@ -1,103 +0,0 @@
|
||||
#
|
||||
# File: makefile.nt
|
||||
# Author: Julian Smart
|
||||
# Created: 1993
|
||||
# Updated:
|
||||
# Copyright: (c) 1993, AIAI, University of Edinburgh
|
||||
#
|
||||
# "%W% %G%"
|
||||
#
|
||||
# Makefile : Builds GLCanvas class library (MS VC++).
|
||||
# Use FINAL=1 argument to nmake to build final version with no debugging
|
||||
# info
|
||||
|
||||
# Set WXDIR for your system
|
||||
WXDIR = $(WXWIN)
|
||||
GLDIR = $(WXDIR)\utils\glcanvas
|
||||
THISDIR = $(GLDIR)\win
|
||||
EXTRALIBS=$(WXDIR)\lib\glcanvas$(LIBEXT).lib
|
||||
DOCDIR=$(WXDIR)\docs
|
||||
LOCALDOCDIR=$(WXDIR)\utils\glcanvas\docs
|
||||
|
||||
|
||||
!include $(WXDIR)\src\makevc.env
|
||||
|
||||
LIBTARGET=$(WXDIR)\lib\glcanvas$(LIBEXT).lib
|
||||
OBJECTS = $(D)\glcanvas.obj
|
||||
|
||||
all: $(D) $(LIBTARGET)
|
||||
|
||||
$(D) :
|
||||
mkdir $(D)
|
||||
|
||||
$(LIBTARGET): $(OBJECTS)
|
||||
-erase $(LIBTARGET)
|
||||
$(implib) @<<
|
||||
-out:$(LIBTARGET)
|
||||
-machine:$(CPU)
|
||||
$(OBJECTS)
|
||||
<<
|
||||
|
||||
$(D)\glcanvas.obj: glcanvas.h glcanvas.$(SRCSUFF) $(DUMMYOBJ)
|
||||
$(cc) @<<
|
||||
$(CPPFLAGS) /c /Fo$@ /Tp $(*B).$(SRCSUFF)
|
||||
<<
|
||||
|
||||
|
||||
clean:
|
||||
-erase $(D)\*.obj
|
||||
-erase *.sbr
|
||||
-erase *.exe
|
||||
-erase *.res
|
||||
-erase *.map
|
||||
-erase *.pdb
|
||||
-erase $(LIBTARGET)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
DOCSOURCES=$(LOCALDOCDIR)\manual.tex $(LOCALDOCDIR)\classes.tex
|
||||
|
||||
html: $(DOCDIR)\html\glcanvas\glcanvas.htm
|
||||
hlp: $(DOCDIR)\winhelp\glcanvas.hlp
|
||||
ps: $(WXDIR)\docs\ps\glcanvas.ps
|
||||
|
||||
$(DOCDIR)\winhelp\glcanvas.hlp: $(LOCALDOCDIR)\glcanvas.rtf $(LOCALDOCDIR)\glcanvas.hpj
|
||||
cd $(LOCALDOCDIR)
|
||||
-erase glcanvas.ph
|
||||
hc glcanvas
|
||||
move glcanvas.hlp $(DOCDIR)\winhelp\glcanvas.hlp
|
||||
move glcanvas.cnt $(DOCDIR)\winhelp\glcanvas.cnt
|
||||
cd $(THISDIR)
|
||||
|
||||
$(LOCALDOCDIR)\glcanvas.rtf: $(DOCSOURCES)
|
||||
cd $(LOCALDOCDIR)
|
||||
-start /w tex2rtf $(LOCALDOCDIR)\manual.tex $(LOCALDOCDIR)\glcanvas.rtf -twice -winhelp
|
||||
cd $(THISDIR)
|
||||
|
||||
$(DOCDIR)\html\glcanvas\glcanvas.htm: $(DOCSOURCES)
|
||||
cd $(LOCALDOCDIR)
|
||||
-mkdir $(DOCDIR)\html\glcanvas
|
||||
-start /w tex2rtf $(LOCALDOCDIR)\manual.tex $(DOCDIR)\html\glcanvas\glcanvas.htm -twice -html
|
||||
-erase $(DOCDIR)\html\glcanvas\*.con
|
||||
-erase $(DOCDIR)\html\glcanvas\*.ref
|
||||
cd $(THISDIR)
|
||||
|
||||
$(LOCALDOCDIR)\manual.dvi: $(DOCSOURCES)
|
||||
cd $(LOCALDOCDIR)
|
||||
-latex manual
|
||||
-latex manual
|
||||
-makeindx manual
|
||||
-bibtex manual
|
||||
-latex manual
|
||||
-latex manual
|
||||
cd $(THISDIR)
|
||||
|
||||
$(WXDIR)\docs\ps\glcanvas.ps: $(LOCALDOCDIR)\manual.dvi
|
||||
cd $(LOCALDOCDIR)
|
||||
-dvips32 -o glcanvas.ps manual
|
||||
move glcanvas.ps $(WXDIR)\docs\ps\glcanvas.ps
|
||||
cd $(THISDIR)
|
||||
|
||||
|
@@ -1,16 +0,0 @@
|
||||
#!/binb/wmake.exe
|
||||
#
|
||||
# File: makefile.wat
|
||||
# Author: Julian Smart
|
||||
# Created: 1999
|
||||
#
|
||||
# Makefile : Builds wxGLCanvas library for Watcom C++, WIN32
|
||||
|
||||
WXDIR = $(%WXWIN)
|
||||
|
||||
OBJECTS=glcanvas.obj
|
||||
LIBTARGET=$(WXDIR)\lib\glcanvas.lib
|
||||
|
||||
!include $(WXDIR)\src\makelib.wat
|
||||
|
||||
|
@@ -303,6 +303,7 @@ void MyApp::GenerateSamples(const wxString& dir)
|
||||
GenerateSample("ExecVC", "exec", dir + wxString("/samples/exec"), wxStringList("exec.cpp", 0));
|
||||
GenerateSample("FontVC", "font", dir + wxString("/samples/font"), wxStringList("font.cpp", 0));
|
||||
GenerateSample("MenuVC", "menu", dir + wxString("/samples/menu"), wxStringList("menu.cpp", 0));
|
||||
GenerateSample("TreelayVC", "test", dir + wxString("/samples/treelay"), wxStringList("test.cpp", "test.h", 0));
|
||||
|
||||
//// Demos
|
||||
|
||||
@@ -433,7 +434,7 @@ void MyApp::GenerateSamples(const wxString& dir)
|
||||
}
|
||||
|
||||
// wxTreeLayout sample
|
||||
|
||||
#if 0
|
||||
project.SetIncludeDirs(wxStringList("../../../include", 0));
|
||||
project.SetResourceIncludeDirs(wxStringList("../../../include", 0));
|
||||
project.SetLibDirs(wxStringList("../../../lib", 0));
|
||||
@@ -450,6 +451,7 @@ void MyApp::GenerateSamples(const wxString& dir)
|
||||
wxString msg("Could not generate wxTreeLayout project");
|
||||
wxMessageBox(msg);
|
||||
}
|
||||
#endif
|
||||
|
||||
// OGLEdit. We have to do it the long way because we need to add the extra ogl.lib.
|
||||
|
||||
|
Before Width: | Height: | Size: 225 B |