in Education by
I am trying to look at a cone in 3D, for which I used gluLookAt. I draw a cone in the middle of the screen at pos (250, 250, 0) and then look at it with a camera above the origin looking at the middle. The output is a circle, contrary to the cone I expected to see. It seems the camera is instead at point (250,250,0) also, but it is specified in gluLookAt it should be above the origin. What am I overlooking here? void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(250, 250, 0); glutSolidCone(30, 10, 20, 20); glTranslatef(-250, -250, 0); gluLookAt(0, 0, 100, 250, 250, 0, 0, 0, 1); glFlush(); glutSwapBuffers(); } int main(int argc, char **argv) { float x, y; glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); glutInitWindowSize(500, 500); glutCreateWindow("Cone"); glutDisplayFunc(display); glutReshapeFunc(reshape); glutKeyboardFunc(keyboard); glutMotionFunc(drag); glutMouseFunc(click); glutSpecialFunc(catchKey); glEnable(GL_DEPTH_TEST); glutMainLoop(); //calls do_one_simulation_step, keyboard, display, drag, reshape return 0; } JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
A few issues: Set your camera matrix, then draw. The way you have it now your gluLookAt() does nothing useful. The default identity projection matrix probably isn't what you want. Set a real perspective transform using gluPerspective() or glFrustum(). Your gluLookAt() eye/center coords were a bit wonky; I've put the eye at (50, 50, 50) and set it to look at the origin. All together: #include #include void display( void ) { glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glMatrixMode( GL_PROJECTION ); glLoadIdentity(); double w = glutGet( GLUT_WINDOW_WIDTH ); double h = glutGet( GLUT_WINDOW_HEIGHT ); gluPerspective( 60.0, w / h, 1.0, 1000.0 ); glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); gluLookAt( 50, 50, 50, 0, 0, 0, 0, 0, 1 ); glutWireCone( 10, 30, 20, 20 ); glutSwapBuffers(); } int main( int argc, char **argv ) { glutInit( &argc, argv ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); glutInitWindowSize( 500, 500 ); glutCreateWindow( "Cone" ); glutDisplayFunc( display ); glEnable( GL_DEPTH_TEST ); glutMainLoop(); return 0; }

Related questions

0 votes
    I am trying to look at a cone in 3D, for which I used gluLookAt. I draw a cone in the middle ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 13, 2022 in Education by JackTerrance
0 votes
    I am working on a use-case of removing duplicate records from incoming structured data (in the form of ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 23, 2022 in Education by JackTerrance
0 votes
    I have a model with two foreign keys to create many to many relationship - I am not using many to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 27, 2022 in Education by JackTerrance
0 votes
    I have a model with two foreign keys to create many to many relationship - I am not using many to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 26, 2022 in Education by JackTerrance
0 votes
    For a function given by F = 4x i + 7y j +z k, the divergence theorem evaluates to ... theory proposed by,electromagnetic theory engineering physics,electromagnetic theory nptel...
asked Nov 11, 2021 in Education by JackTerrance
0 votes
    Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 1, 2022 in Education by JackTerrance
0 votes
    I am trying to inflate one of my fragments. However, the fragment does not show up in the autosuggest ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 19, 2022 in Education by JackTerrance
0 votes
    I have deployed a Django project on Ubuntu 16.04 with Nginx and Gunicorn. I have gotten everything, ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 23, 2022 in Education by JackTerrance
0 votes
    Hi I'm having some issues showing lists in my embed correctly. I'm trying to get my roles to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 14, 2022 in Education by JackTerrance
0 votes
    I am trying to implement the Hateoas using spring boot. In my UserController class i have used the below ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 12, 2022 in Education by JackTerrance
0 votes
    Every now and then, variables just stop showing up in the Workspace pane. who and whos show that there ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 21, 2022 in Education by JackTerrance
0 votes
    I have the following codes in my android application: main.xml : fragmenta.xml : FragmentA.java : package ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 12, 2022 in Education by JackTerrance
0 votes
    In my XSLT stylesheet I extract the value of the current month using a month-from-dateTime like this . ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 17, 2022 in Education by JackTerrance
0 votes
    One hundred identical coins, each with probability `p ,` of showing up heads are tossed once. If `0 A. `(1)/(2)` B ... D. `(51)/(101)` Select the correct answer from above options...
asked Nov 16, 2021 in Education by JackTerrance
...