Jump to content
  • Advertisement
Sign in to follow this  
skockara

urgent help 3D exploration

This topic is 5137 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 need help. I'm stuck and have limited time. I export my 3d scene as Display List Type. Here is my new written header file to acces Gen3DObjectList method from main.cpp. It is Visual C++ 6.0 Console project. I'm calling display list. There is no error given by compiler. But it shows nothing on the screen. How can I run openGL code exported by 3d Exploration as Display List type? /*common.h*/ #ifndef _COMMON_H #define _COMMON_H extern GLint lid; GLint Gen3DObjectList(void); #endif /*common.h*/ /*main.cpp*/ #include <GL/glut.h> #include <math.h> #include "dene.h" const double pi2 = 6.28318530718; void winInit(){ gluOrtho2D(0.0, pi2, 0.0, pi2); glCallList(lid); }; void display(void){ glColor3f(0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); glCallList(lid); }; int main(int argc, char **argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA); glutInitWindowPosition(5,5); glutInitWindowSize(300,300); glutCreateWindow("Coordinate Box"); winInit(); glutDisplayFunc(display); glutMainLoop(); return 0; } /*main.cpp*/

Share this post


Link to post
Share on other sites
Advertisement
Unless I overlooked something, you never actually create the display list by calling Gen3DObjectList() in our initialization function...

So you winInit() needs to look like this:

void winInit(){

glClearColor(0, 0, 0, 1); // this sets the glClear color
gluOrtho2D(0.0, pi2, 0.0, pi2);
// glCallList(lid); <-- won't work: lid is not initialized!
lid = Gen3DObjectList();
};





[edit]
I'd also suggest to clean the depth buffer, too:

void display(void){

//glColor3f(0.0, 0.0, 0.0); <-- see winInit()
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

glCallList(lid);

glFlush(); // make sure everything gets executed
};




Also consider using double-buffering.
[/edit]

Share this post


Link to post
Share on other sites
Thanks man, it worked.
But now, I have another problem. My 3D object's texture doesn't look good. I have 2 bmp files as texture, but one of them is not seen.

Share this post


Link to post
Share on other sites
Dimensions are 256x188. Actually I export 3ds file to opengl using deep exploration. The object is vase with cover. Vase has 2 bmp files. But cover seems white. When I export as App it looks like exactly same as in deep exploration.

Share this post


Link to post
Share on other sites
The generated app code will use gl commands to scale the bitmap.
Scale the textures to 256x256 for example (using an imaging program).

Share this post


Link to post
Share on other sites
I tried another application without bmp textures. Windows Application is working good with colors. But console application is still white. I got display function from windows application file and kinda changed it. Is there any way to do same thing for console application as in windows application.

Here is my main function:
/* dene.h*/
extern GLint Gen3DObjectList(void);
/* dene.h*/

/*main.cpp*/

#include <GL/glut.h>
#include <math.h>
#include "dene.h"

const double pi2 = 6.28318530718;
GLint lid;

void winInit(){

glClearColor(0, 0, 0, 1); // this sets the glClear color
//gluOrtho2D(0.0, pi2, 0.0, pi2);
// glCallList(lid); <-- won't work: lid is not initialized!
lid = Gen3DObjectList();
};

GLdouble gldAspect;

void display(void){
//glColor3f(0.0, 0.0, 0.0); <-- see winInit()
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
/*glTranslatef(0.0,0.0,0.0);
glCallList(lid);

glFlush();*/ // make sure everything gets executed

int sizex=300;
int sizey=300;

gldAspect = (GLdouble) sizex / (GLdouble) sizey;

glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gluPerspective (30.0, // Field-of-view angle
gldAspect, // Aspect ratio of viewing volume
1.0, // Distance to near clipping plane
10.0); // Distance to far clipping plane

glViewport (0, 0, sizex, sizey);
//
// Clear the color and depth buffers.
//
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

//
// Define the modelview transformation.
//
glMatrixMode (GL_MODELVIEW);
glLoadIdentity ();
glTranslatef (0.0f, 0.0f, -8.0f);
/*glRotatef (30.0f, 1.0f, 0.0f, 0.0f);
glRotatef ((GLfloat) nAngle, 0.0f, 1.0f, 0.0f);
glRotatef ((GLfloat) nAngle2, 1.0f, 0.0f, 0.0f);
glScalef (nSize+2.5f,nSize+2.5f,nSize+2.5f); */

int mcount=0;
int mindex=0;

glCallList(lid);
//
// Swap the buffers.
//
glFlush();
//SwapBuffers (hdc);

};


int main(int argc, char **argv)

{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA);
glutInitWindowPosition(5,5);
glutInitWindowSize(300,300);
glutCreateWindow("Coordinate Box");
winInit();
glutDisplayFunc(display);
glutMainLoop();
return 0;

}
/*main.cpp*/

Share this post


Link to post
Share on other sites
I'd suggest you read some OGL/GLUT tutorials first.
You made some mistakes in your display function (e.g. clearing buffers more than once).

I also noticed you tried double-buffering. With GLUT you need to specify GLUT_DOUBLE (or sth. like that, didn't work with GLUT for some years) in glutInitDisplayMode() and call glutSwapBuffers() as
last function in display(). You won't need glFlush() in this case.

I don't know what you are trying to display, but I think ortho mode isn't what you're aiming for. Use gluPerspective() instead.

Share this post


Link to post
Share on other sites
Hi Patric, I've sent my code to you. I've read glut document, but still my object seems white. If you find any mistake in code please let me know. If you correct it, it's better.
Thanks
Email's subject is "Deep Exploration Error and my code"

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!