PDA

View Full Version : Movable objects with opengl



nrslmz
02-07-2011, 07:51 AM
Hi
I have been working on a particle physics motor last year which I have been developing in Adobe Flash. In order to carry my project out to a more professional level, I have decided to write it in c++ with a GUI.
I thought opengl would be suitable to create an object environment equivalent to that of flash's. By which I mean that there will be 2D particles (all of them circles for now with different radii) and they will be able to move in a 2D plane.

In order to pose a simpler question, I will ask like this:
Is it possible to create a circle (which is pointed by an object) which can be moved by the arrow keys? e.g. it would shift 5px left when the left arrow key is pushed.

_arts_
02-07-2011, 08:08 AM
There are several ways to do so.

I's suggest you to draw little quads and texture them with circles.

nrslmz
02-07-2011, 08:15 AM
what is a quad exactly? by texturing, do you mean loading bitmaps to the object

_arts_
02-07-2011, 08:21 AM
something like this:

---
| |
---

Yes, texturing means applying an image to a 2D/3D model.

nrslmz
02-07-2011, 09:39 AM
I am totally new to opengl
glBegin() function is used to create a shape, but I don't know if this shape is an object or an instance, or if it has any attributes that can be called later. From what Ive seen, it does not have any.
Could you just briefly show me if there is a way to create an instance of a shape and then link it to an object etc

_arts_
02-07-2011, 10:40 AM
Object in the sense of drawing, so with glBegin, is just a simple collection of primitive drawings like triangles or quads. OpenGL just allow you to draw, you'll have to deal with everything (almost) else by your code.

I think you should try nehe first: http://nehe.gamedev.net/

It's very nice to start with OpenGL.

nrslmz
02-07-2011, 11:32 AM
Im kind of starting to get it now. There must be a separate algorithm that takes the attributes (x,y,radius) from the intangible object and draw the corresponding shape.

Every program that has ever been designed must have been doing so , right?
I got confused because flash does it automatically.

About the site, my god thats an insult to the eyes! Just kidding, it is a great source.

nrslmz
02-07-2011, 11:35 AM
By the way I want to use as less resources as possible for the sake of efficiency, should I use
linestrips
or
quads

_arts_
02-07-2011, 12:01 PM
linestrips will draw lines whereas quads will draw quad polygons.

Use triangles for efficiency.

nrslmz
02-07-2011, 12:09 PM
just to be clear by linestrips, I mean that I use small linestrips to draw a circle
either wayI realized that I should use triangles since linestrips wouldnt create a fill

MaxH
02-07-2011, 01:38 PM
... there will be 2D particles (all of them circles for now with different radii) and they will be able to move in a 2D plane. If this 'plane' is parallel to the plane of the screen, you can use large, anti-aliases, points. See glBegin(GL_POINTS), glEnable(GL_POINT_SMOOTH), glPointSize(), etc.