Original Post
Hi, I'm trying to implement bump mapping in a demo application. If I'm right I could: - use the original Blinn's idea modifing the vertex normals -> I'd need meshes with lots of polygons, because it's "per-vertex"; - use the hardware capability of modern graphics card with the new opengl multitexture features; - use fragment shaders. Since I've never studied shaders I'd like to try this way. I already have a class which contains a mesh and has a rendering method. Let's suppose to add two private attributes such as: At runtime, I will have some objects which need Bump Mapping and will have the boolean = true. How would the rendering method change? Should I load the fragment shader when the application starts, and then in the rendering method do: Thanks for any advice :)
private bool bumpMapping;
private const char *bumpMap;
void Render()
{
if(bumpMapping)
{
glPushAttrib(GL_CURRENT_BIT | GL_LIGHTING_BIT | GL_TEXTURE_BIT);
cgGLBindProgram(...);
cgGLEnableProfile(...);
cgGLSetParameter3fv(...);
cgGLSetParameter3fv(...);
cgGLSetParameter3fv(...);
}
// Drawing...
glBegin(...);
...
glEnd();
if(bumpMapping)
{
cgGLDisableProfile(...);
glPopAttrib();
}
}