Sign in to follow this  

Unity model not showing in scene

This topic is 2135 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

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
[CODE]
#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);
}
[/CODE]

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

Thankyou :)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
I recommend this [url="http://www.arcsynthesis.org/gltut/"]free online book[/url] to anyone starting in graphics programming, especially with OpenGL.

Share this post


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