View Full Version : NVIDIA CG in thinBASIC
Petr Schreiber
03-05-2008, 09:40
Hi,
week ago, Abraxas send me message about VisualBASIC 6 tutorials, which show how to use NVIDIA CG in VB.
VB uses wrapper library created by Paul Dahuach, but as it is DLL, thinBASIC can use it too.
Yesterday I made another exam, so to celebrate a bit I did the conversion :)
Here is attached sample "Ejemplo 2" ( see all original VB samples here (http://www.pauldahuach.com.ar/program_en.htm#vbCG2) ), which basically paints primitives red :).
You will need NVIDIA CG installed (http://developer.nvidia.com/object/cg_toolkit.html) ( or at least have cg.DLL and cgGL.DLL in same directory as the script ), not sure if it is suitable for ATi/Intel/S3/Matrox... , I guess not :'(
The CG is shader language developed by NVIDIA, something like GLSL, but little different.
You can design shaders in kind of visual way using NVIDIA FX Composer (http://developer.nvidia.com/object/fx_composer_home.html) too.
Have fun, more complex samples will come once I will have more time again.
Bye,
Petr
P.S. The wrapper cgVB.DLL probably will not be necessary once I will do cg*.h headers conversion
Learning resources
The CG Tutorial (http://http.developer.nvidia.com/CgTutorial/cg_tutorial_chapter01.html)
eBook from NVIDIA, explains CG from the basics
Petr Schreiber
03-05-2008, 10:00
You can play with the shader and see what it does,
for example modifying file C2E1v_red.cg ( from zip above ) to:
struct C2E1v_Output {
float4 position : POSITION;
float3 color : COLOR;
};
C2E1v_Output C2E1v_red(float2 position : POSITION)
{
C2E1v_Output OUT;
OUT.position = float4(position,0,1);
OUT.color = float3(1+position.x,position.x > position.y,0);
return OUT;
}
... will give completely new look, as seen on image below :)
Petr
Hey Petr, I thought I'd tell you that it works on my graphics card. :o
I just downloaded the redistributable binaries from this (http://developer.nvidia.com/object/cg-redistributable-binaries.html) page & installed them.
Petr Schreiber
03-05-2008, 15:06
Hi,
I thought you have some Intel or SiS onboard, if it does work with it then I am saying bye to GLSL ;D
Am I correct?
Petr
Yeah, my old XP laptop had a SiS card, my new Vista laptop has an Intel card.
I've tried both the thinBasic examples & they worked, the original VB6 examples wouldn't work but that's probably because VB6 programs aren't really supported on Vista.
Petr Schreiber
03-05-2008, 16:05
Thats is fantastic news,
thanks a lot Matthew!
Petr
Petr, I will test it tonight... the eeepc has an intel graphics chip... will report back then. Am installing apps tonight on it.
I love how you can just crank out one surprise after another when you have even just a little bit of time, congrats on your exams
going well by the way!
I get an error on the eeepc. The intel 915gm in the chart says it should support shaders.
http://www.intel.com/support/graphics/sb/cs-014257.htm
Attached is a screenshot of the dll's I placed from the binaries that Matthew linked to.
Petr Schreiber
05-05-2008, 07:01
Hi Kent,
thanks for the testing, Intel claims on that site that:
Intel provides an optimized graphics pipeline for vertex processing that is included in Microsoft* DirectX*. This can be used by games to provide software geometry processing.
... so D3D only? I think I read somewhere Intel does vertex shaders in software mode anyway, will try to find that source and check what they write about fragment shaders.
It is quite odd to support VS 1-3 but PS 1-2 :)
Thanks,
Petr
I saw that too about D3D, but why directx and not opengl... doesn't make sense to me. I will do more tests as I install things and write back in the future.
I just finally got to downloading the solar system files you guys made and got an error trying to run it.
So maybe the error is in my install of thinbasic. i will install it again and try...
You might find the attached program useful, I wrote it last Year in Basic4GL, it prints out all the OpenGL Extensions that your Graphic card has in a text file called OpenGL.txt.
Here (http://matthew-4gl.wikispaces.com/space/showimage/opengl_old.txt) are the results from my old card & here (http://matthew-4gl.wikispaces.com/space/showimage/opengl_new.txt) are the results from my new card.
Thanks Matthew. Here is what I got:
GL_VENDOR: Intel
GL_RENDERER: Intel 915GM
GL_VERSION: 1.4.0 - Build 7.14.10.4764
GL_EXTENSIONS: GL_ARB_depth_texture
GL_EXTENSIONS: GL_ARB_fragment_program
GL_EXTENSIONS: GL_ARB_multitexture
GL_EXTENSIONS: GL_ARB_occlusion_query
GL_EXTENSIONS: GL_ARB_point_parameters
GL_EXTENSIONS: GL_ARB_shadow
GL_EXTENSIONS: GL_ARB_texture_border_clamp
GL_EXTENSIONS: GL_ARB_texture_compression
GL_EXTENSIONS: GL_ARB_texture_cube_map
GL_EXTENSIONS: GL_ARB_texture_env_add
GL_EXTENSIONS: GL_ARB_texture_env_combine
GL_EXTENSIONS: GL_ARB_texture_env_dot3
GL_EXTENSIONS: GL_ARB_texture_env_crossbar
GL_EXTENSIONS: GL_ARB_transpose_matrix
GL_EXTENSIONS: GL_ARB_vertex_buffer_object
GL_EXTENSIONS: GL_ARB_vertex_program
GL_EXTENSIONS: GL_ARB_window_pos
GL_EXTENSIONS: GL_EXT_abgr
GL_EXTENSIONS: GL_EXT_bgra
GL_EXTENSIONS: GL_EXT_blend_color
GL_EXTENSIONS: GL_EXT_blend_func_separate
GL_EXTENSIONS: GL_EXT_blend_minmax
GL_EXTENSIONS: GL_EXT_blend_subtract
GL_EXTENSIONS: GL_EXT_clip_volume_hint
GL_EXTENSIONS: GL_EXT_compiled_vertex_array
GL_EXTENSIONS: GL_EXT_draw_range_elements
GL_EXTENSIONS: GL_EXT_fog_coord
GL_EXTENSIONS: GL_EXT_multi_draw_arrays
GL_EXTENSIONS: GL_EXT_packed_pixels
GL_EXTENSIONS: GL_EXT_rescale_normal
GL_EXTENSIONS: GL_EXT_secondary_color
GL_EXTENSIONS: GL_EXT_separate_specular_color
GL_EXTENSIONS: GL_EXT_shadow_funcs
GL_EXTENSIONS: GL_EXT_stencil_two_side
GL_EXTENSIONS: GL_ARB_texture_rectangle
GL_EXTENSIONS: GL_EXT_texture_rectangle
GL_EXTENSIONS: GL_EXT_stencil_wrap
GL_EXTENSIONS: GL_EXT_texture_compression_s3tc
GL_EXTENSIONS: GL_EXT_texture_env_add
GL_EXTENSIONS: GL_EXT_texture_env_combine
GL_EXTENSIONS: GL_EXT_texture_lod_bias
GL_EXTENSIONS: GL_EXT_texture_filter_anisotropic
GL_EXTENSIONS: GL_EXT_texture3D
GL_EXTENSIONS: GL_3DFX_texture_compression_FXT1
GL_EXTENSIONS: GL_IBM_texture_mirrored_repeat
GL_EXTENSIONS: GL_NV_blend_square
GL_EXTENSIONS: GL_NV_texgen_reflection
GL_EXTENSIONS: GL_SGIS_generate_mipmap
GL_EXTENSIONS: GL_SGIS_texture_edge_clamp
GL_EXTENSIONS: GL_SGIS_texture_lod
GL_EXTENSIONS: GL_WIN_swap_hint
lIt works, thanks to Eros's help. Cool stuff, nice to finally see it :)
Petr Schreiber
05-05-2008, 08:19
Thanks for the proggie Matthew,
just for fun here is TBGL version with dialog :)
You can download that new script from TBGL troubleshooting (http://community.thinbasic.com/index.php?topic=668.msg3885#msg3885) sticky topic.
Thanks,
Petr
P.S. Which magic Eros used :) ?
REMOVED ATTACHEMENT
Eros mentioned that thinAir didn't know where to look when not in the root.
I went in edited thinAirdat.ini and set the path in the few places it needed it set and all is fiine now :)
ErosOlmi
05-05-2008, 09:59
Eros mentioned that thinAir didn't know where to look when not in the root.
It is not that thinBasic must be in the root. thinBasic can be installed/placed anywhere.
Problem is that thinBasic extensions are registered to be executed by thinBasic.exe (or thinBasicc.exe). If executable is not placed where it is expected by the OS, it gives error. It is like registering .DOC extension to be executed by WINWORD.EXE but you change the directory where WINWORD.EXE is located. If you double click on a .DOC file the OS will try to find WINWORD.EXE without success.
Petr Schreiber
05-05-2008, 17:51
Hi,
I added link to e-book about CG shading language to the first post.
Petr
P.S. I know I post there too much NVIDIA stuff, I will try to find some nice ATi related code