Sign in to follow this  

urgent help 3D exploration

This topic is 4858 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
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
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
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
I sent you an e-mail with the updated code attached.
You didn't load any textures that't why they were not showing up.
I've included a quick-'n-dirty BMP loader that handles 8, 24 and 32 bpp bitmaps. The loader will also scale textures if their dimensions are not powers of two.

The cactus model, however, seems to be broken. There are some cull-mode related issues as well as misaligned triangles. This is an issue with the exporter, in case you didn't modify the original output.

Textures will not be exported (though tex.-coordinates are generated) so there will only be one texture per exported model. Consider writing a loader for binary or ASCII formats since this allows you to also load and assign different textures for different parts of your models. The Deep Exploration exporter might not support that (I don't know, I'm not using it and my remarks are based on the source code you gave me).

Cheers,
Pat.

Share this post


Link to post
Share on other sites

This topic is 4858 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this