Filter:   InfoImg
download buildlwo.c
Language: C
LOC: 73
Project Info
X11
Server: OpenBSD
Type: cvs
...ograms\xlockmore\modes\glx\
   atlantis.c
   atlantis.h
   b_draw.c
   b_lockglue.c
   b_sphere.c
   bubble3d.c
   bubble3d.h
   buildlwo.c
   buildlwo.h
   cage.c
   dolphin.c
   e_textures.h
   gears.c
   i_evert.h
   i_figureeight.cc
   i_figureeight.h
   i_linkage.cc
   i_linkage.h
   i_sphere.cc
   i_sphere.h
   i_spline.cc
   i_spline.h
   i_threejet.cc
   i_threejet.h
   i_threejetvec.cc
   i_threejetvec.h
   i_twojet.cc
   i_twojet.h
   i_twojetvec.cc
   i_twojetvec.h
   invert.c
   lament.c
   Makefile.in
   moebius.c
   morph3d.c
   pipeobjs.c
   pipes.c
   rubik.c
   s1_1.c
   s1_2.c
   s1_3.c
   s1_4.c
   s1_5.c
   s1_6.c
   s1_b.c
   shark.c
   sproingies.c
   sproingiewrap.c
   stairs.c
   superquadrics.c
   swim.c
   text3d.cc
   text3d.h
   whale.c

#if !defined( lint ) && !defined( SABER )
static const char sccsid[] = "@(#)buildlwo.c	4.02 97/04/20 xlockmore";

#endif

/*-
 * buildlwo.c: Lightwave Object Display List Builder for OpenGL
 *
 * This module can be called by any GL mode wishing to use
 * objects created in NewTek's Lightwave 3D.  The objects must
 * first be converted to C source with my converter "lw2ogl".
 * If other people are interested in this, I will put up a
 * web page for it at http://www.netaxs.com/~emackey/lw2ogl/
 *
 * by Ed Mackey, 4/19/97
 *
 */

#ifndef STANDALONE
#include "xlock.h"
#endif

#ifdef USE_GL

#ifdef STANDALONE
#include <GL/glx.h>
#endif
#include <GL/gl.h>
#include <GL/glu.h>
#include "buildlwo.h"

GLuint
BuildLWO(int wireframe, struct lwo *object)
{
	GLuint      dl_num;
	GLfloat    *pnts, *normals, three[3], *grab;
	unsigned short int *pols;
	int         p, num_pnts = 0;

	dl_num = glGenLists(1);
	if (!dl_num)
		return (0);

	pnts = object->pnts;
	normals = object->normals;
	pols = object->pols;

	glNewList(dl_num, GL_COMPILE);

	if (!pols) {
		num_pnts = object->num_pnts;
		glBegin(GL_POINTS);
		for (p = 0; p < num_pnts; ++p) {
			three[0] = *(pnts++);
			three[1] = *(pnts++);
			three[2] = *(pnts++);
			glVertex3fv(three);
		}
		glEnd();
	} else
		for (;;) {
			if (num_pnts <= 0) {
				num_pnts = *pols + 2;
				if (num_pnts < 3)
					break;
				if (num_pnts == 3) {
					glBegin(GL_POINTS);
				} else if (num_pnts == 4) {
					glBegin(GL_LINES);
				} else {
					three[0] = *(normals++);
					three[1] = *(normals++);
					three[2] = *(normals++);
					glNormal3fv(three);
					if (wireframe)
						glBegin(GL_LINE_LOOP);
					else
						glBegin(GL_POLYGON);
				}
			} else if (num_pnts == 1) {
				glEnd();
			} else {
				grab = pnts + ((int) (*pols) * 3);
				three[0] = *(grab++);
				three[1] = *(grab++);
				three[2] = *(grab++);
				glVertex3fv(three);
			}
			--num_pnts;
			++pols;
		}

	glEndList();

	return (dl_num);
}

#endif /* USE_GL */

/* End of buildlwo.c */