Skip to content

Commit

Permalink
Removed the ifdef sound stuff
Browse files Browse the repository at this point in the history
Changed makefile library param
Using display lists for spheres now
  • Loading branch information
Krishna committed Mar 30, 2010
1 parent 857d0fa commit 5f61234
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 31 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
SOURCES = $(wildcard *.cpp)
OBJECTS = $(SOURCES:.cpp=.o)
DEPENDS = $(SOURCES:.cpp=.d)
LDFLAGS = $(shell pkg-config --libs gtkmm-2.4 gtkglextmm-1.2 sdl libpng) -lglut -lsdl_mixer
LDFLAGS = $(shell pkg-config --libs gtkmm-2.4 gtkglextmm-1.2 sdl libpng) -lglut -lSDL_mixer
CPPFLAGS = $(shell pkg-config --cflags gtkmm-2.4 gtkglextmm-1.2 sdl libpng)
CXXFLAGS = $(CPPFLAGS) -W -Wall -g
CXX = g++ -m32
Expand Down
38 changes: 16 additions & 22 deletions viewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#define DEFAULT_GAME_SPEED 50
#define WIDTH 16
#define HEIGHT 10

using namespace std;

Viewer::Viewer()
Expand Down Expand Up @@ -75,7 +74,6 @@ Viewer::Viewer()
glconfig = Gdk::GL::Config::create( Gdk::GL::MODE_RGBA |
Gdk::GL::MODE_DEPTH |
Gdk::GL::MODE_DOUBLE |
Gdk::GL::MODE_ACCUM |
Gdk::GL::MODE_STENCIL);
if (glconfig == 0) {
// If we can't get this configuration, die
Expand Down Expand Up @@ -150,17 +148,25 @@ void Viewer::on_realize()


// Load music
#ifdef ENABLE_AUDIO
introMusic = sm.LoadSound("intro.ogg");
backgroundMusic = sm.LoadSound("lumines.ogg");
moveSound = sm.LoadSound("move.ogg");
turnSound = sm.LoadSound("turn.ogg");
sm.PlaySound(introMusic, -1);
#endif

// Sphere for particles
particleSphere = gluNewQuadric();

sphereDisplayList = glGenLists(1);
glNewList(sphereDisplayList, GL_COMPILE);
GLUquadricObj *sphere = gluNewQuadric();
gluQuadricNormals(sphere, GL_SMOOTH); // Generate Smooth Normals For The Quad
gluQuadricTexture(sphere, GL_TRUE); // Enable Texture Coords For The Quad
gluSphere(sphere, 1.0f, 32, 32);
delete(sphere);
glEndList();

// Load default aniamtion
readFile("head.txt");


Expand Down Expand Up @@ -399,9 +405,7 @@ void Viewer::drawAnimatables()
// Draw something
if (animatables[i].shapeType == 1)
{
gluQuadricNormals(particleSphere, GLU_SMOOTH); // Create Smooth Normals ( NEW )
gluQuadricTexture(particleSphere, GL_TRUE);
gluSphere(particleSphere,1.f,32,32);
glCallList(sphereDisplayList);
}
else
{
Expand Down Expand Up @@ -612,15 +616,12 @@ void Viewer::drawParticles(bool step)
else if (particles[i]->getShape() == 1 && step)
{
colour = particles[i]->getColour();
GLUquadricObj *sphere = gluNewQuadric();
glColor4f(colour[0], colour[1], colour[2], alpha);
gluQuadricNormals(sphere, GLU_SMOOTH); // Create Smooth Normals ( NEW )
gluQuadricTexture(sphere, GL_TRUE);
glPushMatrix();
glTranslatef(pos[0], pos[1], pos[2]);
gluSphere(sphere, rad, 32, 32);
glScalef(rad, rad, rad);
glCallList(sphereDisplayList);
glPopMatrix();
delete(sphere);

if (colour[1] > 1)
{
Expand Down Expand Up @@ -1100,12 +1101,10 @@ bool Viewer::on_button_press_event(GdkEventButton* event)
soundOnTex = soundOffTex;
soundOffTex = temp;
disableSound = !disableSound;
#ifdef ENABLE_AUDIO
if (!disableSound)
sm.PlaySound(introMusic, -1);
else
sm.StopSound(introMusic);
#endif
}
else if (*ptr == singleSkinModeTex)
{
Expand Down Expand Up @@ -1152,11 +1151,9 @@ bool Viewer::on_button_release_event(GdkEventButton* event)
if (clickedButton && loadScreen)
{
loadScreen = false;
#ifdef ENABLE_AUDIO
sm.StopSound(introMusic);
if (!disableSound)
sm.PlaySound(backgroundMusic, -1);
#endif
}

if (!shiftIsDown)
Expand Down Expand Up @@ -1767,16 +1764,15 @@ bool Viewer::on_key_press_event( GdkEventKey *ev )
// Don't process movement keys if its game over
if (gameOver)
return true;

#ifdef ENABLE_AUDIO

if (loadScreen || !disableSound)
{
if (ev->keyval == GDK_Left || ev->keyval == GDK_Right)
sm.PlaySound(moveSound);
else if (ev->keyval == GDK_Up || ev->keyval == GDK_Down)
sm.PlaySound(turnSound);
}
#endif


int r, c;
r = game->py_;
Expand Down Expand Up @@ -2385,7 +2381,6 @@ void Viewer::readFile(char *filename)
void Viewer::toggleSound()
{
disableSound = !disableSound;
#ifdef ENABLE_AUDIO
if (disableSound)
{
sm.StopSound(introMusic);
Expand All @@ -2395,5 +2390,4 @@ void Viewer::toggleSound()
sm.PlaySound(introMusic, -1);
else
sm.PlaySound(backgroundMusic, 1);
#endif
}
10 changes: 2 additions & 8 deletions viewer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,11 @@
#include <gtkmm.h>
#include <gtkglmm.h>
#include "game.hpp"
#include "SoundManager.hpp"
#include <map>
#include <vector>
#include "particle.hpp"
#include <GL/glu.h>
//#define ENABLE_SOUND 1

#ifdef ENABLE_SOUND
#include "SoundManager.hpp"
#endif

// The "main" OpenGL widget
class Viewer : public Gtk::GL::DrawingArea {
public:
Expand Down Expand Up @@ -197,9 +192,7 @@ class Viewer : public Gtk::GL::DrawingArea {
bool loadTexture;
bool loadBumpMapping;
bool transluceny;
#ifdef ENABLE_SOUND
SoundManager sm;
#endif
int backgroundMusic;
int turnSound;
int moveSound;
Expand All @@ -212,6 +205,7 @@ class Viewer : public Gtk::GL::DrawingArea {
bool drawingShadow;
GLuint cube, bumpMap, floorTexId, playButtonTex, playButtonClickedTex, backgroundTex;
GLuint soundOnTex, soundOffTex, singleSkinModeTex, singleSkinModeClickedTex;
GLuint sphereDisplayList;
bool clickedButton;
std::vector< std::pair<Point3D, Point3D> > silhouette;
std::vector< Particle *> particles;
Expand Down

0 comments on commit 5f61234

Please sign in to comment.