Jump to content

  • Log In with Google      Sign In   
  • Create Account


model not showing in scene


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Adam West   Members   -  Reputation: 219

Like
0Likes
Like

Posted 13 March 2012 - 04:31 AM

Hi again,
Firstly, Thank you soo much community for helping me with my last dilemma.
all bugs from that are fixed now, the only problem is when i call the model to be rendered it doesn't show in the viewport.
can anyone shed any light on this?

heres the main.cpp
#include "main.h"
#include "3dsloader.h"


void lighting();
void initRendering();
void drawScene();
void mainLoop();

Object* testcube;

int main(int argc, char **argv)
{
bool running = true;

InitializeWindow();

testcube = new Object("apex.3ds");

initRendering();

testcube->CreateVBO();

mainLoop();

return 0;
}
void initRendering()
{
glClearColor(0.0, 0.0, 0.0, 0.0);
glShadeModel(GL_SMOOTH);
// Enable lighting and set the position of the light
glEnable(GL_LIGHT0);
glEnable(GL_LIGHTING);
GLfloat pos[] = { 0.0, 4.0, 4.0 };
glLightfv(GL_LIGHT0, GL_POSITION, pos);

}

void mainLoop(void)
{
// the time of the previous frame
double old_time = glfwGetTime();
// this just loops as long as the program runs
while(1)
{
  // escape to quit, arrow keys to rotate view
  if (glfwGetKey(GLFW_KEY_ESC) == GLFW_PRESS)
   break;
 
  // draw the figure
  drawScene();
 
  // swap back and front buffers
  glfwSwapBuffers();
}
}
void drawScene()
{
//clear info from last draw
glClear(GL_COLOR_BUFFER_BIT);
glTranslatef(0.0f, 0.0f, -5.0f); // translate camera
// ADD SCENE OBJECTS TO RENDER HERE
testcube->Draw();
glfwSwapBuffers();
};
void shutdown()
{
glfwTerminate();
delete testcube;
exit(1);
}

all the other headers arent necessary but if you think they are, they can be found here->
http://www.gamedev.net/topic/621666-debug-assertion-failed-on-game-project/

Thankyou :)

Attached Thumbnails

  • blank.png


Sponsor:

#2 Hodgman   Moderators   -  Reputation: 29354

Like
0Likes
Like

Posted 13 March 2012 - 04:41 AM

I'm going to assume that you've set up the projection matrix elsewhere in your code, and then switched back into GL_MODELVIEW mode...
Every frame, you call glTranslatef, which concatenates a translation of z-5 units onto the model-view matrix. Since you don't call glLoadIdentity each frame, then after 100 frames, your camera has been translated by 500 units in the z axis, etc, until it flies off into infinity.

#3 meeshoo   Members   -  Reputation: 508

Like
0Likes
Like

Posted 13 March 2012 - 05:41 AM

I recommend this free online book to anyone starting in graphics programming, especially with OpenGL.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS