Jump to content
  • Advertisement
Sign in to follow this  
meetjatin88

Doubt regarding SDL programming

This topic is 2371 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi All,

I have a doubt regarding SDL programming.
Can some one please help me how can i subdivide a Image lets say into 4 parts and then store them in SDL_Surface array.
I intend to animate later using these subdivided images by using SDL_BlitSurface function.

I am new to SDL,so it would be great if someone could provide some codes for reference.

Please note that i am using Microsoft visual c++ 2010 compiler..

Thanks
Jatin

Share this post


Link to post
Share on other sites
Advertisement
hey dude why would you do this? Its a wast of memory

your best bet is to load one surface and then clip it

You can do this by specifying a clipping rect ( SDL_RECT ) when blitting the surface to the screen.

int SDL_BlitSurface(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect); // the second parameter

if you really want to do it like that you could create an array/vector/list then use SDL_CreateRGBSurface to create a new surface, blit from your original onto the new one then store it into the array/vector/list but you will still need to use the clipping to get the segment you want. smile.png

hope this helps

Share this post


Link to post
Share on other sites
Hi Guys,

I am stuck again and need you help on two issues,if some one know any thing about these two things please reply

1)I want to create a negative of an image if say the user enter key 'N'.Now i know the logic of creating an negative ie find RGB value of each pixel on the screen,then subtract the indiviual RGB value from 255 to get the new value.However i do not know how can we take RGB value from each pixel and then write them back on screen.Have anyone tried something like this or do someone have a better idea.Please some reference code if some one has tried anything like this.

2)I am trying to create a camera in SDL by using SDL_rect and then positioning it in the screen by giving some offsets,but what i really want to achieve is that i have created an animation and i would like my camera to move along with it.I mean if my animation is moving to the right ,it should feel like camera is following him.But i am unable to achieve this result.Have anyone tried to emulate a camera in SDL before and if yes assist me.

Share this post


Link to post
Share on other sites
Hi MaxFire,
Thanks for the Information but i have already have a look at them and these things are not there.,but i gained all of knowledge from there.
Can you please suggest some other good SDL programming sites esp related having motion and collision examples.

Thanks
Jatin

Share this post


Link to post
Share on other sites
Lazyfoo does indeed has them all

Camera - http://lazyfoo.net/SDL_tutorials/lesson21/index.php
pixel manipulation - http://lazyfoo.net/SDL_tutorials/lesson31/index.php ( to achieve the effect your looking for you will need to use SDL_GetPixel to get the colours to achive your negative effect )
motion - http://lazyfoo.net/SDL_tutorials/lesson16/index.php
collision detection - http://lazyfoo.net/SDL_tutorials/lesson17/index.php

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!