Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Okay the problem was that I was only drawing 2 vertices and <code>GL_QUAD_STRIP</code> requires 4. The following code now has both vertices set up properly and texture working</p> <pre><code> double x, y, z, dTheta=180/divisions, dLon=360/divisions, degToRad=3.141592665885/180 ; for(double lat =0; lat &lt;=180; lat+=dTheta) { glBegin( GL_QUAD_STRIP ) ; for(double lon =0 ; lon &lt;=360 ; lon+=dLon) { //Vertex 1 x = r*cos(lon * degToRad) * sin(lat * degToRad) ; y = r*sin(lon * degToRad) * sin(lat * degToRad) ; z = r*cos(lat * degToRad) ; glNormal3d( x, y, z) ; glTexCoord2d(lon/360-0.25, lat/180); glVertex3d( x, y, z ) ; //Vetex 2 x = r*cos(lon * degToRad) * sin( (lat + dTheta)* degToRad) ; y = r*sin(lon * degToRad) * sin((lat + dTheta) * degToRad) ; z = r*cos( (lat + dTheta) * degToRad ) ; glNormal3d( x, y, z ) ; glTexCoord2d(lon/360-0.25, (lat + dTheta-1)/(180)); glVertex3d( x, y, z ) ; //Vertex 3 x = r*cos((lon + dLon) * degToRad) * sin((lat) * degToRad) ; y = r*sin((lon + dLon) * degToRad) * sin((lat) * degToRad) ; z = r*cos((lat) * degToRad ) ; glNormal3d( x, y, z ) ; glTexCoord2d((lon + dLon)/(360)-0.25 ,(lat)/180); glVertex3d( x, y, z ) ; //Vertex 4 x = r*cos((lon + dLon) * degToRad) * sin((lat + dTheta)* degToRad) ; y = r*sin((lon + dLon)* degToRad) * sin((lat + dTheta)* degToRad) ; z = r*cos((lat + dTheta)* degToRad ) ; glNormal3d( x, y, z ) ; glTexCoord2d((lon + dLon)/360-0.25, (lat + dTheta)/(180)); glVertex3d( x, y, z ) ; } glEnd() ; } </code></pre> <p>Hope people who get stuck may find this useful.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload