… | |
… | |
14 | #include "txtprt_import.h" |
14 | #include "txtprt_import.h" |
15 | |
15 | |
16 | CGcontext cgc; |
16 | CGcontext cgc; |
17 | CGprogram vsh, fsh; |
17 | CGprogram vsh, fsh; |
18 | CGparameter mv, mvp, lightpos; |
18 | CGparameter mv, mvp, lightpos; |
|
|
19 | CGprofile vsh_profile, fsh_profile; |
19 | |
20 | |
20 | static void CheckCgError(void) |
21 | static void CheckCgError(void) |
21 | { |
22 | { |
22 | CGerror err = cgGetError(); |
23 | CGerror err = cgGetError(); |
23 | |
24 | |
… | |
… | |
374 | //glLightf (GL_LIGHT0, GL_QUADRATIC_ATTENUATION); |
375 | //glLightf (GL_LIGHT0, GL_QUADRATIC_ATTENUATION); |
375 | //glLightfv (GL_LIGHT0, GL_DIFFUSE, lightc); |
376 | //glLightfv (GL_LIGHT0, GL_DIFFUSE, lightc); |
376 | glEnable (GL_LIGHT0); |
377 | glEnable (GL_LIGHT0); |
377 | |
378 | |
378 | cgc = cgCreateContext (); |
379 | cgc = cgCreateContext (); |
|
|
380 | |
|
|
381 | vsh_profile = CG_PROFILE_ARBVP1; |
|
|
382 | if (cgGLIsProfileSupported (CG_PROFILE_VP30)) vsh_profile = CG_PROFILE_VP30; |
|
|
383 | if (cgGLIsProfileSupported (CG_PROFILE_VP40)) vsh_profile = CG_PROFILE_VP40; |
|
|
384 | fsh_profile = CG_PROFILE_ARBFP1; |
|
|
385 | if (cgGLIsProfileSupported (CG_PROFILE_FP30)) fsh_profile = CG_PROFILE_FP30; |
|
|
386 | if (cgGLIsProfileSupported (CG_PROFILE_FP40)) fsh_profile = CG_PROFILE_FP40; |
|
|
387 | |
379 | vsh = cgCreateProgramFromFile (cgc, CG_SOURCE, "vsh.cg", CG_PROFILE_ARBVP1, 0, 0); |
388 | vsh = cgCreateProgramFromFile (cgc, CG_SOURCE, "vsh.cg", vsh_profile, 0, 0); |
380 | CheckCgError (); |
389 | CheckCgError (); |
381 | cgGLLoadProgram (vsh); |
390 | cgGLLoadProgram (vsh); |
382 | CheckCgError (); |
391 | CheckCgError (); |
383 | mv = cgGetNamedParameter (vsh, "WorldProj"); |
392 | mv = cgGetNamedParameter (vsh, "WorldProj"); |
384 | mvp = cgGetNamedParameter (vsh, "WorldViewProj"); |
393 | mvp = cgGetNamedParameter (vsh, "WorldViewProj"); |
385 | lightpos = cgGetNamedParameter (vsh, "LightPos"); |
394 | lightpos = cgGetNamedParameter (vsh, "LightPos"); |
386 | CheckCgError (); |
395 | CheckCgError (); |
387 | |
396 | |
388 | fsh = cgCreateProgramFromFile (cgc, CG_SOURCE, "fsh.cg", CG_PROFILE_ARBFP1, 0, 0); |
397 | fsh = cgCreateProgramFromFile (cgc, CG_SOURCE, "fsh.cg", fsh_profile, 0, 0); |
389 | CheckCgError (); |
398 | CheckCgError (); |
390 | cgGLLoadProgram (fsh); |
399 | cgGLLoadProgram (fsh); |
391 | CheckCgError (); |
400 | CheckCgError (); |
392 | |
401 | |
393 | cgGLBindProgram (vsh); |
402 | cgGLBindProgram (vsh); |