Some style cleanups by Fredrik Ekdahl. Thanks!
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22013 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -5,8 +5,7 @@
|
|||||||
|
|
||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
|
|
||||||
class FPS
|
class FPS {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
FPS();
|
FPS();
|
||||||
~FPS();
|
~FPS();
|
||||||
@@ -15,6 +14,5 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
static void drawChar(GLfloat x, GLfloat y, GLint number);
|
static void drawChar(GLfloat x, GLfloat y, GLint number);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -3,22 +3,17 @@
|
|||||||
This file may be used under the terms of the Be Sample Code License.
|
This file may be used under the terms of the Be Sample Code License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <GL/gl.h>
|
|
||||||
|
|
||||||
#include <InterfaceKit.h>
|
|
||||||
|
|
||||||
#include "GLObject.h"
|
#include "GLObject.h"
|
||||||
|
#include <GL/gl.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <InterfaceKit.h>
|
||||||
#include "glob.h"
|
#include "glob.h"
|
||||||
|
|
||||||
struct material {
|
struct material {
|
||||||
float ambient[3], diffuse[3], specular[3];
|
float ambient[3], diffuse[3], specular[3];
|
||||||
};
|
};
|
||||||
|
|
||||||
float *colors[] =
|
float *colors[] = {NULL, white, yellow, blue, red, green};
|
||||||
{
|
|
||||||
NULL,white,yellow,blue,red,green
|
|
||||||
};
|
|
||||||
|
|
||||||
material materials[] = {
|
material materials[] = {
|
||||||
// Null
|
// Null
|
||||||
@@ -63,23 +58,32 @@ material materials[] = {
|
|||||||
|
|
||||||
extern long setEvent(sem_id event);
|
extern long setEvent(sem_id event);
|
||||||
|
|
||||||
|
|
||||||
GLObject::GLObject(ObjectView *ov)
|
GLObject::GLObject(ObjectView *ov)
|
||||||
|
: rotX(0),
|
||||||
|
rotY(0),
|
||||||
|
lastRotX(0),
|
||||||
|
lastRotY(0),
|
||||||
|
spinX(2),
|
||||||
|
spinY(2),
|
||||||
|
x(0),
|
||||||
|
y(0),
|
||||||
|
z(-2.0),
|
||||||
|
color(4),
|
||||||
|
solidity(0),
|
||||||
|
changed(false),
|
||||||
|
objView(ov)
|
||||||
{
|
{
|
||||||
rotX = rotY = lastRotX = lastRotY = 0;
|
|
||||||
spinX = spinY = 2;
|
|
||||||
x = y = 0;
|
|
||||||
z = -2.0;
|
|
||||||
color = 4;
|
|
||||||
solidity = 0;
|
|
||||||
changed = false;
|
|
||||||
objView = ov;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
GLObject::~GLObject()
|
GLObject::~GLObject()
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
||||||
void GLObject::MenuInvoked(BPoint point)
|
|
||||||
|
void
|
||||||
|
GLObject::MenuInvoked(BPoint point)
|
||||||
{
|
{
|
||||||
BPopUpMenu *m = new BPopUpMenu("Object",false,false);
|
BPopUpMenu *m = new BPopUpMenu("Object",false,false);
|
||||||
BMenuItem *i;
|
BMenuItem *i;
|
||||||
@@ -126,7 +130,9 @@ void GLObject::MenuInvoked(BPoint point)
|
|||||||
setEvent(objView->drawEvent);
|
setEvent(objView->drawEvent);
|
||||||
};
|
};
|
||||||
|
|
||||||
bool GLObject::SpinIt()
|
|
||||||
|
bool
|
||||||
|
GLObject::SpinIt()
|
||||||
{
|
{
|
||||||
rotX += spinX;
|
rotX += spinX;
|
||||||
rotY += spinY;
|
rotY += spinY;
|
||||||
@@ -138,7 +144,9 @@ bool GLObject::SpinIt()
|
|||||||
return c;
|
return c;
|
||||||
};
|
};
|
||||||
|
|
||||||
void GLObject::Draw(bool forID, float IDcolor[])
|
|
||||||
|
void
|
||||||
|
GLObject::Draw(bool forID, float IDcolor[])
|
||||||
{
|
{
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glTranslatef(x, y, z);
|
glTranslatef(x, y, z);
|
||||||
@@ -156,6 +164,7 @@ void GLObject::Draw(bool forID, float IDcolor[])
|
|||||||
changed = false;
|
changed = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
TriangleObject::TriangleObject(ObjectView *ov, char *filename)
|
TriangleObject::TriangleObject(ObjectView *ov, char *filename)
|
||||||
: GLObject(ov),
|
: GLObject(ov),
|
||||||
points(100,100),
|
points(100,100),
|
||||||
@@ -247,6 +256,7 @@ TriangleObject::TriangleObject(ObjectView *ov, char *filename)
|
|||||||
fclose(f);
|
fclose(f);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
TriangleObject::~TriangleObject()
|
TriangleObject::~TriangleObject()
|
||||||
{
|
{
|
||||||
for (int i=0;i<qs.num_items;i++) {
|
for (int i=0;i<qs.num_items;i++) {
|
||||||
@@ -254,7 +264,9 @@ TriangleObject::~TriangleObject()
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
void TriangleObject::DoDrawing(bool forID)
|
|
||||||
|
void
|
||||||
|
TriangleObject::DoDrawing(bool forID)
|
||||||
{
|
{
|
||||||
if (!forID) {
|
if (!forID) {
|
||||||
float c[3][4];
|
float c[3][4];
|
||||||
|
|||||||
@@ -2,8 +2,11 @@
|
|||||||
Copyright 1999, Be Incorporated. All Rights Reserved.
|
Copyright 1999, Be Incorporated. All Rights Reserved.
|
||||||
This file may be used under the terms of the Be Sample Code License.
|
This file may be used under the terms of the Be Sample Code License.
|
||||||
*/
|
*/
|
||||||
|
#ifndef GL_OBJECT_H
|
||||||
|
#define GL_OBJECT_H
|
||||||
|
|
||||||
#include "ObjectView.h"
|
#include "ObjectView.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
struct point {
|
struct point {
|
||||||
float x,y,z;
|
float x,y,z;
|
||||||
@@ -20,35 +23,35 @@ struct quadStrip {
|
|||||||
int *pts;
|
int *pts;
|
||||||
};
|
};
|
||||||
|
|
||||||
#include "util.h"
|
|
||||||
|
|
||||||
class GLObject {
|
class GLObject {
|
||||||
public:
|
public:
|
||||||
float rotX,rotY,spinX,spinY,lastRotX,lastRotY;
|
|
||||||
float x,y,z;
|
|
||||||
int color;
|
|
||||||
int solidity;
|
|
||||||
bool changed;
|
|
||||||
ObjectView * objView;
|
|
||||||
|
|
||||||
GLObject(ObjectView *ov);
|
GLObject(ObjectView *ov);
|
||||||
virtual ~GLObject();
|
virtual ~GLObject();
|
||||||
|
|
||||||
virtual void Draw(bool forID, float IDcolor[]);
|
virtual void Draw(bool forID, float IDcolor[]);
|
||||||
virtual bool SpinIt();
|
virtual bool SpinIt();
|
||||||
virtual void MenuInvoked(BPoint point);
|
virtual void MenuInvoked(BPoint point);
|
||||||
|
|
||||||
virtual void DoDrawing(bool forID) {};
|
virtual void DoDrawing(bool forID) {};
|
||||||
|
|
||||||
|
float rotX,rotY,spinX,spinY,lastRotX,lastRotY;
|
||||||
|
float x,y,z;
|
||||||
|
int color;
|
||||||
|
int solidity;
|
||||||
|
bool changed;
|
||||||
|
ObjectView * objView;
|
||||||
};
|
};
|
||||||
|
|
||||||
class TriangleObject : public GLObject {
|
class TriangleObject : public GLObject {
|
||||||
public:
|
public:
|
||||||
BufferArray<point> points;
|
|
||||||
BufferArray<tri> triangles;
|
|
||||||
BufferArray<quadStrip> qs;
|
|
||||||
|
|
||||||
TriangleObject(ObjectView *ov, char *filename);
|
TriangleObject(ObjectView *ov, char *filename);
|
||||||
virtual ~TriangleObject();
|
virtual ~TriangleObject();
|
||||||
|
|
||||||
virtual void DoDrawing(bool forID);
|
virtual void DoDrawing(bool forID);
|
||||||
|
|
||||||
|
BufferArray<point> points;
|
||||||
|
BufferArray<tri> triangles;
|
||||||
|
BufferArray<quadStrip> qs;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif // GL_OBJECT_H
|
||||||
|
|||||||
@@ -3,16 +3,17 @@
|
|||||||
This file may be used under the terms of the Be Sample Code License.
|
This file may be used under the terms of the Be Sample Code License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "ObjectView.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <InterfaceKit.h>
|
#include <InterfaceKit.h>
|
||||||
#include <FindDirectory.h>
|
#include <FindDirectory.h>
|
||||||
|
|
||||||
#include "ObjectView.h"
|
|
||||||
#include "ResScroll.h"
|
|
||||||
#include "GLObject.h"
|
|
||||||
#include "FPS.h"
|
#include "FPS.h"
|
||||||
|
#include "GLObject.h"
|
||||||
|
#include "ResScroll.h"
|
||||||
|
|
||||||
#define teapotData "teapot.data"
|
#define teapotData "teapot.data"
|
||||||
char teapotPath[PATH_MAX];
|
char teapotPath[PATH_MAX];
|
||||||
@@ -35,12 +36,14 @@ float red[3] = {1.0,0.0,0.0};
|
|||||||
|
|
||||||
float *bgColor = black;
|
float *bgColor = black;
|
||||||
|
|
||||||
|
|
||||||
struct light {
|
struct light {
|
||||||
float *ambient;
|
float *ambient;
|
||||||
float *diffuse;
|
float *diffuse;
|
||||||
float *specular;
|
float *specular;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
light lights[] = {
|
light lights[] = {
|
||||||
{NULL, NULL, NULL},
|
{NULL, NULL, NULL},
|
||||||
{dimWhite, white, white},
|
{dimWhite, white, white},
|
||||||
@@ -50,17 +53,9 @@ light lights[] = {
|
|||||||
{dimWhite, green, green}
|
{dimWhite, green, green}
|
||||||
};
|
};
|
||||||
|
|
||||||
long signalEvent(sem_id event)
|
|
||||||
{
|
|
||||||
long c;
|
|
||||||
get_sem_count(event,&c);
|
|
||||||
if (c<0)
|
|
||||||
release_sem_etc(event,-c,0);
|
|
||||||
|
|
||||||
return 0;
|
long
|
||||||
};
|
signalEvent(sem_id event)
|
||||||
|
|
||||||
long setEvent(sem_id event)
|
|
||||||
{
|
{
|
||||||
long c;
|
long c;
|
||||||
get_sem_count(event,&c);
|
get_sem_count(event,&c);
|
||||||
@@ -71,7 +66,20 @@ long setEvent(sem_id event)
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
long waitEvent(sem_id event)
|
long
|
||||||
|
setEvent(sem_id event)
|
||||||
|
{
|
||||||
|
long c;
|
||||||
|
get_sem_count(event,&c);
|
||||||
|
if (c<0)
|
||||||
|
release_sem_etc(event,-c,0);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
long
|
||||||
|
waitEvent(sem_id event)
|
||||||
{
|
{
|
||||||
acquire_sem(event);
|
acquire_sem(event);
|
||||||
|
|
||||||
@@ -83,7 +91,9 @@ long waitEvent(sem_id event)
|
|||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
long simonThread(ObjectView *ov)
|
|
||||||
|
long
|
||||||
|
simonThread(ObjectView *ov)
|
||||||
{
|
{
|
||||||
int noPause=0;
|
int noPause=0;
|
||||||
while (acquire_sem_etc(ov->quittingSem,1,B_TIMEOUT,0) == B_NO_ERROR) {
|
while (acquire_sem_etc(ov->quittingSem,1,B_TIMEOUT,0) == B_NO_ERROR) {
|
||||||
@@ -101,6 +111,7 @@ long simonThread(ObjectView *ov)
|
|||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
ObjectView::ObjectView(BRect r, char *name, ulong resizingMode, ulong options)
|
ObjectView::ObjectView(BRect r, char *name, ulong resizingMode, ulong options)
|
||||||
: BGLView(r,name,resizingMode,0,options)
|
: BGLView(r,name,resizingMode,0,options)
|
||||||
{
|
{
|
||||||
@@ -130,13 +141,16 @@ ObjectView::ObjectView(BRect r, char *name, ulong resizingMode, ulong options)
|
|||||||
objListLock.Unlock();
|
objListLock.Unlock();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
ObjectView::~ObjectView()
|
ObjectView::~ObjectView()
|
||||||
{
|
{
|
||||||
delete_sem(quittingSem);
|
delete_sem(quittingSem);
|
||||||
delete_sem(drawEvent);
|
delete_sem(drawEvent);
|
||||||
};
|
};
|
||||||
|
|
||||||
void ObjectView::AttachedToWindow()
|
|
||||||
|
void
|
||||||
|
ObjectView::AttachedToWindow()
|
||||||
{
|
{
|
||||||
float position[] = {0.0, 3.0, 3.0, 0.0};
|
float position[] = {0.0, 3.0, 3.0, 0.0};
|
||||||
float position1[] = {-3.0, -3.0, 3.0, 0.0};
|
float position1[] = {-3.0, -3.0, 3.0, 0.0};
|
||||||
@@ -204,7 +218,9 @@ void ObjectView::AttachedToWindow()
|
|||||||
setEvent(drawEvent);
|
setEvent(drawEvent);
|
||||||
};
|
};
|
||||||
|
|
||||||
void ObjectView::DetachedFromWindow()
|
|
||||||
|
void
|
||||||
|
ObjectView::DetachedFromWindow()
|
||||||
{
|
{
|
||||||
BGLView::DetachedFromWindow();
|
BGLView::DetachedFromWindow();
|
||||||
|
|
||||||
@@ -224,7 +240,9 @@ void ObjectView::DetachedFromWindow()
|
|||||||
while (locks--) Window()->Lock();
|
while (locks--) Window()->Lock();
|
||||||
};
|
};
|
||||||
|
|
||||||
void ObjectView::Pulse()
|
|
||||||
|
void
|
||||||
|
ObjectView::Pulse()
|
||||||
{
|
{
|
||||||
Window()->Lock();
|
Window()->Lock();
|
||||||
BRect p = Parent()->Bounds();
|
BRect p = Parent()->Bounds();
|
||||||
@@ -237,7 +255,9 @@ void ObjectView::Pulse()
|
|||||||
Window()->Unlock();
|
Window()->Unlock();
|
||||||
};
|
};
|
||||||
|
|
||||||
void ObjectView::MessageReceived(BMessage *msg)
|
|
||||||
|
void
|
||||||
|
ObjectView::MessageReceived(BMessage *msg)
|
||||||
{
|
{
|
||||||
BMenuItem *i;
|
BMenuItem *i;
|
||||||
bool *b;
|
bool *b;
|
||||||
@@ -320,7 +340,9 @@ void ObjectView::MessageReceived(BMessage *msg)
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
int ObjectView::ObjectAtPoint(BPoint p)
|
|
||||||
|
int
|
||||||
|
ObjectView::ObjectAtPoint(BPoint p)
|
||||||
{
|
{
|
||||||
LockGL();
|
LockGL();
|
||||||
glShadeModel(GL_FLAT);
|
glShadeModel(GL_FLAT);
|
||||||
@@ -347,7 +369,9 @@ int ObjectView::ObjectAtPoint(BPoint p)
|
|||||||
return objNum;
|
return objNum;
|
||||||
};
|
};
|
||||||
|
|
||||||
void ObjectView::MouseDown(BPoint p)
|
|
||||||
|
void
|
||||||
|
ObjectView::MouseDown(BPoint p)
|
||||||
{
|
{
|
||||||
BPoint op=p,np=p;
|
BPoint op=p,np=p;
|
||||||
BRect bounds = Bounds();
|
BRect bounds = Bounds();
|
||||||
@@ -441,7 +465,9 @@ void ObjectView::MouseDown(BPoint p)
|
|||||||
setEvent(drawEvent);
|
setEvent(drawEvent);
|
||||||
};
|
};
|
||||||
|
|
||||||
void ObjectView::FrameResized(float w, float h)
|
|
||||||
|
void
|
||||||
|
ObjectView::FrameResized(float w, float h)
|
||||||
{
|
{
|
||||||
LockGL();
|
LockGL();
|
||||||
|
|
||||||
@@ -481,7 +507,9 @@ void ObjectView::FrameResized(float w, float h)
|
|||||||
setEvent(drawEvent);
|
setEvent(drawEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ObjectView::RepositionView()
|
|
||||||
|
bool
|
||||||
|
ObjectView::RepositionView()
|
||||||
{
|
{
|
||||||
if (!(persp != lastPersp) &&
|
if (!(persp != lastPersp) &&
|
||||||
!(lastObjectDistance != objectDistance) &&
|
!(lastObjectDistance != objectDistance) &&
|
||||||
@@ -516,7 +544,9 @@ bool ObjectView::RepositionView()
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
void ObjectView::EnforceState()
|
|
||||||
|
void
|
||||||
|
ObjectView::EnforceState()
|
||||||
{
|
{
|
||||||
glShadeModel(gouraud?GL_SMOOTH:GL_FLAT);
|
glShadeModel(gouraud?GL_SMOOTH:GL_FLAT);
|
||||||
if (zbuf) glEnable(GL_DEPTH_TEST); else glDisable(GL_DEPTH_TEST);
|
if (zbuf) glEnable(GL_DEPTH_TEST); else glDisable(GL_DEPTH_TEST);
|
||||||
@@ -542,7 +572,9 @@ void ObjectView::EnforceState()
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
bool ObjectView::SpinIt()
|
|
||||||
|
bool
|
||||||
|
ObjectView::SpinIt()
|
||||||
{
|
{
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
|
|
||||||
@@ -615,7 +647,9 @@ bool ObjectView::SpinIt()
|
|||||||
return changed;
|
return changed;
|
||||||
};
|
};
|
||||||
|
|
||||||
void ObjectView::DrawFrame(bool noPause)
|
|
||||||
|
void
|
||||||
|
ObjectView::DrawFrame(bool noPause)
|
||||||
{
|
{
|
||||||
LockGL();
|
LockGL();
|
||||||
glClear(GL_COLOR_BUFFER_BIT|(zbuf?GL_DEPTH_BUFFER_BIT:0));
|
glClear(GL_COLOR_BUFFER_BIT|(zbuf?GL_DEPTH_BUFFER_BIT:0));
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
This file may be used under the terms of the Be Sample Code License.
|
This file may be used under the terms of the Be Sample Code License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef ObjectView_h
|
#ifndef OBJECT_VIEW_H
|
||||||
#define ObjectView_h
|
#define OBJECT_VIEW_H
|
||||||
|
|
||||||
#include <GL/glu.h>
|
#include <GL/glu.h>
|
||||||
#include <GLView.h>
|
#include <GLView.h>
|
||||||
@@ -33,8 +33,25 @@ enum lights {
|
|||||||
#define HISTSIZE 10
|
#define HISTSIZE 10
|
||||||
|
|
||||||
class ResScroll;
|
class ResScroll;
|
||||||
|
|
||||||
class ObjectView : public BGLView {
|
class ObjectView : public BGLView {
|
||||||
public:
|
public:
|
||||||
|
ObjectView(BRect r, char *name,
|
||||||
|
ulong resizingMode, ulong options);
|
||||||
|
~ObjectView();
|
||||||
|
|
||||||
|
virtual void MouseDown(BPoint p);
|
||||||
|
virtual void MessageReceived(BMessage *msg);
|
||||||
|
virtual void AttachedToWindow();
|
||||||
|
virtual void DetachedFromWindow();
|
||||||
|
virtual void FrameResized(float width, float height);
|
||||||
|
bool SpinIt();
|
||||||
|
int ObjectAtPoint(BPoint p);
|
||||||
|
virtual void DrawFrame(bool noPause);
|
||||||
|
virtual void Pulse();
|
||||||
|
void EnforceState();
|
||||||
|
bool RepositionView();
|
||||||
|
|
||||||
sem_id drawEvent;
|
sem_id drawEvent;
|
||||||
sem_id quittingSem;
|
sem_id quittingSem;
|
||||||
thread_id drawThread;
|
thread_id drawThread;
|
||||||
@@ -59,21 +76,6 @@ bool lastFog,fog;
|
|||||||
bool forceRedraw;
|
bool forceRedraw;
|
||||||
float objectDistance,lastObjectDistance;
|
float objectDistance,lastObjectDistance;
|
||||||
|
|
||||||
ObjectView(BRect r, char *name,
|
|
||||||
ulong resizingMode, ulong options);
|
|
||||||
~ObjectView();
|
|
||||||
|
|
||||||
virtual void MouseDown(BPoint p);
|
|
||||||
virtual void MessageReceived(BMessage *msg);
|
|
||||||
virtual void AttachedToWindow();
|
|
||||||
virtual void DetachedFromWindow();
|
|
||||||
virtual void FrameResized(float width, float height);
|
|
||||||
bool SpinIt();
|
|
||||||
int ObjectAtPoint(BPoint p);
|
|
||||||
virtual void DrawFrame(bool noPause);
|
|
||||||
virtual void Pulse();
|
|
||||||
void EnforceState();
|
|
||||||
bool RepositionView();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // OBJECT_VIEW_H
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
This file may be used under the terms of the Be Sample Code License.
|
This file may be used under the terms of the Be Sample Code License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef ResScroll_h
|
#ifndef RESSCROLL_H
|
||||||
#define ResScroll_h
|
#define RESSCROLL_H
|
||||||
|
|
||||||
#include <interface/ScrollBar.h>
|
#include <interface/ScrollBar.h>
|
||||||
|
|
||||||
@@ -17,7 +17,6 @@ public:
|
|||||||
ResScroll(BRect r, const char *name,
|
ResScroll(BRect r, const char *name,
|
||||||
ObjectView *target, orientation posture);
|
ObjectView *target, orientation posture);
|
||||||
virtual void ValueChanged(float value);
|
virtual void ValueChanged(float value);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -5,7 +5,8 @@
|
|||||||
|
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
|
||||||
void fatalerror(char *s)
|
void
|
||||||
|
fatalerror(char *s)
|
||||||
{
|
{
|
||||||
printf("FATAL ERROR: %s\n",s);
|
printf("FATAL ERROR: %s\n",s);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
This file may be used under the terms of the Be Sample Code License.
|
This file may be used under the terms of the Be Sample Code License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef error_h
|
#ifndef ERROR_H
|
||||||
#define error_h
|
#define ERROR_H
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
@@ -28,4 +28,4 @@ extern void fatalerror(char *);
|
|||||||
|
|
||||||
#endif //DEBUGGING
|
#endif //DEBUGGING
|
||||||
|
|
||||||
#endif
|
#endif // ERROR_H
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
This file may be used under the terms of the Be Sample Code License.
|
This file may be used under the terms of the Be Sample Code License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "GL/gl.h"
|
#include <GL/gl.h>
|
||||||
|
|
||||||
void auxSolidTeapot(GLdouble scale);
|
void auxSolidTeapot(GLdouble scale);
|
||||||
void auxWireTeapot(GLdouble scale);
|
void auxWireTeapot(GLdouble scale);
|
||||||
|
|||||||
@@ -3,27 +3,29 @@
|
|||||||
This file may be used under the terms of the Be Sample Code License.
|
This file may be used under the terms of the Be Sample Code License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <InterfaceKit.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <InterfaceKit.h>
|
||||||
#include "ObjectView.h"
|
#include "ObjectView.h"
|
||||||
|
|
||||||
class QuitWindow : public BDirectWindow
|
class QuitWindow : public BDirectWindow {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
QuitWindow(BRect r, char *name, window_type wt, ulong something);
|
QuitWindow(BRect r, char *name, window_type wt, ulong something);
|
||||||
|
|
||||||
virtual bool QuitRequested();
|
virtual bool QuitRequested();
|
||||||
virtual void DirectConnected( direct_buffer_info *info );
|
virtual void DirectConnected( direct_buffer_info *info );
|
||||||
ObjectView *bgl;
|
|
||||||
|
|
||||||
|
ObjectView *bgl;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
QuitWindow::QuitWindow(BRect r, char *name, window_type wt, ulong something)
|
QuitWindow::QuitWindow(BRect r, char *name, window_type wt, ulong something)
|
||||||
: BDirectWindow(r,name,wt,something)
|
: BDirectWindow(r,name,wt,something)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QuitWindow::QuitRequested()
|
|
||||||
|
bool
|
||||||
|
QuitWindow::QuitRequested()
|
||||||
{
|
{
|
||||||
printf("closing \n");
|
printf("closing \n");
|
||||||
bgl->EnableDirectMode( false );
|
bgl->EnableDirectMode( false );
|
||||||
@@ -31,14 +33,18 @@ printf( "closing \n" );
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
void QuitWindow::DirectConnected( direct_buffer_info *info )
|
|
||||||
|
void
|
||||||
|
QuitWindow::DirectConnected(direct_buffer_info *info)
|
||||||
{
|
{
|
||||||
if (bgl)
|
if (bgl)
|
||||||
bgl->DirectConnected( info );
|
bgl->DirectConnected( info );
|
||||||
bgl->EnableDirectMode( true );
|
bgl->EnableDirectMode( true );
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
|
int
|
||||||
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
GLenum type = BGL_RGB | BGL_DEPTH | BGL_DOUBLE;
|
GLenum type = BGL_RGB | BGL_DEPTH | BGL_DOUBLE;
|
||||||
//GLenum type = BGL_RGB | BGL_DEPTH | BGL_SINGLE;
|
//GLenum type = BGL_RGB | BGL_DEPTH | BGL_SINGLE;
|
||||||
|
|||||||
+37
-21
@@ -3,15 +3,14 @@
|
|||||||
This file may be used under the terms of the Be Sample Code License.
|
This file may be used under the terms of the Be Sample Code License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef list_h
|
#ifndef UTIL_H
|
||||||
#define list_h
|
#define UTIL_H
|
||||||
|
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
|
||||||
template <class contents>
|
template <class contents>
|
||||||
struct LispNode
|
struct LispNode {
|
||||||
{
|
|
||||||
contents *car;
|
contents *car;
|
||||||
LispNode *cdr;
|
LispNode *cdr;
|
||||||
|
|
||||||
@@ -31,27 +30,34 @@ struct LispNode
|
|||||||
|
|
||||||
|
|
||||||
template <class contents>
|
template <class contents>
|
||||||
struct LispList
|
struct LispList {
|
||||||
{
|
|
||||||
LispNode<contents> *first;
|
LispNode<contents> *first;
|
||||||
|
|
||||||
|
|
||||||
/* -------- List creation --------------- */
|
/* -------- List creation --------------- */
|
||||||
/* Create an empty list */
|
/* Create an empty list */
|
||||||
inline LispList()
|
inline LispList()
|
||||||
{ first = 0; }
|
{
|
||||||
|
first = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Create a list pointing to the specified node */
|
/* Create a list pointing to the specified node */
|
||||||
inline LispList(LispNode<contents> *_first)
|
inline LispList(LispNode<contents> *_first)
|
||||||
{ first = _first; }
|
{
|
||||||
|
first = _first;
|
||||||
|
}
|
||||||
|
|
||||||
/* ?? */
|
/* ?? */
|
||||||
inline LispList(LispList &init)
|
inline LispList(LispList &init)
|
||||||
{ first = init.first; }
|
{
|
||||||
|
first = init.first;
|
||||||
|
}
|
||||||
|
|
||||||
/* ---------- List queries ------------- */
|
/* ---------- List queries ------------- */
|
||||||
inline int is_empty()
|
inline int is_empty()
|
||||||
{ return first == 0; }
|
{
|
||||||
|
return first == 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Determines if a thing is on the list */
|
/* Determines if a thing is on the list */
|
||||||
inline int is_present(contents *element)
|
inline int is_present(contents *element)
|
||||||
@@ -102,7 +108,9 @@ struct LispList
|
|||||||
first = new LispNode<contents>(new_element, first);
|
first = new LispNode<contents>(new_element, first);
|
||||||
}
|
}
|
||||||
inline void add_head(contents *new_element)
|
inline void add_head(contents *new_element)
|
||||||
{ add_head_new(new_element); }
|
{
|
||||||
|
add_head_new(new_element);
|
||||||
|
}
|
||||||
|
|
||||||
/* Create new node pointing to thing, & add to end of list. */
|
/* Create new node pointing to thing, & add to end of list. */
|
||||||
inline void add_tail_new(contents *new_element)
|
inline void add_tail_new(contents *new_element)
|
||||||
@@ -113,7 +121,9 @@ struct LispList
|
|||||||
*pred = new LispNode< contents >(new_element);
|
*pred = new LispNode< contents >(new_element);
|
||||||
}
|
}
|
||||||
inline void add_tail(contents *new_element)
|
inline void add_tail(contents *new_element)
|
||||||
{ add_tail_new(new_element); }
|
{
|
||||||
|
add_tail_new(new_element);
|
||||||
|
}
|
||||||
|
|
||||||
/* Create new node pointing to thing, & add anywhere on list */
|
/* Create new node pointing to thing, & add anywhere on list */
|
||||||
inline void add_new(contents *new_element)
|
inline void add_new(contents *new_element)
|
||||||
@@ -230,8 +240,7 @@ struct LispList
|
|||||||
inline contents *get_head()
|
inline contents *get_head()
|
||||||
{
|
{
|
||||||
contents *c = 0;
|
contents *c = 0;
|
||||||
if(first)
|
if(first) {
|
||||||
{
|
|
||||||
c = first->car;
|
c = first->car;
|
||||||
delete rem_head();
|
delete rem_head();
|
||||||
}
|
}
|
||||||
@@ -240,22 +249,30 @@ struct LispList
|
|||||||
|
|
||||||
/* Take something off the list */
|
/* Take something off the list */
|
||||||
inline contents *get()
|
inline contents *get()
|
||||||
{ return(get_head()); }
|
{
|
||||||
|
return(get_head());
|
||||||
|
}
|
||||||
|
|
||||||
/* XXX inline contents *get_tail() { } */
|
/* XXX inline contents *get_tail() { } */
|
||||||
|
|
||||||
/* -------- Stack simulation (by j.h.) ------------ */
|
/* -------- Stack simulation (by j.h.) ------------ */
|
||||||
/* Put a thing onto the head of the list */
|
/* Put a thing onto the head of the list */
|
||||||
inline void push(contents *c)
|
inline void push(contents *c)
|
||||||
{ put_head( c ); }
|
{
|
||||||
|
put_head(c);
|
||||||
|
}
|
||||||
|
|
||||||
/* Remove a thing from the head of the list */
|
/* Remove a thing from the head of the list */
|
||||||
inline contents *pop()
|
inline contents *pop()
|
||||||
{ return(get_head()); }
|
{
|
||||||
|
return(get_head());
|
||||||
|
}
|
||||||
|
|
||||||
/* Pop everything off the stack. Empty the stack/list. */
|
/* Pop everything off the stack. Empty the stack/list. */
|
||||||
inline void pop_all()
|
inline void pop_all()
|
||||||
{ rem_del_all(); }
|
{
|
||||||
|
rem_del_all();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------- list/list manipulations ------------ */
|
/* ----------- list/list manipulations ------------ */
|
||||||
@@ -330,8 +347,7 @@ struct DoubleLinkedList : public DoubleLinkedNode<thetype>
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
struct BufferArray
|
struct BufferArray {
|
||||||
{
|
|
||||||
T * items;
|
T * items;
|
||||||
int num_items;
|
int num_items;
|
||||||
int num_slots;
|
int num_slots;
|
||||||
@@ -378,4 +394,4 @@ struct BufferArray
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // UTIL_H
|
||||||
|
|||||||
Reference in New Issue
Block a user