Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: chckn crossin d road

  1. #1
    Junior Member Newbie
    Join Date
    Apr 2011
    Posts
    22

    chckn crossin d road

    hi frenz...m a beginner wid opengl doin my projct...game'"chckn crossin d road"

    1.hav writtn code for road,cars,chckn n worm
    2.bt unable to bring thm on same screen



    pls help me((((

  2. #2
    Junior Member Newbie
    Join Date
    Apr 2011
    Posts
    22

    Re: chckn crossin d road

    here s my code for road



    #include<stdio.h>
    #include<GL/glut.h>
    #include<windows.h>
    #include<fstream.h>
    #include<iostream.h>
    #include<stdlib.h>




    void Init()
    {
    glClearColor(0.0,0.8,0.0,0.0);
    gluOrtho2D(0.0,50.0,0.0,50.0);
    glEnable(GL_BLEND);
    }


    void drawPL(char * f1)
    {
    fstream inStream;
    inStream.open(f1,ios::in);
    if(inStream.fail())
    return;
    glClear(GL_COLOR_BUFFER_BIT);
    GLfloat numpolys,numLines,x,y;
    inStream>>numpolys;
    for(int j=0;j<numpolys;j++)
    {
    inStream>>numLines;
    glColor3f(1.0,0.5,0.0);
    glBegin(GL_LINE_STRIP);
    for(int i=0;i<numLines;i++)
    {
    inStream>>x>>y;
    glVertex2f(x,y);
    }
    glEnd();
    }
    glFlush();
    inStream.close();
    }




    void display(void)
    {
    glClear(GL_COLOR_BUFFER_BIT);
    glLineWidth(4);
    drawPL("f2.dat");
    glPointSize(6.0);
    glBegin(GL_POINTS);
    glColor3f(1.0,1.0,1.0);
    glVertex2f(32.5,45);
    glVertex2f(34,45);
    glEnd();
    glPointSize(4.0);
    glBegin(GL_POINTS);
    glColor3f(0.0,0.0,0.0);
    glVertex2f(32.5,45);
    glVertex2f(34,45);
    glEnd();


    glBegin(GL_POLYGON);


    glColor3f(0.5,0.5,0.5);

    glVertex2i(0,12);
    glVertex2i(50,12);
    glVertex2i(50,3;
    glVertex2i(0,3;
    glEnd();

    glBegin(GL_POLYGON);
    glColor3f(1.0,1.0,0.0);
    glVertex2i(0,25);
    glVertex2i(50,25);
    glVertex2i(50,24);
    glVertex2i(0,24);
    glEnd();



    glColor3f (1.0, 1.0, 1.0);
    glEnable (GL_LINE_STIPPLE);
    glLineWidth (6.0);
    glLineStipple (4, 0x00FF); /* dotted */

    glBegin(GL_LINES);
    glColor3f(1.0,1.0,1.0);
    glVertex2f (0.0,18.5);
    glVertex2f (50.0,18.5);
    glVertex2f(0.0,31.5);
    glVertex2f(50.0,31.5);
    glEnd();
    glFlush();
    glutSwapBuffers();
    }




    void main(int argc,char **argv)
    {
    glutInit(&amp;argc,argv);
    glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
    glutInitWindowSize(500,500);
    glutInitWindowPosition(100,100);
    glutCreateWindow("CRAZY CHICKEN");
    glutDisplayFunc(display);
    Init();
    glutMainLoop();
    }

  3. #3
    Senior Member OpenGL Pro BionicBytes's Avatar
    Join Date
    Mar 2009
    Location
    UK, London
    Posts
    1,161

    Re: chckn crossin d road

    Rather than just posting "please help" or "please do my home work for me", why not actually take the time to describe what is not working for you, and try and pin down where in your code you think the problem lies.
    Thinking for yourself in this way often helps you debug your code and you don't actually need to post any questions.

    As it stands we can't or won't help because your question is to general.

  4. #4
    Junior Member Newbie
    Join Date
    Apr 2011
    Posts
    22

    Re: chckn crossin d road

    f3.dat

    7
    5
    2 18
    9 18
    9 21
    2 21
    2 18

    5
    3 19
    8 19
    8 20
    3 20
    3 19

    2
    2 18
    3 19


    2
    9 18
    8 19

    2
    9 21
    8 20

    2
    2 21
    3 20

    4
    9 18
    10 19
    10 20
    9 21

  5. #5
    Junior Member Newbie
    Join Date
    Apr 2011
    Posts
    22

    Re: chckn crossin d road

    d problm s.... file f3.dat has points for a car shape....it works wen calld in a seperate progrm bt its nt being displayd on d road wen included in my program...

  6. #6
    Senior Member OpenGL Pro BionicBytes's Avatar
    Join Date
    Mar 2009
    Location
    UK, London
    Posts
    1,161

    Re: chckn crossin d road

    ...and you think the contents of f3.dat is going to mean anything to anyone here?

    I think you are making all sorts of assumptions about what system you are devoping on and assume everyone else is using the same.

  7. #7
    Senior Member Regular Contributor
    Join Date
    Oct 2010
    Location
    France
    Posts
    458

    Re: chckn crossin d road

    glUnseparateProgram ("car.exe", "road.exe", "chicken.exe");
    glCompile();
    glRunChickenOnTheRoad();
    glBeCarefulOfTheCarPoorChicken();
    glDestroyBloodyChicken();
    ...

  8. #8
    Junior Member Newbie
    Join Date
    Apr 2011
    Posts
    22

    Re: chckn crossin d road

    m clearly tellin...m unable to display car on d road....

  9. #9
    Junior Member Newbie
    Join Date
    Apr 2011
    Posts
    22

    Re: chckn crossin d road

    OMG!! dat f3.dat file has coordinates of a car....
    m workin wid MSvisualstudioC++......copy f3.dat n execute d main program....u vl knw my problem

  10. #10
    Junior Member Newbie
    Join Date
    Apr 2011
    Posts
    22

    Re: chckn crossin d road

    #include<stdio.h>
    #include<GL/glut.h>
    #include<windows.h>
    #include<fstream.h>
    #include<iostream.h>
    #include<stdlib.h>




    void Init()
    {
    glClearColor(0.5,0.5,0.5,0.0);
    gluOrtho2D(0.0,50.0,0.0,50.0);
    glEnable(GL_BLEND);

    }









    void drawcar(char * f1)
    {
    fstream inStream;
    inStream.open(f1,ios::in);
    if(inStream.fail())
    return;
    glClear(GL_COLOR_BUFFER_BIT);
    GLfloat numpolys,numLines,x,y;
    inStream>>numpolys;
    for(int j=0;j<numpolys;j++)
    {
    inStream>>numLines;
    glColor3f(1.0,0.0,0.0);
    glBegin(GL_LINE_STRIP);
    for(int i=0;i<numLines;i++)
    {
    inStream>>x>>y;
    glVertex2f(x,y);
    }
    glEnd();
    }
    glFlush();
    inStream.close();
    }



    void display(void)
    {
    glClear(GL_COLOR_BUFFER_BIT);
    glLineWidth(4);
    drawcar("f3.dat");
    glColor3f(1.0,1.0,0.0);
    glPointSize(4.0);
    glBegin(GL_POINTS);
    glVertex2f(10,19);
    glVertex2f(10,20);
    glEnd();
    glColor3f(0.0,0.0,0.0);
    glPointSize(8.0);
    glBegin(GL_POINTS);
    glVertex2f(3,1;
    glVertex2f(7,1;
    glVertex2f(3,21);
    glVertex2f(7,21);
    glEnd();
    glFlush();
    }




    void main(int argc,char **argv)
    {
    glutInit(&amp;argc,argv);
    glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
    glutInitWindowSize(1024,76;
    glutInitWindowPosition(0,0);
    glutCreateWindow(" crazy chicken");
    glutDisplayFunc(display);

    Init();
    glutMainLoop();
    }

Page 1 of 2 12 LastLast

Similar Threads

  1. two windows - one way road only ??
    By gummibaer in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 04-14-2011, 05:00 PM
  2. Bumpy Road
    By rp_bohs in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 11-25-2003, 12:04 AM
  3. NV_render_depth_texture - one way road?
    By CWiC in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 10-27-2002, 07:59 AM
  4. road modelling
    By anantshi in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 08-18-2001, 12:16 AM
  5. How do I go about Texturing a Road
    By royster in forum OpenGL: Advanced Coding
    Replies: 0
    Last Post: 06-09-2001, 01:21 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean