# Polygons in Quartz?



## goldenmeg (Apr 3, 2006)

I'm in the process of converting my QuickDraw OS 9 code to Quartz using xcode 1.5 in Panther. I can't find a reference to polygons in the quartz documentation or quickdraw transfer help. Is it possible to create and fill polygons, or irregular shapes in Quartz?

Thanks,
Meg


----------



## Lt Major Burns (Apr 4, 2006)

AFAIK, Quartz is strictly 2D, so there would be nothing in it about polygons.  for the 3D stuff, look in OpenGL.


----------



## goldenmeg (Apr 4, 2006)

OK, I'll look into this. Can I mix OpenGL and Quartz code? Or should I just look at Open GL and drop Quartz?

What is AFAIK?

Thanks


----------



## lurk (Apr 4, 2006)

Howdy, 

Our good major has it wrong since you are talking about drawing actual 2d polygons and he is talking about the polygons used to render 3d surfaces in openGL.  They are not related in the least.

All that you need to do is create a closed path and fill it to get that in Quartz. The easiest way at the appkit level is just to make a closed bezier path and then fill it.  You can use solid colors, gradients, tiled images almost anything like that.

If you are just doing 2d stuff you really should not get into OpenGL as there are lots of complications that will not help in the 2D case.


----------



## goldenmeg (Apr 4, 2006)

Thanks - yes, I'm doing 2D polygons. I'll do the closed path route.

On the otherhand - After getting my code ported to OS X I want to increase its functionality and add some 3D graphical displays of data - I'm guessing I need to go to OpenGL for that? Should I continue along with Carbon with Quartz 2D then add the OpenGL functionality later? Or should I look ahead and structure my code to fit with OpenGL?

Thanks


----------



## lurk (Apr 4, 2006)

You cannot easily mix the two because each has a different rendering context.  They really have very different ideas about what you are doing and so conversion is problematic.  In the 2D case you are very much in the mode of placing ink on paper and the like.  When you go to 3D and openGl you need to create a model of the thing and then properly light and position the camera so that it is rendered the right way.  It is like the difference between drawing and sculpture, and you cannot just gradually pop from medium to the other.

Now that said you might still be in the 2D realm and say want to include a picture of a 3D object, then you could do that by creating a separate 3D rendering context and getting a snapshot of the object there which you then include in your 2D image. But that is quite a bit of suffering.

I guess my point is that the transition for 2D to 3D is not something you can ease into as an afterthought.  You need to design it in from the get go.
Right now I don't know what you are doing but I suspect that if you are porting code form 2d Quickdraw then you already have committed to the 2D route, if you want 3D you will need to re-impliment and redesign to get there.


----------



## goldenmeg (Apr 4, 2006)

I'm building a scientific simulation model. The output of the model is 3D. My current code displays 2D (cartesian coordinates x-y; x-z and y-z) slices of the 3D data. Given my model data structure, I can most easily access it in the form of 3D rectilinear boxes and 3D cylinders. I want to continue with the 2D slices and also add 3D later.

I have 2 ideas - 1) output my model data and create a different application to input the data and view 3D using OpenGL. Or 2) within my current carbon application, call an entirely different routine to display the OpenGL 3D

Any thoughts?

Thanks


----------



## Lt Major Burns (Apr 4, 2006)

whoops...

AFAIK: As far as I know


----------



## lurk (Apr 4, 2006)

If that is what you are doing I would ask if this needs to be for a commercial product or something that you just need to be functional in some research context?  Becasue I would suggest that OpenDX might be your best choice since that will give you lots of power in the scientific visualization realm.  I am just not certain about the licensing implications.


----------



## goldenmeg (Apr 4, 2006)

This might be just the thing - I'm not developing commercial software, but I may use it in a consulting mode. I'll look into the liscensing issues (a quick look and there doesn't seem to be a problem) and supported data input structures.

Thanks!


----------

