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

0 Members and 1 Guest are viewing this topic.

Offline Pixel_Outlaw

  • Pentium
  • *****
  • Posts: 1382
  • Karma: 83
    • View Profile
Re: opengl 3d second tryout
« Reply #60 on: March 14, 2009 »
You might be able to colorize the vertex points by height for a cool graphic effect. Or better yet you might provide a function to colorize them by height. In this way you could get procedural land with mountains and oceans. ;). In my old random terrain generator I just used a bitmap that measured 1x255 pixels. The height of the vertex set the color based on the bands or colors in the image.
Challenge Trophies Won:

Offline zawran

  • Sponsor
  • Pentium
  • *******
  • Posts: 909
  • Karma: 67
    • View Profile
Re: opengl 3d second tryout
« Reply #61 on: March 14, 2009 »
After I made the method that created the terrain from the heightmap, I did actually think about making one of those "fly over never ending land" effects :) Where it randomly creates new heights as the terrain is moved. But I was too tired, so it will be something I might look at later on. Today I will be trying out how VBO works because I am thinking that it might be better if I get that added to it before I settle on my load/save object format. I will need to find out how data for VBO is formated, so that I store it most effeciently in my mesh type. As it looks right now, at least half my day looks to be free of other things, so I might have even more progress today. :)

Offline zawran

  • Sponsor
  • Pentium
  • *******
  • Posts: 909
  • Karma: 67
    • View Profile
Re: opengl 3d second tryout
« Reply #62 on: March 14, 2009 »
I decided to take a stab at coloring the terrain using a heightmap color gradient. And I think it worked out great. I also made load/save methods for my mesh type, so now instead of taking 1500 millisecs to calculate the terrain from the heightmap, it takes 23 millisecs to load and prepare it from a binary file :)



[edit] I just did a small test using my old heightmap tool I made back when using blitzplus. You can download it from here:

http://zac-interactive.dk/temp/zhmap.zip
« Last Edit: March 14, 2009 by zawran »

Offline TinDragon

  • Pentium
  • *****
  • Posts: 644
  • Karma: 24
    • View Profile
    • J2K's blog
Re: opengl 3d second tryout
« Reply #63 on: March 14, 2009 »
The test runs fine, looks good.

I am having a rethink of my approach at the moment as it stands my engine can only deal with fixed meshs, due to it only using displaylists, there fast but once made there pretty much set it stone so to speak. I think your approach from what I have seen is much better and much easier to adapt and add to. My other concern atm is why my code is failing on someones system, I am really at a lost on that one :S

Offline zawran

  • Sponsor
  • Pentium
  • *******
  • Posts: 909
  • Karma: 67
    • View Profile
Re: opengl 3d second tryout
« Reply #64 on: March 14, 2009 »
I have just figured out how multi texturing works, so will be working that into my engine as soon as I have grabbed something to eat. This will allow me to use a detail texture on the terrain, and I am sure there are other uses as well.

I have displaylists running, but as you mention, they have to be completely remade, if you want to change something, so for dynamic objects, like transforming/morphing primitives, tunnels, changeable terrain etc its not a good solution. If kept at a lower amount of vertices, you can get away with building the objects each frame, but for more complex stuff, I think it will have to be a combination between displaylists for static non-changing objects, for which they are great as they are fast, or VBO for dynamic objects. VBO can be used for static objects as well, but from what I have read so far, they are a bit slower than display lists, but since I haven't made any VBO objects yet, I cannot confirm this.

[edit] I re-uploaded the terrain test with one using the multi texture feature to add the detail map.
« Last Edit: March 14, 2009 by zawran »

Offline zawran

  • Sponsor
  • Pentium
  • *******
  • Posts: 909
  • Karma: 67
    • View Profile
Re: opengl 3d second tryout
« Reply #65 on: March 14, 2009 »
I ran into a problem which I haven't figured out yet.

Code: [Select]
If Self.multitexture = 0 Then
glBindTexture(GL_TEXTURE_2D,Self.texture[0].resource)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
glEnable(GL_TEXTURE_2D)
glBegin(GL_TRIANGLES)
Self.mesh.drawTextured()
glEnd()
Else
glActiveTextureARB(GL_TEXTURE0_ARB)
glBindTexture(GL_TEXTURE_2D, Self.texture[0].resource)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
glEnable(GL_TEXTURE_2D)
glActiveTextureARB(GL_TEXTURE1_ARB)
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB) ' combine textures
glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, Self.multitexturescale) ' set RGB scaling
glBindTexture(GL_TEXTURE_2D, Self.texture[1].resource)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
glEnable(GL_TEXTURE_2D)
glBegin(GL_TRIANGLES)
Self.mesh.drawMultiTextured()
glEnd()
End If

The code above shows how I setup the multi texture, but if I add a texture to one entity, then all entities becomes multi textured. I am thinking its because I need to somehow turn it off when doing the entities with only one texture on. But I have been searching around on the net and not finding anything yet that can enlighten me. So I am hoping one of you guys might have ideas worth trying out.

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2757
  • Karma: 493
    • View Profile
    • https://www.rbraz.com/
Re: opengl 3d second tryout
« Reply #66 on: March 14, 2009 »
http://www.berkelium.com/OpenGL/examples/multitex.c
Take a look at this example, it might help you.
Challenge Trophies Won:

Offline zawran

  • Sponsor
  • Pentium
  • *******
  • Posts: 909
  • Karma: 67
    • View Profile
Re: opengl 3d second tryout
« Reply #67 on: March 14, 2009 »
Yes that actually did help, I added the following after its done with multi texturing and now it works:

Code: [Select]
glActiveTextureARB(GL_TEXTURE1_ARB)
glDisable(GL_TEXTURE_2D)
glActiveTextureARB(GL_TEXTURE0_ARB)
glDisable(GL_TEXTURE_2D)

And the order does matter. If I disabled TEXTURE0 first, then no textures were being draw on the objects without multi texture, but disabling TEXTURE1 first, then it works. Thanks for the link, now I can move on. :)

I have uploaded a small example showing some cubes with 2 textures blended.



It can be downloaded from here: http://zac-interactive.dk/temp/multitex.zip
« Last Edit: March 14, 2009 by zawran »

Offline TinDragon

  • Pentium
  • *****
  • Posts: 644
  • Karma: 24
    • View Profile
    • J2K's blog
Re: opengl 3d second tryout
« Reply #68 on: March 14, 2009 »
Very nice, your certainly getting the hang of opengl, I would say from that demo you could likely create some demos and intros that surpassed anything we did in the old ttdvectorlib   ;D

Now I really have to suss out lights and textures into my engine proper rather than from outside it in the other code :D

Offline zawran

  • Sponsor
  • Pentium
  • *******
  • Posts: 909
  • Karma: 67
    • View Profile
Re: opengl 3d second tryout
« Reply #69 on: March 14, 2009 »
Quote
you could likely create some demos

I might just do that some day :)  But for the moment I am using my momentum to get this engine of mine to a stage where I am happy with the features and usability that it will enable me to put something together without too much fuzz. Exactly when that is, I am not sure yet. But I am starting to think about what kind of features I need for a version 1.0 and then focusing on only getting to that goal. Then when that goal has been reached, I would probably use it to make some kind of intro/demo thing, and after that make a list of additional features I can work on.

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: opengl 3d second tryout
« Reply #70 on: March 14, 2009 »
Looking good Zawran :)

Works here (ATI), no problems at all. I upgraded the forum to allow you to add files up to 1mb to your posts if it makes it easier for you to add the files.
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Hotshot

  • DBF Aficionado
  • ******
  • Posts: 2114
  • Karma: 91
    • View Profile
Re: opengl 3d second tryout
« Reply #71 on: March 14, 2009 »
Quote
I am having more fun this time around with opengl than last time I tried, and that has been a motivational factor for me.

You doing very well and my motivational isnt good.
Your Demo run fine on my system.


Offline Pixel_Outlaw

  • Pentium
  • *****
  • Posts: 1382
  • Karma: 83
    • View Profile
Re: opengl 3d second tryout
« Reply #72 on: March 16, 2009 »
Very very nice progress.
Challenge Trophies Won:

Offline zawran

  • Sponsor
  • Pentium
  • *******
  • Posts: 909
  • Karma: 67
    • View Profile
Re: opengl 3d second tryout
« Reply #73 on: March 20, 2009 »
I got the .obj loader working to my satisfaction, and I have successfully loaded a handful of .obj files found on the net. But it resulted in some changes in my mesh type, which then broke some of the procedual mesh creation methods, so during the coming weekend I will have to recode those parts of my engine. But its not all bad, because it might just end up with it being more effecient and model loading is a fairly important part of it, so its essential that it works, I can always adjust the procedual stuff. So if all goes well, then sometime during the weekend I will post another small test to show whatever progress I manage.

Offline zawran

  • Sponsor
  • Pentium
  • *******
  • Posts: 909
  • Karma: 67
    • View Profile
Re: opengl 3d second tryout
« Reply #74 on: March 21, 2009 »
Well I managed to get VBO working, so now I have the choice between intermediate, display lists and vbo. I still have to rewrite my procedual primitive creation methods, but thats ok, I doubt those are going to be too much trouble. I also need to rewrite my terrain method, which might be a bit more difficult. Once those things are taken care of, I am not totally sure what I will try next, but I will put on the thinking cap for the rest of the weekend to figure that out.

For now I am just happy that I managed to get the vbo working. :)

Offline TinDragon

  • Pentium
  • *****
  • Posts: 644
  • Karma: 24
    • View Profile
    • J2K's blog
Re: opengl 3d second tryout
« Reply #75 on: March 23, 2009 »
Good to hear you got VBO's in, I havent looked into them yet but will be something to consider I am sure. Look forward to seeing your next engine demo  ;)

Offline zawran

  • Sponsor
  • Pentium
  • *******
  • Posts: 909
  • Karma: 67
    • View Profile
Re: opengl 3d second tryout
« Reply #76 on: March 24, 2009 »
I decided to look at how shaders are loaded and used, and I used the shader files from Jon's example. I haven't looked at how to include them into the exe yet though, which I will once I clean up the code and make it more in line with the rest of the engine.



http://zac-interactive.dk/temp/shaderball.zip

At the same time I found out how to use gluQuadric's. I still have no plans for actually using shaders for anything, but I figured that I might as well give it a try since I was home sick and really, really bored.

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2757
  • Karma: 493
    • View Profile
    • https://www.rbraz.com/
Re: opengl 3d second tryout
« Reply #77 on: March 25, 2009 »
Works fine for me, great progress, and keep it up
Challenge Trophies Won:

Offline zawran

  • Sponsor
  • Pentium
  • *******
  • Posts: 909
  • Karma: 67
    • View Profile
Re: opengl 3d second tryout
« Reply #78 on: March 27, 2009 »
Quote
great progress, and keep it up

Thanks, I am hoping to get some coding done on it this weekend. Its been really fun making it so far thats for sure.

Offline zawran

  • Sponsor
  • Pentium
  • *******
  • Posts: 909
  • Karma: 67
    • View Profile
Re: opengl 3d second tryout
« Reply #79 on: March 29, 2009 »
I have been cleaning up my mesh type and re-written a bunch of mesh methods after changing the way meshes are stored. To get a break from code clean-up every now and then, I started working on a native gui for the engine. I first thought about using the windows gui, but since I have made a lot of gui's before and I don't really feel like messing around with the window api, I decided to go for a custom gui. I have windows drawing and some gadget drawing done. Next I will be working on the mouse control for it so that it can get a little interactive.



The gui is fully skinable and I added a font type to deal with text writing which I probably will expand on later on so I can use it for other things besides just the gui.