Jump to content
  • Advertisement
Sign in to follow this  
xyuri

OpenGL matrix shows when run from IDE but not otherwise ...

This topic is 4946 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am displaying a little space ship (triangle) using the following function:
  void DrawScene(void)
  {
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);    // Clear The Screen And The Depth Buffer
    glLoadIdentity();                                      // Reset The View
    gluLookAt(0, 0, 80, 0, 0, 0, 0, 1, 0);    // This determines where the camera's position and view is

    glBegin(GL_LINES);
    glColor3ub(0, 255, 0); glVertex3f(0, 15, 0); glVertex3f(0, -15, 0);
    glEnd();

    //Draw Ship!
    glPushMatrix();
    glTranslatef(object.XPos, object.YPos, object.ZPos);
    glRotatef(object.angle, 0.0f, 0.0f, 1.0f);
    glBegin (GL_TRIANGLES);
    glColor3ub(0, 255, 0); //GREEN
    glVertex3f(-1, -1, 0);
    glColor3ub(255, 0, 0); //RED
    glVertex3f(2, 0, 0);
    glColor3ub(0, 255, 0); //GREEN
    glVertex3f(-1, 1, 0);
    glEnd();
    //If accelerating...
    if (object.accelerating)
    {
      //Draw FLAMES !!!!! :-)
      glBegin(GL_LINES);
      glColor3ub(0, 0, 255); //BLUE
      glVertex3f(-1, -1, 0);
      glVertex3f(-1, 1, 0);
      glColor3ub(0, 0, 200); //LESS BLUE
      glVertex3f(-1.4, -0.8, 0);
      glVertex3f(-1.4, 0.8, 0);
      glColor3ub(0, 0, 150); //LESS BLUE
      glVertex3f(-1.8, -0.6, 0);
      glVertex3f(-1.8, 0.6, 0);
      glColor3ub(0, 0, 100); //LESS BLUE
      glVertex3f(-2.2, -0.4, 0);
      glVertex3f(-2.2, 0.4, 0);
      glColor3ub(0, 0, 50); //LESS BLUE
      glVertex3f(-2.4, -0.2, 0);
      glVertex3f(-2.4, 0.2, 0);
      glEnd();
    }
    glRotatef(0 - object.angle, 0.0f, 0.0f, 1.0f);
    glPopMatrix();

    SDL_GL_SwapBuffers();                                  // Swap the backbuffers to the foreground
    CalculateFrameRate();
  }
There is a vertical line there for visual orientation (testing). When I compile and run the app from Dev-C++ it shows the ship (which is in a seperate matrix) and I can move it around and stuff fine. But, when I run the executable by browsing to it in windows it will not display the ship, it only shows the green line. Why will it not show anything in that matrix?? I'm very very very new to this, so please be nice :D Thanks.

Share this post


Link to post
Share on other sites
Advertisement
When you run it from Windows rather than Dev-C++, is that a release build rather than a debug build? Are you initialising your object structure (the x-, y-, z-pos and then angle)?

cheers
sam

Share this post


Link to post
Share on other sites
Quote:
Original post by izzo
When you run it from Windows rather than Dev-C++, is that a release build rather than a debug build? Are you initialising your object structure (the x-, y-, z-pos and then angle)?

cheers
sam

I just click "Rebuild All" then "Compile & Run" and it works. This is what I do every time and this is the first time something like this has happened :( I have never done a debug build as far as I know.

and dont worry about the creation of the "object" object, it is initialised and some parameters set before this function is ever called.

Does anyone have anything for me :( ??

Share this post


Link to post
Share on other sites
Just for the record, I have had a look through the project settings and enabled what I think to be the debugging stuff, which results in a larger EXE size but does not solve this problem.

Share this post


Link to post
Share on other sites
uuuuuuuuh. for some reason it works now !!!!

I had previously rried everything, even rebooting!

Before I left this morning it was not work ...

Since I have gotten home I've recorded a session with FRAPS to show someone, and changed the following lines of code (the commented ones are the original lines, and the others are the replacement code)

//if (keys[SDLK_RIGHT]) {gameclass->SetAngle(-220 * (Timer.time_factor * 1000));}
//if (keys[SDLK_LEFT]) {gameclass->SetAngle(220 * (Timer.time_factor * 1000));}
if (keys[SDLK_RIGHT]) {gameclass->SetAngle(-220 * rtime);}
if (keys[SDLK_LEFT]) {gameclass->SetAngle(220 * rtime);}

Share this post


Link to post
Share on other sites
Weird... no idea :) it really just sounded like some variables that weren't being initialised. Well at least it works now :)

sam

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!