Sign in to follow this  
Toshio

OpenGL Weird artifacts and Frame Independent Movement

Recommended Posts

Greetings. I have two problems here.

First off, I'm using OpenGL with SDL.

The first problem are weird lines around the transparent PNG picture as shown in the screenshot:
[attachment=10761:screenshot.png]

This is the PNG picture:
[attachment=10762:catanimate.png]

How can I make the lines disappear?

The second problem is Frame Independent Movement. I got it all set up, and I thought it worked until a lot of things went happening at the same time. At some places entities move very fast, at some very slow, depending on what's rendering on screen and what logic is currently happening.

Here is some code:

this is main.cpp:
[CODE]
Uint32 delta = SDL_GetTicks();
SDL_Event event;
g.OnInit();
while(g.running)
{
if(SDL_PollEvent(&event))
{
g.OnEvent(&event);
}
g.OnLoop(SDL_GetTicks() - delta);
delta = SDL_GetTicks();
g.OnRender();
}
[/CODE]

and this is how the player, for example, moves:
[CODE]
x += xVel * (delta / 1000.0f);
[/CODE]

Thank you for your help [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]

Share this post


Link to post
Share on other sites
The easiest way to fix those lines is probably to move the texture coordinates by 0.5 pixels. And for your timestepping problem: [url="http://gafferongames.com/game-physics/fix-your-timestep/"]http://gafferongames...-your-timestep/[/url] Edited by Sponji

Share this post


Link to post
Share on other sites
[quote name='Manabreak' timestamp='1345380483' post='4971092']
I think the artifacts are caused by wrapping. Clamping the texture to edges should prevent this.
[/quote]

I am using Clamp to edge.

[quote name='Sponji' timestamp='1345394533' post='4971143']
The easiest way to fix those lines is probably to move the texture coordinates by 0.5 pixels. And for your timestepping problem: [url="http://gafferongames.com/game-physics/fix-your-timestep/"]http://gafferongames...-your-timestep/[/url]
[/quote]

How can I move the texture coordinates by pixels?

Share this post


Link to post
Share on other sites
Well... if your image's width is 512 pixels, and opengl wants it to the range 0.0-1.0, one pixel's width is then 1.0/512.0. Just move the texture coordinates by 0.5/512.0.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this