SpotLighting (OpenGL)

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Hi,

      Thanks for the warning. I started having panics attacks but after I googled, I felt somewhat better. I have 4 Quads so I should be ok.

      Source Code

      1. glBegin( GL_QUADS );
      2. glNormal3f( 0.00, 0.00, 1.00 ); glTexCoord2f( 0, 0 ); glVertex3f( -2.0, 1.0, 0.0 );
      3. glNormal3f( 0.00, 0.00, 1.00 ); glTexCoord2f( 0, 1 ); glVertex3f( -2.0, -1.0, 0.0 );
      4. glNormal3f( 0.00, 0.00, 1.00 ); glTexCoord2f( 1, 1 ); glVertex3f( 2.0, -1.0, 0.0 );
      5. glNormal3f( 0.00, 0.00, 1.00 ); glTexCoord2f( 1, 0 ); glVertex3f( 2.0, 1.0, 0.0 );
      6. glEnd();


      I have been playing with the materials and lighting properties including attenuation. I've been playing with these setting so much I think I'm rubbing out the ink on the pixcel for the "Start" button. (Which is why I'm writting a console now. "Plug and play compiling" stinks! )

      From what you guys are suggesting, it sounds like I'm on the right road (execpt for the per-pixel thingy).

      Sorry to hear about the crash. I know I have a few memory leaks in the code, but I can not track them down. Heres an example:

      Source Code

      1. Dumping objects ->
      2. {104} normal block at 0x01C80438, 8 bytes long.
      3. Data: < > A8 00 CC 01 00 01 CC 01

      I have 5 simualr leaks, and I don't know where its comming from or even how to track them down. If you have any ideas on how to track these down, let me know. I've been searching for 'How to' bugging, but not much sucess.


      Thanks poumpa, good idea. I doubled checked that and I'm ok with the direction. (I hope/think).

      Thanks for the help, and keep the ideas comming. I'll get it yet! :)

      S.
    • Go to codeproject.com and do a search for vld. It's an awesome little open-source utility that helps track down memory leaks by dumping the allocation call stack so you can see exactly which resource is leaking. Very handy.

      -Rez
    • I had to stop everything and go back and fix some of those bugs since one member reported a crash.

      Rez,

      I LOVE VLD!!! Its EASY to use and figure out AND it gives file and line numbers! NICE!!!

      It does tell me 2 bugs, but I can't figure out why its leaking. (I'm doing a push_back). There are 5 other bugs that VLD is not telling about and its not showing me where its comming from. (file and line number). So I'm not sure how to track them down.

      S
    • By "bug" do you mean memory leak? That's the only thing it tracks.

      If it's pointing you to push_back on an STL container, are you doing something like this:
      someList.push_back(new Kitten);
      If so, those Kitten objects you're pushing will leak unless you call some sort of KillKittens() function that loops over the list and calls delete on all those objects.

      Also, I vaguely remember reading somewhere that vld and the CRT memory leak detection functions don't play well together because one detects that the other is leaking. But I could be confusing that with something else entirely.

      -Rez
    • Yes I do mean memory leak.... Opps.

      Source Code

      1. ...::SomeFunction( const char *cResourcePath )
      2. {
      3. ...
      4. String stringBuffer = cResourcePath;
      5. ..
      6. ResourcePathList.push_back( stringBuffer ); // Image computer blowing up here....KABOOM!
      7. ...
      8. }


      Heres an example of another memory leak that I don't know how to track.

      Source Code

      1. Dumping objects ->
      2. {105} normal block at 0x01D80480, 8 bytes long.
      3. Data: < m n > A8 6D DE 00 00 6E DE 00

      Any suggestion on how to track this down? (Other than commenting out bilions and billons of lines.)

      Side Note: Is it possable for " _CrtDumpMemoryLeaks();" to give "false leaks" ? From what I have read on MSDN there is no mention of this, but you never know.


      LOL... shame on you! "KillKittens()"... lol!!!


      S.
    • The first problem I see is that you seem to be instantiating an object in SomeFunction(), then pushing it to a list, passing by value. I can't recall how STL handles this.. but I think it just instantiates a new object and calls the copy constructor. So.... best case, you're calling a constructor to construct an object, calling a function that's passing (sizeof(String)) bytes onto the stack, then calling the constructor again to create another String object. Eek!

      Why not:

      Source Code

      1. ...::SomeFunction( const char *cResourcePath )
      2. {
      3. ...
      4. String* stringBuffer = new String(cResourcePath);
      5. ..
      6. ResourcePathList.push_back( stringBuffer ); // Image computer blowing up here....KABOOM!
      7. ...
      8. }


      And of course you'll have to remember to walk ResourcePathList and call delete on all the pointers, but now your performance won't take such a big hit. You're only shuffling around pointers instead of doing it by value. If this list is accessed in numerous places and can have members deleted by more than one object, you might actually want to use a smart pointer instead of a dumb pointer.

      _CrtDumpMemoryLeaks() is the CRT memory leak detector. I don't think it plays very nicely with vld. Try commenting out the vld include file and see if you still get that memory leak.

      Also, I assume vld isn't detecting it? The problem with using the CRT leak detector is that it's hard to tell what's leaking. As you can see, it's only giving you a memory address and dumping the bytes. That's why vld is my hero. ;)

      When you spend several thousand dollars on one poor sick little kitten, your love for kittens can no longer be questioned and you can get away with writing functions like KillKittens(). ;)

      -Rez

      PS: Is it just me, or are my posts getting longer and more rambly?
    • Definately longer and more rambly...

      Mine, on the other hand are growing shorter and sparser. I need to be careful because Kain is a scant few posts away from taking my lead (at one point, I had twice the posts of the next placed guy).
      -Larrik Jaerico

      www.LarrikJ.com
    • Um - I'm no OpenGL expert, but that code has four verticies - which make one quad.

      You need ten verticies to make a strip of four contiguous rectangles....
      Mr.Mike
      Author, Programmer, Brewer, Patriot
    • Originally posted by Larrik
      Definately longer and more rambly...

      Mine, on the other hand are growing shorter and sparser. I need to be careful because Kain is a scant few posts away from taking my lead (at one point, I had twice the posts of the next placed guy).


      I just checked and saw that I was in 8th place! Hey Mike, do I get a prize?

      -Rez
    • Originally posted by rezination
      Originally posted by Larrik
      Definately longer and more rambly...

      Mine, on the other hand are growing shorter and sparser. I need to be careful because Kain is a scant few posts away from taking my lead (at one point, I had twice the posts of the next placed guy).


      I just checked and saw that I was in 8th place! Hey Mike, do I get a prize?

      -Rez


      Howabout a bill for all of his bandwidth you've been using up?
      -Larrik Jaerico

      www.LarrikJ.com
    • ok, I understand what your saying now. (Taking a shower does help!)

      Brainfuck Source Code

      1. Before
      2. |
      3. y |----------+
      4. | |
      5. | |
      6. | |
      7. +------------>
      8. 0 x
      9. After
      10. |
      11. y |----------+
      12. | | |
      13. |-----+---|
      14. | | |
      15. +--------------->
      16. 0 x
      Display All

      Before I had one big quad, but I needed to create more quads. So with paper and pen in-hand I plotted some points and wrote some code. It works however, when I 'paste' the pic onto the big (or smaller) quads I get the effect I had before - no spotlighting effect. :( Its only when I turn off texturing I get effect I want.

      Is there a specific order of execution? Blending problem?

      I doubled checked the trans-matrix flux buffer and noted that it was off by .0027 so I realined the trans-ducent buffer to .23 then inverted the cozaxial adjunct so it was synchronized with the boron coupling. I'm not sure if that will help, but you never know.

      Update verions here This version has a console also. :)

      Sabrina.

      Source Code

      1. EngineLogo.Bind();
      2. glBegin( GL_QUADS );
      3. glNormal3f( 0.00, 0.00, 1.00 ); glTexCoord2f( 0, 0 ); glVertex3f( -1.10, 0.51, 0.00 );
      4. glNormal3f( 0.00, 0.00, 1.00 ); glTexCoord2f( 0, 1 ); glVertex3f( -1.10, -0.51, 0.00 );
      5. glNormal3f( 0.00, 0.00, 1.00 ); glTexCoord2f( 1, 1 ); glVertex3f( 1.10, -0.51, 0.00 );
      6. glNormal3f( 0.00, 0.00, 1.00 ); glTexCoord2f( 1, 0 ); glVertex3f( 1.10, 0.51, 0.00 );
      7. glEnd();
      8. EngineLogo.UnBind();
      9. glBegin( GL_QUADS );
      10. glNormal3f( 0.00, 0.00, 1.00 ); glTexCoord2f( 0, 0 ); glVertex3f( -1.0, 0.5, 0.0);
      11. glNormal3f( 0.00, 0.00, 1.00 ); glTexCoord2f( 0, 1 ); glVertex3f( -1.0, 0.0, 0.0);
      12. glNormal3f( 0.00, 0.00, 1.00 ); glTexCoord2f( 1, 1 ); glVertex3f( 0.0, 0.0, 0.0);
      13. glNormal3f( 0.00, 0.00, 1.00 ); glTexCoord2f( 1, 0 ); glVertex3f( 0.0, 0.5, 0.0);
      14. glNormal3f( 0.00, 0.00, 1.00 ); glTexCoord2f( 0, 0 ); glVertex3f( 0.0, 0.5, 0.0);
      15. glNormal3f( 0.00, 0.00, 1.00 ); glTexCoord2f( 0, 1 ); glVertex3f( 0.0, 0.0, 0.0);
      16. glNormal3f( 0.00, 0.00, 1.00 ); glTexCoord2f( 1, 1 ); glVertex3f( 1.0, 0.0, 0.0);
      17. glNormal3f( 0.00, 0.00, 1.00 ); glTexCoord2f( 1, 0 ); glVertex3f( 1.0, 0.5, 0.0);
      18. glNormal3f( 0.00, 0.00, 1.00 ); glTexCoord2f( 0, 0 ); glVertex3f( 0.0, 0.0, 0.0);
      19. glNormal3f( 0.00, 0.00, 1.00 ); glTexCoord2f( 0, 1 ); glVertex3f( 0.0, -0.5, 0.0);
      20. glNormal3f( 0.00, 0.00, 1.00 ); glTexCoord2f( 1, 1 ); glVertex3f( 1.0, -0.5, 0.0);
      21. glNormal3f( 0.00, 0.00, 1.00 ); glTexCoord2f( 1, 0 ); glVertex3f( 1.0, 0.0, 0.0);
      22. glNormal3f( 0.00, 0.00, 1.00 ); glTexCoord2f( 0, 0 ); glVertex3f( -1.0, 0.0, 0.0);
      23. glNormal3f( 0.00, 0.00, 1.00 ); glTexCoord2f( 0, 1 ); glVertex3f( -1.0, -0.5, 0.0);
      24. glNormal3f( 0.00, 0.00, 1.00 ); glTexCoord2f( 1, 1 ); glVertex3f( 0.0, -0.5, 0.0);
      25. glNormal3f( 0.00, 0.00, 1.00 ); glTexCoord2f( 1, 0 ); glVertex3f( 0.0, 0.0, 0.0);
      26. glEnd();
      Display All

      The post was edited 1 time, last by Sabrina ().