Results 1 to 4 of 4

Thread: Creating 2 quads? - v simple question

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

    Creating 2 quads? - 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: Creating 2 quads? - 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.

  3. #3
    Senior Member Regular Contributor
    Join Date
    Mar 2009
    Posts
    153

    Re: Creating 2 quads? - v simple question

    Code :
    glVertexPointer(2, GL_FLOAT, 0, squareVertices);
    glEnableClientState(GL_VERTEX_ARRAY);
    glColorPointer(4, GL_UNSIGNED_BYTE, 0, squareColors);
    glEnableClientState(GL_COLOR_ARRAY);
     
    glDrawArrays(...);
     
    glVertexPointer(2, GL_FLOAT, 0, squareVertices2);
    glEnableClientState(GL_VERTEX_ARRAY);
    glColorPointer(4, GL_UNSIGNED_BYTE, 0, squareColors);
    glEnableClientState(GL_COLOR_ARRAY);
     
    glDrawArrays(...);

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

    Re: Creating 2 quads? - v simple question

    Thank you! For some reason I was expecting the drawArrays method to only work for one context, getting there!

Similar Threads

  1. memory leak? while creating simple textures
    By outburst in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 09-18-2013, 01:45 PM
  2. Draw simple quads with least data
    By myk45 in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 06-07-2013, 10:02 AM
  3. Creating a simple 3D world with Floor Co Ordinates
    By Nikhil Rao in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 04-23-2012, 12:09 PM
  4. Creating a simple menu in OpenGL GLUT
    By uberweiss in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 04-18-2010, 07:18 AM
  5. Creating A simple Pyramid
    By lynear in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 05-26-2002, 10:12 PM

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