Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7835097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T13:28:45+00:00 2026-06-02T13:28:45+00:00

Currently i am working in simple game app using openGLES, draw a line using

  • 0

Currently i am working in simple game app using openGLES, draw a line using GL_Lines mode and working fine, i want to draw a line using GL_TRIANGLE_STRIP, is it possible to draw a line using GL_TRIANGLE_STRIP?

Thanks in Advance

I tried the source code:

  glClearColor(0.65f, 0.65f, 0.65f, 1.0f); //Background color changes, its like Red,Green,Blue,Alpha color. 
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    [self.effect prepareToDraw];


        const GLfloat line[] = 
        {
            0.0f, 0.5f,
            0.0f, -1.5f,
           0.0f,-1.5f,
        };

        // Create buffer object array
        GLuint bufferObjectNameArray;

        // Have OpenGL generate a buffer name and store the buffer object array 
        glGenBuffers(1, &bufferObjectNameArray);

        // Bind the buffer object array to the GL_ARRAY_BUFFER target buffer  
        glBindBuffer(GL_ARRAY_BUFFER, bufferObjectNameArray); 

        // Send the line data over to the target buffer
        glBufferData(
                     GL_ARRAY_BUFFER,   // the target buffer 
                     sizeof(line),      // the number of bytes to put into the buffer
                     line,              // a pointer to the data being copied 
                     GL_STATIC_DRAW);   // the usage pattern of the data 

        // Enable vertex data to be fed down the graphics pipeline to be drawn
        glEnableVertexAttribArray(GLKVertexAttribPosition); 

        // Specify how the GPU looks up the data 
        glVertexAttribPointer(
                              GLKVertexAttribPosition, // the currently bound buffer holds the data 
                              2,                       // number of coordinates per vertex 
                              GL_FLOAT,                // the data type of each component 
                              GL_FALSE,                // can the data be scaled 
                              2*4,                    // how many bytes per vertex (2 floats per vertex)
                              NULL);                   // offset to the first coordinate, in this case 0 
        glDrawArrays(GL_TRIANGLE_STRIP, 0, 3); 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T13:28:46+00:00Added an answer on June 2, 2026 at 1:28 pm

    You need to duplicate each vertex of the line and offset it:

    const GLfloat line[] = 
        {
            -1.0f, 0.5f, 1.0f, 0.5f,//0.0f, 0.5f,
            -1.0f, 0.5f, 1.0f, 1.5f,//0.0f, -1.5f,
        };
    ...
    glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); 
    

    It’s simply for line with predefined line direction. Otherwise you need to calculate direction of offset as perpendicular to direction of line.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently working on a simple web application through Google App engine using
I'm new to android game development. I currently working on a simple android app
I am currently working on a simple Silverlight app that will allow people to
I'm currently working on a reasonably simple MVC app which allows the user to
I'm currently working on my first iPhone game with openGLES- it is amazing! Loving
I'm currently working on this really simple text based game and to play again,
I'm currently working on a simple game in Java with several different modes. I've
I'm currently working on a simple game that is drawn on a form by
I'm currently working on a simple 2d game library for self education only. Until
I am working on a simple game in Java, everything goes fine, except I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.