Author Topic: opengl 3d second tryout  (Read 32745 times)

0 Members and 1 Guest are viewing this topic.

Offline zawran

  • Sponsor
  • Pentium
  • *******
  • Posts: 909
  • Karma: 67
    • View Profile
opengl 3d second tryout
« on: February 15, 2009 »
Yesterday I started working on opengl 3d again. Its been a long while since I messed around with raw opengl, so not everything is fresh in my mind. But I got off to a decent start I think.



Download from here: http://zac-interactive.dk/temp/ogl.zip

It isn't much, but its a start. It shows 9 cubes with texture and a lightsource. There is a readme.txt file which explains the keyboard controls.

I would like to add some shadows, some of those selfshadowing ones would be cool, but I am not sure how those are done yet, so for now I will work on adding more dynamic object creation options than just the cube, while I look around for a solution for shadows.

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: opengl 3d second tryout
« Reply #1 on: February 15, 2009 »
You could use the stencil buffer to make shadows in this case Zawran :)

Works well here on old hardware. It would be great to see a demo from you again after all this time.
Shockwave ^ Codigos
Challenge Trophies Won:

Offline zawran

  • Sponsor
  • Pentium
  • *******
  • Posts: 909
  • Karma: 67
    • View Profile
Re: opengl 3d second tryout
« Reply #2 on: February 15, 2009 »
Quote
stencil buffer

And I am off to google it right away :)

Yeah it would be cool, if I got back into it and made some kind of demo, even a small intro would be nice. We'll see how things goes. At least I have the coming week off work and nothing better to do.   :updance:

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: opengl 3d second tryout
« Reply #3 on: February 15, 2009 »
Nice one dude, its a start at least. And I second that about a new demo eventually :)

I'd recommend you look at some of the NeHe examples that were converted to BlitzMax. Im not sure if its been done yet, but there is a Nehe article / source on Cartoon Shading.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline nkk_kan

  • C= 64
  • **
  • Posts: 32
  • Karma: 4
  • poisoning the world with goodness
    • View Profile
Re: opengl 3d second tryout
« Reply #4 on: February 15, 2009 »
good work dude
runs smooth even on my sad excuse of a pc :D

Offline Pixel_Outlaw

  • Pentium
  • *****
  • Posts: 1382
  • Karma: 83
    • View Profile
Re: opengl 3d second tryout
« Reply #5 on: February 15, 2009 »
Looks great!


Just remember that Blitz only uses OpenGL 1.1. Why they haven't updated, I have no clue.  :boxer:
Also shaders seem to have hit and miss support with many computers.
« Last Edit: February 15, 2009 by Pixel_Outlaw »
Challenge Trophies Won:

Offline zawran

  • Sponsor
  • Pentium
  • *******
  • Posts: 909
  • Karma: 67
    • View Profile
Re: opengl 3d second tryout
« Reply #6 on: February 15, 2009 »
Quote
Also shaders seem to have hit and miss support with many computers.

Shaders, yikes I have just jumped back in, I don't think I will be messing with shaders yet. First I am going to try and get the basics going before I try and step into the big league :)

But from what I have found searching the BlitzResearch forums is that using glew, you can get access to extensions and GLSL shaders in GL2.0, but I have not even begun to look into how it might work yet.

Offline zawran

  • Sponsor
  • Pentium
  • *******
  • Posts: 909
  • Karma: 67
    • View Profile
Re: opengl 3d second tryout
« Reply #7 on: February 15, 2009 »
Not a huge update, but I have added the option of turning things foggy :)



I am still working on adding more mesh building code to enable me to build more complex entities. At some point I will take a look at loading a model from a 3d package. I seem to remember that I have some code somewhere that I might be able to convert to bmax.

Offline Pixel_Outlaw

  • Pentium
  • *****
  • Posts: 1382
  • Karma: 83
    • View Profile
Re: opengl 3d second tryout
« Reply #8 on: February 15, 2009 »
I started a topic about loading .3ds models in OpenGL with Blitzmax but I don't think the code was every fully written. It didn't help that it was in French.

Funny thing is I was going to suggest you try some fog and you beat me to it. You might try some black fog too.

Some time ago I wrote a small primative routine library. It was intended for gl lists and the models only had per face lighting calculations but I can provide it if you see any value in it.
« Last Edit: February 16, 2009 by Pixel_Outlaw »
Challenge Trophies Won:

Offline benny!

  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4384
  • Karma: 228
  • in this place forever!
    • View Profile
    • bennyschuetz.com - mycroBlog
Re: opengl 3d second tryout
« Reply #9 on: February 16, 2009 »
First version runs smooth here. Nice start!
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won:

Offline zawran

  • Sponsor
  • Pentium
  • *******
  • Posts: 909
  • Karma: 67
    • View Profile
Re: opengl 3d second tryout
« Reply #10 on: February 16, 2009 »
Well I got 3ds model loading working, at least for models without texture and color definition, but its a start :)



Download test here: http://zac-interactive.dk/temp/oglloader.zip

I also changed my mesh setup, and re-coded the dynamic primitives code so that it works the same. Now I have to find a simple 3ds model with texture so that I can work on the code to read the texture data. After that I will start working on adding options for either displaylists or vbo depending on which I can get my head around an which works best. A long time ago I did dabble with displaylists and I seem to remember it being straight forward, but we'll see once I get started on it.

[edit] It seems rather difficult to locate a free simple 3ds model with texture, something like a crate or barrel will do. If one of you guys have one or a link to one you are willing to share I appreciate it highly.
« Last Edit: February 16, 2009 by zawran »

Offline hellfire

  • Sponsor
  • Pentium
  • *******
  • Posts: 1294
  • Karma: 466
    • View Profile
    • my stuff
Re: opengl 3d second tryout
« Reply #11 on: February 16, 2009 »
Quote
a free simple 3ds model with texture
Here's some simple knot.
I can put some more stuff somewhere later...
« Last Edit: February 16, 2009 by hellfire »
Challenge Trophies Won:

Offline Pixel_Outlaw

  • Pentium
  • *****
  • Posts: 1382
  • Karma: 83
    • View Profile
Re: opengl 3d second tryout
« Reply #12 on: February 16, 2009 »
[edit] It seems rather difficult to locate a free simple 3ds model with texture, something like a crate or barrel will do. If one of you guys have one or a link to one you are willing to share I appreciate it highly.

It seems that the .3ds format required a path to the texture rather than including the texture in the .3ds file. I may be mistaken however.

Hellfire's knot looks untextured in AutoCAD (which supports textured .3ds file import)
« Last Edit: February 16, 2009 by Pixel_Outlaw »
Challenge Trophies Won:

Offline zawran

  • Sponsor
  • Pentium
  • *******
  • Posts: 909
  • Karma: 67
    • View Profile
Re: opengl 3d second tryout
« Reply #13 on: February 16, 2009 »
Yes the texture is not included in the 3ds files, but has to be loaded seperately, but the texture UV coords are there, and I need a model with its texture image to test that I am reading the texture UVs correctly. :)

The knot Hellfire provided, although doesn't make use of texture, does look great.

Offline hellfire

  • Sponsor
  • Pentium
  • *******
  • Posts: 1294
  • Karma: 466
    • View Profile
    • my stuff
Re: opengl 3d second tryout
« Reply #14 on: February 16, 2009 »
Ah right, I applied a procedural material, so 3dsmax didn't export a texture-filename.
Challenge Trophies Won:

Offline zawran

  • Sponsor
  • Pentium
  • *******
  • Posts: 909
  • Karma: 67
    • View Profile
Re: opengl 3d second tryout
« Reply #15 on: February 16, 2009 »
Quote
I'll whip something up sir

Why thank you my good man :)

For starters it would probably be best with just a cube/box with each face UV mapped to a different part of a texture. That is perhaps the most simple model to test with and it should be very easy to see if the outcome is correct. Unfortunately I do not have any 3d software available at the moment. (the knot looked really cool though  :clap: )

Offline hellfire

  • Sponsor
  • Pentium
  • *******
  • Posts: 1294
  • Karma: 466
    • View Profile
    • my stuff
Re: opengl 3d second tryout
« Reply #16 on: February 16, 2009 »
Quote
just a cube/box with each face UV mapped to a different part of a texture
Try this.
I intentionally rotated and scaled the texture-coordinates of each face differently so that wrong uvs are obvious.
« Last Edit: February 16, 2009 by hellfire »
Challenge Trophies Won:

Offline Pixel_Outlaw

  • Pentium
  • *****
  • Posts: 1382
  • Karma: 83
    • View Profile
Re: opengl 3d second tryout
« Reply #17 on: February 16, 2009 »
Ah sorry I went a bit overboard and made a castle lol.

Perhaps the cube is best for now. I do know that Anim8or will export .3ds however it doesn't supply texture information.
Challenge Trophies Won:

Offline zawran

  • Sponsor
  • Pentium
  • *******
  • Posts: 909
  • Karma: 67
    • View Profile
Re: opengl 3d second tryout
« Reply #18 on: February 16, 2009 »


Well it looks like I still have work to do with reading the texture UV coors, or it could be something wrong in the code that picks the UV coords during the render. Anyway my work is not quite done it seems. Well onwards and upwards as they say :)

Offline hellfire

  • Sponsor
  • Pentium
  • *******
  • Posts: 1294
  • Karma: 466
    • View Profile
    • my stuff
Re: opengl 3d second tryout
« Reply #19 on: February 16, 2009 »
in opengl texture-coordinates are bootom-up.
simply try v=1-v.
(the knot should have proper uvs included, too, by the way)
« Last Edit: February 16, 2009 by hellfire »
Challenge Trophies Won: