0
0

Uh…let me see where should i begin from….I’m a completely beginner (even as a programmer), c is my first language and i’ve been passing trough some troubles.
I use dev c++ 4.992 with the dos project (yea…that black screen…) so, all that i wanted with fmod, was just to have some background sound, like an mp3 playing during the program. I’ve tried the faq, the help, searched the forum and everyting else that i could, but i didn’t manage to understand how to do that.
I know it might sound silly for experienced programmers….but it isn’t for me. So, could anyone, please, help with that?

  • You must to post comments
0
0

i am creating a game.. but my game got a menu.
i wan to play the music after my menu … whad should i do?
do i do it in my gameworld.cpp or main?

and if do in game world ? how to appply the fmod in side the gameworld.cpp and gameworld.h

–>>>>>the follow are my sourc code in main
[code:13wsvivc]
//main.cpp
//IT2931 lab02
//Dioselin Gonzalez
//last edited: April 2006

//Hijacked by Enimal

include "headers.h"

include "MenuDump.h"

GameWorld * gameworld = NULL ;
Input * input = NULL ;
//player * Player = NULL ;

/*
////////////////////////////////Camera//////////////////////////////////

double posX = 0.0f ;
double posY = 4.0f ;
double posZ = 6.0f ;
double upY = -0.5f ;

camera gCamera(posX, posY, posZ, upY);

//////////////////// Model and Variables used for Model ////////////////////
player Player ;
/
float isMoving = 0.0 ;
float isTurning = 0.0 ;
bool isDown = false ;
/

float moveX = 0.0 ;
float moveZ = 0.0 ;
float moveY = 0.0 ;
float rotY = -180.0 ;
float rotX = 0.0 ;
*/

static GLboolean debug = GL_FALSE ;

//GL scene parameters
const GLfloat light_ambient[] = { 0.0f, 0.0f, 0.0f, 1.0f };
const GLfloat light_diffuse[] = { 1.0f, 1.0f, 1.0f, 1.0f };
const GLfloat light_specular[] = { 1.0f, 1.0f, 1.0f, 1.0f };
const GLfloat light_position[] = { 2.0f, 10.0f, 3.0f, 0.0f };

const GLfloat mat_ambient[] = { 0.7f, 0.7f, 0.7f, 1.0f };
const GLfloat mat_diffuse[] = { 0.8f, 0.8f, 0.8f, 1.0f };
const GLfloat mat_specular[] = { 0.2f, 0.2f, 0.2f, 1.0f };
const GLfloat high_shininess[] = { 100.0f };

void initGL(void);

//callbacks
void initEventCallback(void);

//void mouse(int b, int s, int x, int y);

void RenderScene(void)
{
glDisable(GL_TEXTURE_2D);
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

/////////////////////////axis////////////////////////////////
glColor3ub(255,255,255);

glDisable(GL_LIGHTING);
glPushMatrix() ;

glBegin(GL_LINES);

glVertex3f(0.0f, 0.0f, 100.0f);
glVertex3f(0.0f, 0.0f, 0.0f);

glColor3ub(0,0,255) ;
glVertex3f(100.0f, 0.0f, 0.0f);
glVertex3f(-10.0f, 0.0f, 0.0f);

glColor3ub(255,255,0) ;
glVertex3f(0.0f, 100.0f, 0.0f);
glVertex3f(0.0f, -10.0f, 0.0f);

glEnd();

glPopMatrix() ;

/////////////////////////axis end//////////////////////////////

glEnable(GL_LIGHTING) ;
glDisable(GL_COLOR_MATERIAL) ;
/*
gCamera.MoveLogic(isTurning,isDown,Player.getPlayerDirx(), Player.getPlayerDiry(),Player.getPlayerDirz(),Player.getPlayerPosx(),Player.getPlayerPosy(),Player.getPlayerPosz()) ;
//gCamera.CheckTurn(Player.getPlayerDirx(), Player.getPlayerDiry(),Player.getPlayerDirz(),Player.getPlayerPosx(),Player.getPlayerPosy(),Player.getPlayerPosz()) ;
gCamera.setView();
*/
/////////////////////////////Model///////////////////////////
//Movement
/*
glPushMatrix() ;
//const double t = glutGet(GLUT_ELAPSED_TIME) / 1000.0;  
glRotated(rotY,0,1,0);
glTranslated(moveX, moveY, moveZ) ;
glPushMatrix() ;
glRotatef(rotX,0,1,0) ;

//Render Model
glEnable(GL_COLOR_MATERIAL) ;
glColor3ub(10,10,10) ;
//((CNYP_IMAGE*)g_pTexMan->LoadImage("data\\textures\\Step-05.jpg"))->SetTexture();
object->Render();
// CD Box //
if(debug)
box->drawBox() ;

glDisable(GL_COLOR_MATERIAL) ;

glPopMatrix() ;
glPopMatrix() ;
*/
/*
Player.MoveLogic(isTurning, isDown) ;
Player.DrawPlayer(debug) ;
*/
//Player.drawMinMax() ;

////////////////////////////World/////////////////////////////

gameworld->DrawWorld();
gameworld->TickMovement() ;

}

/************************
* display
*
*************************/
void display(void)
{
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

// Position the camera
//glEnable(GL_LIGHTING);
if(!new_mode)
{
    //std::cout<< "abc"<< std::endl;
    //const double t = glutGet(GLUT_ELAPSED_TIME) / 1000.0; //Time based movement

    //glColor3fv(teapot_color); 
    glMatrixMode(GL_MODELVIEW);
    glPushMatrix();
    glLoadIdentity();

    //  glTranslated(0.0,2.0,-10.0);
    //  glRotated(t*90.0,0,1,0); 
    //  glRotated(t*10.0,1,0,0);    
    //  //std::cout <<"I was here!"<< std::endl ;
    //  glutSolidTeapot(2.5);
    //glPopMatrix();

    //glDisable(GL_LIGHTING);

    //glEnable(GL_LIGHTING) ;
    glColor3ub(255,255,255);
    glDisable(GL_COLOR_MATERIAL) ;

    //Plane
    //Texture
    glEnable(GL_TEXTURE_2D);
    ((CNYP_IMAGE*)g_pTexMan->LoadImage("data\\textures\\abc.jpg"))->SetTexture();
    glBegin(GL_QUADS) ;

    glNormal3f(0.0,0.0,1.0);
    glTexCoord2f(0.0,0.0);
    glVertex3f(-512.0, 384.0, -380.0);
    glTexCoord2f(1.0,0.0);
    glVertex3f(512.0, 384.0,-380.0);
    glTexCoord2f(1.0,1.0);
    glVertex3f(512.0, -384.0, -380.0);;
    glTexCoord2f(0.0,1.0);
    glVertex3f(-512.0, -384.0, -380.0);
    glEnd() ;
    glDisable(GL_TEXTURE_2D);
    //std::cout<<"BLAHBLAH"<<std::endl ;
    glPopMatrix() ;
    //glDisable(GL_LIGHTING) ;

    //Menu
    if (main_val.getMode()){    
        renderMenu();
    }

    else if (start_val.getMode()){    
        renderStart();
    }

    else if (opt_val.getMode()){    
        renderOptions();
    }

    else if (load_val.getMode()){    
        renderLoad();
    }

    //Editing player name
    //if (edit_mode){
    //  renderPlayerName();
    //}

    if(vol_msg.getMode()){
        volume_text() ;
    }
    if(con_msg.getMode()){
        controls_text() ;
    }
    if(high_msg.getMode()){
        highscore_text() ;
    }

    //Message
    //glColor3f(0.9,0.6,0.5);
    //std::stringstream message;
    //message << "Welcome, " << player_name << "!";
    //glMatrixMode(GL_PROJECTION);
    //glPushMatrix();
    //glLoadIdentity();

    //    glOrtho(0,10,0,10,-1,1);
    //    glRasterPos2d(1,1);
    //glPopMatrix();
    //bitmapString (GLUT_BITMAP_9_BY_15, message.str());

    // glMatrixMode(GL_MODELVIEW);
    // glPopMatrix();

}
else if(new_mode){
    RenderScene() ;
}

glutSwapBuffers();

}

void idle(void)
{
glutPostWindowRedisplay(currentWindow);
}

/************************
* key
* callback for pressing a key
* Not really For editing of player’s name
*************************/
void key(unsigned char key, int px, int py){
if (edit_mode){
switch (key)
{
case 8: //backspace
if (tmp_player_name.length() > 0)
tmp_player_name = tmp_player_name.erase(tmp_player_name.length() – 1,1);
break;
case 13: //enter
player_name = tmp_player_name;
edit_mode = GL_FALSE;
break;

    //default:
    //  tmp_player_name += key;
    //  break;
}
}
else
{
    const double t = glutGet(GLUT_ELAPSED_TIME) / 1000.0; 
    switch (key) 
    {  
        case 'P':
        case 'p':
            write_data(data_file);
            exit(0);
            break;

        //case 'w':
        //case 'W':
            //Camera Move Forward
            //gCamera.move(camera::WALK, 0.1);
        //  break;

        //case 'r':
        //case 'R':
            //Camera Move Forward
            //Player.Balance(1.0);
        //  break;

        //case 's':
        //case 'S':
            //Camera Move back
            //gCamera.move(camera::BACK, 0.1);
        //  break;

        //case 'q':
        //case 'Q':
            //Camera Left
            //gCamera.move(camera::LEFT, 0.1);
        //  break;

        //case 'e':
        //case 'E':
            //Camera Right
            //gCamera.move(camera::RIGHT, 0.1);
        //  break;

        //case 'u': 
        //case 'U':
            //Camera Move up
            //gCamera.move(camera::UP, 0.1);
        //  break;
        //case 'j':
        //case 'J':
            //Camera Move Down
            //gCamera.move(camera::DOWN, 0.1);
        //  break;

        //case 'a':
        //case 'A':
            //Turn Left
            //gCamera.rotate(camera::ROTATE_Y,5.0);
        //  break;
        //case 'd':
        //case 'D':
            //Turn Right
            //gCamera.rotate(camera::ROTATE_Y,-5.0);
        //  break;
        case 'm':
        case 'M':
            input->BalanceMode() ;
            break ;

        case 'z':
        case 'Z':
            //cout << "Hi I'm Z Key" << endl ;
            input->CounterRight() ;
            break ;

        case 'x':
        case 'X':
            //cout << "Hi I'm X Key" << endl ;
            input->CounterLeft() ;
            break ;

        case 'b':
        case 'B':
            //Currently Used for Drawing debug stuff
            input->DebugMode() ;
            /*
            if(debug)
                debug = GL_FALSE ;
            else
                debug = GL_TRUE ;
            */
            break;

        case 13: //Enter
        if(!new_mode)
        {
            if( main_val.getMode() ) //Main Menu
            {
                switch ( main_val.getCurrent() ) 
                {
                case 0 : //Start
                    main_val.swapMode() ;
                    start_val.swapMode() ;
                    break ;
                case 1 : //Options
                    main_val.swapMode() ;
                    opt_val.swapMode() ;
                    break ;
                case 2 :
                    //For Highscore table
                    high_msg.changeMode() ;
                    break ;
                case 3: //Exit game
                    write_data(data_file) ;
                    exit(0) ;
                    break ;
                }
            }
            else if( start_val.getMode() ) //Start Menu
            {
                switch ( start_val.getCurrent() ){
                case 0: //Start New game
                    start_val.swapMode();
                    new_mode =GL_TRUE;
                    break ;
                case 1: //Load Game
                    start_val.swapMode();
                    load_val.swapMode() ;
                    break ;
                case 2: //Back (To Main Menu)
                    start_val.swapMode() ;
                    main_val.swapMode() ;
                    break;
                }
            }
            else if( opt_val.getMode() ) //Option Menu
            {
                switch ( opt_val.getCurrent() ){
                case 0: //Adjust Volume
                    vol_msg.changeMode() ;
                    break ;
                case 1: //Controls
                    con_msg.changeMode() ;
                    break ;
                case 2: //Back (To Main Menu)
                    opt_val.swapMode() ;
                    main_val.swapMode() ;
                    break;
                }
            }
            else if( load_val.getMode() )
            {
                switch ( load_val.getCurrent() ){
                case 0: 
                    data_file="data\\saves\\player.dat" ;
                    read_data(data_file) ;
                    break ;
                case 1: 
                    data_file="data\\saves\\player2.dat" ;
                    read_data(data_file) ;
                    break ;
                case 2: 
                    data_file="data\\saves\\player3.dat" ;
                    read_data(data_file) ;
                    break ;
                case 3: //Back (To Start Menu)
                    load_val.swapMode() ;
                    start_val.swapMode() ;
                    break;
                }
            }
        }
    } 
}

}

void notkeydown(unsigned char key, int px, int py)
{
switch(key)
{
case ‘x’:
case ‘X’:
//cout << "Hi I’m not X Key" << endl ;
input->Notx() ;
input->Notz() ;
break ;
case ‘z’:
case ‘Z’:
//cout << "Hi I’m not Z Key" << endl ;
input->Notx() ;
input->Notz() ;
break ;
}
}

void special(int key, int x, int y)
{
if(new_mode) //Inside game
{
switch (key)
{
case GLUT_KEY_UP: //Up
//std::cout << "SPAM " ;
//gCamera.move(camera::WALK, 0.1);
//std::cout << Player.getPlayerDirx() << " " << Player.getPlayerDiry() << " " << Player.getPlayerDirz() << std::endl ;
input->Moving() ;
//isDown = true ;
break ;

        case GLUT_KEY_LEFT: //Turn Left
            //gCamera.move(camera::LEFT, 0.1);
            //isTurning = 1 ;
            input-&gt;TurnLeft() ;
            break ;

        case GLUT_KEY_RIGHT: //Turn Right
            //gCamera.move(camera::RIGHT, 0.1);
            //isTurning = -1 ;
            input-&gt;TurnRight() ;
            break ;

        case GLUT_KEY_DOWN: //Backwards, for debugging purposes
            //gCamera.move(camera::BACK, 0.1);
            break ; 
    }
    //std::cout &lt;&lt; &quot;Key pressing Check&quot; &lt;&lt; std::endl ;
}
else //if(!new_mode)
{  
    switch (key) //Menu selection
    { 
        case GLUT_KEY_UP: //Up
            if( main_val.getMode() )
            {
                main_val.subtractValue() ;
            }
            else if( start_val.getMode() )
            {
                start_val.subtractValue() ;
            }
            else if( opt_val.getMode() )
            {
                opt_val.subtractValue() ;
            }
            else if( load_val.getMode() )
            {
                load_val.subtractValue() ;
            }
        break;

        case GLUT_KEY_DOWN: //Down
            if( main_val.getMode() )
            {
                main_val.addValue() ;
            }
            else if( start_val.getMode() )
            {
                start_val.addValue() ;
            }
            else if( opt_val.getMode() )
            {
                opt_val.addValue() ;
            }
            else if( load_val.getMode() )
            {
                load_val.addValue() ;
            }
            break ;
    }
}

}

void release(int key, int x, int y)
{
switch(key)
{

    case GLUT_KEY_LEFT:
    case GLUT_KEY_RIGHT:
        //std::cout &lt;&lt; &quot;Left/Right key released&quot; &lt;&lt; std::endl ;
        input-&gt;NotTurning() ;
        //isTurning = 0 ;
        break ;

    case GLUT_KEY_UP:
        //std::cout &lt;&lt; &quot;Key Up released&quot; &lt;&lt; std::endl ;
        input-&gt;NotMoving() ;
        input-&gt;NotTurning() ;
        //isDown = false ;
        //isTurning = 0 ;
        break ;

    case GLUT_KEY_DOWN:
        break ;
}
//Player.MoveLogic(isTurning, isDown) ;

}

void initGL(void)
{
//std::cout<<"Spam" << std::endl ;
glClearColor(0.0, 0.0, 0.0, 1.0);
glPointSize(3.0);

//glEnable(GL_CULL_FACE);
//glCullFace(GL_BACK);

glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);

glEnable(GL_LIGHT0);
glEnable(GL_NORMALIZE);
//glEnable(GL_COLOR_MATERIAL);

glLightfv(GL_LIGHT0, GL_AMBIENT,  light_ambient);
glLightfv(GL_LIGHT0, GL_DIFFUSE,  light_diffuse);
glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular);
glLightfv(GL_LIGHT0, GL_POSITION, light_position);

glMaterialfv(GL_FRONT, GL_AMBIENT,   mat_ambient);
glMaterialfv(GL_FRONT, GL_DIFFUSE,   mat_diffuse);
glMaterialfv(GL_FRONT, GL_SPECULAR,  mat_specular);
glMaterialfv(GL_FRONT, GL_SHININESS, high_shininess);

}

static void resize(int width, int height)
{
const float ar = (float) width / (float) height;

glViewport(0, 0, width, height);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
//glFrustum(-ar, ar, -1.0, 1.0, 1.0, 100.0);
gluPerspective(90.0, ar, 1.0, 10000.0);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity() ;

}

void initEventCallback(void)
{
//glutIgnoreKeyRepeat(1);

glutReshapeFunc(resize);
glutDisplayFunc(display);  
glutIdleFunc(idle);
glutKeyboardFunc(key);
glutKeyboardUpFunc(notkeydown);
glutSpecialFunc(special);
glutSpecialUpFunc(release) ;

currentWindow = glutGetWindow();

}

/**************
* main
**************/
int main(int argc, char **argv){

INIT_LIB(); //For NYP Framework
//read game data
read_data(data_file);

main_val.swapMode() ;
input = new Input() ;
//Player = new player() ;

gameworld = new GameWorld() ;

//gCamera.CalculateVector(Player.getPlayerPosx(), Player.getPlayerPosy(),Player.getPlayerPosz()) ;

//create main menu
menu_caption m0(main_0);
m0.set_color(menu_default_color);
menu_caption m1(main_1);
m1.set_color(menu_default_color);
menu_caption m2(main_2);
m2.set_color(menu_default_color); 
menu_caption m3(main_3);
m3.set_color(menu_default_color); 

menu.push_back(m0);
menu.push_back(m1);
menu.push_back(m2);
menu.push_back(m3);

//create Start menu
menu_caption s0(start_0) ;
s0.set_color(menu_default_color);
menu_caption s1(start_1) ;
s1.set_color(menu_default_color);
menu_caption s2(start_2) ;
s2.set_color(menu_default_color);

menu_start.push_back(s0);
menu_start.push_back(s1);
menu_start.push_back(s2);

//create Options menu
menu_caption opt0(option_0) ;
opt0.set_color(menu_default_color);
menu_caption opt1(option_1) ;
opt1.set_color(menu_default_color);
menu_caption opt2(option_2) ;
opt2.set_color(menu_default_color);

menu_opt.push_back(opt0);
menu_opt.push_back(opt1);
menu_opt.push_back(opt2);

//Load Menu
menu_caption load0(load_0) ;
load0.set_color(menu_default_color);
menu_caption load1(load_1) ;
load1.set_color(menu_default_color);
menu_caption load2(load_2) ;
load2.set_color(menu_default_color);
menu_caption load3(load_3) ;
load3.set_color(menu_default_color);

menu_load.push_back(load0);
menu_load.push_back(load1);
menu_load.push_back(load2);
menu_load.push_back(load3);

//menu.push_back(menu_caption(&quot;hola&quot;));

//glut initialization
//must pass a pointer to the unmodified argc variable from the main function
//and a pointer to the unmodified argv variable from the main function
glutInit(&amp;argc, argv);

//GLUT_DOUBLE: use double buffer
//GLUT_RGBA: use red,green,blue,alpha color mode
//GLUT_DEPTH: enable depth buffer
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
glClearColor(0.0, 0.0, 0.0, 0.0);
glutInitWindowPosition(100,100);
    glutInitWindowSize(800,600);

mainWindow = glutCreateWindow(&quot;Ani-Mail&quot;);

//No cursor since game does not need cursor
glutSetCursor(GLUT_CURSOR_NONE);
//It is a full screen game
//glutFullScreen();

initGL();

initEventCallback();  

glutMainLoop();  //in original GLUT, this function will not return control back to main
                //see freeglut.sourceforge.net for an alternative

SHUTDOWN_LIB();//Shutdown the lib(NYP Framework)

return 0;             /* ANSI C requires main to return int. */

}

–>>>>>the follow are my sourc code in gameworld.cpp

include "GameWorld.h"

GameWorld::GameWorld(void)
{
HouseModel = "data\models\house.obj" ;
HouseModel2 = "data\models\house2.obj" ;
HouseModel3 = "data\models\house3.obj" ;
TreeModel = "data\models\tree.obj" ;

House = new mesh(HouseModel);
House2 = new mesh(HouseModel2);
House3 = new mesh(HouseModel3);
Tree = new mesh(TreeModel) ;

collided = false ;

double posX = 0.0f ;
double posY = 4.0f ;
double posZ = 6.0f ;
double upY = -0.5f ;

gCamera = new camera(posX, posY, posZ, upY);
Fence = new fence() ;
//player Player(0.0,0.0,0.0,1.0) ;
//player Player ;
Player = new player ;
h1 = 0 ;
w1 = 0 ;

gCamera-&gt;CalculateVector(Player-&gt;getPlayerPosx(), Player-&gt;getPlayerPosy(),Player-&gt;getPlayerPosz()) ;
//gCamera-&gt;MoveLogic(Player-&gt;getPlayerDirx(), Player-&gt;getPlayerDiry(),Player-&gt;getPlayerDirz(),Player-&gt;getPlayerPosx(),Player-&gt;getPlayerPosy(),Player-&gt;getPlayerPosz()) ;
//gCamera-&gt;setView() ;

void Pause(clock_t Delay);
FMUSIC_MODULE *Song;

// Initalize the Fmod System at 44Khz and 32 channels
if(FSOUND_Init(44100, 32, 0))
{
printf("FMOD Init OK\n");
}
else
{
printf("FMOD Init Failed!\n");
return 0;
}

}

GameWorld::~GameWorld(void)
{
}

void GameWorld::DrawWorld()
{
/*
GLfloat mat_specular[] = {0.9,0.9,0.9,1.0};
GLfloat mat_diffuse[] = {0.9,0.9, 0.9,1.0};
glMaterialfv(GL_FRONT, GL_SPECULAR,mat_specular);
glMaterialfv(GL_FRONT, GL_DIFFUSE,mat_diffuse);
*/
gCamera->setView();
Player->DrawPlayer() ;

DrawFloor() ;
DrawHouse() ;
DrawSkybox() ;
DrawFence() ;
DrawTrees() ;
DrawGUI() ;

}

void GameWorld::TickMovement()
{
//Logic Stuff, CD sohuld be here
gCamera->MoveLogic(Player->getPlayerDirx(), Player->getPlayerDiry(),Player->getPlayerDirz(),Player->getPlayerPosx(),Player->getPlayerPosy(),Player->getPlayerPosz()) ;

if(input-&gt;isDown)
{
    Player-&gt;CalNext(0.1) ;
    collided = Fence-&gt;checkCollision(Player-&gt;getNextMoveMaxx(),Player-&gt;getNextMoveMaxy(),Player-&gt;getNextMoveMaxz(),Player-&gt;getNextMoveMinx(),Player-&gt;getNextMoveMiny(),Player-&gt;getNextMoveMinz()) ;

    if(!collided)
        Player-&gt;MovePlayer(player::WALK,0.1,0.0) ;
}

if(input-&gt;isTurning == 1)
{
    Player-&gt;MovePlayer(player::LEFT,0.0,5.0) ;
}

if(input-&gt;isTurning == -1)
{
    Player-&gt;MovePlayer(player::RIGHT,0.0,-5.0) ;
}

}

void GameWorld::TickAnimation()
{
//Not sure
}

void GameWorld::DrawFence()
{
Fence->OrientFence() ;
}

void GameWorld::DrawTrees()
{
glEnable(GL_LIGHTING);
/*
glEnable( GL_BLEND );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
glEnable(GL_TEXTURE_2D);
((CNYP_IMAGE*)g_pTexMan->LoadImage("data\textures\tree.tga"))->SetTexture();
glBegin(GL_QUADS);

glColor3ub(0,0,0);
glTexCoord2f(0.0,0.0);
glVertex3f(10.0, 10.0, -10.0);
glTexCoord2f(1.0,0.0);
glVertex3f(20.0, 10.0, -10.0);
glTexCoord2f(1.0,1.0);
glVertex3f(20.0, 0.0, -10.0);
glTexCoord2f(0.0,1.0);
glVertex3f(10.0, 0.0, -10.0);
glEnd();

glBegin(GL_QUADS);

glColor3ub(0,0,0);
glTexCoord2f(0.0,0.0);
glVertex3f(15.0, 10.0, -15.0);
glTexCoord2f(1.0,0.0);
glVertex3f(15.0, 10.0, -5.0);
glTexCoord2f(1.0,1.0);
glVertex3f(15.0, 0.0, -5.0);
glTexCoord2f(0.0,1.0);
glVertex3f(15.0, 0.0, -15.0);
glEnd();

glBegin(GL_QUADS);

glColor3ub(0,0,0);
glTexCoord2f(0.0,0.0);
glVertex3f(30.0, 10.0, -80.0);
glTexCoord2f(1.0,0.0);
glVertex3f(40.0, 10.0, -80.0);
glTexCoord2f(1.0,1.0);
glVertex3f(40.0, 0.0, -80.0);
glTexCoord2f(0.0,1.0);
glVertex3f(30.0, 0.0, -80.0);

glEnd();

glBegin(GL_QUADS);

glColor3ub(0,0,0);
glTexCoord2f(0.0,0.0);
glVertex3f(-40.0, 10.0, 30.0);
glTexCoord2f(1.0,0.0);
glVertex3f(-50.0, 10.0, 30.0);
glTexCoord2f(1.0,1.0);
glVertex3f(-50.0, 0.0, 30.0);
glTexCoord2f(0.0,1.0);  
glVertex3f(-40.0, 0.0, 30.0);
glEnd();
glPopMatrix();
*/

glPushMatrix() ;
glTranslatef(10.0, 0.0, 5.0) ;
Tree-&gt;Render() ;
glPopMatrix() ;

glPushMatrix() ;
glTranslatef(30.0, 0.0, 10.0) ;
Tree-&gt;Render() ;
glPopMatrix() ;

glPushMatrix() ;
glTranslatef(-20.0, 0.0, 5.0) ;
Tree-&gt;Render() ;
glPopMatrix() ;

glPushMatrix() ;
glTranslatef(-60.0, 0.0, -10.0) ;
Tree-&gt;Render() ;
glPopMatrix() ;

glPushMatrix() ;
glTranslatef(150.0, 0.0, -5.0) ;
Tree-&gt;Render() ;
glPopMatrix() ;

glPushMatrix() ;
glTranslatef(-25.0, 0.0, -10.0) ;
Tree-&gt;Render() ;
glPopMatrix() ;

glDisable(GL_LIGHTING);
glDisable(GL_TEXTURE_2D);

}

void GameWorld::DrawSkybox()
{
glEnable(GL_LIGHTING);
glEnable(GL_TEXTURE_2D);
((CNYP_IMAGE*)g_pTexMan->LoadImage("data\textures\sky1.bmp"))->SetTexture();
glBegin(GL_QUADS);

glTexCoord2f(0.0 , 0.0);
glVertex3f(-500, 0, 500);
glTexCoord2f(1.0, 0.0);
glVertex3f(-500, 0, -500);
glTexCoord2f(0.0,1.0);
glVertex3f(-500, 500, -500);
glTexCoord2f(1.0 , 1.0);
glVertex3f(-500, 500, 500);

glBegin(GL_QUADS);

glVertex3f(500, 0 , 500);
glVertex3f(-500, 0 , 500);
glVertex3f(-500, 500, 500);
glVertex3f(500, 500, 500);

glBegin(GL_QUADS);

glVertex3f(500, 0, -500);
glVertex3f(500, 0 , 500);
glVertex3f(500, 500, 500);
glVertex3f(500, 500, -500);

glBegin(GL_QUADS);

glVertex3f(-500, 0, -500);
glVertex3f(500, 0 , -500);
glVertex3f(500, 500,-500);
glVertex3f(-500, 500, -500);

glBegin(GL_QUADS);

glVertex3f(-500,500 ,500);
glVertex3f(500, 500, 500);
glVertex3f(500, 500,-500);
glVertex3f(-500,500,-500);

glEnd();
glDisable(GL_TEXTURE_2D);

}

void GameWorld::DrawHouse()
{
glPushMatrix() ;
glRotatef(180,0,1,0) ;
glTranslatef(0.0, 0.0, 22) ;
House->Render() ;
glPopMatrix() ;

glPushMatrix() ;
//glRotatef(180,0,1,0) ;
glTranslatef(-22.0, 0.0, 0.0) ;
House2-&gt;Render() ;
glPopMatrix() ;

glPushMatrix() ;
//glRotatef(180,0,1,0) ;
glTranslatef(20.0, 0.0, 10.0) ;
House3-&gt;Render() ;
glPopMatrix() ;

}

void GameWorld::DrawFloor()
{
glEnable(GL_TEXTURE_2D);
((CNYP_IMAGE*)g_pTexMan->LoadImage("data\textures\mapNoRed.bmp"))->SetTexture();
glEnable(GL_LIGHTING);

/*
glBegin(GL_QUADS);
glColor3ub(200,200,200);
glNormal3f(0.0,1.0,0.0);

for(int i=0; i&lt;100; i++)
{
    for(int j=0; j&lt;100; j++)
    {
        glTexCoord2f(0.0,0.0);
        glVertex3f(-500.0 + 10.0*j, 0.0, -500.0 + 10.0*i);
        glTexCoord2f(1.0,0.0);
        glVertex3f(-500.0 + 10.0*j, 0.0, -510.0+ 10.0*i);
        glTexCoord2f(1.0,1.0);
        glVertex3f(-510.0 + 10.0*j, 0.0, -510.0+ 10.0*i);
        glTexCoord2f(0.0,1.0);
        glVertex3f(-510.0 + 10.0*j, 0.0, -500.0+ 10.0*i);
    }
}
*/

float size = 100 ;

glBegin(GL_QUADS);
glNormal3f(0.0,1.0,0.0);
glTexCoord2f(0.0,0.0);
glVertex3f(-size, 0.0, -size) ;
glTexCoord2f(1.0,0.0);
glVertex3f(size, 0.0, -size) ;
glTexCoord2f(1.0,1.0);
glVertex3f(size, 0.0, size) ;
glTexCoord2f(0.0,1.0);
glVertex3f(-size, 0.0, size) ;
glEnd();

glDisable(GL_TEXTURE_2D);

}

void GameWorld::orthoBegin()
{
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
gluOrtho2D(0, w1, 0, h1);
glScalef(1, -1, 1);
glTranslatef(0, -h1, -1);
glMatrixMode(GL_MODELVIEW);

}
void GameWorld::orthoEnd()
{
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
//glPushMatrix();

}
void GameWorld::DrawGUI()
{
glLoadIdentity();

orthoBegin();

glEnable(GL_TEXTURE_2D);
((CNYP_IMAGE*)g_pTexMan-&gt;LoadImage(&quot;data\\textures\\map4.bmp&quot;))-&gt;SetTexture();
glEnable(GL_LIGHTING);

glBegin(GL_QUADS);

glTexCoord2f(0.0,0.0);
glVertex2f(0.5, 0.5);
glTexCoord2f(1.0,0.0);
glVertex2f(0.5, 1);
glTexCoord2f(1.0,1.0);
glVertex2f(1, 1);
glTexCoord2f(0.0,1.0);
glVertex2f(1, 0.5);
glEnd();

glEnable( GL_BLEND );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
glEnable(GL_TEXTURE_2D);
((CNYP_IMAGE*)g_pTexMan-&gt;LoadImage(&quot;data\\textures\\jar.tga&quot;))-&gt;SetTexture();
glEnable(GL_LIGHTING);

glBegin(GL_QUADS);

glTexCoord2f(0.0,1.0);
glVertex2f(-1, -1);
glTexCoord2f(1.0,1.0);
glVertex2f(-0.7, -1);
glTexCoord2f(1.0,0.0);
glVertex2f(-0.7, -0.5);
glTexCoord2f(0.0,0.0);
glVertex2f(-1, -0.5);
glEnd();

glDisable( GL_BLEND ) ;

orthoEnd();

}

–>>>>>the follow are my sourc code in gameworld.h

pragma once

include "headers.h"

include "camera.h"

include "player.h"

include "fence.h"

include "mesh.h"

include <conio.h> // console input/output

include "include/fmod.hpp"

include "include/fmod_errors.h"

class fence ;
class camera ;
class player ;
//player Player ;

class GameWorld
{
public:
GameWorld(void);
~GameWorld(void);

void DrawWorld();
void TickMovement();
void TickAnimation();
void DrawTrees();
void DrawHouse();
void orthoBegin();
void orthoEnd();
void DrawGUI();
//void Billboarding();
//void Billboardingend();
//void DrawFloor(); 
//void TickInput() ;

void DrawFence() ;
void DrawSkybox() ;
void DrawFloor() ;

private:
mesh * House ;
mesh * House2 ;
mesh * House3 ;
mesh * Tree ;

const char * HouseModel ;
const char * HouseModel2 ;
const char * HouseModel3 ;
const char * TreeModel ;

double posX ; //= 0.0f ;
double posY ;//= 4.0f ;
double posZ ;//= 6.0f ;
double upY ;//= -0.5f ;

bool collided ;

player * Player ;

fence * Fence ;
camera * gCamera ;

int w1;
int h1;

};
[/code:13wsvivc]

pls help me

  • You must to post comments
0
0

btw….i don’t know if i was clear enough…i don’t know even how to install it, i’ve just downloaded, but i don’t know where should i put each file and so on. But all that i want is to play a simple sound on the program.
(if it is to complicated with fmod, it could be even another library or any other way to play a simple sound)
thanks

  • You must to post comments
0
0

When posting more than a few lines of code, please upload the code to a file somewhere or to a pastebin.

Additionally, you should be aware that most CS programs require you not to recieve any help from third parties while developing an assignment.

  • You must to post comments
0
0

If you just want to play a simple sound, you can use the PlaySound function in the windows API, it’s very simple.

But if you want to use fmod, do the following:
go to project options, to the parameters tab, then click the "add a file" button, then search for libfmodex.a
then put fmodex.dll in the same directory than your executalbe program, and fmod.h in the same directory than your source code

now add

include "fmod.h"

to the top of your program source code

next, put (this is almost copy-pasted from the playsound example)
[code:3secw16u]
int main(int argc, char* argv[])
{
FMOD_SYSTEM *system;
FMOD_SOUND *sound;
FMOD_CHANNEL *channel = 0;
FMOD_System_Create(&system);
FMOD_System_Init(system, 32, FMOD_INIT_NORMAL, NULL);
FMOD_System_CreateSound(system, "put/your/sound/file/here.mp3", FMOD_HARDWARE | FMOD_LOOP_OFF, 0, &sound);
FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound, 0, &channel);

// ... the rest of your program goes here

FMOD_Sound_Release(sound);
FMOD_System_Close(system);
FMOD_System_Release(system);
return 0;
}[/code:3secw16u]

I didn’t test it but it should work fine, this is the simplest way to do what you want, it doesn’t even check for errors

(just replace FMOD_LOOP_OFF with FMOD_LOOP_ON if you want your sound to loop)

  • You must to post comments
0
0

You forgot the most important part : the loop, here, the sound will play a few milliseconds and exit ๐Ÿ˜‰

  • You must to post comments
0
0

I put "the rest of your program goes here"… I suppose his program accepts some kind of input like cin >> var; and doesn’t exit immediately if he wants to play music while it executes :)

  • You must to post comments
0
0

He is a complete beginner, who know if he already studied i/o concept ? ๐Ÿ˜†
Btw, the forum isn’t intended to teach programming, taikanatur should better learn the C language before anything else.

  • You must to post comments
0
0

Thanks a lot everyone ๐Ÿ˜€
I’ll try to do that.
Yea…I know i should learn c first, that’s what i’ve been doing for quite some time, but i just tough some sound would be nice. (normal i/o i know ๐Ÿ˜€ altough that doesn’t mean much)

  • You must to post comments
0
0

Well…first time i compiled there were some errors, but……..it worked!!!
Man, you don’t know how much you’ve helped me! thanks!

btw….that’s just a detail, but i didn’t manage to put the loop working, when i change: "FMOD_LOOP_ON" to "FMOD_LOOP_OFF" it says:

FMOD_LOOP_ON’ undeclared (first use this function)

well, that doesn’t make much sense for me, unless that it isn’t on the .h file? Or have i guessed wrong?

  • You must to post comments
0
0

Where did you put the header files ? If it is in the root of your sourcecode, include them with #include "foo.h " instead of #include <foo.h>.
If it is in your $INCLUDE_PATH and you put them inside a folder (fmodex/fmod.h for example ) then you will have to add the "fmodex" folder in your compiler settings (not the linker).
And make sure that you don’t have headers conflit, it occurs when you put different headers in the know include path of your compiler.

  • You must to post comments
0
0

[quote="KarLKoX":3gif1qsl]Where did you put the header files ? If it is in the root of your sourcecode, include them with #include "foo.h " instead of #include <foo.h>.
If it is in your $INCLUDE_PATH and you put them inside a folder (fmodex/fmod.h for example ) then you will have to add the "fmodex" folder in your compiler settings (not the linker).
And make sure that you don’t have headers conflit, it occurs when you put different headers in the know include path of your compiler.[/quote:3gif1qsl]

that’s not that

I’m sorry, it’s not FMOD_LOOP_ON, it’s FMOD_LOOP_NORMAL (see the doc)

  • You must to post comments
0
0

Thanks a lot both of you. It’s working quiet perfectly ๐Ÿ˜€

  • You must to post comments
Showing 12 results
Your Answer

Please first to submit.