|  | 
 
 DISCLAMERS
I say again THIS IS NOT FOR THE FAINT HEARTED. I assume you know how openGL works. they require the program and them to be programmed together. since for cool looking water you might need to pass a sine wave etc. IntroductionWelcome to my introduction to the World of Using CG with a GL compatable version of Blitz.At the moment the only OpenGL Library in the public arena is Peter Scheutz's GLDirect to use CG with this extension Download my CG expansion for Blitz. which you just unpack into the Directory, you have GLdirect in, and copy over the userlibs. So What is CG?
 Getting Started with CG and BlitzUsing CG in Blitz is almost 100% indentical as using it with OpenGL via C++, since I use the same names for calling the Dll as C/C++ does This makes it useful if one day you start using C++ with openGL. Anyway lets get started. The first thing you want to do is include the CG.bb file that is in the GL directory of GLDirect. all code assumes that you have all the GL includes in a subdirectory of you Program. Also needed are some vars that will hold the information that you want to send and receive from the Shader, also requried is a Varable to hold a reference to the program itself Here is some Background for those varables... A Model view Matrix holds the current world location of the model that is about to be drawn to the screen. The Projection matrix holds info about the screen, and its aspect ratio. Loading A CG program to be usedI normally do all the initilisation for my GL programs in a function Called GLInit, so at the end of this function So here I will Explain all the Steps for loading a CG program to be able to be used in GL.As stated in the code, this checks what your videocard will let you do with shaders, then chooses the best one that CG is able to use. Next we get the parameters from the CG program and let blitz know how to reference them, this is so values can be passed between CG and Blitz. Drawing a SceneNow that the Vertex Shader is all loaded and ready to go, we can use it to take over the Vertex Transformations, yes, that is the purpose of a Vertex Shader, instead of the card handleing them normally you use the Vertex Shader, or as they are properly called in OpenGL Vertex Programs, since they Program Vertex's , to take control of them.An Example of a CG ProgramHere is the progam that is used with the Article It looks like C code becasue C for Graphics is C :)I will Explain more about CG in another Article. here is that source as vertex Shader Assemberly. This will get all you old school programers excited... well maybe not, but hey it is Assemberly :)  Conclusion |