Archived

This topic is now archived and is closed to further replies.

Nukem

glut and md2

Recommended Posts

I wrote an md2 class, based on nehe's. When I goto run it I dont see the md2 but, I see everything else just fine. I read threw the md2 code and im 100% its not that. What is wrong is glut. There is something wrong with the reshape funtion(im pretty sure its the reshape), init, or draw. Ill post all of them.
  
void init()
{
   axy.x = 0.0f;
   axy.y = 0.0f;
   axy.z = -25.0f;

  if(ng.LoadTexture("jon.bmp", texture, 0) == 0)
  {
    cout << "Texture loading failed\n";
  }

  if(ng.LoadTexture("alien.bmp", texture, 1) == 0)
  {
    cout << "Texture loading failed\n";
  }

        glShadeModel(GL_SMOOTH);                                // Enable Smooth Shading

        glClearColor(0.0f, 0.0f, 0.0f, 0.5f);                   // Black Background

        glClearDepth(1.0f);                                     // Depth Buffer Setup

        glEnable(GL_DEPTH_TEST);                                // Enables Depth Testing

        glDepthFunc(GL_LEQUAL);
        glEnable(GL_LIGHT0);                                    // Quick And Dirty Lighting (Assumes Light0 Is Set Up)

        glEnable(GL_LIGHTING);                                  // Enable Lighting

        glEnable(GL_COLOR_MATERIAL);
  glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
}

static void Reshape(int width, int height)
{
  GLfloat h = (GLfloat) height / (GLfloat) width;

  glViewport(0, 0, (GLint) width, (GLint) height);
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  glFrustum(-1.0, 1.0, -h, h, 5.0, 1000.0);
  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();
  glTranslatef(0.0, 0.0, 40.0);
}

static void Draw()
{
  static GLfloat move = 0.0;
  ng.Clear();

  glPushMatrix();

  glPushMatrix();
    ng.SetColor(RGB(0.0, 1.0, 1.0));
    ng.MoveAxis(XYZ(-2.5, 0, -20));
    ng.RotateAllAxis(move);
    ng.Sphere(0.275, 32, 32);
  glPopMatrix();

  glPushMatrix();
    ng.SetColor(RGB(0.0f, 1.0f, 0.0f));
    ng.MoveAxis(XYZ(-2.5, 0, -20));
    ng.RotateAxis(XYZ(move + 270, move, move));
    ng.WireRing(0.275, 0.85, 10, 30);
  glPopMatrix();

  glPushMatrix();
    ng.SetColor(RGB(0.0f, 0.0f, 1.0f));
    ng.MoveAxis(XYZ(-2.5, 0, -20));
    ng.RotateAllAxis(move);
    ng.WireRing(0.275, 0.85, 10, 30);
  glPopMatrix();

/*  glPushMatrix();
    //glBindTexture(GL_TEXTURE_2D, texture[0]);
    ng.SetColor(RGB(0.0, 1.0, 0.0));
    ng.MoveAxis(axy);
    ng.RotateAllAxis(move);
    ngc.WireDraw(true);
  glPopMatrix();
 */
  glEnable(GL_TEXTURE_2D);

  glPushMatrix();
    glEnable(GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, texture[0]);
    ng.SetColor(RGB(1.0, 1.0, 1.0));
    ng.MoveAxis(XYZ(3.0, 0.0, -60.0));
    ng.RotateAllAxis(move);
    ng.Cube();
  glPopMatrix();

  glBindTexture(GL_TEXTURE_2D, texture[1]);
  ng.MoveAxis(axy);
  glScalef(0.5, 0.5, 0.5);
  md2.Animate(md2.StateStart, md2.StateEnd, 0.2);
  glBindTexture(GL_TEXTURE_2D, texture[1]);
  md2.Animate(md2.StateStart, md2.StateEnd, 0.2);

  glFlush();

  glDisable(GL_TEXTURE_2D);

  move += 1.0f;

  glutSwapBuffers();
}
  
Thanks, Nuke P.S I'm using Linux [edited by - nukem on August 11, 2002 12:43:26 AM]

Share this post


Link to post
Share on other sites
Iam not sure if it the problem but it seems you glPush... more than you glPop... in the Draw() function. [ does glFlush() empty the matrix stacks? ].

And a suggestion for debug: Why dont you scale your MD2 real big[disable the backface culling] and see if anything gets drawn?

Oztan

Share this post


Link to post
Share on other sites
quote:
Original post by shurcool
don''t use glut, it''s absolete. u''re bound into running in all sorts of limitations



A vague comment like this is useless. Exactly what kind
of limitations are you referring to? I''ve been using
GLUT quite happily and have yet to find the so-called
limitations . Englighten me.





Kami no Itte ga ore ni zettai naru!

Share this post


Link to post
Share on other sites
quote:
Original post by tangentz
A vague comment like this is useless. Exactly what kind
of limitations are you referring to? I''ve been using
GLUT quite happily and have yet to find the so-called
limitations . Englighten me.


i might have been a little harsh, so sorry. but i''ve used both glfw and glut, and picked glfw. you only used glut. how can you know what''s better? and to name a limitation: try to make a window which can dynamically change resolutions (and go back to windowed mode), and start in either full screen or windowed mode. and another thing, try inegrating it with another library which also has a structure when you have to register a "game-loop" function. all i''m asking is that you consider glfw. read the manual, try examples, write ur own simple test prog. and hopefully you''ll see.

but then again, that''s just my opinion.

---
shurcool
wwdev

Share this post


Link to post
Share on other sites
quote:
Original post by shurcool
you only used glut. how can you know what''s better?



I didn''t say anything about which is better . That''s
pretty irrelevant. I try to find out what I can and cannot
do with a library. If I find something that it can''t do and
I need to do it, I''ll search for another one or write
one myself.

quote:

try to make a window which can dynamically change resolutions (and go back to windowed mode)



No particularly relevant. When my game starts, it stays in
the same resolution throughout. The resolution is controlled
by an external config file. Also, once a user picked a
resolution to use, it tends to stay that way. *shrug*

quote:

start in either full screen or windowed mode.



glutGameModeString(), glutEnterGameMode(), glutLeaveGameMode()

quote:

try inegrating it with another library which also has a structure when you have to register a "game-loop" function.



For example? Let me guess, glfw?

quote:

all i''m asking is that you consider glfw. read the manual, try examples, write ur own simple test prog. and hopefully you''ll see.



Actually, I''ve tried GLOW and GLUI and found them lacking.
I haven''t got around to glfw, yet. I might at some point.
Who knows? Maybe I''ll switch from GLUT to glfw.

Peace.



Kami no Itte ga ore ni zettai naru!

Share this post


Link to post
Share on other sites
if your game can''t change resoltion when it''s running, then it''s probably a simple game or a demo, not even close to quality/finish-ness of a good commercial game. i''m pretty sure most people would like to change resultions in menus in a game.

and no, glfw does not have this register-a-function-to-be-called-acting-as-a-game-loop-which-works-out-really-bad-if-u-have-an-object-oriented-engine system. that''s what i like about it (i know there''s a ''hack'' to get rid of that in glut too, but come on... it''s a ''hack''! glfw offers that w/o any ''hacking''. ).

quote:
glutGameModeString(), glutEnterGameMode(), glutLeaveGameMode()


i know... i did use glut. but the way it works, it just feels like there are two comepletely different things: a window and a full screen mode. i don''t like that. u can''t just go from one to another that easily, etc. and u can''t get a list of avaliable resolutions (u can ''check'' if a game mode string is ''supported''... oh, wow, how convinient), set refesh rate, turn vsync on or off, etc.

quote:
Actually, I''ve tried GLOW and GLUI and found them lacking.
I haven''t got around to glfw, yet. I might at some point.
Who knows? Maybe I''ll switch from GLUT to glfw.


me too. well, at least glow (didn''t try glui). also didn''t like them. do try glfw. at least take a look at the user''s guide and see how well it explains the api.

btw, it supports threads too, unlike any other glxx (put some two letters in place of xx) thing i''ve ever seen. and if u know how to [efficiently] use threads (there''s a good tut explainig it in user''s guide), you''re a pro.

---
shurcool
wwdev

Share this post


Link to post
Share on other sites
quote:
Original post by shurcool
if your game can''t change resoltion when it''s running, then it''s probably a simple game or a demo, not even close to quality/finish-ness of a good commercial game. i''m pretty sure most people would like to change resultions in menus in a game.



There are really two schools of thoughts here. There are
examples of commercial games where you have to change
the settings externally with a config program (e.g. Baldur''s Gate)
and there are games where you can change the settings from
within the game (e.g. Warcraft III). I don''t think either
is more "polished" than the other.

Of course, you also have games where you cannot change
the resolution, period.

quote:

and no, glfw does not have this register-a-function-to-be-called-acting-as-a-game-loop-which-works-out-really-bad-if-u-have-an-object-oriented-engine system. that''s what i like about it (i know there''s a ''hack'' to get rid of that in glut too, but come on... it''s a ''hack''! glfw offers that w/o any ''hacking''. ).



Win32 already works that way.

"WndProc" is the register-a-function-to-be-called-acting-as-a-game-loop-which-works-out-really-bad-if-u-have-an-object-oriented-engine function.

Yet, people have no trouble building OO framework on top
of it. MFC anyone?

So are you saying every Win32 program is a "hack"?

For the record, I''ve successfully built an entire framework
on top of GLUT. GLOW, GLUI, and I guess glfw also work this way.

quote:

i know... i did use glut. but the way it works, it just feels like there are two comepletely different things: a window and a full screen mode. i don''t like that. u can''t just go from one to another that easily, etc.



I don''t know, maybe a simple if-else at startup?


if (FullScreen)
glutEnterGameMode();
else
glutInitWindow();
// end if


I admit that it''s not easy to switch between these two modes
dynamically while the program is running. But I question
why you need to do that in the first place. Like I
said, most normal players pick a resolution, and then
windowed/fullscreen, and stick to it.

quote:

and u can''t get a list of avaliable resolutions (u can ''check'' if a game mode string is ''supported''... oh, wow, how convinient), set refesh rate, turn vsync on or off, etc.



That''s true... but it''s a totally platform-dependent thing
to do. How do you suppose you can do it in a cross-platform
manner? I know how to do it in Win32, but what about Linux
and other Unix? Remember, GLUT is designed to be cross-platform.

Just a recap, I have not tried glfw and I did not ever try to
"bash" glfw. I''m only trying to point out that GLUT is more
useful than many people assume.



Kami no Itte ga ore ni zettai naru!

Share this post


Link to post
Share on other sites
glfw is 100% portable. all function have two versions: one for windows and another for linux (unix, x11, etc. - all that).

and take quake 3 for example: u can change resolution from in-game. there are so many game that do this. and i personally don't like to set up things outside of the game. i like to do it in menus.

ps. did u look at the glfw user's guide? please do...

---
shurcool
wwdev


[edited by - shurcool on August 13, 2002 2:59:07 PM]

Share this post


Link to post
Share on other sites
You can hardly comapre GLUI to most other libaries. Its only meant to be used to give an interface. Its supposed to be used on top of GLUT not instead of it.

Share this post


Link to post
Share on other sites