|
Render in Image flippedHi, Still working on my plugin, I have a trouble that I remeber I had once in another situation : when I put the consumer patch in a Render In Image, it is automatically flipped vertically. The patch is rendering vertices in OpenGL like this (very very ugly code, full of mistakes...) : - (void) renderGLScene:(CGLContextObj)cgl_ctx withWorld:(BLWorld*)world andDrawings:(id)drawings backgroundColor:(CGColorRef)color { glPushAttrib(GL_COLOR_BUFFER_BIT | GL_TRANSFORM_BIT | GL_VIEWPORT_BIT); GLfloat lWidth[2]; glGetFloatv(GL_LINE_WIDTH_RANGE, lWidth); { const CGFloat* colorComponents; colorComponents = CGColorGetComponents(color); // Antialias // -> le permettre dans le plug-in lui-même glEnable (GL_LINE_SMOOTH); // Blend mode -> permettre de choisir glEnable(GL_BLEND); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glClearColor(colorComponents[0], colorComponents[1], colorComponents[2], colorComponents[3]); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glViewport(0, 0, [world width], [world height]); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); int ptm = [world ptm]; double aspect = [world aspectRatio]; glOrtho(-ptm/2. * aspect, ptm/2. * aspect, -ptm/2., ptm/2., -1, 1); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); } [self drawBodies:cgl_ctx inWorld:world]; if ([drawings isKindOfClass:[NSArray class]]) { if ([drawings count] == 6) { [self renderDrawingIn:cgl_ctx inWorld:world withDef:drawings]; } } glMatrixMode(GL_MODELVIEW); glPopMatrix(); glMatrixMode(GL_PROJECTION); glPopMatrix(); glPopAttrib(); glDisable(GL_BLEND); glDisable(GL_LINE_SMOOTH); } Is there something that I am doing wrong ? Another trouble : I can't configure a blend mode input that would work properly... Thanks a lot for your advices ! Ben
|
Well... So I understood (did I undertsand right ?) that OpenGL renders the vertically beginning by the bottom of the image... Am I right ?
Looking forward to understand how to make my consumer patch appear in the right sense both directly and in a RII... Learning learning... :-)
By the way, thanks so much for everything I learned by here !