vcglib/apps/nexus/nexusmt.h

144 lines
4.2 KiB
C
Raw Normal View History

2005-02-08 13:43:03 +01:00
/****************************************************************************
* VCGLib o o *
* Visual and Computer Graphics Library o o *
* _ O _ *
* Copyright(C) 2004 \/)\/ *
* Visual Computing Lab /\/| *
* ISTI - Italian National Research Council | *
* \ *
* All rights reserved. *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program 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 General Public License (http://www.gnu.org/licenses/gpl.txt) *
* for more details. *
* *
****************************************************************************/
/****************************************************************************
History
$Log: not supported by cvs2svn $
****************************************************************************/
2005-01-14 16:25:29 +01:00
#ifndef NXS_MT_H
#define NXS_MT_H
2004-09-17 17:25:59 +02:00
2004-09-28 12:26:35 +02:00
#include <vector>
#include <queue>
#include <wrap/gui/frustum.h>
2004-09-17 17:25:59 +02:00
2005-01-14 16:25:29 +01:00
#include "nexus.h"
#include "history.h"
#include "extraction.h"
#include "metric.h"
#include "preload.h"
#include "watch.h"
2004-09-17 17:25:59 +02:00
2004-09-28 12:26:35 +02:00
namespace nxs {
2004-09-17 17:25:59 +02:00
2005-01-14 16:25:29 +01:00
struct DrawContest {
2004-09-30 02:27:42 +02:00
2005-01-14 16:25:29 +01:00
enum Mode { POINTS, SMOOTH, XRAY, HIDDEN_LINE, FLAT_WIRE, FLAT, PATCHES };
enum Attr { COLOR = 0x1, NORMAL = 0x2, TEXTURE = 0x4, DATA = 0x8 };
2004-09-30 02:27:42 +02:00
2005-01-14 16:25:29 +01:00
Mode mode;
unsigned int attrs;
2004-12-15 09:46:16 +01:00
2005-01-14 16:25:29 +01:00
DrawContest(Mode m = SMOOTH, unsigned int a = 0xf): mode(m), attrs(a) {}
void SetAttr(Attr attr, bool value);
bool HasComponent(Attr attr);
};
struct Stats {
float ktri; //k triangles rendered.
float kdisk; //k readed per frame (mean)
float kdisk_peak; //k readed peak.
float fps;
float fps_peak; //low fps peaks
//double last_time;
unsigned int count;
Watch watch;
Stats(): count(0) {}
void Init();
};
2005-02-03 13:35:01 +01:00
2005-01-14 16:25:29 +01:00
class NexusMt: public Nexus {
public:
bool use_vbo;
bool prefetch;
2004-12-13 01:44:48 +01:00
2005-01-14 16:25:29 +01:00
unsigned int vbo_used; //TODO remember to zero it!
2004-12-14 15:10:22 +01:00
2005-01-14 16:25:29 +01:00
Preload preload;
2004-12-13 01:44:48 +01:00
2005-01-14 16:25:29 +01:00
NexusMt();
~NexusMt();
bool Load(const std::string &filename);
// void Close();
bool InitGL(bool use_vbo = true);
void Render(DrawContest contest = DrawContest());
void Render(Extraction &extraction,
DrawContest &contest,
Stats *stats = NULL);
2005-02-01 17:42:30 +01:00
void SetPreload(bool on);
2005-01-14 16:25:29 +01:00
2005-02-03 13:35:01 +01:00
void Flush(bool all = true);
Patch &GetPatch(unsigned int patch, float error, bool flush = true);
bool CanAdd(Item &item);
2005-01-14 16:25:29 +01:00
protected:
2005-02-03 13:35:01 +01:00
std::vector<Item> heap;
2005-01-14 16:25:29 +01:00
void FlushPatch(unsigned int id);
void LoadVbo(Entry &entry);
void FlushVbo(Entry &entry);
void Draw(unsigned int cell, DrawContest &contest);
};
/* class NexusViewer {
public:
NexusMt &mt;
DrawContest contest;
Extraction extraction;
Statistics stats;
NexusViewer(NexyusMt &_mt): mt(&mt) {}
void Render();
2004-12-14 15:10:22 +01:00
2004-12-13 01:44:48 +01:00
2005-01-14 16:25:29 +01:00
bool SetMode(DrawContest::Mode mode);
bool SetComponent(DrawContest::Component c, bool on);
bool SetComponents(unsigned int mask);
2004-10-14 15:42:33 +02:00
2005-01-14 16:25:29 +01:00
void SetMetric(MetricKind kind);
void SetError(float error);
2004-11-28 02:23:26 +01:00
2005-01-14 16:25:29 +01:00
//Uinits expressed in Kb
void SetExtractionSize(unsigned int ksize);
void SetDrawSize(unsigned int ksize);
void SetDiskDelta(unsigned int kdelta);
//void SetPrefetchSize(unsigned int size);
};*/
2004-09-30 02:27:42 +02:00
2004-09-17 17:25:59 +02:00
2004-12-13 01:44:48 +01:00
2004-09-17 17:25:59 +02:00
}
2005-01-14 16:25:29 +01:00
2004-09-17 17:25:59 +02:00
#endif