A computer components & hardware forum. HardwareBanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » HardwareBanter forum » Video Cards » Nvidia Videocards
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Questions regarding nVidia's Cg toolkit



 
 
Thread Tools Display Modes
  #1  
Old September 20th 04, 05:27 PM
O.B.
external usenet poster
 
Posts: n/a
Default Questions regarding nVidia's Cg toolkit

I'm prototyping code to execute a small program on an nVidia GeForce 6800 Ultra
GPU using OpenGL and Cg. However, I'm a bit of newbie in this area and have a
few questions:

1. Is it correct to assume that when cgGLBindProgram is executed that the
CGprogram is executed at that point?

2. Is it correct to assume that when any argument of the CGprogram changes
(after it is binded) that the CGprogram executes again?

3. Is using cgGetNamedParameter the correct operation to access "out" arguments
for the CGprogram?

4. What's the difference between vertex and fragment profiles? Why would you
use one over the other?

5. Where can I find "float3" defined? The Cg manual talks about using it but
never defines it.




Below is my prototype code.

In testProgram.cg:

void testProgram(float3 val1, float3 val2, float returnValue)
{
returnValue = dot(val1, val2);
}

In test.cpp:

int main ()
{
// create context
CGcontext cgContext = cgCreateContext();
if ( 0 == cgContext ) {
return 1;
}

// initialize profiles ... which one is correct to use?
CGprofile vertexProfile = cgGLGetLatestProfile(CG_GL_VERTEX);
cgGLSetOptimalOptions(vertexProfile);
// CGprofile fragmentProfile = cgGLGetLatestProfile(CG_GL_FRAGMENT);
// cgGLSetOptimalOptions(fragmentProfile);

// create program
//
// What's the difference between using a vertextProfile
// and a fragmentProfile?
CGprogram myTestProgram = cgCreateProgramFromFile(
cgContext,
CG_SOURCE,
"testProgram.cg",
vertexProfile,
"testProgram",
0);

// load the program
cgGLLoadProgram(myTestProgram);

// assign parameters
float3 array1 = cgGetNamedParameter(myTestProgram, "val1");
float3 array2 = cgGetNamedParameter(myTestProgram, "val2");

// Is this the correct way for accessing "out" parameters?
float rv = cgGetNamedParameter(myTestProgram, "returnValue");

// set input values
//
// Is it possible to set one element at a time? ie array1[0] = 1.0
array1 = { 1.0, 2.0, 3.0 };
array2 = { 4.5, 5.0, 5.4 };

// Bind the program. I'm assuming this executes testProgram?
//
// Is this a synchronous call? If not, how will I know when the
// computation is complete?
cgGLBindProgram(cgProgram);

// Print returned value
printf("Result = %lf\n", rv);

// Disable profiles
cgGLDisableProfile(vertexProfile);
// cgGLDisableProfile(fragmentProfile);

cgDestroyContext(cgContext);

return 0;
}

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Compaq EN P600 w/i820 chipset upgrade questions Eddie Crismond General 21 November 26th 04 10:17 PM
Nvidia's History with Sega Zackman Nvidia Videocards 37 June 20th 04 07:02 AM
K8V SE Questions William Asus Motherboards 9 April 10th 04 10:09 AM
Throwing out my GeForce2.... questions (kinda long) Uncooked meat prior to state vector collapse Ati Videocards 1 November 6th 03 07:58 AM
serial ATA vs ATA133...can't decide on wich...to much unanswered questions... KILOWATT General 2 July 12th 03 10:13 AM


All times are GMT +1. The time now is 09:19 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 HardwareBanter.
The comments are property of their posters.