# Drawing circles (Beginner question)

**URL:** <https://discourse.libcinder.org/t/drawing-circles-beginner-question/415>\
**Category:** Using Cinder\
**Created:** [November 27, 2016, 12:51pm UTC](https://discourse.libcinder.org/t/drawing-circles-beginner-question/415 "2016-11-27T12:51:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![stdout](https://avatars.discourse-cdn.com/v4/letter/s/7ea924/32.png) [@stdout](https://discourse.libcinder.org/u/stdout)\
**Post date:** [November 27, 2016, 12:51pm UTC](https://discourse.libcinder.org/t/drawing-circles-beginner-question/415/1 "2016-11-27T12:51:43Z")

</div>

Hello,

i am a cinder newbie. My goal is to display some anti-aliased circles and lines using the  
GPU.  
I looked at the tutorials [https://www.libcinder.org/docs/guides/opengl](https://www.libcinder.org/docs/guides/opengl)  
and derived following code which is intended to be a reduced to the minimum  
starting point (draw one circle). It does not show anything though.  
I do not know what i am missing here. A hint would be nice.  
(As well as a hint on how to implement the anti-aliasing, if possible.  
I know this tutorial but cannot translate it to cinder [https://rubendv.be/blog/opengl/drawing-antialiased-circles-in-opengl/](https://rubendv.be/blog/opengl/drawing-antialiased-circles-in-opengl/))

Here is my code:

```auto
#include <stdio.h>
#include "cinder/app/App.h"
#include "cinder/app/RendererGl.h"
#include "cinder/gl/gl.h"
#include "cinder/ImageIo.h"
#include "cinder/Utilities.h"
#include "cinder/params/Params.h"
#include "cinder/GeomIo.h"

using namespace std;
using namespace ci;
using namespace ci::app;

class BasicApp : public App {
public:
	void setup() override;
	void draw() override;
	
	CameraPersp mCam;
	gl::BatchRef	mBatch;
	vector<gl::BatchRef> Circles;
};

void BasicApp::setup() {
	auto lambert = gl::ShaderDef().lambert().color();
	gl::GlslProgRef shader = gl::getStockShader( lambert );
	
	auto circle = geom::Circle().center(vec2(10 , 10)).radius(10);
	mBatch = gl::Batch::create( circle, shader );
	
	mCam.lookAt( vec3( 10, 10, 0 ), vec3( 0 ) );
}

void BasicApp::draw() {
	gl::clear();
	gl::enableDepthRead();
	gl::enableDepthWrite();
	
	gl::setMatrices( mCam );
	mBatch->draw();
}

CINDER_APP( BasicApp, RendererGl )

```

---

<div class="post-metadata">

**Author:** ![balachandran\_c](https://avatars.discourse-cdn.com/v4/letter/b/f17d59/32.png) [@balachandran\_c](https://discourse.libcinder.org/u/balachandran_c)\
**Post date:** [November 27, 2016, 1:18pm UTC](https://discourse.libcinder.org/t/drawing-circles-beginner-question/415/2 "2016-11-27T13:18:19Z")

</div>

Hi,

1. Try changing the z coordinate of the eyepoint of your camera, to say 100.
2. You can set the number of samples for antialiasing in this way:

```auto
CINDER_APP( BasicApp, RendererGl( RendererGl::Options().msaa( 4 ) ) )

```

You can find code for advanced antialiasing under samples/\_opengl/PostProcessingAA.

---

<div class="post-metadata">

**Author:** ![paul.houx](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/paul.houx/32/31_2.png) [@paul.houx](https://discourse.libcinder.org/u/paul.houx)\
**Post date:** [November 27, 2016, 2:29pm UTC](https://discourse.libcinder.org/t/drawing-circles-beginner-question/415/3 "2016-11-27T14:29:40Z")

</div>

Hi,

your camera is positioned at (10, 10, 0), looking at (0, 0, 0). Your circle is drawn in the XY-plane. So you’re looking at the side of the flat circle, which is infinitely thin, so you won’t be able to see it. Try this instead:

`mCam.lookAt( vec3( 0, 0, 10 ), vec3( 0 ) );`

With that being said, you don’t really need a 3D camera when drawing circles. Circles are flat, 2D objects and, by default, Cinder is setup to draw in 2D with the origin (0, 0) at the upper left corner of the window. Disable the call to `gl::setMatrices( mCam );` to see what I mean.

As @balachandran_c pointed out, you can enable multi-sampling using `RendererGl::Options().msaa(...)`. You could also render to a multi-sampled frame buffer object (Fbo) when you create it using `gl::Fbo::Format().samples( 16 )`. The advanced anti-aliasing found in the PostProcessingAA sample is called FXAA and SMAA, which can be used instead of a multi-sampled Fbo, for instance when using an advanced deferred rendering pipeline. It can _not_ be used with the main buffer. I would advice to simply start with `RendererGl::Options().msaa(16)` until you have learned more about graphics programming.

-Paul

P.S.: kudo’s for using a batch to render your circle. It is faster than `gl::drawSolidCircle()```.

---

<div class="post-metadata">

**Author:** ![stdout](https://avatars.discourse-cdn.com/v4/letter/s/7ea924/32.png) [@stdout](https://discourse.libcinder.org/u/stdout)\
**Post date:** [November 27, 2016, 3:21pm UTC](https://discourse.libcinder.org/t/drawing-circles-beginner-question/415/4 "2016-11-27T15:21:43Z")

</div>

That was it. Error fixed.

Thanks for the hints about anti-aliasing.

Best regards
