How to start GL_Painter - opengl-3

I Hope that any one could help me to start doing this program in OpenGl
Write an OpenGL program (interactive program) that draw lines by clicking on the start point and then drag on the display window drawing area.
Give the user a menu that (s)he choose from. The menu contains the following options:
1- Clearing the display window.
2- Choose a line drawing color which includes at least the colors (red, green, blue, black).
3- Choose a line pattern which includes (dash, dot, dot-dash, solid lines).
4- Choose a line thickness. (line width from 1 to 4).
5- Quit the program.

AntTweakBar is good minimalistic gui library and it integrate well with OpenGL (and you do not need much code).
FreeGLUT will be good for windowing and mouse handling and it is also little code.
OpenGL.
glBegin can be used for drawing lines.
glCorol can be used for color (for choosing color use AntTweakBar).
If you need more help update question (you probably do not have rights to add comments, but you can edit your question).
PS From question I've draw assumption that you are beginner, hence level of my answer. I can go deeper if you like.
PSPS You do not need OpenGL to do this kind of stuff, but I assume that OpenGL is a requirement, right? Otherwise there are simpler solutions. Also clarify your question a bit (aspecially section about drawing lines, do you allow non-straight lines?).

Related

Use image library from Hammerspoon

I'd like to use a more sophisticated graphics or GUI widget library in my Hammerspoon config file, in order to get user input and do more advanced drawing on the screen than Hammerspoon allows (as far as I can tell) by default. I'm new to Lua and Hammerspoon, and so far I've been unable to figure out how to get this working. (Simple drawing on-screen is not a problem, so examples of geometric shapes are not helpful. I can do that already with no difficulty.)
I initially thought one of the Lua libraries designed for building games would have more than I could possibly need, and looked into love2d, but it did not appear to be possible to use with Hammerspoon in any straightforward manner.
To give two concrete examples of things I'd like to do:
I'd like to display a dialog box in which the user can enter two values, to specify how many rows and how many columns they want in their screen grid. A native Cocoa dialog would be better, but something graphically drawn on screen with Lua would be fine, as long as the details of the image are abstracted away for me, and I can just define the text and fields and buttons in the dialog.
I'd like to draw a dotted-line rectangle with curved corners and a shadow around specified grid segments as a preview of where a window would be moved if the user completed a certain command.
There's a lot more, but anything that allows me to do those things should allow me to do anything else I want.
We don't yet have a good answer to generating dialog boxes, although it is possible to do it with AppleScript, which you can call from Hammerspoon with hs.osascript.
As for drawing things like dotted-line rectangles, we can't currently do that, but if you'd like to file an issue on our GitHub project, it's something we can look at for a future release :)

Painting issues with TScaledLayout & custom styles

I'm experiencing painting issues when combining TScaledLayout and custom styles created from the bitmap style designer in fmx.
To demonstrate, I loaded the default custom style created by chosing "New style for VCL / FMX" -> "save as .style" in the bitmap style designer. I dropped several standard controls on some colored rectangles: The red & green ones on a TScaledLayout, the blue one directly on the form. As I stretch the form, colored lines appear on the controls on the ScaledLayout; the background is partially visible:
If I size the form to exactly match the design-time dimensions, the lines disappear. That seems like a pretty significant issue, I certainly can't use those two together like that. Does anybody have an idea for a possible fix or workaround?
Looks like this is a known issue with scaling and bitmaps. See the Google+ discussion here - https://plus.google.com/+PaulThornton/posts/ACAHkJD3a84. I'll quote Marco Cantu's thoughts:
I've found an internally reported issue of a similar case, but haven't
found one that matches this scenario. Certainly worth adding to quality
portal. Having said this, I fear that bitmap-based operations and
scaling don't really fit together very well, and it might be difficult
to have an all encompassing solution.
Let me explain with an example. Take a button. This is painted by FMX
with 9 sections (borders, corners, central part) so that regardless of
the size the bitmap elements are stretched in one direction at most,
often just draw. Stretching a single bitmap for the button to the
target size would break anti-aliasing and create a blurred image when
using colors.
This is example what happens with a ScaledLayout, given it takes the
complete final image and transforms it. ScaledLayout was originally
introduced with vector styles, and worked very well in that scenario.
With todays's bitmap styles things get a bit more complex.
Regardless of this explanation of there the issue lies, I'd recommend
reporting it on QC, and I'll make sure it doesn't get closed as design
(it could naturally happen, this is how the system works) but that we
do some investigation to address the issue -- turning this into a
feature request.

How to check intersection of two images that aren't rectangular?

New user to the site, but I have used it in the past so I felt it best to ask my question here, for the best chance of getting a response.
What I'm dealing with is one object, this being the sprite for my latest app, which I need to check for when it comes in to contact with another object, in this case, a tunnel which will curve.
Now, I'm aware of CGRectIntersectsRect, however I can't see that being helpful, as if I've got 2 UIImages, that being the top and bottom of a "mountain", and said pieces curving, there's no doubt that the sprite would touch the "rectangle".
What I need is something to trigger when the sprite hits the actual wall, however my limited knowledge of Objective-C isn't helping my case.
I imagine someone out there will know what I can do to resolve this, as for all I know it could be a simple solution.
Thank you in advance everyone!
First, I'd probably not build these basic pieces yourself. For iOS 7, you can use SpriteKit, which is built-in. If you want to support older versions of iOS, look at cocos2d (it's good for iOS 7, too).
But to the question, one approach for detecting arbitrary overlaps is to draw both objects into a buffer and check if there are any overlapping pixels (for instance, by drawing one in in pure red, and another in pure green, and then looking for pixels that have both). For a discussion of how to do this kind of thing in Core Graphics, see Clipping a CGRect to a CGPath, which provides sample code for the simplest version (checking for the intersection of a rectangle and curve), but the same approach can be used more generally. Note that this drawing can get expensive if you're doing it constantly, so usually you first check whether the bounding rectangles overlap. That tells you whether it's even worth the trouble to look closer.
But first I'd look at SpriteKit.

2013, Existing package for drawing (painting, brush, lines) in iOS?

I need to add typical finger drawing to an app.
(The usual.... choose colors, erase, thickness - just the usual you see in every app made.)
It's hard to believe I have to program this from scratch, in this day and age?
It's hard to believe there is not a common solution for this?
All I could find is...
https://github.com/levinunnink/Smooth-Line-View
Review: that is a (beautifully written) example fragment of a few lines of code being how to draw with a path, with a good smooth result. It works perfectly, but it's just for drawing one "path." For example, you can't make a drawing with more than one color. there is no undo or anything like that. (See also note on the fourth review item here regarding path-math.)
https://github.com/sumanthk2006/Smooth-Line-View-1 (variation of above, but does not run under ARC, unfortunately demo does not properly launch etc)
Review: this is "abandonedware" or maybe "frustrationware" :) It does not run and is not ARC-ready. It is a seemingly well-written class that claims to do undo, colors, erase, etc. It even has a proper delegate to track your button states. But it doesn't work.
UPDATE Regarding this paackage. As a matter of fact, if you massage it it works well. Suggest (i) throw away the example app files. (ii) using modern Xcode, use the "convert to ARC project" feature on the two main files. There are a coupe little problems like it should use awakeFromNib. If you get it working it actually does everything, really well.
THERE ARE SERIOUS BUGS in SmoothLineView1. just to be clear, it suffers some serious bugs - you'll see there's a "streaking" effect when you draw.
http://www.cdframeworks.com/product/brushengine
Review: This commercial package (under $100) is well made and email support is fast. Unfortunately it does not have undo so it's not suitable for many situations. (Also does not have erase.)
Mentioned below is this popular article:
http://mobile.tutsplus.com/tutorials/iphone/ios-sdk_freehand-drawing/
Review: this is a good article on the actual TECHNOLOGY of drawing curves, on the let's say "path-math". Unfortunately it's no help at all if you need a working, ready to use, drawing package (with the obvious features, undo, erase, colors etc) to use in an iOS app. Thus for example, whatever actual solution you were using, you may, perhaps, want to apply the math concepts in this article.
I appreciate that the basic concepts are very simple, it's easy enough to "start from scratch". But it's just - ridiculous - to have to do from scratch for something so commonplace. Is there a solid package I'm missing?
It's fairly amazing that the four scratchy references above are the only things out there.
Any ideas? What's the best package today (late 2013) for adding drawing to an iOS app? THANKS.
As of 2017, I use https://github.com/acerbetti/ACEDrawingView/.
It can be used through cocoa pods, and provide full functionality over integrating a drawing feature in your app (color, brush, size, eraser, undo/redo/, etc).
http://mobile.tutsplus.com/tutorials/iphone/ios-sdk_freehand-drawing/ has a good, clear tutorial on smooth freehand drawing on the ios. If you just follow the tutorial, you can implement it easily into whatever app you are trying to make. It has stuff about increasing line quality and smoothness, and stroke quality.http://www.raywenderlich.com/18840/ is another tutorial on a simple drawing app, self-contained. You can combine aspects of both to get what you want.
edit: https://developer.apple.com/library/ios/samplecode/GLPaint/Introduction/Intro.html is the GLPaint sample provided by apple, which includes detecting shake. I thought it seemed more official, since it's from apple
to answer your question, there is no package for drawing directly, but there is a UIKit class, UIBezierPath, that lets you draw shapes made of straight lines or some curves.

Clear single viewport in DirectX 10

I am preparing to start on a C++ DirectX 10 application that will consist of multiple "panels" to display different types of information. I have had some success experimenting with multiple viewports on one RenderTargetView. However, I cannot find a definitive answer regarding how to clear a single viewport at a time. These panels (viewports) in my application will overlap in some areas, so I would like to be able to draw them from "bottom to top", clearing each viewport as I go so the drawing from lower panels doesn't show through on the higher ones. In DirectX 9, it seems that there was a Clear() method of the device object that would clear only the currently set viewport. DirectX 10 uses ClearRenderTargetView(), which clears the entire drawing area, and I cannot find any other option that is equivalent to the way DirectX 9 did it.
Is there a way in DirectX 10 to clear only a viewport/rectangle within the drawing area? One person speculated that the only way may be to draw a quad in that space. It seems that another possibility would be to have a seprate RenderTargetView for each panel, but I would like to avoid that as it requires other redundant resources, such as a separate depth/stencil buffers (unless that is a misunderstanding on my part).
Any help will be greatly appreciated! Thanks!
I would recommend using one render target per "viewport", and compositing them together using quads for the final view. I know of no way to scissor a clear in DX 10.
Also, according to the article here, "An array of render-target views may be passed into ID3D10Device::OMSetRenderTargets, however all of those render-target views will correspond to a single depth stencil view."
Hope this helps.
Could you not just create a shader together with the appropriate blendstate settings and a square mesh (or other shape of mesh) and use it to clear the area where you want to clear? I haven't tried this but I think it can be done.

Resources