Jump to content

View more

Image of the Day

Adding some finishing touches...
Follow us for more
#screenshotsaturday #indiedev... by #MakeGoodGames https://t.co/Otbwywbm3a
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Weird artifacts and Frame Independent Movement

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
6 replies to this topic

#1 Toshio   Members   

135
Like
0Likes
Like

Posted 19 August 2012 - 04:42 AM

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:
screenshot.png

This is the PNG picture:
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:
	 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();
	 }

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

Thank you for your help Posted Image

#2 Manabreak   Members   

141
Like
0Likes
Like

Posted 19 August 2012 - 06:48 AM

I think the artifacts are caused by wrapping. Clamping the texture to edges should prevent this.

#3 Sponji   Members   

2461
Like
0Likes
Like

Posted 19 August 2012 - 10:42 AM

The easiest way to fix those lines is probably to move the texture coordinates by 0.5 pixels. And for your timestepping problem: http://gafferongames...-your-timestep/

Edited by Sponji, 19 August 2012 - 10:42 AM.

Derp

#4 Toshio   Members   

135
Like
0Likes
Like

Posted 20 August 2012 - 03:38 AM

I think the artifacts are caused by wrapping. Clamping the texture to edges should prevent this.


I am using Clamp to edge.

The easiest way to fix those lines is probably to move the texture coordinates by 0.5 pixels. And for your timestepping problem: http://gafferongames...-your-timestep/


How can I move the texture coordinates by pixels?

#5 Sponji   Members   

2461
Like
0Likes
Like

Posted 20 August 2012 - 08:49 AM

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.
Derp

#6 Hodgman   Moderators   

50854
Like
0Likes
Like

Posted 20 August 2012 - 09:28 AM

Another fix for your sprite problem is to insert a row/column of transparent pixels in between each 'cell'.

#7 Toshio   Members   

135
Like
0Likes
Like

Posted 20 August 2012 - 02:54 PM

Thank you all, fixed the problem by moving the texture coordinates :)




Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.