Dark Bit Factory & Gravity
GENERAL => Projects => Topic started by: TinDragon on March 13, 2009
-
After seeing Zawrans progress on making an opengl engine and watching Shockwave's more recent intros which also use opengl I decided it might be a good way to get myself coding again by also having a go at making a simple opengl engine. After some chatting to Zawran and some messing around with bmax's types to get a feel for the way they work, which to be honest is very much like a c++ class in my view, I made a start on my engine attempt.
So I would like to present my 4th test, the engine itself handles some basic information about entities such as position and rotation but I havent full implemented the drawing side of the code in the engine so I am doing that outside the engine but hope to have that part going soon so everything will be drawn with a simple renderworld type command. It uses displaylists to store an entity's mesh, at the moment it has cube and plane primatives. Next I need to get lights in there but for an afternoons work I am happy :)
Pic and demo with erm bodged in texture support attached :D
-
Works like a charm on my computer. And great to see you at the code again :)
-
The image looks good but I can't get the demo to run here. :(
When I double-click the exe a window appears & then quickly disappears.
What screen resolution does the demo use because I know my graphics card doesn't like some.
-
It runs in a window which looks like its 1024x768.
[edit] forgot to mention, that if you could post what graphics card you have and you if its on XP or Vista, that might be helpful.
-
yes its using 1024x768 res in a window, and ofc needs opengl but that should be on any xp or newer machine, I am on vista 32bit myself. Not sure why it doesnt run. Hopefully some more people will try it and we can narrow down the probelm.
-
Works fine here, around 2850 fps
-
Thanks rbz, and wow what gfx card are you running, I know mine is rather low end geforce 8series but I am only getting the 600 in the screenshot. Havent checked the engine out on my XP machine with a radeon but that one os even lowend lol.
-
If it helps any, I'm running Vista on a laptop using Mobile Intel 965 Express Chipset for graphics.
I was wondering whether or not I was missing any dlls so I tried running Dependency Walker on the exe & it said I was missing IESHIMS.dll.
Apparently it's a dll related to Internet Explorer & I'd recently installed IE8 Beta.
So I uninstalled it but still couldn't get the demo to work, sorry.
-
I have no idea why it would say it needs anything to do with internet explorer, its a simple blizmax exe using opengl, if you can run zawrans code then you should be able to run mine, its the same language ??? I really have no idea why it isnt working for you. Only thing I can say is maybe lack of opengl support on the laptops video drivers but I doubt that to be honest, especially if you can use zawrans exe's.
-
...and wow what gfx card are you running...
Tested it on my Geforce 8800 + Core2Duo 2.40Ghz.
I have no idea why it would say it needs anything to do with internet explorer, its a simple blizmax exe using opengl, if you can run zawrans code then you should be able to run mine, its the same language ??? I really have no idea why it isnt working for you. Only thing I can say is maybe lack of opengl support on the laptops video drivers but I doubt that to be honest, especially if you can use zawrans exe's.
That's weird indeed, the problem could be with your "pixel format" setup, can you show us how you are doing it ?
-
I am not setting the pixel format up at all rbz, I am using blitzmax GLgraphics command to open the screen which as far as i am aware does all the needed stuff like that, same as I believe zawran and pixeloutlaw are probably doing in there bmax opengl programs.
On the engine front, reworked my code so that meshs are seperate to the entity and only reference by it, makes no visual difference but the memory footprint shrinks and it also ment I can now have different types of mesh other than displaylists. This means I can also look at getting some form of model loader into it, will have to reference Zawrans examples and see what I can come up with, but first I need to add textures to the system and get them assigned to entities since at the moment I am just adding a global texture used on everything.
Here's a shot anyway showing my first experiemt with a light source.
-
Here's a new test version of my progress so far, textures are now set to entities rather than global so now more can be done as each entity can have its own texture, the light source is still seperate to the rest of the engine but thats my next target, a system to create position and deal with lights. Then on to get some interesting geo in ;D
cheers
Jon
-
Your test runs smooth and fast on my system. Good to see you are getting further with this. I like the texture as well :)
-
Totally smooth, about 1,000 fps, nice to see you coding again.
Seems to me like you are using an unusual method of delta timing, are you measuring the frames drawn over a second?
-
I am calculating the delta like this
fpsdelta=(60.0/Float(iFramecounter_framerate))
fpsdelta is a float and all the values its used with are also floats, so the rotation is increase 0.5*fpsdelta with the desired rate being 60fps, I know my code to calculate the acutal frames per second is correct as it matchs fraps 100% for value. Are you getting strange results or something? Only thing I did do is set the fps to 900 at startup so there's not a sudden jump from superfast to slow rotation, but after the first fps value is actually calculated it should be pretty smooth unless you get big jumps up and down in fps rapidly
cheers
Jon
-
It works fine unless the window is moved, which makes the speed increase for up to half a second.
You could stop that happening if you just measure the time that the last frame took to draw and based your calculation on that, mind you there really is nothing wrong with the movement, it's all nice and smooth Jon.
-
AH I have never actually moved the window when its been running, that is likely something to do with bmax's handling of events, will have a look see if there's some way to monitor that but it might be part of the gui module that i dont have. Still if thats the only hicup I can live with it for now :D
My next hurdle is working out a way to create and store the normals for objects so that opengl's light behave correctly on them, its easy for the cube and plane as i just set them in the displaylist, but other geo is going to need me to work them out and store them, I need to work out a method of storing them that fits into my mesh storage method for none displaylist objects, will be fun as I didnt consider the normals when i built the types and lists at the base of the engine ;D
-
AH I have never actually moved the window when its been running, that is likely something to do with bmax's handling of events, will have a look see if there's some way to monitor that but it might be part of the gui module that i dont have. Still if thats the only hicup I can live with it for now :D
What happens is that the window stops being updated while it is being dragged and because the FPS is recalculated (I am guessing) every second or so, this is what causes it.
The solution is to calculate the delta value each frame.
Leaving it as it is would not be a problem most of the time, if windows was doing something in the background though it could mess it up quite badly as it is right now.
I used a similar timing routine to this myself some time ago, after complaints from some people I changed it to calculate delta per frame. I don't think it's Bmax's event handling that causes the problem here, it's that you are not calculating the delta value each frame.
-
Could you give me a simple example of what you mean Shockwave, I have a version of freebasic installed if you want to show a code example. Timing routines are something that I havent looked at in awhile, most of my old blitz stuff was fullscreen 640x480 using my current method, but if there's a better approach I am interested in it :)
-
Sure, try something like this;
DIM SHARED OLD AS DOUBLE
DIM SHARED DELTA AS DOUBLE
DELTA=1
WHILE (ESC NOT PRESSED)
OLD=TIMER
DO STUFF
DO MORE STUFF
DO EVEN MORE STUFF
SLEEP 1 (GIVE SOME TIME BACK TO THE SYSTEM AND ENSURE DELTA >=1)
DELTA = (TIMER - OLD) * SOME_FACTOR
WEND
END
The idea of this is to use the variable "delta" as a factor to multiply all movement by so if the last frame took a while, delta would be higher so the next frame needs to move more, if it's running really fast it's cool too because Delta is always in the correct proportion.
-
Your example is basicly delta timing, thats what my code actually does but linked to the frame update rate, and it then changes all movement/rotation * that delta amount. The problem with moving the bmax window is that while your moving it the code gets paused but the timers dont so it thinks its taken longer to render the frame than it should, it then changes the delta based on this time and takes approx 1second for the timer check to catch back up to the actual time.
Now I guess I could uncouple it from the frame rate and use instead some realworld length of time but again it would likely go out for a second due to how the bmax window seems to behave, would depend at what point bmax paused the code if it was just after you set OLD=TIMER and you moved the window for awhile then the timer is going to have increased alot so when you do the delta calc its going to surely still be wrong until you loop around next, but it wouldnt I guess take the 1second my fps based code does.
-
Your example is basicly delta timing, thats what my code actually does but linked to the frame update rate, and it then changes all movement/rotation * that delta amount. The problem with moving the bmax window is that while your moving it the code gets paused but the timers dont so it thinks its taken longer to render the frame than it should, it then changes the delta based on this time and takes approx 1second for the timer check to catch back up to the actual time.
Yes, this is what I described as your problem pretty much.
My solution sorts it out, it's worked in everything I have released for the last 2 years anyway, and in productions by several other people I gave the same advice to.
RBZ did a nice example somewhere as well, I'll try and find it for you.
-
Well if you would like to try this version out I think it should now behave more correctly when you move the window with out speed up or slowdown and you can toggle vsync with F, its off to start with. I seems to work at my end, not sure how it would do for any form of music syncing but I rarely do that anyway lol
-
Perfect.
-
If its any concelation, on my spec ( see signature ) i get a respectfully 92-95 fps.
Welldone on the Z-Ordering / Sort too.
-
Welldone on the Z-Ordering / Sort too.
Opengl does all that for you Clyde :)
-
Looking good!
OpenGl is really great to know and use.
-
Wow Clyde thats actually very suprizing, I would have thought eveyone would get a couple hundered fps on such a simple scene even on very old gfx cards, Its not like its a doom3 level engine ;D How does zawrans code run, tho not sure he has fps display atm.
On the actual engine front, not made any progress at the moment as I am looking to redesign my mesh handling so that I can store normals for lighting, the simple cube and plane displaylists have them pre set since there easy but I need a way to create and store them for models that are loaded in etc. and my current code doesnt offer a way to do that. But it should hopefully just be a case of reworking the mesh type's methods once i work out a sensible structure for the information :)
-
Just saw the whole thread and downloaded all releases
of the last days. Runs very smooth here. Very well done!
-
Thanks Benny, it came together very well up to this point but I have hit a snag with opengl lighting, it works fine if everything is textured or if everything isnt but I am getting probelms when i try to mix textured and none textured, I probably need to change certain state variables and such but every exmapl I have found makes my textured objects either seem to go full bright or take on the color of the non-textured object. :'(
Still I have my new mesh setup ready to go so now I can try to get a model loader going and thanks to zawrans posts in the blitz forum I have somewhere to start :inspired:
-
The problem with moving the bmax window is that while your moving it the code gets paused but the timers dont so it thinks its taken longer to render the frame than it should
That can be a problem. The OS might go off for a sleep, or even you might implement a pause button.
One thing you could do is not only have a 1ms fastest rate, but a 30ms slowest rate, so even if everything gets delayed for a second or two, you just insist that it ran at 30fps.
delta_t = max(1,min(delta_t,30))
Jim
-
At last I finally get to see it. :updance:
Over the weekend I got sick of Windows Vista so I tried installing my XP recovery disks on my Vista computer.
Surprisingly it worked & after a few hours of tracking down the relevant hardware drivers, I'm now running XP.
I was getting about 170 FPS from my Intel card. O0
-
Glad to hear you got it going, must have been some vista opengl driver problem with the intel graphics chip.
On the engine front I have reworked my method of storing mesh data with some handy tips from zawran on certain aspects of bmax, the engine was back to the same level within an hour of recoding the needed parts, so I then decided to retry adding a .obj loader based on zawrans code, fun and games have followed with me recoding whole sections and trying different things as i couldnt get models to display correctly or in some cases the files to read in as expected, turns out there are versions of the .obj file that are not standard and this caused me some headaches, but I couldnt load a file zawran could, which is wierd when the actual part that reads the data from the file is the same. After some tweaking it started to load the files I have been getting out of a 3d model converter i got off the net but it appears UV and normals are not working as intended, but I present a screenshot for those following the thread. Its a taxi model with its texture but as you can see its erm borked, still atleast I can get some different geo to a cube in :D
Cheers
Jon
-
This is both good and bad news to me. Its bad news because it shows that my loader function does not work as intended, but its good news because it shows that my loader code does not work as intended :)
I will work on the code the next couple of days to see if I cannot get this working as I am going to be needing a working model loader soon.
-
Looks to me as if some triangles are facing the wrong way.
-
The triangles were actually drawn correctly untextured it looked fine ;) , some look wrong due to the black parts of the texture, zawran got the taxi to load and display textured correctly in his engine and we discovered that the format uses an index UV coord set, so were i I thought it loaded in the vu's in the same order as the vertex's it doesnt, which is why the texture UV's are out, but we did discover that some programs dont export the .obj files as the format is ment to be and skip parts, making them not work correctly with the loader so zawrans going to work on it some more. For me its going to need some heavy reworking of the loading code to cover the index'd textures which at the moment I am going to skip, instead I am going to write a little app in b3d to export a model's data to a file in the order I want it so that I can get some models in and check my texture code is working as intended, then I can get lights going and work on other features including model loaders, but I kinda need to see that my code is working right or it will always seem like a loader is broken if its an error else where :)
Will hopefully post up a working spinning textured model exe later today :)
-
WooT, we have a correctly texture model in the engine :updance:
After coding a little blitz3d program to load in a model and export it to a binary file listing all vertex and face data needed in an order that I picked, then coding the bmax loader for it, I finally got the taxi model in and textured correctly, its a great feeling when something actually works and from this I can tell that my setup for the vertex uv's is right. Now to work on other features, not sure what to tackle next but I am just happy to have gotten this far ;)
Attached is a screenshot and an exe for those interested in testing, F switchs vsync on/off, its off to start with.
Cheers
Jon
-
Well for the success of getting the model in and drawn another error appears, I didnt notice it at first but if you look the taxi and number plate writting are backwards, the realy craze thing is after looking over my code and the exporter, and how b3d handles models, the model should be inside out as b3d uses CW poly winding and my engine uses opengl's CCW :S
I dont know how to fix this and am starting to think I should just scrap this altogether :'(
-
Runs very smooth here. And even smoother with vsync off.
Nice model btw and good work!
-
the model should be inside out as b3d uses CW poly winding and my engine uses opengl's CCW :S
I dont know how to fix this and am starting to think I should just scrap this altogether
I strongly believe you just have one axis of your vertex-coordinates flipped.
There's no correlation between polygon-winding and texture-orientation.
-
Jon had sent me his model conversion code earlier tonight and based on what Hellfire writes I took another look at it. Once I reversed the z coordinates, the z normals and the winding order of the faces, then his model loads correctly. B3D has these things reversed compaired to opengl. I have sent him the updated conversion code and he will probably be able to confirm that this works tomorrow. I will still work on getting my .obj model loader working correctly since Jon found that there were some issues with it.
-
It's looking great :)
Nice one!
-
:updance:
Just got zawrans email with the changes he made to the conversion code and it does work, the taxi is drawn correctly and textured correctly, so a big thankyou to zawran for looking over my code, and a big thanks to hellfire who pointed zawran were to look. :cheers: to you both, you made my day :)
-
No problem, I am happy that it finally works.
-
Well done Tin Dragons on your development. Sorry for being a nosey sod, but do you have plans beyond the engines, or is it early days or going to be a surprise. I like surprises :D
-
Well my goal is to one day have a powerful graphics engine that can do all the fancy eyecandy, but I dont expect to get there on my first go. Much like ID didnt go from castle wolfenstein straight to Doom3, I plan on building a small engine and then slowly work up to a powerful one as I learn how all these things work together. At the moment with this engine I am learning how opengl works, how blitzmax differs from b3d, how to do things in a more OOP style and of course how to build an engine.
I dont know how far this will get, my approach is build it in sections until it becomes difficult to add something new. So far the only real problem I have encounter is understanding how opengl lights work, which I now sort of get but need to experiment more with, and model loading, which is more due to there being so many formats and variations within those formats as well.
I would say that what I have as far as entity/mesh control goes that the engine could do any of the demos/intros a version of the ttdvectorlib did, which itself is a good basic 3d engine but of course software rendered. It would of course surpass the amount of polygons that could be render and the framerate due to hardware acceleration. It also handles textures, something we never got in the old lib. Only area it might currently struggle is glenz type effects since I havent coded for them ;)
-
Well my goal is to one day have a powerful graphics engine that can do all the fancy eyecandy, but I dont expect to get there on my first go.
You'll quite certainly trash the first 2-3 engine-designs when at some point handling different rendering-methods and -passes became just a big and buggy mess of special-case handling.
But don't worry, it's always that way with incrementally growing projects and it gets better with every try ;D
-
Well it appears my approach is already different to zawrans in some areas, he also has some features in, such as multi texturing, that I dont yet, will be interesting to see were we both end up. :)
[EDIT] New exe attached, correct texture display in this one with 3 versions of the car spinning independantly :)
-
It looks great, and congrats on your progress. :carrot:
-
Well some small progress on my 3d engine, created some code to make a multipart mesh surface, which at first wasnt working right but with some changes and a nudge from zawran pointing out were I had missed calculated a variable it worked as intended, then I added code to turn one of my surface type meshs, which are rather slow to render when there's alot of tris invloved, into a displaylist to improve rendering speed. Having got that working I then set about making a terrain mesh generator from a heightmap and have that coded in as well. So here's a little test showing a terrain created from a heightmap and then textured with a colormap. It runs fairly well here so hopefully it will for others :)
cheers
Jon
-
Nice looking terrain you got there :) Congrats on getting it working, you are making progress every day, its inspiring.
-
Neat terrain really, I got around 880 fps on GF 8800 GTS
-
Was talking to some friends and they asked me about what sort of game I want to make with my engine, while I have no idea tbh but I thought it might be nice to get an oldskool doom1 style camera going so I had a quick mess about this afternoon and made this little test, no collision checks yet but you can rotate and wlk about in the 3d cube maze thing which has a floor and ceiling, lighting isnt that hot at the moment but it was more a little test of my camera/movement code :)
Feedback welcome:)
-
Not the most interesting maze, but I am sure you already knows that :) It seems to work ok, although the turning speed is on the slow side, it would be ok to increase that. Since all walls are done using cube shapes, with the same width and length, you could probably get away with using a two dimensional array for storing the location of the walls and then move the player around in that array and get you wall collisions from checking against the array and prevent the player from moving into a wall. And being that it is made to be like the old games, it would be an acceptable control scheme I would think.
-
No its not the most interesting maze but it served its purpose for testing the camera, I had some difficultly at first, rotating the view was easy but then moving in the direction your facing was more difficult to get right than I thought, but with some correct sin/cos maths I got it going :) I am probably going to setup my camera class to have different modes, such as normal & fps, then when I send rotation or movement information into it the camera either acts like in this demo, or it acts on just position and rotation so it sort of orbits a scene. I should make it possible to do some scripted scene fly thru's and stuff like that if I do it right :)
Cheers
jon
-
It sounds promising, and something like fly throughs would be cool for demos as well. I'm looking forward to see how this part of you engine comes along.
-
Had a little mess around this afternoon with a couple things in opengl and got a reflection going, It's given me a couple thoughts about doing an update to one of the routines in an old ttd demo. Its been awhile since I have done any sort of demo/intro and it might be nice to see what I can currently get out of my engine beyond a few tests. In the meantime here's a shot of the reflection effect with some sphere :)
Posted it because it reminds me of some of the first raytraced pictures I made on the amiga, use to wait for ages for renders to appear back then ;D
-
It looks good, are you using the stencil buffer?
-
Nope its not using the stencil buffer, I am doing it the same way blitz3d does its mirror plane entity ;)
-
Well it looks great no matter how it was done :)
-
Zawran, he's probably used Glscale to flip the y axis to render the reflection, it's a fast and very common way of rendering reflections in OpenglRender the inverted scene, flip the Y axis, enable glblend, draw the floor, disable glblend and then render the other half of the scene.
Blitz3d uses directx but it probably does it the same way.
Stencil buffers are more useful for things like shadows and that kind of stuff.
-
he's probably used Glscale
Ah yes ofcause, don't know why I didn't think about scaling. That would be the easy way to do it :)
-
Yep thats how I did it, b3d's mirror plane command does the same thing, it renders the scene upside down like that. Would be cool to get the sphere's reflecting the floor back, could use a cubemap i think for that bu not got that deep into special effects yet :)
-
Not much engine progress to report at the moment, havent added any new features but have cleaned up some of the code. Have been messing around with lights but not happy with the results at the moment. Having hit a bit of a wall with things not working how I expected I have taken a side step and much like zawran, after we had chatted about it I also started to code a GUI for use with my engine, while its not needed for demos it will be useful for editors and since i dont have the maxgui module it would be fairly hard work to use the windows GUI as I would have to code all the binding etc. myself and I am not that sure how I go about that ;)
So far I only have basic window drawing and dragging coded, windows can be skinned and can be setup to have features like status bars and each window can be set to be dragable or not. Next feature is to add some gadgets so the windows can actually do something. I am not looking to make this a full on GUI so I will only be adding features to enable me to make the tools I want. Anyway here's a screenshot of some windows over a 3d backdrop, it runs fast enough at the moment but I need to get the font drawing to the window rather than over it to reduce redrawing of none changing stuff.
-
Looks promising!
A useful gui-item would be some sort of list or tree to hold the objects of your scene.
Is it possible to resize windows?
If so, how are you going to distribute the new space along items inside the window?
-
windows arent resize-able at the moment, Not sure if I will implement that or not, depends if anything I make needs it I guess :D
I dont really know if I will need the windows to be moveable but since I hadn't coded that type of GUI element before I thought what the hell and added it. I could likely make editors with fixed buttons and gadgets but I wanted to have a go at making something alittle different to what I have done in the past, I have never coded a windowed GUI as such, so its an experiement as much as anything.
-
Wonder if you folks would mind doing a little test for me, I have recoded the drawing part of my gui system after having some problems with the old method and have changed how I handle the text to allow retime updating of status text but I am not sure how well it will run on across hardware, while the gui is more for me I might at some point use it elsewhere and would be good to know it can run on more hardware at a decent fps. The windows are all dragable but there is a slight bug were you can end up collecting all the windows, I know about it but havent fixed it yet cos I had more pressing concerns :D
If you could post fps and gfx card info I would be grateful.
Thanks
Jon
-
Geforce 8500 GT, 550fps
Geforce 8800 GT, 3460fps
Runs really well it seems. No slowdown at any time.
-
Geforce 8800 GTS, 4000 fps.
Geforce 8600 GTS, 1600 fps
(both winxp)
-
47 FPS
ATi Radeon Xpress 1100.
-
315fps on 9600xt (Intel P4 3.0HT)
-
My computers, she is a bad. :boxer:
-
Vista, nVidia 8600GT, 960fps.
Windows 7, Intel GMA 950, 2fps, my netbook, lol!
Jim
-
Thanks for the feedback folks, some suprizing numbers but for the most part shows that I am fairly safe to go down this drawing method route as far as using the gui with some 3d. The drawing overhead shouldnt get much higher for the gui so the only increase will be in event checking, once i start to add some gadgets :)
@Jim, does windows 7 and that intel chip have a decent opengl driver ? Could it be running it in software mode :D
-
Don't know if this is too late for you Jon but I got 860fps on this computer (ATI X1650 SE).
Looking good.
-
Not been doing much coding the last week or so but have been tinkering with shaders abit when i get a chance. Finally today I managed to get my first bumpmap shader to work, it's not of massive use since it doesnt deal with tangent space and all that other complex stuff that I havent mastered yet but it does atleast give the impression of 3d depth on the texture :)
Here's a shot and a sample exe for those interested.
-
Wow, when toggling between the off and on setting there is a world if difference.
-
Looks good and great to see that you are progressing.
-
The shader makes it look really really nice Jon. I like this a lot.
-
Thanks for the feedback :)
Its also nice to know its working on more than just my pc, its my 3rd attempt at getting some form of bumpmapping to work with a shader, I have learnt a fair bit while doing this about how to use different shaders and it's been a very interesting experience. My next move with them is to get my head round tangent space normals but thats for a little way of in the future. I have some updating to do of my opengl engine 1st, which currently doesnt even handle multi textures :-[
I plan to add support for multitexturing and a few other minor features then start looking into the stencil buffer and probably shadows, also still need to code a proper model loader but been abit busy with other things.
-
Slightly off topic but is that texture procedural?
-
The texture#s is one i got off the net somewhere along time ago, i think from a dot3 c++ example but not sure tbh, I dont have any texture generating code that complex, have some simple ones and a perlin noise in BB but havent looked to convert them to bmax at all.
-
Just wondering. :)
I had an idea some time ago to produce something similar by randomly joining grid blocks into larger rectangular clusters.
It will prove interesting to see where you go next!
-
Looking good Jon dude with your progression in OGL circles. Cannot wait to see what you officially release with it :)
Added Info: The texture if from a Dot3 experiment from Blitz3D; its in the code archives over at BlitzBasic.com or BlitzMax.com
All the very best,
Clyde.