Results 1 to 2 of 2

Thread: How to create 2 objects? - v simple question

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2010
    Posts
    5

    How to create 2 objects? - v simple question

    Hello,

    I'm trying to learn how to use Open GL for an iPhone app. Just getting my head around the basics trying a few trial runs to get something going, and I'm stumped by a very simple problem!

    using iOs 3.2 / Open Gl 1.1

    In the apple provided OpenGl XCode Framework, they implement a simple program that draws a quad bouncing up and down according to sin(x)/2. As an experiment I'm trying to make 2 quads, but I don't know how to add the second???

    What I've tried:
    There's a class called ES1Renderer that initializes a 'context' to start drawing in, I've tried creating a new instance of ES12Renderer, and passing new parameters to the drawing method (making it bounce at sin(x)/3 for example)but that makes the whole screen blank.

    I then tried making a second 'context' a context is:
    [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1]
    and again this made the screen go blank.

    I've also tried making a new set of squareVertices:

    Code :
    GLfloat squareVertices[] = {
            -0.5f,  -0.33f,
             0.5f,  -0.33f,
            -0.5f,   0.33f,
             0.5f,   0.33f,
        };
     
    GLfloat squareVertices2[] = {
            -0.7f,  -0.33f,
    	0.7f,  -0.33f,
            -0.7f,   0.33f,
    	0.7f,   0.33f,
        };
     
        glVertexPointer(2, GL_FLOAT, 0, squareVertices);
        glEnableClientState(GL_VERTEX_ARRAY);
        glColorPointer(4, GL_UNSIGNED_BYTE, 0, squareColors);
        glEnableClientState(GL_COLOR_ARRAY);
     
    	glVertexPointer(2, GL_FLOAT, 0, squareVertices2);
        glEnableClientState(GL_VERTEX_ARRAY);
        glColorPointer(4, GL_UNSIGNED_BYTE, 0, squareColors);
        glEnableClientState(GL_COLOR_ARRAY);

    but depending which way round I write this, I get one quad or the other, but not both.

    This must be simple, but at which point do I start drawing 2 separate shapes?

  2. #2
    Junior Member Newbie
    Join Date
    Dec 2010
    Posts
    5

    Re: How to create 2 objects? - v simple question

    sorry about the double post, I got a message saying the database encountered a problem, so I clicked back, and posted the same message again.

Similar Threads

  1. how do u create lighting/normals for glut objects
    By jenny88 in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 05-25-2011, 12:16 AM
  2. New way to create objects
    By V-man in forum OpenGL: General
    Replies: 15
    Last Post: 07-03-2009, 12:49 AM
  3. Create objects and keep them based on the data from outside?
    By orchis in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 11-23-2005, 11:53 PM
  4. how to create a simple animation game..(beginer)
    By c4blue in forum OpenGL: User Software
    Replies: 0
    Last Post: 09-25-2005, 07:32 PM
  5. Besway to create a ground under some objects
    By Andrew Davey in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 05-07-2004, 02:44 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