We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOpenGL and 3D Libraries › OpenGL to improve 2D-motion
Page Index Toggle Pages: 1
OpenGL to improve 2D-motion? (Read 836 times)
OpenGL to improve 2D-motion?
Oct 14th, 2008, 1:41am
 
Hihi,
i'm working on a 2D project. Main thing is a rotating circle. I'm just in the testing phase and the display-performance leaves me quite unsatisfied. Should I work with OpenGL-Libaries to get a smooth motion? Are there any basic tricks on displaying motions?
I'm quite unexperienced and just want to know, if you can give me hint in which direction i should search.

You can see my state of work at

http://www.sights.de/hulala/

Thanks for help,
johannes
Re: OpenGL to improve 2D-motion?
Reply #1 - Oct 14th, 2008, 2:15am
 
eehhm... ok. didn't think, that opengl support is that easy. thought it was a complete new libary. it works better now... at a framerate of 60 it looks tolerably. but there are still some strange blocking effects, lines appear, and it stucks sometimes... not realy beautiful - even at a frame rate of 60. on tv you have one of 25 i believe. but tv is so blured. is that the idea? to blur the motion somehow?

i uploaded the current version.
Re: OpenGL to improve 2D-motion?
Reply #2 - Oct 14th, 2008, 5:57pm
 
Hi.

looking at it, i think that maybe you're referring to image tearing. to resolve that you can define vertical sync to be on, using opengl commands. Vertical sync basically syncs your application's frame rate to the refresh rate of your screen so that you are always displaying images that are correctly rendered.

your code would be something like this:
Code:

import processing.opengl.*;
import javax.media.opengl.GL;

PGraphicsOpenGL pgl;
GL gl;

float a = 0;

float fix_x = 200;
float fix_y = 200;

float center_x = 0;
float center_y = 0;

void setup()
{
size(400,400, OPENGL);
pgl = (PGraphicsOpenGL) g; //processing graphics object
gl = pgl.beginGL(); //begin opengl
gl.setSwapInterval(1); //set vertical sync on
pgl.endGL(); //end opengl
}

void draw()
{
strokeWeight(3);
background(180);
smooth();
fill(0, 0);
a = a + 1;
center_x = sin(a/6)*58 + fix_x;
center_y = cos(a/6)*68 + fix_y;
ellipse(center_x,center_y,200,200);
fill(0);
ellipse(200,200,70,50);
println(frameRate);

/* PFont font;
font = loadFont("AnAkronism-30.vlw");
textFont(font, 19);
String s = "framerate " + frameRate;
text(s, 15, 20, 400, 70); */
}



Re: OpenGL to improve 2D-motion?
Reply #3 - Oct 14th, 2008, 9:50pm
 
thanks for your suggestion pelintra. unfortunetly it doesn't make a difference. i still have displacement-lines, as if in one frame the circle gets a different position from one line to the other. and i have some stucks in the movement. they are very short. but it just destroys the impression of a fluently motion.
Re: OpenGL to improve 2D-motion?
Reply #4 - Oct 14th, 2008, 11:23pm
 
looks fine to me. i don't see any of those problems when i run the code pelintra posted in the PDE.
Page Index Toggle Pages: 1