Author Topic: Defining/using Open-GL Camera paths  (Read 25070 times)

0 Members and 1 Guest are viewing this topic.

Offline benny!

  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4384
  • Karma: 228
  • in this place forever!
    • View Profile
    • bennyschuetz.com - mycroBlog
Re: Defining/using Open-GL Camera paths
« Reply #20 on: September 08, 2007 »
Awesome. Well done.
K++ for sharing code !!!
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won:

Offline da_fatstuff

  • C= 64
  • **
  • Posts: 38
  • Karma: 16
  • Stupid is forever, ignorance can be fixed
    • View Profile
Re: Defining/using Open-GL Camera paths
« Reply #21 on: September 08, 2007 »
Thanks everyone - all very kind.

Textures - my next step is to generate the towers using cubes of a set size then pasting in-code generated (basic) window-like texture(s) on each block's sides (probably not in the next week though!)...I'll also probably try something similar with the grass, and make the top block a different shape - to make that slightly less blocky looking.  Also got to have some better-looking "FATSTUFF" object too, but some kid of texture on that will help that too if I can't think of anything else ;)

Music - erm - I have absolutely no talent in composition but I think I'm going to do something simple based on the FuxPlux engine (Pouet link I posted earlier) but stripped down to ensure it goes in <4k with the other stuff...I might even make the music fractal to keep a theme going (really it'll be because the computer will do a much better job than me!)...have to see how many bytes are left once it's pretty to see my options really.


Anyway - thanks again for the feedback - really is appreciated!

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17414
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Defining/using Open-GL Camera paths
« Reply #22 on: September 08, 2007 »
Fractal music would indeed carry on the theme :)

What are your plans for this 4k? Are you just going to release it generally or do you want to see if you can get some money for it by enering it into a competition at a scene party?

Standards for 4KB's are pretty high but if you chose the right party and with some nice textures , objects , camera paths , lighting and storyboard you could have a serious chance of winning something.

Also if you wanted to keep the fractal theme going, there are certainly lots of options you could use to generate fractal objects to live in your 4kb world :)

You are certainly not all that far away from something like this;

http://www.intro-inferno.com/production.php?id=216

Which you can achieve now with the right objects, colours, camera paths etc..
Shockwave ^ Codigos
Challenge Trophies Won:

Offline da_fatstuff

  • C= 64
  • **
  • Posts: 38
  • Karma: 16
  • Stupid is forever, ignorance can be fixed
    • View Profile
Re: Defining/using Open-GL Camera paths
« Reply #23 on: September 08, 2007 »
No intentions other than as a learning exercise for me, and that hopefully something in there might be useful/inspiring to someone else.

However, I do want to try and polish it as much as possible in 4K, and when/if I get it done I'll see what you guys think about needed improvements then see what's happening at the time - if there's an appropriate competition I might throw it in, but most likely I'll just showcase it   :-\





Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: Defining/using Open-GL Camera paths
« Reply #24 on: September 10, 2007 »
Very impressive for a couple of kb.  Nice work with the camera splines :)

BTW, correct place to get all these d3dx9_??.dll files is from
http://www.microsoft.com/downloads/details.aspx?FamilyId=2DA43D38-DB71-4C1B-BC6A-9B6652CD92A3&displaylang=en
It will automatically patch your DirectX install up to the latest version.

Jim
Challenge Trophies Won:

Offline da_fatstuff

  • C= 64
  • **
  • Posts: 38
  • Karma: 16
  • Stupid is forever, ignorance can be fixed
    • View Profile
Re: Defining/using Open-GL Camera paths
« Reply #25 on: October 20, 2007 »
Hi again,

I haven't been able to spend much time on finishing this (usual real-life stuff getting in the way that we all endure ;) ) but I've added some bits:
  • (very) basic textures on buildings/grass/water
  • rooftops/mounds
  • waves...well water movement, hardly realistic motions!
  • erm...a scroller...always a scroller...but I've implemented it differently so it's staying in for now ;D

Anyway, the purpose of this prog for me was/is as a learning exercise, and there's been stacks of C++/OpenGL learning been done which is why it's taking so long...one such learning curve is that I OO'd it then eventually found that new/delete and memalloc/free link to the MSVCRT.DLL...so de-OO'd it and used GlobalAlloc/GlobalFree instead to avoid the __chkstk errors from my huge static arrays at the time (I haven't implemented my own new/delete routines yet)...which brings me to an issue I'm currently stuck on, and I'm really hoping someone here has some suggestions...

...when I enable the VC 2005 size optimizations, my textures go wrong (compare debug and release EXEs) - they look different...if I make the debug version use the size optimizations it also looks wrong, so I have tracked it to the optimizations specifically.  The textures are created in the Shapes.cpp's InitTextures method and are stored using pointer arrays allocated using GlobalAlloc, extract here:

Code: [Select]
void InitTextures() {
GLubyte **textureStore = (GLubyte**)GlobalAlloc(GPTR,TEXTURES*sizeof(GLubyte*));
for (int t=0;t<TEXTURES;t++) {
textureStore[t] = (GLubyte*)GlobalAlloc(GPTR,TEXTURES*TEXTURE_SIZE*sizeof(GLubyte));
}
...
glGenTextures(TEXTURES, textureIDs);
for (int x=0;x<TEXTURES;x++) {
glBindTexture (GL_TEXTURE_2D, x);
// Texture repeats over both S & R axis so out of range co-ords still get textured
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, TEXTURE_WIDTH, TEXTURE_HEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE, &textureStore[x][0]);
}
// Free dynamic array
GlobalFree(textureStore);
}

I've tried giving textureStore broader scope by defining it out of the method, also removing the GlobalFree altogether (as in attached source) without any difference...mainly because I figure that if the optimization is affecting it then maybe my texture memory is being seen as available and something is stomping over it, but the corruption seems consistent which kind of shoots that theory really...maybe the optimizations use different data types under the hood yielding different values or something like that?

BTW this is regardless of whether I use Crinkler or not so it's not the compressor trashing data or anything like that.

Anyone come across stuff like this before?  I'm away from my computer for a week (not sure how I'll cope) - but thanks in advance for any ideas if you have any!

Correct kind of view (without optimization):


Wrong kind of view (with size optimization):


Apart from this issue the code itself seems to work fine, albeit quite hard going on the CPU/GPU, and I've put as many comments in as I can - in case anyone sees something they want to try and improve on in their own intros...I'm at the 4k limit, so I'll have to start making the code optimizations (i.e. will be unreadable) now to fit stuff in  ::)

PS Shockwave - cheers for the mention in the gears intro - I was/am totally gobsmacked!

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: Defining/using Open-GL Camera paths
« Reply #26 on: October 20, 2007 »
The problem is GlobalAlloc doesn't return a pointer to memory, it returns a handle.
To get a pointer you must do
Code: [Select]
HGLOBAL global = GlobalAlloc(flags, size);
char *ptr = (char *)GlobalLock(global);
...
GlobalUnlock(global);
GlobalFree(global);
I think you're been fortunate it hasn't bitten you in the debug version.

Jim



Challenge Trophies Won:

Offline taj

  • Bytes hurt
  • DBF Aficionado
  • ******
  • Posts: 4810
  • Karma: 189
  • Scene there, done that.
    • View Profile
Re: Defining/using Open-GL Camera paths
« Reply #27 on: October 20, 2007 »
Jim, dafatstuff isnt the only one who has been fortunate. I must learn to RTFM. Thanks Jim. K++ , again!
Challenge Trophies Won:

Offline da_fatstuff

  • C= 64
  • **
  • Posts: 38
  • Karma: 16
  • Stupid is forever, ignorance can be fixed
    • View Profile
Re: Defining/using Open-GL Camera paths
« Reply #28 on: October 20, 2007 »
Cheers - you're a star - I KNEW you'd know what the heck I was doing wrong!

I'll change it when I get back, so fingers crossed...might be just one of many bugs in there of course ;)
« Last Edit: October 20, 2007 by da_fatstuff »

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17414
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Defining/using Open-GL Camera paths
« Reply #29 on: October 20, 2007 »
Yep, you were right, it is pretty intensive! The release version wouldn't run but I got the debug version to work, it's pretty cool actually :) And it's always my pleasure to mention the people I know in my greets when I can ;)

K+ (for once again uploading your whole project)
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2757
  • Karma: 493
    • View Profile
    • https://www.rbraz.com/
Re: Defining/using Open-GL Camera paths
« Reply #30 on: October 20, 2007 »
da_fatstuff: nice work, a bit slow when the view is far.

Btw, why didn't you use an array (buffer) for your textures ?  I gues you can save some bytes instead allocating memory with "GlobalAlloc".
Challenge Trophies Won:

Offline benny!

  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4384
  • Karma: 228
  • in this place forever!
    • View Profile
    • bennyschuetz.com - mycroBlog
Re: Defining/using Open-GL Camera paths
« Reply #31 on: October 21, 2007 »
@da_fatstuff:
Amazing work !!! I really like it. Keep it up. (And thx for greeting).

K++ for sharing code !!!
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won:

Offline da_fatstuff

  • C= 64
  • **
  • Posts: 38
  • Karma: 16
  • Stupid is forever, ignorance can be fixed
    • View Profile
Re: Defining/using Open-GL Camera paths
« Reply #32 on: October 29, 2007 »
Thanks all, I appreciate the responses!

RBRAZ - I originally used a static array buffer, but then I used 64*64 resolution textures and that caused a __chkstk link error because I'd exceeded the stack allowance with the static arrays (I think this is what you meant, but I'm not up on the C++ terms yet)...

...as I'm now using lower-res 16*16 resolution textures you're right in that the GlobalAlloc and dynamic arrays aren't essential...so I've reverted to static arrays, along with removing the OO code and other stuff that (I think) wasn't being used (project attached here with these changes)...and I still have the same texture problem, still only with the MS VC size-optimized builds...it's really odd, so I'll be spending a lot of time reading up on what this setting really changes (any knowledge anyone has about it is welcome!).

BTW I notice my GLU32.DLL has a dependency on MSVCRT.DLL, probably because it's installed with MS VC++, but is there a release that doesn't use MSVCRT?  I tried to download it from OpenGL instead, but it seems to be just specs and 3rd-party libraries that I can see :'(  I guess it's irrelevant to 4K anyway, because if GLU is accepted, whatever DLLs it uses are accepted too...maybe...

BTW2 I'll try to do something with the scroller so it's not so far away and set the view distance to something more sensible to speed it up...I might pre-render each 3D char with proper lighting etc and capture them as 2D images to use in ortho blended on top of the Fractaland as a standard scroller...depends how many bytes that change uses :-\ not an original concept, but all good fun to play with...far more interesting than the day job ;)



Offline taj

  • Bytes hurt
  • DBF Aficionado
  • ******
  • Posts: 4810
  • Karma: 189
  • Scene there, done that.
    • View Profile
Re: Defining/using Open-GL Camera paths
« Reply #33 on: October 31, 2007 »
Hi there,

there are loads of ways to get this smaller...piece by piece, which will help you squeeze in a synth. I think you could get this down by 0.5k easily in time. The biggest one I can spot by eye is the  camera_moves[]. At first glance it seems the entire array could be into a range of 0..255. This means it could be stored as a byte array. Also its unlikely you will visually see the difference between 5.1 and 5.3 (as an example) so approximating both to 5 wont hurt. I didnt believe this until I tried it with a city scape in 4k. 0..255 is more than enough for almost any stored data (models, camera paths, timings etc).

Chris

Challenge Trophies Won:

Offline da_fatstuff

  • C= 64
  • **
  • Posts: 38
  • Karma: 16
  • Stupid is forever, ignorance can be fixed
    • View Profile
Re: Defining/using Open-GL Camera paths
« Reply #34 on: October 31, 2007 »
Hi Chris,

Thanks for the tip!  The camera_moves are multiplied by WORLD_SCALE, so a position difference of .2 is actually .2*20...but you're absolutely right - those bytes saved (and others like that) are going to be needed for the synth and hopefully other things...all good learning for me (I'm a Java programmer who does non audio/visual stuff by day :) )

Thanks again!

[Edit] I just tried the camera_moves change, and that change alone saved 1020 bytes in the (uncompressed) debug version, and even 61 bytes in the (compressed) Crinkler release version - so I'll definitely be replacing floats with smaller types wherever possible, as they'll all add up.  I'll also replace the unchanging calcs with constants once I've got the finished app in place - at the moment it's easiest to leave them in so I can change stuff easily.
« Last Edit: November 02, 2007 by da_fatstuff »

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: Defining/using Open-GL Camera paths
« Reply #35 on: October 31, 2007 »
Code: [Select]
glGenTextures(TEXTURES, textureIDs);
for (int x=0;x<TEXTURES;x++) {
glBindTexture (GL_TEXTURE_2D, x);
note that glGenTextures doesn't necesarily return 0->TEXTURES-1.
Should be:
Code: [Select]
glBindTexture (GL_TEXTURE_2D, textureIDs[x]);
Don't know if that fixes it, I'm in a bit of a rush  :-\
Jim
Challenge Trophies Won:

Offline da_fatstuff

  • C= 64
  • **
  • Posts: 38
  • Karma: 16
  • Stupid is forever, ignorance can be fixed
    • View Profile
Re: Defining/using Open-GL Camera paths
« Reply #36 on: October 31, 2007 »
I appreciate you looking at it Jim - all ideas are very welcome, as I'm running out of them  :-\

I tried setting all glBindTexture to use the value from the textureIDs array, as well as the specific one you highlighted, but alas no difference in the output (I've kept these in though because you're still right)...

...I've been trying to find out why size-optimization (/O1 and/or /Os) specifically should cause this texture corruption, but no joy yet.

A version of the Intel compiler for CE had an optimization problem with local arrays >3.5KB and a size not divisible by 4, so I set the texture count to 16 in case VS2005 had a similar issue, but it made no difference...my gut feel is it's going to be something like this, just because it works ok without size optimization, but I'm aware of my inexperience as the most likely cause!

FYI I also found someone having a similar problem with OpenGL on a Mac, but alas a solution wasn't posted:
http://lists.apple.com/archives/mac-opengl/2006/Dec/msg00013.html

I've tried it on AMD with NVidia FX5500 and Intel with ATI X600 and it displayed the same issue, so it's not CPU or driver-based issue...oh and I reinstalled/updated VS2005 out of desperation too  :)
« Last Edit: October 31, 2007 by da_fatstuff »

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: Defining/using Open-GL Camera paths
« Reply #37 on: November 01, 2007 »
More than likely you've done something daft  :o.  Often when this happens it means that you've either crapped over the stack or you've not initiliased something - in the debug version the stack might contain all 0s, in the release it's been optimised into registers which might contain anything.  The last time I found a bug in Microsoft's compiler was in 1998 and I was using VC6 without any service packs.  Sorry, but right now I've not had a chance to look at your code in any great detail.  I checked the texture array and you didn't seem to be overrunning that - you threw me to start by using y for the horizontal and x for the vertical in a loop somewhere though :D  x*width+y just looks a bit too funky!

Jim
Challenge Trophies Won:

Offline da_fatstuff

  • C= 64
  • **
  • Posts: 38
  • Karma: 16
  • Stupid is forever, ignorance can be fixed
    • View Profile
Re: Defining/using Open-GL Camera paths
« Reply #38 on: November 01, 2007 »
Well, if it's a choice between me or Microsoft doing something daft, then I KNOW it's me  :D  Although I think the Intel compiler error I mentioned was surprisingly from last year.

It does happen in Debug mode if I enable the size optimization, it's just the data in the arrays is hard to spot by eye when it changes...hopefully the Watch can watch for changes in it (will check this out) so I can see what's corrupting it.

BTW the x and y confusion is probably where I've been moving this code around to try different things and that stuck by mistake - I'll clean that one up  ;)

[edit] I think that this was my 25th post so I can finally give you karma for the tons of help!

[edit] Damn...debugging is out of the question because the optimization screws the symbols...but one thing I can see is that the texture array is being populated with duff values when run under size optimization, rather than being corrupted afterwards...the 'colMap' array that the textures derived their values from is being populated with 0's when size-optimized for some reason, and the textures still look the same when I overwrite values in that array anyway...time to look at COD outputs :'(
« Last Edit: November 02, 2007 by da_fatstuff »

Offline frea

  • C= 64
  • **
  • Posts: 61
  • Karma: 2
    • View Profile
Re: Defining/using Open-GL Camera paths
« Reply #39 on: November 01, 2007 »
BTW I notice my GLU32.DLL has a dependency on MSVCRT.DLL, probably because it's installed with MS VC++, but is there a release that doesn't use MSVCRT?
google freeglut or glut windows, first or second hit is what you need.
Nananan.