Got Penguin sample running under Windows.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1362 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
1999-01-10 12:04:02 +00:00
parent b669a48e12
commit 45b5751fb4
11 changed files with 148 additions and 23 deletions

View File

@@ -10,8 +10,8 @@ Penguin: penguin.o trackball.o lw.o glcanvas.o
penguin.o: penguin.cpp
$(CPP) `wx-config --cflags` -I../../src -c penguin.cpp
lw.o: lw.c
$(CC) `wx-config --cflags` -I../../src -c lw.c
lw.o: lw.cpp
$(CPP) `wx-config --cflags` -I../../src -c lw.cpp
trackball.o: trackball.c
$(CC) `wx-config --cflags` -I../../src -c trackball.c

View File

@@ -16,8 +16,9 @@
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifdef __WXMSW__
#include <windows.h>
#endif
#include "lw.h"
#include <stdlib.h>
@@ -100,7 +101,7 @@ static void read_srfs(FILE *f, int nbytes, lwObject *lwo)
/* allocate more memory for materials if needed */
if (guess_cnt <= lwo->material_cnt) {
guess_cnt += guess_cnt/2 + 4;
lwo->material = realloc(lwo->material, sizeof(lwMaterial)*guess_cnt);
lwo->material = (lwMaterial*) realloc(lwo->material, sizeof(lwMaterial)*guess_cnt);
}
material = lwo->material + lwo->material_cnt++;
@@ -112,7 +113,7 @@ static void read_srfs(FILE *f, int nbytes, lwObject *lwo)
material->g = 0.7;
material->b = 0.7;
}
lwo->material = realloc(lwo->material, sizeof(lwMaterial)*lwo->material_cnt);
lwo->material = (lwMaterial*) realloc(lwo->material, sizeof(lwMaterial)*lwo->material_cnt);
}
@@ -164,7 +165,7 @@ static void read_pols(FILE *f, int nbytes, lwObject *lwo)
/* allocate more memory for polygons if necessary */
if (guess_cnt <= lwo->face_cnt) {
guess_cnt += guess_cnt + 4;
lwo->face = realloc(lwo->face, sizeof(lwFace)*guess_cnt);
lwo->face = (lwFace*) realloc((void*) lwo->face, sizeof(lwFace)*guess_cnt);
}
face = lwo->face + lwo->face_cnt++;
@@ -173,7 +174,7 @@ static void read_pols(FILE *f, int nbytes, lwObject *lwo)
nbytes -= 2;
/* allocate space for points */
face->index = calloc(sizeof(int)*face->index_cnt,1);
face->index = (int*) calloc(sizeof(int)*face->index_cnt,1);
/* read points in */
for (i=0; i<face->index_cnt; i++) {
@@ -200,7 +201,7 @@ static void read_pols(FILE *f, int nbytes, lwObject *lwo)
face->material -= 1;
}
/* readjust to true size */
lwo->face = realloc(lwo->face, sizeof(lwFace)*lwo->face_cnt);
lwo->face = (lwFace*) realloc(lwo->face, sizeof(lwFace)*lwo->face_cnt);
}
@@ -209,7 +210,7 @@ static void read_pnts(FILE *f, int nbytes, lwObject *lwo)
{
int i;
lwo->vertex_cnt = nbytes / 12;
lwo->vertex = calloc(sizeof(GLfloat)*lwo->vertex_cnt*3, 1);
lwo->vertex = (float*) calloc(sizeof(GLfloat)*lwo->vertex_cnt*3, 1);
for (i=0; i<lwo->vertex_cnt; i++) {
lwo->vertex[i*3+0] = read_float(f);
lwo->vertex[i*3+1] = read_float(f);
@@ -265,7 +266,7 @@ lwObject *lw_object_read(const char *lw_file)
}
/* create new lwObject */
lw_object = calloc(sizeof(lwObject),1);
lw_object = (lwObject*) calloc(sizeof(lwObject),1);
/* read chunks */
while (read_bytes < form_bytes) {

View File

@@ -49,6 +49,9 @@ typedef struct {
} lwObject;
#ifdef __cplusplus
extern "C" {
#endif
int lw_is_lwobject(const char *lw_file);
lwObject *lw_object_read(const char *lw_file);
@@ -58,5 +61,9 @@ void lw_object_show(const lwObject *lw_object);
GLfloat lw_object_radius(const lwObject *lw_object);
void lw_object_scale (lwObject *lw_object, GLfloat scale);
#ifdef __cplusplus
}
#endif
#endif /* LW_H */

View File

@@ -0,0 +1,71 @@
#
# File: makefile.nt
# Author: Julian Smart
# Created: 1997
# Updated:
#
# "%W% %G%"
#
# Makefile : Builds penguin example (MS VC++).
# Use FINAL=1 argument to nmake to build final version with no debugging
# info
# Set WXDIR for your system
WXDIR = $(WXWIN)
WXUSINGDLL=0
EXTRAINC=-I..\..\win
EXTRALIBS=$(WXDIR)\lib\glcanvas.lib glu32.lib opengl32.lib
!include $(WXDIR)\src\ntwxwin.mak
THISDIR = $(WXDIR)\utils\glcanvas\samples\penguin
PROGRAM=penguin
OBJECTS = $(PROGRAM).obj trackball.obj lw.obj
$(PROGRAM): $(PROGRAM).exe
all: wx $(PROGRAM).exe
wx:
cd $(WXDIR)\src\msw
nmake -f makefile.nt FINAL=$(FINAL)
cd $(THISDIR)
wxclean:
cd $(WXDIR)\src\msw
nmake -f makefile.nt clean
cd $(THISDIR)
$(PROGRAM).exe: $(DUMMYOBJ) $(WXLIB) $(OBJECTS) $(PROGRAM).res
$(link) @<<
-out:$(PROGRAM).exe
$(LINKFLAGS)
$(DUMMYOBJ) $(OBJECTS) $(PROGRAM).res
$(LIBS)
<<
$(PROGRAM).obj: $(PROGRAM).$(SRCSUFF) $(PROGRAM).h $(DUMMYOBJ)
$(cc) @<<
$(CPPFLAGS2) /c /Tp $*.$(SRCSUFF)
<<
lw.obj: lw.c lw.h
$(cc) @<<
$(CPPFLAGS2) /c $*.$(SRCSUFF)
<<
$(PROGRAM).res : $(PROGRAM).rc $(WXDIR)\include\wx\msw\wx.rc
$(rc) -r /i$(WXDIR)\include -fo$@ $(PROGRAM).rc
clean:
-erase *.obj
-erase *.exe
-erase *.res
-erase *.map
-erase *.sbr
-erase *.pdb

View File

@@ -183,15 +183,16 @@ void TestGLCanvas::LoadLWO(const wxString &filename)
void TestGLCanvas::OnMouse( wxMouseEvent& event )
{
wxSize sz(GetClientSize());
if (event.Dragging())
{
/* drag in progress, simulate trackball */
float spin_quat[4];
trackball(spin_quat,
(2.0*info.beginx - m_width) / m_width,
( m_height - 2.0*info.beginy) / m_height,
( 2.0*event.GetX() - m_width) / m_width,
( m_height - 2.0*event.GetY()) / m_height);
(2.0*info.beginx - sz.x) / sz.x,
( sz.y - 2.0*info.beginy) / sz.y,
( 2.0*event.GetX() - sz.x) / sz.x,
( sz.y - 2.0*event.GetY()) / sz.y);
add_quats( spin_quat, info.quat, info.quat );

View File

@@ -28,7 +28,8 @@ extern "C" {
/* information needed to display lightwave mesh */
typedef struct
{
gint do_init; /* true if initgl not yet called */
// gint do_init; /* true if initgl not yet called */
int do_init;
lwObject *lwobject; /* lightwave object mesh */
float beginx,beginy; /* position of mouse */
float quat[4]; /* orientation of object */

View File

@@ -0,0 +1,3 @@
/* mondrian ICON "mondrian.ico" */
#include "wx/msw/wx.rc"