Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 5 of 5

Thread: help a fellow coder in need

  1. #1
    Intern Contributor
    Join Date
    Sep 2002
    Location
    london, uk
    Posts
    64

    help a fellow coder in need

    hi. can you help with these questions?

    1) proper bump/reflection/refraction mapping: could you please point me to some sample code (don't need an entire app) that only uses opengl 1.3 and/or arb extensions? i've got nvidia sdk but it relies on nv_combiners etc, i'm looking for a method that (a) is not reliant on a specific card/manufacturer, (b) allows me to vary the intensity of bumping *and* highlight colour/strength (preferrably dynamically and per vertex, but per triangle's okay too)

    2) somewhat related to the above, i understand that, for max performance, you need to use vertex programs (otherwise it's respecify entire world geometry every frame): opengl 1.4 pdf doesn't say how you write vertex programs, is there a place where i can get language spec/syntax reference, like intel assemebly opcodes? hopefully some simple example code chunks, as i want to explore custom lighting etc.

    3) colour/convolution matrix (the imaging subset): again, glspec 1.4 pdf is too abstract for my coding brain - are there any decent code samples on potential application? specifically, i wanna know if you can use it for things like hue rotation, on-the-fly tinting/grayscaling/colour space inversion (like a smooth "flash" from negative to normal image colours).

    i haven't been able to play with these features cos there's no opengl 1.3/1.4 sdk for win32 and i'm in the process of building my own headers/libs, and all of these features are post-1.1 version of opengl. formal gl spec is quite impenetrable in places and i prefer to learn through code, so if you could help/point me to a good resource, i'd be well grateful if it helps in any way, i've done around 10 years of c/c++ and about 3-4 years of opengl 1.1. thanks for reading

  2. #2
    Intern Contributor
    Join Date
    Oct 2002
    Posts
    56

    Re: help a fellow coder in need

    http://www.opengl.org/discussion_boa...ML/007714.html
    http://www.opengl.org/discussion_boa...ML/007732.html


    Here's some snippets from a program I made:
    Code :
    typedef void (__stdcall *PFNGLGENPROGRAMSARB) ( int n, const unsigned int
    *programs );
    typedef void (__stdcall *PFNGLBINDPROGRAMARB) ( const int target, unsigned
    int program );
    typedef void (__stdcall *PFNGLPROGRAMSTRINGARB) ( const int target, const
    int format, int len, const void *string );
     
     
    PFNGLGENPROGRAMSARB   glGenProgramsARB = NULL;
    PFNGLBINDPROGRAMARB   glBindProgramARB = NULL;
    PFNGLPROGRAMSTRINGARB  glProgramStringARB = NULL;
     
     
    // membrane effect (as seen in nVidia effects browser)
    const unsigned char myprogram[] = "!!ARBvp1.0 \n\
     # variable declarations\n\
     TEMP xfNorm, xfPos, r0;\n\
     # transform vertex to clip cooridinates\n\
     DP4 result.position.x, state.matrix.mvp.row[0], vertex.position;\n\
     DP4 result.position.y, state.matrix.mvp.row[1], vertex.position;\n\
     DP4 result.position.z, state.matrix.mvp.row[2], vertex.position;\n\
     DP4 result.position.w, state.matrix.mvp.row[3], vertex.position;\n\
     # produce point-to-eye vector\n\
     DP4 xfPos.x, state.matrix.modelview.row[0], vertex.position;\n\
     DP4 xfPos.y, state.matrix.modelview.row[1], vertex.position;\n\
     DP4 xfPos.z, state.matrix.modelview.row[2], vertex.position;\n\
     DP4 xfPos.w, state.matrix.modelview.row[3], vertex.position;\n\
     # normalize point-to-eye vector\n\
     DP3 r0.x, xfPos, xfPos;\n\
     RSQ r0.x, r0.x;\n\
     MUL xfPos, xfPos,-r0.x;\n\
     # transform normal to eye coordinates\n\
     DP3 xfNorm.x, state.matrix.modelview.invtrans.row[0], vertex.normal;\n\
     DP3 xfNorm.y, state.matrix.modelview.invtrans.row[1], vertex.normal;\n\
     DP3 xfNorm.z, state.matrix.modelview.invtrans.row[2], vertex.normal;\n\
     # determine color\n\
     DP3 r0.x, xfPos, xfNorm;\n\
     ADD result.color, vertex.normal.w,-r0.x;\n\
     MOV result.texcoord[0].x, r0.x;\n\
     END";
     
     
    // cloaked object effect
    const unsigned char myprogram[] = "!!ARBvp1.0 \n\
     # variable declarations\n\
     TEMP xfNorm, xfPos, xfLit, Half, r0;\n\
     # transform vertex to clip cooridinates\n\
     DP4 result.position.x, state.matrix.mvp.row[0], vertex.position;\n\
     DP4 result.position.y, state.matrix.mvp.row[1], vertex.position;\n\
     DP4 result.position.z, state.matrix.mvp.row[2], vertex.position;\n\
     DP4 result.position.w, state.matrix.mvp.row[3], vertex.position;\n\
     # produce point-to-eye vector\n\
     DP4 xfPos.x, state.matrix.modelview.row[0], vertex.position;\n\
     DP4 xfPos.y, state.matrix.modelview.row[1], vertex.position;\n\
     DP4 xfPos.z, state.matrix.modelview.row[2], vertex.position;\n\
     DP4 xfPos.w, state.matrix.modelview.row[3], vertex.position;\n\
     # normalize point-to-eye vector\n\
     DP3 r0.x, xfPos, xfPos;\n\
     RSQ r0.x, r0.x;\n\
     MUL xfPos, xfPos,-r0.x;\n\
     # transform normal to eye coordinates\n\
     DP3 xfNorm.x, state.matrix.modelview.invtrans.row[0], vertex.normal;\n\
     DP3 xfNorm.y, state.matrix.modelview.invtrans.row[1], vertex.normal;\n\
     DP3 xfNorm.z, state.matrix.modelview.invtrans.row[2], vertex.normal;\n\
     # produce light vector\n\
     ADD xfLit, state.light[0].position,-xfPos;\n\
     # normalize light vector\n\
     DP3 r0.x, xfLit, xfLit;\n\
     RSQ r0.x, r0.x;\n\
     MUL xfLit, xfLit, r0.x;\n\
     # compute half vector\n\
     ADD Half, xfLit, xfPos;\n\
     # normalize half vector\n\
     DP3 r0.x, Half, Half;\n\
     RSQ r0.x, r0.x;\n\
     MUL Half, Half, r0.x;\n\
     # determine color\n\
     DP3 r0.y, xfNorm, Half;\n\
     MOV r0.w, state.material.shininess;\n\
     LIT r0, r0;\n\
     DP3 r0.x, xfNorm, xfPos;\n\
     MUL r0.z, r0.z, r0.z;\n\
     ADD result.color, r0.z,-r0.x;\n\
     END";
     
     
     glGenProgramsARB = (PFNGLGENPROGRAMSARB)wglGetProcAddress(
    "glGenProgramsARB" );
     glBindProgramARB = (PFNGLBINDPROGRAMARB)wglGetProcAddress(
    "glBindProgramARB" );
     glProgramStringARB = (PFNGLPROGRAMSTRINGARB)wglGetProcAddress(
    "glProgramStringARB" );
     if (!glGenProgramsARB | | !glBindProgramARB | | !glProgramStringARB) {
      MessageBox( NULL, "Unable to retrieve vertex program procedure
    addresses.", "", MB_OK );
      return false; }
     glGenProgramsARB( 1, programs );
     glBindProgramARB( GL_VERTEX_PROGRAM_ARB, programs[0] );
     glProgramStringARB( GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
    strlen( (const char*)myprogram ), myprogram );
     if (glGetError() == GL_INVALID_OPERATION)   // tripped
      MessageBox( NULL, "Invalid Operation", "", MB_OK );
     
     
    // ... and last, but not least, our beloved glEnable() call.
     glEnable( GL_VERTEX_PROGRAM_ARB );

  3. #3
    Intern Contributor
    Join Date
    Sep 2002
    Location
    london, uk
    Posts
    64

    Re: help a fellow coder in need

    thanks, code chunks are always handy, but i was primarily looking for the vertex program _language_ reference... gl 1.4 pdf has nothing to say on that, there must be a proper language spec somewhere

    any takers on the other two?

  4. #4
    Junior Member Regular Contributor
    Join Date
    Sep 2001
    Location
    Wake Forest, NC, USA
    Posts
    176

    Re: help a fellow coder in need

    The ARB_vertex_program extension spec can be found at:
    http://oss.sgi.com/projects/ogl-samp...ex_program.txt


    [This message has been edited by pbrown (edited 10-31-2002).]

  5. #5
    Intern Contributor
    Join Date
    Sep 2002
    Location
    london, uk
    Posts
    64

    Re: help a fellow coder in need

    phew. that'll keep me busy for years thanks

    what about the imaging subset? as far as i can remember right now, even my lowly gf2 supports it... sort of makes sense, cos as far as i know, according to gl spec the subset is either supported or not, and since the very common additive blending is part of it, you get the whole subset functionality?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •