Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: glBegin/glEnd

  1. #1
    Newbie Newbie
    Join Date
    Jun 2013
    Posts
    2

    glBegin/glEnd

    Code :
                  glBegin(GL_TRIANGLE_STRIP);
    			for(i; i <= degree; i++)
    			{
    				float 
    				sunX=-200/2*cos(i*M_PI/180),
    				sunZ=200/2*sin(i*M_PI/180);
     
    				glVertex3f(0, 0, 0);
    				glVertex3f(sunX, 0, sunZ);
    			}
    			glEnd();
    This code is work. But...
    Code :
    			for(i; i <= degree; i++)
    			{
    				float 
    				sunX=-200/2*cos(i*M_PI/180),
    				sunZ=200/2*sin(i*M_PI/180);
                                    glBegin(GL_TRIANGLE_STRIP);
    				glVertex3f(0, 0, 0);
    				glVertex3f(sunX, 0, sunZ);
                                    glEnd();
    			}
    But this doesn't work. Wtf? Where is logic?

    I need to insert another code into for cycle for text out:
    Code :
        glPushAttrib(GL_LIST_BIT);
        glListBase(1000);
        glCallLists(strlen(text), GL_UNSIGNED_BYTE, text);
        glPopAttrib();
    but i can't to insert it, because beetwen glBegin(GL_TRIANGLE_STRIP) and glEnd() it does not work. And i can't write glBegin(GL_TRIANGLE_STRIP), glEnd() inside for cycle, because it does not work there.

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Dec 2007
    Location
    Hungary
    Posts
    985
    Sure it doesn't, because glEnd finishes your primitive, and you render triangle strips which require at least three vertices to produce a primitive, otherwise it doesn't product anything, and you only passed two.

    When you do glBegin it won't magically catch up from where you left.
    Disclaimer: This is my personal profile. Whatever I write here is my personal opinion and none of my statements or speculations are anyhow related to my employer and as such should not be treated as accurate or valid and in no case should those be considered to represent the opinions of my employer.
    Technical Blog: http://www.rastergrid.com/blog/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •