Skip to content

Commit

Permalink
Undo renaming Drawable to VSDrawable; more on OpenGL stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
stephengtuggy committed Apr 26, 2024
1 parent 4e0e104 commit f9dbe1c
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 50 deletions.
70 changes: 35 additions & 35 deletions engine/src/cmd/drawable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
#include "vega_cast_utils.h"

// Required definition of static variable
std::string VSDrawable::root;
std::string Drawable::root;

// Dupe to same function in unit.cpp
// TODO: remove duplication
Expand All @@ -58,7 +58,7 @@ inline static float perspectiveFactor(float d) {
}
}

VSDrawable::VSDrawable() :
Drawable::Drawable() :
halos(new HaloSystem()),
animatedMesh(true),
activeAnimation(0),
Expand All @@ -71,7 +71,7 @@ VSDrawable::VSDrawable() :
curtime(0.0) {
}

VSDrawable::~VSDrawable() {
Drawable::~Drawable() {
for (Mesh *mesh : meshdata) {
if (mesh != nullptr) {
delete mesh;
Expand All @@ -82,8 +82,8 @@ VSDrawable::~VSDrawable() {
clear();
}

bool VSDrawable::DrawableInit(const char *filename, int faction,
Flightgroup *flightgrp, const char *animationExt) {
bool Drawable::DrawableInit(const char *filename, int faction,
Flightgroup *flightgrp, const char *animationExt) {
string fnam(filename);
string::size_type pos = fnam.find('.');
string anifilename = fnam.substr(0, pos);
Expand Down Expand Up @@ -144,7 +144,7 @@ bool VSDrawable::DrawableInit(const char *filename, int faction,
addAnimation(meshes, animationName.c_str());

int numFrames = meshes->size();
++VSDrawable::unitCount;
++Drawable::unitCount;
sprintf(count, "%u", unitCount);
uniqueUnitName = drawableGetName() + string(count);
Units[uniqueUnitName] = vega_dynamic_cast_ptr<Unit>(this);
Expand All @@ -167,7 +167,7 @@ extern double calc_blend_factor(double frac,
unsigned int when_it_will_be_simulated,
unsigned int cur_simulation_frame);

void VSDrawable::Draw(const Transformation &parent, const Matrix &parentMatrix) {
void Drawable::Draw(const Transformation &parent, const Matrix &parentMatrix) {
Unit *unit = vega_dynamic_cast_ptr<Unit>(this);

//Quick shortcut for camera setup phase
Expand Down Expand Up @@ -348,7 +348,7 @@ void VSDrawable::Draw(const Transformation &parent, const Matrix &parentMatrix)
Sparkle(On_Screen, ctm);
}

void VSDrawable::AnimationStep() {
void Drawable::AnimationStep() {
#ifdef DEBUG_MESH_ANI
VS_LOG(debug, (boost::format("Starting animation step of Unit: %1%") % uniqueUnitName));
#endif
Expand Down Expand Up @@ -378,7 +378,7 @@ void VSDrawable::AnimationStep() {
#endif
}

void VSDrawable::DrawNow(const Matrix &mato, float lod) {
void Drawable::DrawNow(const Matrix &mato, float lod) {
Unit *unit = vega_dynamic_cast_ptr<Unit>(this);

static const void *rootunit = NULL;
Expand Down Expand Up @@ -503,7 +503,7 @@ void VSDrawable::DrawNow(const Matrix &mato, float lod) {
}
}

void VSDrawable::UpdateFrames() {
void Drawable::UpdateFrames() {
std::map<string, Unit *>::iterator pos;
for (pos = Units.begin(); pos != Units.end(); ++pos) {
pos->second->curtime += GetElapsedTime();
Expand All @@ -514,30 +514,30 @@ void VSDrawable::UpdateFrames() {
}
}

void VSDrawable::addAnimation(std::vector<Mesh *> *meshes, const char *name) {
void Drawable::addAnimation(std::vector<Mesh *> *meshes, const char *name) {
if ((meshes->size() > 0) && animatedMesh) {
vecAnimations.push_back(meshes);
vecAnimationNames.push_back(string(name));
}
}

void VSDrawable::StartAnimation(unsigned int how_many_times, int numAnimation) {
void Drawable::StartAnimation(unsigned int how_many_times, int numAnimation) {
if (animationRuns()) {
StopAnimation();
}

done = false;
}

void VSDrawable::StopAnimation() {
void Drawable::StopAnimation() {
done = true;
}

string VSDrawable::getAnimationName(unsigned int animationNumber) const {
string Drawable::getAnimationName(unsigned int animationNumber) const {
return vecAnimationNames.at(animationNumber);
}

unsigned int VSDrawable::getAnimationNumber(const char *name) const {
unsigned int Drawable::getAnimationNumber(const char *name) const {
string strname(name);
for (unsigned int i = 0; i < vecAnimationNames.size(); i++) {
if (strname == vecAnimationNames[i]) {
Expand All @@ -548,48 +548,48 @@ unsigned int VSDrawable::getAnimationNumber(const char *name) const {
return 0; //NOT FOUND!
}

void VSDrawable::ChangeAnimation(const char *name) {
void Drawable::ChangeAnimation(const char *name) {
unsigned int AnimNumber = getAnimationNumber(name);
if ((AnimNumber < numAnimations()) && isAnimatedMesh()) {
activeAnimation = AnimNumber;
}
}

void VSDrawable::ChangeAnimation(unsigned int AnimNumber) {
void Drawable::ChangeAnimation(unsigned int AnimNumber) {
if ((AnimNumber < numAnimations()) && isAnimatedMesh()) {
activeAnimation = AnimNumber;
}
}

bool VSDrawable::isAnimatedMesh() const {
bool Drawable::isAnimatedMesh() const {
return animatedMesh;
}

double VSDrawable::framesPerSecond() const {
double Drawable::framesPerSecond() const {
return 1 / timeperframe;
}

double VSDrawable::timePerFrame() const {
double Drawable::timePerFrame() const {
return timeperframe;
}

unsigned int VSDrawable::numAnimations() {
unsigned int Drawable::numAnimations() {
return vecAnimations.size();
}

void VSDrawable::ToggleAnimatedMesh(bool on) {
void Drawable::ToggleAnimatedMesh(bool on) {
animatedMesh = on;
}

bool VSDrawable::isContinuousLoop() const {
bool Drawable::isContinuousLoop() const {
return infiniteLoop;
}

void VSDrawable::SetAniSpeed(float speed) {
void Drawable::SetAniSpeed(float speed) {
timeperframe = speed;
}

void VSDrawable::clear() {
void Drawable::clear() {
StopAnimation();

for (unsigned int i = 0; i < vecAnimations.size(); i++) {
Expand All @@ -605,7 +605,7 @@ void VSDrawable::clear() {
Units.erase(uniqueUnitName);
}

bool VSDrawable::animationRuns() const {
bool Drawable::animationRuns() const {
return !done;
}

Expand All @@ -628,9 +628,9 @@ Matrix *GetCumulativeTransformationMatrix(Unit *unit, const Matrix &parentMatrix
}

/**
* @brief VSDrawable::Sparkle caused damaged units to emit sparks
* @brief Drawable::Sparkle caused damaged units to emit sparks
*/
void VSDrawable::Sparkle(bool on_screen, Matrix *ctm) {
void Drawable::Sparkle(bool on_screen, Matrix *ctm) {
Unit *unit = vega_dynamic_cast_ptr<Unit>(this);
const Vector velocity = unit->GetVelocity();

Expand Down Expand Up @@ -696,7 +696,7 @@ void VSDrawable::Sparkle(bool on_screen, Matrix *ctm) {
}
}

void VSDrawable::DrawHalo(bool on_screen, float apparent_size, Matrix wmat, Cloak cloak) {
void Drawable::DrawHalo(bool on_screen, float apparent_size, Matrix wmat, Cloak cloak) {
Unit *unit = vega_dynamic_cast_ptr<Unit>(this);

// Units not shown don't emit a halo
Expand Down Expand Up @@ -740,7 +740,7 @@ void VSDrawable::DrawHalo(bool on_screen, float apparent_size, Matrix wmat, Cloa

}

void VSDrawable::DrawSubunits(bool on_screen, Matrix wmat, Cloak cloak, float average_scale, unsigned char char_damage) {
void Drawable::DrawSubunits(bool on_screen, Matrix wmat, Cloak cloak, float average_scale, unsigned char char_damage) {
Unit *unit = vega_dynamic_cast_ptr<Unit>(this);
Transformation *ct = &unit->cumulative_transformation;

Expand Down Expand Up @@ -825,7 +825,7 @@ void VSDrawable::DrawSubunits(bool on_screen, Matrix wmat, Cloak cloak, float av
}
}

void VSDrawable::Split(int level) {
void Drawable::Split(int level) {
Unit *unit = vega_dynamic_cast_ptr<Unit>(this);

if (game_options()->split_dead_subunits) {
Expand Down Expand Up @@ -952,7 +952,7 @@ void VSDrawable::Split(int level) {
unit->Mass *= game_options()->debris_mass;
}

void VSDrawable::LightShields(const Vector &pnt, const Vector &normal, float amt, const GFXColor &color) {
void Drawable::LightShields(const Vector &pnt, const Vector &normal, float amt, const GFXColor &color) {
Unit *unit = vega_dynamic_cast_ptr<Unit>(this);

// Not sure about shield percentage - more variance for more damage?
Expand All @@ -972,7 +972,7 @@ void VSDrawable::LightShields(const Vector &pnt, const Vector &normal, float amt
std::min(1.0f, std::max(0.0f, amt)), color);
}

Matrix VSDrawable::WarpMatrix(const Matrix &ctm) const {
Matrix Drawable::WarpMatrix(const Matrix &ctm) const {
const Unit *unit = vega_dynamic_const_cast_ptr<const Unit>(this);

if (unit->GetWarpVelocity().MagnitudeSquared()
Expand Down Expand Up @@ -1010,7 +1010,7 @@ Matrix VSDrawable::WarpMatrix(const Matrix &ctm) const {
}
}

void VSDrawable::UpdateHudMatrix(int whichcam) {
void Drawable::UpdateHudMatrix(int whichcam) {
Unit *unit = vega_dynamic_cast_ptr<Unit>(this);

Matrix m;
Expand All @@ -1028,7 +1028,7 @@ void VSDrawable::UpdateHudMatrix(int whichcam) {
unit->GetAcceleration());
}

VSSprite *VSDrawable::getHudImage() const {
VSSprite *Drawable::getHudImage() const {
const Unit *unit = vega_dynamic_const_cast_ptr<const Unit>(this);
return unit->pImage->pHudImage;
}
10 changes: 5 additions & 5 deletions engine/src/cmd/drawable.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ using std::vector;
using std::string;
using std::map;

class VSDrawable {
class Drawable {
public:
//number of meshes (each with separate texture) this unit has
std::vector<Mesh *> meshdata;
Expand Down Expand Up @@ -74,8 +74,8 @@ class VSDrawable {

static std::map<string, Unit *> Units;

VSDrawable();
~VSDrawable();
Drawable();
~Drawable();

bool DrawableInit(const char *filename,
int faction,
Expand All @@ -90,9 +90,9 @@ class VSDrawable {

protected:
// forbidden
VSDrawable(const VSDrawable &) = delete;
Drawable(const Drawable &) = delete;
// forbidden
VSDrawable &operator=(const VSDrawable &) = delete;
Drawable &operator=(const Drawable &) = delete;

public:
string getAnimationName(unsigned int animationNumber) const;
Expand Down
12 changes: 6 additions & 6 deletions engine/src/cmd/unit_generic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ char *GetUnitDir(const char *filename) {
**********************************************************************************
*/
// Called by Planet
Unit::Unit(int dummy) : VSDrawable(), Damageable(), Movable() {
Unit::Unit(int dummy) : Drawable(), Damageable(), Movable() {
pImage = (new UnitImages<void>);
pImage->cockpit_damage = NULL;
pilot = new Pilot(FactionUtil::GetNeutralFaction());
Expand All @@ -287,7 +287,7 @@ Unit::Unit(int dummy) : VSDrawable(), Damageable(), Movable() {
}


Unit::Unit() : VSDrawable(), Damageable(), Movable() //: cumulative_transformation_matrix( identity_matrix )
Unit::Unit() : Drawable(), Damageable(), Movable() //: cumulative_transformation_matrix( identity_matrix )
{
pImage = (new UnitImages<void>);
pImage->cockpit_damage = NULL;
Expand All @@ -298,7 +298,7 @@ Unit::Unit() : VSDrawable(), Damageable(), Movable() //: cumulative_transformati

// Called by Missile
Unit::Unit(std::vector<Mesh *> &meshes, bool SubU, int fact)
: VSDrawable(), Damageable(), Movable() //: cumulative_transformation_matrix( identity_matrix )
: Drawable(), Damageable(), Movable() //: cumulative_transformation_matrix( identity_matrix )
{
pImage = (new UnitImages<void>);
pilot = new Pilot(fact);
Expand All @@ -324,7 +324,7 @@ Unit::Unit(const char *filename,
std::string unitModifications,
Flightgroup *flightgrp,
int fg_subnumber)
: VSDrawable(), Damageable(), Movable() //: cumulative_transformation_matrix( identity_matrix )
: Drawable(), Damageable(), Movable() //: cumulative_transformation_matrix( identity_matrix )
{
pImage = (new UnitImages<void>);
pilot = new Pilot(faction);
Expand Down Expand Up @@ -4250,11 +4250,11 @@ void Unit::applyTechniqueOverrides(const std::map<std::string, std::string> &ove
}
}

std::map<string, Unit *> VSDrawable::Units;
std::map<string, Unit *> Drawable::Units;



unsigned int VSDrawable::unitCount = 0;
unsigned int Drawable::unitCount = 0;

void Unit::ActTurn() {
// Dock
Expand Down
2 changes: 1 addition & 1 deletion engine/src/cmd/unit_generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ struct PlanetaryOrbitData;
*/

// TODO: move Armed to subclasses
class Unit : public Armed, public Audible, public VSDrawable, public Damageable, public Energetic,
class Unit : public Armed, public Audible, public Drawable, public Damageable, public Energetic,
public Intelligent, public Movable, public JumpCapable, public Carrier, public UpgradeableUnit {

protected:
Expand Down
2 changes: 1 addition & 1 deletion engine/src/gldrv/gl_globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ struct GFXStats
#endif
#if defined(__APPLE__) && defined(__MACH__)
#include <epoxy/gl.h>
#include <epoxy/glx.h>
//#include <epoxy/glx.h>
//#include <GLUT/glut.h>
//#include <SDL_opengl.h>
//#include <SDL_opengl_glext.h>
Expand Down
2 changes: 1 addition & 1 deletion engine/src/star_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ void StarSystem::Draw(bool DrawCockpit) {
_Universe->AccessCockpit()->Draw();
}

VSDrawable::UpdateFrames();
Drawable::UpdateFrames();

// And now we're done with the occluder set
Occlusion::end();
Expand Down
2 changes: 1 addition & 1 deletion engine/src/vegastrike.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ extern float AUDIO_ATOM;
#ifndef NO_GFX
#if defined(__APPLE__) && defined(__MACH__)
#include <epoxy/gl.h>
#include <epoxy/glx.h>
// #include <epoxy/glx.h>
#include <GLUT/glut.h>
#else //defined (__APPLE__) || defined (MACOSX)
#define __glext_h_
Expand Down

0 comments on commit f9dbe1c

Please sign in to comment.