|
|
Visual Basic
|
vbGL: Simple triangle with OpenGL and VB6
A minimalist example for those that want to know
what is needed to begin to work with OpenGL.
References:
vbGL 1.2 (ANSI) Type Library
vb6 OpenGL Triangle
Paul Dahuach, 2008-05-18.
|
|
vbGL: Introduction to Arrays with OpenGL and VB6
As soon as you have used up to the weariness OpenGL's
triangles, you will fall into account that, the bigger
is the quantity of triangles, the major will be the
amount of calls to the API and major the time of latency
between frame and frame. To avoid this latency, OpenGL has
presented several resources along hes evolution, the technique
shown here, is one of the first ones and does not need of
hardware acceleration. In the example, we load a series of
vertexes, normals and colors, I extracted from the first
level of Quake's 3 demo by Id Software and stored in
independent files, to facilitate the load from vb.
The magic resides in sending the major possible quantity of
vertices in a single call to OpenGL, for this we use the
following code:
glEnableClientState GL_VERTEX_ARRAY
glEnableClientState GL_NORMAL_ARRAY
glEnableClientState GL_COLOR_ARRAY
glVertexPointer 3, GL_FLOAT, 0, Vertices(0).xyz(0)
glNormalPointer GL_FLOAT, 0, Normals(0).xyz(0)
glColorPointer 3, GL_FLOAT, 16, Colors(0).xyzw(0)
glDrawArrays GL_TRIANGLES, 0, vertexCount
glDisableClientState GL_VERTEX_ARRAY
glDisableClientState GL_NORMAL_ARRAY
glDisableClientState GL_COLOR_ARRAY
Other matrices exist like GL_TEXTURE_COORD_ARRAY and
GL_INDEX_ARRAY, these deserve a separated example.
References:
vbGL 1.2 (ANSI) Type Library
vb6 OpenGL Arrays
Paul Dahuach, 2008-05-18.
|
|
vbGL: Texture Coord Arrays with OpenGL and VB6
This example introduces the use of GL_TEXTURE_COORD_ARRAY,
a simple example of the ordinary procedure. The coordinates
are loaded in a common array, the use of textures is enabled
with glEnable GL_TEXTURE_2D, is warned to the engine that the
texture coordinates will passed as arrays with
glEnableClientState GL_TEXTURE_COORD_ARRAY, then
we tell to the engine where it can take the information
with glTexCoordPointer passing the first element of our
array and glDrawArrays it takes charge using the
coordinates at the moment of drawing.
Finally, the use of textures is disabled to leave the
state as we found it originally; for it we use
glDisableClientState GL_TEXTURE_COORD_ARRAY and
glDisable GL_TEXTURE_2D.
References:
vbGL 1.2 (ANSI) Type Library
vb6 OpenGL Texture Coord Array
Paul Dahuach, 2008-05-24.
|
|
vbGL: Multiple textures (GL_BLEND) with OpenGL and VB6
A bit more on the application of textures. One of the
primitive methods to apply several textures on the same object
is to draw repeatedly the object changing texture in every
iteration. In other words, we select a texture and draw, then
we select another texture and draw again. This process of
applying several textures one over another is possible thanks
to GL_BLEND that indicates to the engine that it must realize
a logical operation between the new drawing and the one
that already it has ready to present on screen,
For example glBlendFunc GL_ZERO, GL_SRC_COLOR indicates to the
engine that should combine the color of the object to draw
with the color stored in the frame buffer. This method has
the advantage of being compatible with the most ancient video
cards and the disadvantage of having to draw several times
the same thing. In this example it is in use for drawing a
base texture and a lightmap, a texture that simulates the
lights and shades that would be projected on the objects if
the suitable lighting was located.
References:
vbGL 1.2 (ANSI) Type Library
vb6 OpenGL Multiple Passes
Paul Dahuach, 2008-05-24.
|
|
vbGL: Multiple textures (MultiTexture) with OpenGL and VB6
For this example, we need a video card that it can handle
more then a texture simultaneously. If the card allows it to
us, we can combine more than one texture in a single pass.
This allows us to reduce considerably the quantity of
information that we have to send to the engine, since the
vertices, normal, colors, etc. will be drawn only one time,
being the hardware the manager of combining all the textures
correctly. To use this technique, we are served OpenGL's
extensions. With glActiveTexture and glClientActiveTexture we
can indicate to the engine to what unit of textures we
refer with the commands that we indicate later.
In this example we only use the first two units
(GL_TEXTURE0_ARB and GL_TEXTURE1_ARB).
References:
vbGL 1.2 (ANSI) Type Library
vb6 OpenGL MultiTexture
Paul Dahuach, 2008-05-24.
|
|
vbGL: Multiple textures (dot3 bumpmap) with OpenGL and VB6
In this example we see again the great usefulness of being
able to handle more than a texture simultaneously. With the
first two units of texture we handle a base texture and
a texture with the normal map necessary to generate the
bumpmap. The bumpmap is the technique that simulates a
great level of detail in an object that actually has very
few vertices. To achieve the effect we can use very varied
technologies, in this case, we use the second texture
combined with the color array that instead of containing
the colors, contains the light vector in tangent space.
References:
vbGL 1.2 (ANSI) Type Library
vb6 OpenGL Dot3 BumpMap
Paul Dahuach, 2008-05-24.
|
|
vbGL: Cg Normal Map and Gloss Map with OpenGL and VB6
In this example, we apply previous Cg's examples in our
small cube, in addition we use a Gloss Map to generate
a mask for controling the specular value in the surface
of the bump map. Note that if you apply a white only
texture as gloss map, you'll get a super shiny material.
References:
Cg Toolkit
vbGL 1.2 (ANSI) Type Library
OpenGL Extensions 2.0 for VB6
vb6 OpenGL Normal Map + Gloss Map
Paul Dahuach, 2008-06-01.
|
|
vbGL: Cg Shadow Volume with OpenGL and VB6
A simple example of a technique for the generation of shadows
that helps itself with a shader for the silhouette extrussion
of the body that projects the shadows. The example comes from
Andreas T Jonsson in http://www.codesampler.com that in turn
inspired in of
this GameDev's article.
It uses, in addition, OpenGL's extensions to accede to glActiveStencilFaceEXT.
References:
Cg Toolkit
vbGL 1.2 (ANSI) Type Library
OpenGL Extensions 2.0 for VB6
vb6 Cg Shadow Volumes
Paul Dahuach, 2008-06-01.
|
|
vbGL: Sphere Collision Detection with ColDet.dll, OpenGL and VB6
An introductory example to collision detection, in this opportunity
we use ColDet.dll from www.photoneffect.com,
in indirect form trought our vbColDet.dll that in a similar way to vbCg20.dll,
simply calls to the functions in the original dll;
in this case, actually, it must go just beyond,
becouse ColDet works with C classes, and that's why
vbColDet needs to create instances of these classes
to be able to call the functions.
For the present time we do not need to create a
great quantity of instances, since only we are testing
the collisions with the room that surrounds us, for
this vbColDet only it allows to create up to two
model instances simultaneously.
In the image, a triangle highlighted with green
corresponds to the last triangle with which we clash,
and a sphere in red color corresponds to the exact
point of the collision.
References:
Cg Toolkit
vbGL 1.2 (ANSI) Type Library
OpenGL Extensions 2.0 for VB6
ColDet - Free 3D Collision Detection Library
vb6 Sphere Collision Detection
Paul Dahuach, 2008-06-03.
|
|
vbGL: Ray Collision Detection with ColDet.dll, OpenGL and VB6
Exploring a bit more in the possibilities of the ColDet.dll,
we find the possibility of detecting collisions between
a ray and a triangle. The ray is emitted from a point,
with certain direction and with an adjustable length.
The example uses a Cg shader to realize bump mapping,
though this one lacks a transformation to the
tangent space. Also a shader presented here some time ago
tries to recreate a surface covered of hair. To capture /
release the control of the sight with the mouse, it is
enough to push the right button.
References:
Cg Toolkit
vbGL 1.2 (ANSI) Type Library
OpenGL Extensions 2.0 for VB6
ColDet - Free 3D Collision Detection Library
vb6 Ray Collision Detection
Paul Dahuach, 2008-06-15.
|
|
vbCg: Vertex Program (Vertex Shader) with OpenGL and VB6
One of the most wanted features in OpenGL is the access to the
straight programming of 3D cards. It's a fundamental tool in
the most recent generation of games. What they do is to transfer
pieces of code into the memory space of the hardware and at the
time that the GPU is drawing a vertex or a pixel, that code gets
executed.
There are several high level languages that allows you to create
that programs useing a similar sintax to C. For instance, when
you use GLSL, you can send the source code to OpenGL through the
function glShaderSourceARB, then ask to the library for the
conversion of it to the language that the card can understand
(machine code), that can be achieved calling glCompileShaderARB and
finally you activate or select the program useing glUseProgramObjectARB.
Another method available to access the programming of the 3D cards
it's the Cg Toolkit made by NVIDIA,
(Cg = "C" for graphics), that presents you a model, at some
point, similar to the one mentioned earlier: the function
cgCreateProgramFromFile sends the source code to the dll,
cgGLLoadProgram ask for the compilation and a call to
cgGLBindProgram puts it on the pipeline at the right moment.
Well, now the bad news, not a single one of this libraries were made having in mind being accessed
from a language like Visual Basic 6, so we get far away from the
last advances in 3D graphics, again. The 3D graphics world it's
part of the aeternal kingdom of the low (or high but complex?)
level languages like C/C++. Ok but, it seems that writeing a
little wrapper dll, we can get complete access to the amazing
graphic power that these tools can give. In this particular case,
the chosen library was the NVIDIA's Cg Toolkit.
The library that I'm going to show you on this article it simply
exports the original functions but useing the calling convention
that vb can understand, the one known as _stdcall, leaving them
fully accessible from VB through Declare instructions. The only
job they do is to call the corresponding function in the NVIDIA's
library. To avoid confusions, the functions exported by our
little wrapper have the prefix "vb6_".
For example, vb6_cgCreateContext it's the one that will call
cgCreateContext into cg.dll and vb6_cgGLLoadProgram
it's the one that will call cgGLLoadProgram into cgGL.dll.
At the end of the article you will find a link to a basic example
of the utilization of this library that we will call, with a total
absence of imagination: vbCG. Along with the example, the
compiled version of the wrapper it's included, named vbCg.dll.
The library was developed and tested with version 1.5.0.23 of the
Cg Toolkit, I don't know what kind of compatibility will have with
new versions of the toolkit. The example uses vbGL.tlb that can
be found at http://home.pacific.net.hk/~edx/tlb.htm,
this one will save you from doing a lot of work to get started
with the basic functions of OpenGL when you are useing VB6.
Be my guest and download Vertex Program with vbCG,
test it, and post any suggestion on the Programming Forum.
I will answer to any question or doubt and will fix the bugs
that I'm shure, must be somewhere, hidden from my FOV.
References:
Cg Toolkit
vbGL 1.2 (ANSI) Type Library
Cg Wrapper For Visual Basic 6
Paul Dahuach, 2008-03-02.
|
|
vbCg: Vertex and Fragment Program with OpenGL and VB6
The first example it shows the basic use of the library loading
a Vertex Program from a file. The next step, without doubt it's
load a Fragment Program (pixel shader).
El procedure it's mostly the same as the previous one:
cgGLGetLatestProfile obtains the latest configuration of the parameters into the scope of Fragment Programs,
cgGLSetOptimalOptions makes this info the current configuration,
cgCreateProgramFromFile loads into memory the shader code,
cgGLLoadProgram ask for the compilation of the source code.
Later, when you are inside the main render loop, you call cgGLBindProgram
and cgGLEnableProfile to get your code into the GPU pipeline.
To avoid artifacts, disable the profile with cgGLDisableProfile.
Don't forget to clean up memory at the end of the program, this
is achieved when talking about a Fragment Program, with cgDestroyProgram.
Note: this examples could seem too simple or useless at all, but
like in all areas of knowledge, it's always convenient, start simple
and get more into the deep at the time the ideas get solidified.
On the next weeks I will be adding more advanced examples, including:
parameters, multitextures, vertex transformations, lightmapping, bump mapping,
vertex buffers, and so on. See ya later.
References:
Cg Toolkit
vbGL 1.2 (ANSI) Type Library
vb6 Cg Vertex and Fragment Program
Paul Dahuach, 2008-03-22.
|
|
vbCg: Uniform Parameter with OpenGL and VB6
One more step on the OpenGL series, this time passing a parameter to the Vertex Program from our app.
With Cg, this kind of variables are called Uniform Parameters and allows you to manage global variables
inside the shader from outside of the 3D card, this time, from our main program in VB.
The most relevant functions on this example are the following:
cgGetNamedParameter obtaines a handle that we can use to reference a parameter,
cgSetParameter3f allow us to send the value of the parameter.
There are several variants of the command, that permits send more or less info, depending on the needs of the
program. You can find the definitions of all of them in the example.
References:
Cg Toolkit
vbGL 1.2 (ANSI) Type Library
vb6 Cg Uniform Parameter
Paul Dahuach, 2008-03-25.
|
|
vbCg: Varying Parameter with OpenGL and VB6
The varying parameters are the ones that you manipulate inside
the shader itself, so, the example it's limitated to show that
it's the shader the one that plays with the colours between pixel and pixel.
Note: the examples presented on this article, are based on the examples included by
NVIDIA along with the setup of the Cg Toolkit. The only detail
that makes them special it's that while they're implemented with
Visual Basic 6 and the vbCg.dll, the examples by NVIDIA are implemented
with C and the original libraries that they develop in addition to
the auxiliar GLUT include.
References:
Cg Toolkit
vbGL 1.2 (ANSI) Type Library
vb6 Cg Varying Parameter
Paul Dahuach, 2008-03-26.
|
|
vbCg: Texture Sampling with OpenGL and VB6
In this example the coordinates of texture taken in the
vertex shader, feeds the pixel/fragment shader and then
this one, obtains the color to apply to the pixel,
in agreement to the texture id that we point across
a uniform parameter that we call "decal" along the code
of the shader.
References:
Cg Toolkit
vbGL 1.2 (ANSI) Type Library
vb6 Cg Texture Sampling
Paul Dahuach, 2008-04-15.
|
|
vbCg: Vertex Twisting with OpenGL and VB6
In this example the vertex shader takes charge realizing
transformations on the vertexes that it receives as entry
applying to them a certain degree of rotation of agreement
to a parameter that we feed from the program in vb.
The shader receives the vertexes of what must be a simple
triangle and delivers a form softly deformed of the same one.
References:
Cg Toolkit
vbGL 1.2 (ANSI) Type Library
vb6 Cg Vertex Twisting
Paul Dahuach, 2008-04-15.
|
|
vbCg: Two Texture Accesses with OpenGL and VB6
In this example the shaders take charge displacing the
coordinates of the unique texture and realizing a linear
interpolation between the colors corresponding to the
displaced coordinates.
References:
Cg Toolkit
vbGL 1.2 (ANSI) Type Library
vb6 Cg Two Textures Accesses
Paul Dahuach, 2008-04-19.
|
|
vbCg: Vertex Transform with OpenGL and VB6
In this example the vertex shader establishes the position
of the objects transforming of object space to clip space.
For it, all the necessary arrays are constructed in vb
and the result of the operations is sent to the shader.
References:
Cg Toolkit
vbGL 1.2 (ANSI) Type Library
vb6 Cg Vertex Transform
Paul Dahuach, 2008-04-19.
|
|
vbCg: Vertex Lighting with OpenGL and VB6
In this example, the vertex shader applies the
transformations indicated from vb on the position of the
vertexes and realizes the calculation of the properties of
the materials related to the lighting such as emissive,
ambient, diffuse and specular factors, delivering the color
to the fragment shader.
The fragment shader simply passes the received value
to the next step in the render pipeline.
References:
Cg Toolkit
vbGL 1.2 (ANSI) Type Library
vb6 Cg Vertex Lighting
Paul Dahuach, 2008-04-19.
|
|
vbCg: Fragment Lighting with OpenGL and VB6
This example is an evolution of the previous example,
but, in this case, the light calculations are made in
the pixel shader, increasing the precision
level obtained.
References:
Cg Toolkit
vbGL 1.2 (ANSI) Type Library
vb6 Cg Fragment Lighting
Paul Dahuach, 2008-04-19.
|
|
vbCg: Two Lights and Cg Structs with OpenGL and VB6
As the title indicates it, two lights are formed and
Cg's Structs gets introduced (slightly as Types in vb6).
The calculations are realized in the vertex shader,
whereas the pixel shader simply passes the arguments
received to the following stage to be drawn.
References:
Cg Toolkit
vbGL 1.2 (ANSI) Type Library
vb6 Cg Two Lights with Structs
Paul Dahuach, 2008-04-19.
|
|
vbCg: Light Attenuation with OpenGL and VB6
Extending the previous examples, this time it is presented
an effect of light that loses power as it advances in the
distance. The calculations to apply the lighting are
realized in the fragment shader, taking the arguments sent
from the vertex shader.
References:
Cg Toolkit
vbGL 1.2 (ANSI) Type Library
vb6 Cg Light Attenuation
Paul Dahuach, 2008-04-19.
|
|
vbCg: SpotLights with OpenGL and VB6
This example, adds a direction to the light, to simulate the
effect of a spotlight, that is to say, a light that affects
a limited and specific zone.
References:
Cg Toolkit
vbGL 1.2 (ANSI) Type Library
vb6 Cg SpotLight
Paul Dahuach, 2008-04-19.
|
|
vbCg: Bulge with OpenGL and VB6
In this case, the arguments of the vertex shader are in use
for realizing displacements in the received vertexes and
additionally, to apply correct illumination to the deformed
resultant forms.
References:
Cg Toolkit
vbGL 1.2 (ANSI) Type Library
vb6 Cg Bulge
Paul Dahuach, 2008-04-19.
|
|
vbCg: Particle System with OpenGL and VB6
In this case, a particle system is generated with help of the
vertex shader, this one takes charge calculating the
position, the color and the size of the particles on
the basis of the values sent from vb.
References:
Cg Toolkit
vbGL 1.2 (ANSI) Type Library
vb6 Cg Particle System
Paul Dahuach, 2008-04-19.
|
|
vbCg: Keyframe Interpolation with OpenGL and VB6
This example presents a use for the function lerp
(Linear Interpolation).
Additionally, it presents a simple way to load an md2 file.
The md2 file format was developed by Id Software for the
very well-known Quake 2.
Also it shows how to load the vertexes, normal and
coordinates of texture in Vertex Buffers to avoid the
traffic appellant between cpu and gpu.
Referencias:
Cg Toolkit
vbGL 1.2 (ANSI) Type Library
vb6 Cg Keyframe Interpolation
Paul Dahuach, 2008-04-22.
|
|
vbCg: Cube-Map Reflection with OpenGL and VB6
This example, together with the following ones up to 21,
are translations of those that came attached to NVIDIA's Cg
Toolkit version 2.0, though we do not use the functions
that they added in this version, we only use those
who were included in the version 1.5.
In this case especially, it loads a texture with his
correspondents mipmaps, to apply to the central figure and
the group of six images that shape the cube that makes
the environment. Both groups of textures are extracted
of several dds files (DirectDraw Surfaces) acceding
directly to the file in binary form.
The central effect of the example is situated in the
generation of reflections of the environment on the surface
of the central figure, to achieve it the following line of
program it is used: texCUBE (environmentMap, R), where R
is a texture coordinate from the vertex shader generated
with the following instruction: R = reflect (I, N);.
References:
Cg Toolkit
vbGL 1.2 (ANSI) Type Library
vb6 Cg Cube-Map Reflection
Paul Dahuach, 2008-04-25.
|
|
vbCg: Cube-Maps Refraction with OpenGL and VB6
A variation of the previous example, in which the rebound of
the light is simulated inside a refractive body. The key
instruction in the example, is situated once again, in the
vertex shader: T = refract (I, N, etaRatio);
References:
Cg Toolkit
vbGL 1.2 (ANSI) Type Library
vb6 Cg Cube-Map Refraction
Paul Dahuach, 2008-04-25.
|
|
vbCg: Chromatic Dispersion with OpenGL and VB6
Another variation of the example 18, wich had combined the
concepts of reflection and refraction.
Referencias:
Cg Toolkit
vbGL 1.2 (ANSI) Type Library
vb6 Cg Chromatic Dispersion
Paul Dahuach, 2008-04-25.
|
|
vbCg: Bump-Map Wall with OpenGL and VB6
This example can be used as introduction to the
technique of bump-mapping applying it over one of the
simplest flat objects, a square.
Serves also, to demonstrate how simply can be implemented
this effect when one relies on access to the hardware
acceleration and to a resource as useful as texCUBE().
References:
Cg Toolkit
vbGL 1.2 (ANSI) Type Library
vb6 Cg Bump-Map Wall
Paul Dahuach, 2008-04-25.
|
|
vbCg: BumpMaps con OpenGL en VB6
The beautiful technique of the Bump-mapping, using in this case
a map of normal and a cube map. It is usually applied
for generating the highest level of detail with a
limited group of polygons.
At the same time, it shows how to revolutionize a flat form
to create the torus.
Referencias:
Cg Toolkit
vbGL 1.2 (ANSI) Type Library
vb6 Cg Bump-Map Torus
Paul Dahuach, 2008-04-22.
|
|
vbCg: Uniform Fog with OpenGL and Cg from VB6
A new offer for the generation of fog, in this opportunity,
using a linear interpolation in the fragment shader with the
lerp() function to calculate the degree of visibility between
the objects and the fog.
The textures applied to the objects are extracted from DDS files
acceding directly in binary form and passing them to OpenGL
practically without any process.
References:
Cg Toolkit
vbGL 1.2 (ANSI) Type Library
vb6 Cg Uniform Fog
Paul Dahuach, 2008-04-27.
|
|
vbCg: CgFX Introduction with Cg 2.0 and OpenGL over VB6
It is time to begin with the good thing, CgFX from vb6, to
accede it was necessary to incorporate the whole API
corresponding to CgFX that had been overlooked in the
first version of vbCg.dll.
At the same time, I have taken advantage to include Cg's
innovations 2.0, with which, the library loses his
compatibility with Cg 1.5. For this motive, I have
renamed the dll as vbCg20.dll to separate it from the
original version and to allow that both versions should
coexist in the same directory. It is necessary to emphasize
that the new dll has not had yet, a sufficiently generous
period of tests to assure a normal access to all the
functions, if someone finds some incorrect definition
in mdlCg.bas, feel free to indicate it and I it will
correct them as soon as i can.
In this example, it is in use cgCreateEffect,
cgCreateTechnique and many other functions that were not
available till now with vbCg.dll.
References:
Cg Toolkit
vbGL 1.2 (ANSI) Type Library
vb6 CgFX ProcFx
|
|
vbCg: CgFX Combine Programs with Cg 2.0 and OpenGL over VB6
A derivative of the example of the torus, using the function
cgCombinePrograms to load from different files and to
combine them in memory, being able accede then to them as
if it was a question of one only.
References:
Cg Toolkit
vbGL 1.2 (ANSI) Type Library
vb6 CgFX Combine Program
Paul Dahuach, 2008-05-01.
|
|
vbCg: CgFX Bump Demo with Cg 2.0 and OpenGL over VB6
A derivative of the example of the torus using a file .cgfx
to define the interfaz that will be accessible from the Cg api.
It defines in addition, different implementations of the
main algorithm in order that it could choose according to
the available hardware.
The code in vb is prepared to draw in multiple passes,
though the current .cgfx defines only one.
References:
Cg Toolkit
vbGL 1.2 (ANSI) Type Library
vb6 CgFX Bump demo
Paul Dahuach, 2008-05-01.
|
|
vbCg: CgFX Bump Demo2 with Cg 2.0 and OpenGL over VB6
A derivative of the example of the torus using a file .cgfx
and defining different implementations of the main algorithm,
between those can be selected the wished one using a
contextual menu. The different implementations come from
different physical files that are included in the principal
file in pre-compilation time.
References:
Cg Toolkit
vbGL 1.2 (ANSI) Type Library
vb6 CgFX Bump demo2
Paul Dahuach, 2008-05-01.
|
|
vbCg: CgFX Interfaces con Cg 2.0 y OpenGL en VB6
In this example it is possible to choose between different
techniques taking advantage of the shader model that
implements the hardware of the client and in addition it
presents an interface that encapsulates a logic of layers
with independent effects. It includes in addition, a fps
counter.
References:
Cg Toolkit
vbGL 1.2 (ANSI) Type Library
vb6 CgFX Interfaces
Paul Dahuach, 2008-05-01.
|
|
vbCg: Buffer Ligthing with Cg 2.0 and OpenGL on VB6
Example demonstrating use of buffers to
contain uniform material, transform, and lighting
parameters.
For this it is served such functions like cgCreateBuffer,
cgSetProgramBuffer, cgSetBufferSubData, cgGetParameterBufferIndex and
cgGetParameterBufferOffset,
References:
Cg Toolkit
vbGL 1.2 (ANSI) Type Library
vb6 Buffer Lighting
Paul Dahuach, 2008-05-07.
|
|
vbCG: Fur effect with OpenGL and VB6
This time, a basic example of the real time generation of hair through vertex and fragment/pixels shaders.
The idea came from Jan Tosovsky of
nio.astronomy.cz
, who raised the doubt it brings over of if it would be possible to generate this effect in vb. So here it is the answer.
Clear it is that in this area, exists variants so much complex than this one, but I believe that it serves to begin in the
topic. A good place to begin to study the topic is
bkenwright@xbdev.net
article that explains it with a great clarity and in gradual form.
The example uses, to accede to the extensions referred to the managing of multiple textures, the class of Raedwulf.
References:
Fur effect with Visual Basic 6 and vbCg
vbGL 1.2 (ANSI) Type Library
OpenGL Extensions 2.0 for VB6
Paul Dahuach, 2008-04-02.
|
|
vbCg: CgFX Glow and FBO with OpenGL and VB6
This example comes from the sdk 10 of NVIDIA and proposes a
CgFX shader to generate Gaussian Blur as a post-production effect.
This version differs from the original one in that the last
step draws the effect finished as a texture applied to a
rectangle superposed to the original scene, whereas the
original version allows that the shader should take charge
applying it automatically. In this example FBO
(Frame Buffer Objects) are in use for rendering in two
temporary textures. One of these textures is the one that is
applied to a rectangle located just in front of the camera.
References:
CgFx Glow with OpenGL and Visual Basic 6
NVIDIA SDK10 C++ Simple Glow
vbGL 1.2 (ANSI) Type Library
OpenGL Extensions 2.0 for VB6
Paul Dahuach, 2008-06-15.
|
|
NeHe Lesson 37 and Lesson 38 in VB6
NeHe's lessons
have been for me of great help in my beginning with
OpenGL. If one begins to follow the lessons from the
first to the last one, it will dominate many of the
fundamental features of OpenGL.
Thanks to the contributions of the community,
the lessons have been ported to different languages
among which Visual Basic is.
Lamentably only there are ports to VB up to the
lesson 36, of a whole of 48. A small contribution of my
part, the lesson 37 and lesson 38 ported to VB6.
References:
NeHe Lesson 37
NeHe Lesson 38
NeHe Lesson 37 in VB6
NeHe Lesson 38 in VB6
vbGL 1.2 (ANSI) Type Library
Paul Dahuach, 2008-03-29.
|
|
NeHe's Lesson 39 & Lesson 40 in VB6
Two more lessons ported to vb6, in this case related to the
simulation of physical effects as the gravity, the
acceleration, the friction, the mass, the force, etc.
These lessons are not particularly attractive visually, but
they help to understand the methods that usually use the
games or the simulation applications to recreate the behavior
of the materials in the reality.
In the lesson 39, I have tried to respect to the maximum the
approach of the author in the implementation and I used a
series of classes to realize all the operations. As expected,
this approach in Visual Basic is not, in general, the most
efficient path at the moment of measuring times of execution.
In the lesson 40, the results of using the same approach
that the original author (all included in classes) was
Incredibly slow, so I chose to go without the classes and
fall down to the functional programming, whose performance
is very much efficient in repetitive calls.
References:
NeHe's Lesson 39
NeHe's Lesson 40
NeHe Lesson 39 en VB6
NeHe Lesson 40 en VB6
vbGL 1.2 (ANSI) Type Library
Paul Dahuach, 2008-04-06.
|
|
NeHe's Lesson 41 (Volumetric Fog Tutorial) in VB6
The Lesson 41 demonstrates how simply is to add a volumetric fog effect to a scene
using the GL_EXT_fog_coord extension.
References:
NeHe's Lesson 41
NeHe Lesson 41 in VB6
vbGL 1.2 (ANSI) Type Library
Paul Dahuach, 2008-04-09.
|
|
NeHe's Lesson 42 (Multiple Viewports) in VB6
The lesson 42 shows a procedure to handle several Viewports simultaneously.
At the same time, donates to us an algorithm for dynamic maze generation.
References:
NeHe's Lesson 42
NeHe Lesson 42 in VB6
vbGL 1.2 (ANSI) Type Library
Paul Dahuach, 2008-04-09.
|
|
NeHe's Lesson 43 (TrueType Font Tutorial) en VB6
This tutorial shows you how to use TrueType fonts with an
alternative method to the classic one that uses wglUseFontBitmaps,
in order to achieve an smoothed effect when drawing text on
screen.
I must confess that it was not easy to port this example to
vb6, mainly for the incompatibility of calling conventions
presented by the FreeType library.
The library possesses a simple method to change the calling
convention: redefining the macros FT_EXPORT and FT_EXPORT_DEF,
though changeing the convention to __ stdcall,
that is the only one that vb can understand, produces
some collateral effects that leave the dll failing in
some points of the code.
Definitively, The FreeType version that I had attached to the
source code of the example only exports with __ stdcall
the necessary functions to port this example and I leave
the one who wants to go deeper into this topic the task of
exporting with __ stdcall the remaining ones.
References:
NeHe's Lesson 43
NeHe Lesson 43 in VB6
FreeType 2.1.10 modified for VB6
vbGL 1.2 (ANSI) Type Library
Paul Dahuach, 2008-04-13.
|
|
NeHe's Lesson 44 (Lens Flare Tutorial) in VB6
This tutorial shows how to simulate the the reflection
that produces the light when faces the lens of the camera
(without hardware acceleration).
Pressing the key 1, there can be seen a series of statistical
information among which you will find a FPS counter, this way
the author introduces close to the principal topic, procedures
to draw text in 2D and to count the frames per second.
References:
NeHe's Lesson 44
NeHe's Lesson 44 in VB6
vbGL 1.2 (ANSI) Type Library
Paul Dahuach, 2008-04-13.
|
|
NeHe's Lesson 45 (VBO (Vertex Buffer Objects) Tutorial) in VB6
One of the most interesting lessons of the serie, it
presents the basics to send a massive quantity of geometry,
coordinates of textures, colors and indexes directly to the
video card, increasing considerably the performance when
drawing complex scenes.
The most important functions used in this example:
glGenBuffersARB, glBindBufferARB, glBufferDataARB,
glVertexPointer, glTexCoordPointer and glDrawArrays.
NOTE: the original example uses the GLAUX library, this one
is really difficult to obtain and, since nobody wants to
include a 1MB+ dll just to load a picture, I have decided
to avoid the references to it.
References:
NeHe's Lesson 45
NeHe's Lesson 45 in VB6
vbGL 1.2 (ANSI) Type Library
OpenGL Extensions 2.0 for VB6
Paul Dahuach, 2008-04-13.
|
|
NeHe's Lesson 46 (FSAA (Full Scene Anti Aliasing) Tutorial) en VB6
This example, shows how to activate the Anti-alias filtering
to smooth the classic edge of handsaw in the diagonal
surfaces. The original tutorial looks for the presence of
the extension WGL_ARB_multisample to activate the effect,
for my part, this extension it was not present on my video
card, thats why I added the search of the extension
GL_ARB_multisample before giving up with the validation.
I have used an alternative method to call wglChoosePixelFormatARB,
by useing a modified version of the CallApiByName function,
which I do not know from where it came out, but you can find
many references to it in Google.
It is necessary to emphasize that this method is much slower
than the VTable class replacement method, thats why I do not
recommend it for the code that forms a part of the main loop.
References:
NeHe's Lesson 46
NeHe's Lesson 46 in VB6
vbGL 1.2 (ANSI) Type Library
OpenGL Extensions 2.0 for VB6
CallApiByName
Paul Dahuach, 2008-04-13.
|
|
NeHe's Lesson 47 en VB6
This one is a version ported to vb6 of the lesson 47
that there introduces a very basic example of a vertex
shader that produces a visible effect on the geometry.
To implement it in vb6, we use our small dll that allow
us to accede to OpenGL's portion in Cg, so called CgGL.
Note: NVIDIA has published the version 2.0 of the Cg
Toolkit in January, 2008, in this one they present
many innovations, among which one finds the access to
Geometry Shaders. The version of the toolkit used to
compile vbCg.dll, is the 1.5; this way, so, it does not
include the necessary definitions to handle Geometry Shaders,
though in a little time I will incorporate them.
References:
NeHe Lesson 47
NeHe Lesson 47 in VB6
vbGL 1.2 (ANSI) Type Library
Paul Dahuach, 2008-03-31.
|
|
NeHe's Lesson 48 (ArcBall Rotation Tutorial) en VB6
The last NeHe's tutorial until today, shows how to manipulate
the rotation of 3D objects with the mouse. I have seen many
other implementations of the same feature in vb, for example
you can check out the Ken Shoemake's one.
References:
NeHe's Lesson 48
NeHe's Lesson 48 in VB6
vbGL 1.2 (ANSI) Type Library
Paul Dahuach, 2008-04-13.
|
|
vbNewton: Game Dynamics Hello in VB6
An example to step into the world of Newton Game Dynamics,
an sdk for the simulation of physical effects.
References:
Newton Game Dynamics
vbNewton Hello
Paul Dahuach, 2008-06-28.
|
|
vbNewton: Using Callbacks in VB6
A little bit more on Newton, this time we begin to use the
callback functions that are in use everywhere in Newton.
The function that we use in this example is called to the
moment to apply force and torque to a body, opportunely,
Newton passes a pointer to the body that is going to
receive the force. The example shows also the form in
which Newton takes charge simulating the collision between
the different bodies.
References:
Newton Game Dynamics
vbNewton Callbacks
Paul Dahuach, 2008-06-28.
|
|
Comment:
|
|