Jump to content
  • Advertisement
Sign in to follow this  
Ultimate_Fusion

converting sol's SDL to another engine

This topic is 4055 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

I have done all of sol's SDL tutorials. I am wanting to convert one of the techniques into another graphics library. I was looking at http://sol.gfxile.net/gp/ch20.html where you can create a rotating sphere with dots on that move. All of the code was easier enough to copy but the hard part is converting the graphics syntax. gScreen // is a surface I couldn't us e a surface in my new graphics library and creating a 'RECT' I could just use RECT.x/y/w/h there was no pixels. This is the line I am having trouble with. ((unsigned int*)gScreen->pixels)[ofs + j] = c; I compiled the line below using the video address but this produced a rectangle at the top of the screen that was dashed. ((unsigned int*)pTheDrawEngine->videoAddress)[ofs + j] = c; The standard way to draw (pixel manipulation) is to ue something like: videoAddress+x*bytesPerPixel+y*memoryPitch)=c; any ideas guys? thanks for looking.

Share this post


Link to post
Share on other sites
Advertisement
Are the bytes per pixel the same in each case? What about the pitch of the surface in the new library?

Share this post


Link to post
Share on other sites
This is the line I am having trouble with.
((unsigned int*)gScreen->pixels)[ofs + j] = c;


Display memory (or surface memory) is simply a 2-dimensional array of pixels. The above line is easier to understand in context, in this case in chapter 6 of my tutorial (http://iki.fi/sol/gp/ch06.html). Instead of calculating y*pitch+x for each pixel, the function calculates the offset of one scanline (ofs).

I haven't played a lot with other 2d libs, so I can't help there, but the basic idea should be the same. (As long as you can access pixels, anyway =)

Share this post


Link to post
Share on other sites
I have tried different combinations like
((unsigned int*)videoAddress)[j*bytesPerPixel+ofs*memoryPitch] = c;

but most the program crashes, i think because the memory address is really wrong.

Share this post


Link to post
Share on other sites
Quote:
Original post by Ultimate_Fusion
i'm guessing there are the same, i can't be sure,


You need to be sure. Your new library - what is it? - must provide ways of setting or at least determining the characteristics of the surface that 'pTheDrawEngine' refers to. Without knowing the pitch of the surface or the pixel format, any attempt to write to it is just going to be guesswork.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!