I am studying Core Graphics to make dynamic textures for my project.
A friend told me that i should use CGLayerCreate and CGContextDrawLayerAtPoint
to improve the texture of the brush app that i am building but i haven't found any book or tutorial that includes CGLayerCreate and CGContextDrawAtPoint.
can you guys tell what's the use of this two and how will able to code them?
also if you know any core graphics book that includes those please tell me, it'll surely help me.
thanks!
The Quartz 2D Programming Guide has a chapter that discusses CGLayer objects.
Your friend might be thinking of this use of layers, quoting that chapter:
Repeated drawing. For example, you might want to create a pattern that
consists of the same item drawn over and over. Draw the item to a
layer and then repeatedly draw the layer, as shown in Figure 12-1. Any
Quartz object that you draw repeatedly—including CGPath, CGShading,
and CGPDFPage objects—benefits from improved performance if you draw
it to a CGLayer. Note that a layer is not just for onscreen drawing;
you can use it for graphics contexts that aren’t screen-oriented, such
as a PDF graphics context.
There's also a very very simple example in the Quartz2DBasics sample app.
Related
I just started coding some basics in SharpDX (VB.net) and I already got it to Render a 2D triangle. And I know how to render other 2D stuff, but I want to create something in 3D where I'm able to rotate the camera around some cubes. I tried it, but failed at converting the 3D Space to screen coordinates. Now Here are my Questions:
How can I calculate a Matrix for Perspective projection?
How can I pass that Matrix to my Vertex Shader
How can I make the Camera rotate around the Objects when I drag the mouse over the screen?
Please explain these things to me and give some code examples. I'm just a Beginner in SharpDX and everything I found was just not understandable for me.
A few things you can do when you first start.
Firstly, there are some great examples you can leverage (Even in c# but you need VB) that you can use to learn from.
I suggest you look at this within the Sharpdx repository. Sharpdx direct 3d 11 samples
Within these examples (especially triangle example), it goes through the basics including setting up the device, the creation of simple resources to bind to your GPU and compiling the bytecode.
The samples though use the effects methodology, which is deprecated and as such once you become familiar with compiling code, I would advise moving away from this paradigm.
The more advanced examples will show you how to set up your matrices.
The last item you wanted to know about is mouse movement. I would advise just having a look at MSDN around mousemove events. You will need to bind one to your window/control and then read the deltas. Use those deltas to create your rotation/movement based upon this. Look into Vector3 (sharpdx), basically, you need to do this all in vector space and then create the various translation/rotation matrices from this.
Hope this is start.
I am developing an iPhone application that uses cocos3d. My question is: how to draw custom shape in cocos3d? for example a cylinder, a cylinder with an ellipse as its base instead of a circle, a polygone, etc. Can anyone please guide me how to start?
Thanks in advance
There's good support for doing that in Cocos3D.
CC3Mesh has simple property settings for allocating space for vertex content, plus a large family of methods for getting and setting various vertex content. Make sure you understand how to use the vertexContentTypes property.
The source files CC3ParametricMeshes.m and CC3ParametricMeshNodes.m contain a number of examples of creating mesh shapes programmatically. Have a look at the implementations in those files.
after experimenting with VB.NET image and drawing classes, I am searching a new one that I could use.
The problem is that the actual classes are really slow and even a rate of 24 fps is too slow to refresh a moving 225x70 image and with double buffer. Using .FillRectangle with a brush is fast and could do the job, but the image is tiled behind the rectangle and does not move with the rectangle.
Do you have ideas of what I could do ? Please try to be clear in your answer if I need to install DLLs or things like that, as I am new to VB.net language.
*I already tried openTK, but it seems to be mostly 3D, I only need 2D. Should I use it anyway ? I can't find beginner tutorials for VB.NET.
I think XNA or GorgonLib would be the best options. OpenTK is good too, but I think it will be a little too complicated for just 2d drawing. There is also SDL.NET, but it hasn't been updated in a while and again, it's meant for 2d. The best 2d library I've used in terms of speed is allegro, but I'm not sure if there are any wrappers available for .NET.
Gorgon: http://code.google.com/p/gorgonlib/
I have been reading for several hours now documentation about drawing two dimensional graphics in a objective-c cocoa application. There appears to be several different technologies all specific to certain tasks. My understanding is that the following technologies do the following things. Please correct me if I'm wrong.
Quartz 2D: The primary library for drawing shapes, text, and images to the screen.
Core Graphics: this is the name of the framework that contains Quartz. This can be used as a synonym for Quartz.
QuartzGL: A GPU acceleration mode for Quartz that is not enabled by default and not necessarily faster for drawing things on the screen.
OpenGL: The most low level library, talk directly to the graphics card at the cost of more lines of code. More suited for 3D graphics.
Core Image: A library for displaying images and text, but not so much for drawing shape primitives.
Core Animation: A library for automatically animating objects. Apparently not suited for moving large numbers of objects. Nor for continuous animation of objects.
QuickTime: A library that apparently also does images and text in addition to video, but probably not good for drawing primitive shapes.
What I would like to do is create a browser for some specific type of data. The view would not very complicated and would consist of drawing rectangles at specific locations. However, the user should be able to move around by dragging the view to the left or the right and the this movement should be fluid. Here is a example that is very close to what I'm trying to make:
http://jbrowse.org/ucsc/hg19/
What drawing technology would you recommand I start coding with?
You want Quartz. Unless your graphing MASSIVE amounts of data, any Mac (I'm assuming Mac not iOS) should handle it easily. It is easy, efficient, and will probably get you where you need to go. For the dragging movement, you'll probably manage that with Core Animation layers.
Note: Everything in the end is handled by AppKit (Mac) or UIKit (iOS) and, eventually, Core Animation. If you're doing graphics, you will encounter Core Animation at some point, as it manages everything displayed.
Note: If you are graphing that much data, you can use OpenGL, but even then, the need shouldn't be too much until you start displaying, probably many millions of vertices or complex visualisations.
So I want to have a view (NSView, NSOpenGLView, something CG related?) which basically displays a map. Such as:
http://dump.tanaris4.com/map.png
Obviously that looks horrible, but I did it using an NSView, and it draws SO slow. Clearly not designed for this.
I just need to allow users to click on the individual (x,y) coordinates to make changes, and zoom into a certain area (to see it better).
Should I go the OpenGL route? And if so - any suggestions as to how to get started? (I was able to follow the guide to draw a triangle, so that's good).
I did find this post on zooming in an NSView: How to implement zoom/scale in a Cocoa AppKit-application
My concern is if I'm drawing over 6000 coordinates and the lines connecting them, this isn't efficient at all.
I don't think using OpenGL would be of any good here. The problem does not seem to be the actual painting, but rather the rendering strategy. You would need a scene graph of some kind to dynamically handle level of detail and culling.
Qt has all this packaged in a nice class class QGraphicsScene (see http://doc.qt.nokia.com/latest/qgraphicsscene.html for reference, and http://doc.qt.nokia.com/main-snapshot/demos-chip.html for an example).
Some basic concepts you should consider using:
http://en.wikipedia.org/wiki/Scene_graph
http://en.wikipedia.org/wiki/Quadtree
http://en.wikipedia.org/wiki/Level_of_detail
Try using core graphics for this, really there is so much that could be done. Watch the video Practical Drawing for iOS Developers from WWDC 2011 and it should give an over view of what can be done with CG.
I believe even CoreGraphics will suffice for what you want to achieve, and that should work under a UIView if you draw the rectangle of your view completely under the DrawRect method of your UIView (you must overload this method). Please see the UIView Class Reference. I have a mobile application that logs points on the UIMapKit, kind of like Nike+, and it certainly works well for massive amounts of points/line segments. There is no reason why this simple approach cannot work for you as well.