Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Pixels don't appear with glDrawArrays



I can't see anything wrong with the structure of my program, but the pixels don't appear with glDrawArrays(they do when I draw with glVertex4f directly from the struct). My initGL method is called from initWithFrame...


[...]<x-tad-smaller>
</x-tad-smaller><x-tad-smaller> glVertexPointer(</x-tad-smaller><x-tad-smaller>4</x-tad-smaller><x-tad-smaller>,GL_FLOAT, </x-tad-smaller><x-tad-smaller>sizeof</x-tad-smaller><x-tad-smaller>(GLfloat), mVertex);
glColorPointer(</x-tad-smaller><x-tad-smaller>4</x-tad-smaller><x-tad-smaller>,GL_FLOAT, </x-tad-smaller><x-tad-smaller>sizeof</x-tad-smaller><x-tad-smaller>(GLfloat), mColor);
[...]


my drawRect: looks like:

- (</x-tad-smaller><x-tad-smaller>void</x-tad-smaller><x-tad-smaller>)drawRect:(NSRect)rect {
</x-tad-smaller><x-tad-smaller>int</x-tad-smaller><x-tad-smaller> i;



glClearColor( </x-tad-smaller><x-tad-smaller>0.0</x-tad-smaller><x-tad-smaller>f, </x-tad-smaller><x-tad-smaller>0.0</x-tad-smaller><x-tad-smaller>f, </x-tad-smaller><x-tad-smaller>0.0</x-tad-smaller><x-tad-smaller>f, </x-tad-smaller><x-tad-smaller>0.0</x-tad-smaller><x-tad-smaller>f );
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) ;

srandom((</x-tad-smaller><x-tad-smaller>unsigned</x-tad-smaller><x-tad-smaller> </x-tad-smaller><x-tad-smaller>int</x-tad-smaller><x-tad-smaller>) time(</x-tad-smaller><x-tad-smaller>NULL</x-tad-smaller><x-tad-smaller>));

DrawAxes(</x-tad-smaller><x-tad-smaller>50.0</x-tad-smaller><x-tad-smaller>);

[</x-tad-smaller><x-tad-smaller>self</x-tad-smaller><x-tad-smaller> drawTaoVertices];
glEnd() ;




</x-tad-smaller><x-tad-smaller>//glFlush() ; </x-tad-smaller><x-tad-smaller>


[[</x-tad-smaller><x-tad-smaller>self</x-tad-smaller><x-tad-smaller> openGLContext] flushBuffer];
}



finally, where the vertices get drawn, -drawTaoVertices
[...]
glEnableClientState(GL_COLOR_ARRAY);
glEnableClientState(GL_VERTEX_ARRAY);


glDrawArrays(GL_LINE_STRIP,</x-tad-smaller><x-tad-smaller>self</x-tad-smaller><x-tad-smaller> vertexCount]); // [self vertexCount] returns '257'


glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
[...]



when the vertex arrays are originally created:

- (</x-tad-smaller><x-tad-smaller>void</x-tad-smaller><x-tad-smaller>)setVertices:(taoVertexStruct *)inStruct
{
</x-tad-smaller><x-tad-smaller>int</x-tad-smaller><x-tad-smaller> i;

mVertices = inStruct;




free(mVertex);
free(mColor);


mVertex = (GLfloat *)malloc(</x-tad-smaller><x-tad-smaller>self</x-tad-smaller><x-tad-smaller> vertexCount]*</x-tad-smaller><x-tad-smaller>sizeof</x-tad-smaller><x-tad-smaller>(GLfloat));
mColor = (GLfloat *)malloc(</x-tad-smaller><x-tad-smaller>self</x-tad-smaller><x-tad-smaller> vertexCount]*</x-tad-smaller><x-tad-smaller>sizeof</x-tad-smaller><x-tad-smaller>(GLfloat));

</x-tad-smaller><x-tad-smaller>for</x-tad-smaller><x-tad-smaller>(i = </x-tad-smaller><x-tad-smaller>0</x-tad-smaller><x-tad-smaller>; i < [</x-tad-smaller><x-tad-smaller>self</x-tad-smaller><x-tad-smaller> vertexCount]; i++)
{

mVertex[i * </x-tad-smaller><x-tad-smaller>4</x-tad-smaller><x-tad-smaller>] = mVertices[i].mX;
mVertex[i * </x-tad-smaller><x-tad-smaller>4</x-tad-smaller><x-tad-smaller> + </x-tad-smaller><x-tad-smaller>1</x-tad-smaller><x-tad-smaller>] = mVertices[i].mY;
mVertex[i * </x-tad-smaller><x-tad-smaller>4</x-tad-smaller><x-tad-smaller> + </x-tad-smaller><x-tad-smaller>2</x-tad-smaller><x-tad-smaller>] = mVertices[i].mZ;
mVertex[i * </x-tad-smaller><x-tad-smaller>4</x-tad-smaller><x-tad-smaller> + </x-tad-smaller><x-tad-smaller>3</x-tad-smaller><x-tad-smaller>] = mVertices[i].mW;


mColor[i * </x-tad-smaller><x-tad-smaller>4</x-tad-smaller><x-tad-smaller>] = mVertices[i].mRed;
mColor[i * </x-tad-smaller><x-tad-smaller>4</x-tad-smaller><x-tad-smaller> + </x-tad-smaller><x-tad-smaller>1</x-tad-smaller><x-tad-smaller>] = mVertices[i].mGreen;
mColor[i * </x-tad-smaller><x-tad-smaller>4</x-tad-smaller><x-tad-smaller> + </x-tad-smaller><x-tad-smaller>2</x-tad-smaller><x-tad-smaller>] = mVertices[i].mBlue;
mColor[i * </x-tad-smaller><x-tad-smaller>4</x-tad-smaller><x-tad-smaller> + </x-tad-smaller><x-tad-smaller>3</x-tad-smaller><x-tad-smaller>] = mVertices[i].mAlpha;


}
[...]



hopefully there are suggestions as to what I'm doing wrong...

regards,
Michael





















</x-tad-smaller>
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Mac-opengl mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/mac-opengl/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.