Mailing Lists: Apple Mailing Lists

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

artifacts [was OpenGL & Print, Save, Copy]



Hello all,
Using the example code at <http://homepage.mac.com/gstahl/FileSharing6.html> I copied and pasted the methods from the BasicOpenGLView subclass to perform these functions(---- Image Data Creation ---- and ---- Printing and copying ---- methods) into my own NSOpenGLView subclass. I had to override the FirstResponder methods and perform a couple of connections in IB from the -saveDocument and -print menu items to their corresponding FirstResponder methods.


However whenever I copy, print or save, I get a horizontal white line artifact ended with a pink pixel in the new bitmap. I made double-sure that I wasn't writing the artifacts into the view and I'm certain they appear as a result of the -copy, -print or -saveDocument methods. I'm using 10.3.9 and XCode 1.5.


See the artifacts here:

http://siddha.ca/myimages/artifacts.png

The line length is proportional to the width of the view(1/4).



I also used the same +BasicPixelFormat method and the -initWithFrame are identical. However the resizeGL, prepareOpenGL methods are different (it's only two-dimensional):

- (void) resizeGL
{
NSRect rectView = [self bounds];
// ensure camera knows size changed
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(rectView.origin.x,rectView.size.width,rectView.origin.y, rectView.size.height);
glMatrixMode(GL_MODELVIEW);
glViewport((GLfloat)rectView.origin.x, (GLfloat)rectView.origin.y,(GLfloat)rectView.size.width, (GLfloat)rectView.size.height);
}


- (void) prepareOpenGL
{
long swapInt = 1;
[[self openGLContext] setValues:&swapInt forParameter:NSOpenGLCPSwapInterval]; // set to vbl sync
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);


}

here is my drawRect: too

- (void)drawRect:(NSRect)rect {
int i;
if (NO == fGLInit)
[self prepareOpenGL];
fGLInit = YES;
// setup viewport and prespective
[self resizeGL]; // forces projection matrix update (does test for size changes)
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) ;
[self drawTaoVertices];
[[self openGLContext] flushBuffer];
}


I guess I'd better include how I draw the vertices:

- (void)drawTaoVertices
{
	glVertexPointer(2,GL_FLOAT, 2*sizeof(GLfloat), mVertex);
	glColorPointer(4,GL_FLOAT, 4*sizeof(GLfloat), mColor);

	glEnableClientState(GL_COLOR_ARRAY);
	glEnableClientState(GL_VERTEX_ARRAY);
	
	glDrawArrays(GL_POINTS,0,[self vertexCount]);
		
	glDisableClientState(GL_COLOR_ARRAY);
	glDisableClientState(GL_VERTEX_ARRAY);
}

Not sure where to go from here. You deserve a medal if you got to this line :)

best regards,
Michael

On 30-Jan-05, at 8:22 PM, email@hidden wrote:

In a message dated 1/30/05 6:01:38 PM, email@hidden writes:

THANKS a bunch! Save didn't work for me [out of the box :>)] but perhaps I can get it to work later.

Sorry, I launched your app in my web surfing user and tried to save in a spot that had no permissions. Save DOES work. All is well!


 I have changed the project to XCode 1.5 and am off & running.

 Thanks again!

Bob _______________________________________________

_______________________________________________ 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.