Results 1 to 3 of 3

Thread: [Unit] Sour

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    [Unit] Sour

    Sour stands for SDL-OpenGL Unsophisticated Rendering and is a simple unit for performing some basic 2D OpenGL drawing with SDL. The interface was written to mimic the software rendering API of SDL as much as possible, to make sure anyone who has ever used SDL will be able to quickly switch to using Sour, without any loss of productivity and development speed.

    Sour was originally developed as part of one of my game projects. Since the project did not require any sophisticated graphics and I didn't really want to learn OpenGL thoroughly from the beginning, I decided to make myself a simple rendering unit that could easily replace SDL software drawing.

    Sample screenshot, presenting FillRect, TexRect, DrawImage, DrawImgRot and PrintText:

    Download: click
    The unit comes with a full HTML documentation.

    Since I'm an OpenGL newbie myself and parts of the code were taken from google, it would be very appreciated if someone took a look at the code (mainly initialization and setup routines) and pointed out what am I doing wrong and what can be improved.
    Last edited by Super Vegeta; 11-10-2012 at 12:27 AM. Reason: Link change

  2. #2
    Procedure DrawImage(...);
       glBindTexture(GL_Texture_2D, Tex^);
    You have this as a base for every drawing operation. Especially the glBindTexture() is a heavy operation. Consider when you would need to draw 10000 particles with same texture, it would call that pointlessly 9999 times per frame. It's possible to store last used texture-index and skip bind if its unchanged, but it comes with problems if some other operation binds without letting your engine know. I went with SetTex() function myself, but that might not go well with SDL-style programming.

    Other thing i found when quickly skimming through, was:
    Procedure SetGLAttributes(R,G,B,Double:LongWord);
    Is that even possible, i could do this?
    var double: double;
    Usually recommended to avoid using reserved names in variables and constants.

    But overall seemed good work of course
    Last edited by User137; 08-10-2012 at 12:50 PM.

  3. #3
    Okay, so having some free time this evening, I gave this thing some extra work and bumped the version to 1.1.

    Thanks to User137, I made the unit remember if texturing is enabled and the boundtex number - and it turned out the thing works way faster now. Furthermore, I implemented a proper initialisation procedure, making starting the unit, at least in my opinion, as easy as it can get. Also, I added some extra routines allowing to change the settings and (duh) free resources.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Comodo SSL