A straight way into openGL...and fries with that?

BlitzMax Forums/OpenGL Module/A straight way into openGL...and fries with that?

Taron(Posted 2010) [#1]
Ok, I am ashamed to go about this in such a way, but maybe someone of you has mercy with me...

DESIRED RESULT: drawing a single textured, bumpmapped (normalmap is fine, too) vertex (with alpha) in a scene with a light (or more) and probably just a fixed camera, if that's needed?! (without having to use a mod, that is.)

WHERE I AM: I have no idea about openGL, yet. Checked into it enough to realize that it'll take me days or weeks to crawl towards a hope to set this up without growing a brain tumor. (...I consider that likely!)

WHAT I GIVE: My eternal gratitude, guaranteed joy and happiness as well as a promiss to use this kickstart to explore and share my discoveries along the way. (...I'm a wild one at that, honestly! Love to share!)

Any help is greatly appreciated. I'm really wondering if there's a simple and direct approach to that or if it takes a tremendous setup. Maybe encouragement would already help enough, but a tiny code example would friggin make me dance! :}

Thanks in advance and I apologize for appearing so lazy!

WHAT I'VE GATHERED SO FAR:
- shaders (.frag) are written in some kind of assembler (good old "MOV" brings back memories, MAD, DP3 and the likes. I understand that well!)
- those have to be loaded and somehow bound to what ever they manipulate or need (geometry/vertex and what ever fragment shaders are (pixel output manipulations?))
- then they need to be set again? I don't think I get it, yet.
- eventually all of this gets rendered.

Has anybody anywhere posted a simple one .bmx + .frag example that loads one image (if it isn't created in the code) and draws one polygon, bound with a shader and one light source and renders it into the middle of the window?

Can a shader be tied to a polygon that is not loaded but simply created in the code?

I admire all your virtuosity with this stuff, I must say. Here's a bow to you and my thanks for even thinking about helping me in, too.


Taron(Posted 2010) [#2]
Alright, I realize I'm asking for a lot... so I'll post a simple code to show the setup...
It generates a pixmap as texture for simplicity reasons.
Then I swirl it around a little, moving vertecies of a textured polygon. The GL stuff is somewhat ripped together from several examples I found, while I've managed to simplify it a bit.



My question now is, can I simply link a shader to this? Oh, no, that's not a yes/no question, HAHAHA. Any help is appreciated a lot!

Next comes lighting and then I'd be done with this... :}


FreakForFreedom(Posted 2010) [#3]
Yea, you can simply link a shader to this.
Here I got a little shader-file-loading-class:


What you simply need to do, is load the shader like this:
Global Dot3:TShader = TShader.Load("dot3.vert", "dot3.frag")

then declare that you want to use it
Dot3.Use()

You can change it at runtime, like
BumpMapping.Use()
or turn all shaders off:
TShader.TurnOff()


If you want a simple lighting shader:
heres the GLSL code (Sry, no assembler):

.frag
void main()
{
	gl_FragColor = gl_Color;
}


.vert

have fun^^


Taron(Posted 2010) [#4]
I havn't even checked it, yet, and you're already my hero! :}}}
I've also updated the little simple code, by the way... realized I could do the textured polygon with even less afford.

I'll post what I've learned, ASAP!

THANK YOU ONCE AGAIN a dozen times! Just awesome!


Taron(Posted 2010) [#5]
glCreateProgramObjectARB() and ShaderObject create access violations. Did I forget to import something besides pub.glew and brl.GLMax2D?

Thank god, glew isn't too heavy size wise, by the way. Almost had me worried.

Here's what I have...(I also have the files dot3.vert and dot3.frag made, so they're loading fine)



FreakForFreedom(Posted 2010) [#6]
I'll guess you forgot to initialize glut^^
glewInit()



Taron(Posted 2010) [#7]
I have a love/hate relationship to such situations! LOL

T H A N K Y O U !!!


Taron(Posted 2010) [#8]
I have to admit, it ain't so very easy without knowing enough. I'm currently trying to figure out how data gets exchanged with the shaders. I'm struggling to update the normals according to how I rotate the geometry, for example.

Other than that I've already managed to use a texture as normalmap and do some lighting (outside of must hope for control as of now, hehe).


FreakForFreedom(Posted 2010) [#9]
Yeah, I found myself messing with shaders too, not so long ago.
Unfortunatly, I got a bug with the direction the light is pointing at... and I just couldn't find a solution - so I gave up :/

Heres the code for my parallax mapping tryout:
(You will need a texturemap and a normalmap)



.vert


.frag


If you find a solution - please let me know :P


Taron(Posted 2010) [#10]
I'll definitely have ago at it tomorrow!
I got it to run real quick and use a generated set of images which showed the parallax effect on the quad when rotated. Curious stuff for sure!