Any simple vertex programs?

Was wondering if there are any simple vertex programs out there, say, like a nehe tutorial num 1 … just a vertex proggy to say light a quad…

What is wrong with the nehe example?
Are you looking for a GLUT example of vertex array’s?
I am not really shure what you are looking for?

Originally posted by Booga:
Was wondering if there are any simple vertex programs out there, say, like a nehe tutorial num 1 … just a vertex proggy to say light a quad…

There is nothing wrong with a nehe tut … just wanted a tutorial like it that was easy and delt with vertex programs. (per pixel lighting, etc)

Thanks

Look at nehe 7 & 12 go into ligthing of objects.

You need to look at ploting vertex normals for surface lighting.

code will look something
like this.

glNornal3f( x, y,z );
glTexCoord2f(x,y);// if you are using a texture map.
glVertex3f( x, y, z);

Originally posted by Booga:
[b]There is nothing wrong with a nehe tut … just wanted a tutorial like it that was easy and delt with vertex programs. (per pixel lighting, etc)

Thanks [/b]

Originally posted by Booga:
Was wondering if there are any simple vertex programs out there, say, like a nehe tutorial num 1 … just a vertex proggy to say light a quad…

OpenGL texture shader tutorial http://www.cfxweb.net/~projectfy/shaders.php

I think he is talking about the GL_NV_vertex_program extension .
That´s the NV OGL thing for the DX8 vertex shaders.

I copied this from a NVIDIA demo, perhaps it helps:

#ifdef _WIN32
#include <windows.h>
#endif
#define GLH_NVEB_USING_NVPARSE
#define GLH_EXT_SINGLE_FILE
#include <glh_nveb.h>
#include <glh_extensions.h>
#include <glh_genext.h>
#include <glh_glut.h>
#include <glh_obs.h>
#include “array_texture.h”
#include “data_path.h”
#include “nv_png.h”
#include “nvparse.h”
#include “read_text_file.h”

// Declare the effect browser information

NVEB_EFFECT_NAME(“Lit Quad”);
NVEB_EFFECT_VERSION(“1.0”);
NVEB_EFFECT_LOCATION(“Effects\Basic”);
NVEB_EFFECT_ABOUT(0, NULL, “Lit Quad”, “NVEffectsExplained.htm#vtxprg_litquad”);
NVEB_EFFECT_ABOUT(1, NULL, “NVIDIA Corporation”, “http://www.nvidia.com”);
NVEB_EFFECT_ABOUT(2, NULL, “Developer Relations”, “NVIDIA Developer”);
NVEB_EFFECT_EXTENSIONS(“GL_NV_vertex_program”);

using namespace glh;

glut_callbacks cb;
glut_simple_mouse_interactor camera, object;
glut_perspective_reshaper reshaper;

// Some structures for storing data.

struct xyzstruct {
float x;
float y;
float z;
};
struct uvstruct {
float u;
float v;
};

// Data for the Quad.
xyzstruct vertexdata[4];
xyzstruct normaldata[4];
uvstruct texuvdata[4];

// Vertex Program ID (Similar to a texture object ID)
// Vertex State Program ID (Similar to a texture object ID)
GLuint vpid;
GLuint vspid;

// Texture object for the texture.
tex_object_2D decaltex;

void CheckParseErrors()
{
for (char * const * errors = nvparse_get_errors(); *errors; errors++)
fprintf(stderr, *errors);
}

// Initialize data for the quad.
void InitializeQuadData()
{
vertexdata[0].x = -1; normaldata[0].x = 0; texuvdata[0].u = 0.0;
vertexdata[0].y = -1; normaldata[0].y = 0; texuvdata[0].v = 0.0;
vertexdata[0].z = 0; normaldata[0].z = 1;

vertexdata[1].x = 1;    normaldata[1].x = 0;    texuvdata[1].u = 1.0;
vertexdata[1].y = -1;   normaldata[1].y = 0;    texuvdata[1].v = 0.0;
vertexdata[1].z = 0;    normaldata[1].z = 1;

vertexdata[2].x = 1;    normaldata[2].x = 0;    texuvdata[2].u = 1.0;
vertexdata[2].y = 1;    normaldata[2].y = 0;    texuvdata[2].v = 1.0;
vertexdata[2].z = 0;    normaldata[2].z = 1;

vertexdata[3].x = -1;   normaldata[3].x = 0;    texuvdata[3].u = 0.0;
vertexdata[3].y = 1;    normaldata[3].y = 0;    texuvdata[3].v = 1.0;
vertexdata[3].z = 0;    normaldata[3].z = 1;

}

// Display function.
void display()
{
glClear( GL_COLOR_BUFFER_BIT |GL_DEPTH_BUFFER_BIT );

// Setup the viewing transformation
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();

camera.apply_inverse_transform();
object.apply_transform();

// Vertex "state" programs are used to update data stored in constant
// memory.  Vertex state programs differe from standard vertex programs
// in that they may read AND write to constant memory but may not write
// to the output registers.

// Run a vertex state program that transforms the light direction
// into object space and puts the result in c[4].  Also, transforms
// the view direction into object space and puts the result in c[8].
// Also, computes an object space H vector and stores in c[5].
// Normally you'd rotate the normal by the inverse transpose modelview,
// but rotating the light direction by the inverse modelview puts the
// light in object space - the same space as the normals.
float lightdir[4] = { 0.7071, 0.0, -0.7071, 0.0 };
// Put a camera space view vector in constant register 5
glProgramParameter4fNV( GL_VERTEX_PROGRAM_NV, 8, 0.0, 0.0, -1.0, 1.0 );
glExecuteProgramNV( GL_VERTEX_STATE_PROGRAM_NV, vspid, lightdir );

// c[4] now contains object space L vector.
// c[5] now contains object space H vector.
// c[8] now contains object space V vector.
// Enable the vertex program.
glBindProgramNV( GL_VERTEX_PROGRAM_NV, vpid );
glEnable( GL_VERTEX_PROGRAM_NV );

// Put the material color in register 6
glProgramParameter4fNV( GL_VERTEX_PROGRAM_NV, 6, 0.5, 0.7, 0.5, 1.0 );
// Put a (0,10,20,25) in register 7
glProgramParameter4fNV( GL_VERTEX_PROGRAM_NV, 7, 0.0, 10.0, 50.0, 100.0 );
// Put the light color in register 10
glProgramParameter4fNV( GL_VERTEX_PROGRAM_NV, 10, 0.7, 0.7, 1.0, 1.0 );

decaltex.bind();
decaltex.enable();

// Draw the quad.
glBegin( GL_QUADS );

    glTexCoord2fv( &(texuvdata[0].u) );
    glNormal3fv( &(normaldata[0].x) );
    glVertex3fv( &(vertexdata[0].x) );

    glTexCoord2fv( &(texuvdata[1].u) );
    glNormal3fv( &(normaldata[1].x) );
    glVertex3fv( &(vertexdata[1].x) );

    glTexCoord2fv( &(texuvdata[2].u) );
    glNormal3fv( &(normaldata[2].x) );
    glVertex3fv( &(vertexdata[2].x) );

    glTexCoord2fv( &(texuvdata[3].u) );
    glNormal3fv( &(normaldata[3].x) );
    glVertex3fv( &(vertexdata[3].x) );

glEnd();

decaltex.disable();

// Disable the vertex program.
glDisable( GL_VERTEX_PROGRAM_NV );

glutSwapBuffers();
}

void LOAD_VERTEX_PROGRAM( unsigned int _i, char *_n )
{
char *str = read_text_file( _n );
glBindProgramNV( GL_VERTEX_PROGRAM_NV, _i );
nvparse( str );
CheckParseErrors();
delete str;
}

void LOAD_VERTEX_STATE_PROGRAM( unsigned int _i, char *_n )
{
char *str = read_text_file( _n );
nvparse( str, _i );
CheckParseErrors();
delete str;
}

void init_opengl()
{
if( !glh_init_extensions( “GL_NV_vertex_program” ) )
{
cerr << “Necessary extensions were not supported:” << endl
<< glh_get_unsupported_extensions() << endl << endl
<< “Press to quit.” << endl;
char buff[10];
cin.getline(buff, 10);
exit( -1 );
}

// Create the vertex program.
glGenProgramsNV( 1, &vpid );

LOAD_VERTEX_PROGRAM( vpid, “vtxprg_litquad.vp” );

// Create the vertex state program that transforms the directional light into object space.
glGenProgramsNV( 1, &vspid );

LOAD_VERTEX_STATE_PROGRAM( vspid, “vtxprg_litquad.vsp” );

// Track the concatenation of the modelview and projection matrix in registers 0-3.
glTrackMatrixNV( GL_VERTEX_PROGRAM_NV, 0, GL_MODELVIEW_PROJECTION_NV, GL_IDENTITY_NV );

// Track the modelview matrix in registers 12-15 for use by the vertex state program.
glTrackMatrixNV( GL_VERTEX_PROGRAM_NV, 12, GL_MODELVIEW, GL_INVERSE_NV );
decaltex.bind();
array2<vec3ub> decal_img;
read_png_rgb("rgb_gloss_map.png", decal_img);
make_rgb_texture( decal_img, true );
decaltex.parameter( GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
decaltex.parameter( GL_TEXTURE_MAG_FILTER, GL_LINEAR );

// Setup the blending state.
nvparse( "!!RC1.0       

"
"out.rgb = tex0 * col0;
" );
CheckParseErrors();

glClearColor( 0.67, 0.67, 0.67, 1.0 );

}

void keyboard( unsigned char k, int x, int y )
{
if ( k == 27 | | k == ‘q’ )
{
glDeleteProgramsNV( 1, &vpid );
glDeleteProgramsNV( 1, &vspid );
exit( 0 );
}
}

void idle()
{
object.trackball.increment_rotation();
glutPostRedisplay();
}

int main( int argc, char **argv )
{
glutInit( &argc, argv );
glutInitDisplayMode( GLUT_DOUBLE | GLUT_DEPTH | GLUT_RGB );
glutInitWindowSize( 512, 512 );
glutInitWindowPosition( 256, 256 );
glutCreateWindow( “vtxprg_litquad” );

// Initialize the data for Quad.
InitializeQuadData();

// Do some OpenGL initialization.

init_opengl();

glut_helpers_initialize();

cb.keyboard_function = keyboard;
cb.idle_function = idle;
camera.configure_buttons(1);
camera.set_camera_mode(true);
camera.pan.pan = vec3f( 0.0, 0.0, 2.0 );
object.configure_buttons(1);
object.dolly.dolly[2] = -1;

glut_add_interactor(&cb);
glut_add_interactor(&object);
glut_add_interactor(&reshaper);

glut_idle(1);

glutDisplayFunc( display );
glutMainLoop();
}

Diapolo

try here
http://www.chronos-central.com/

nehe type and very easy

Nutty has one on his site also, the last tutorial on this page:
http://opengl.nutty.org/extensions/index.html