├── glut └── lib │ └── glut │ ├── ObjectType.mk │ ├── glut_warp.c │ ├── makefile.nvmk │ ├── glut_keyctrl.c │ ├── glut_dials.c │ ├── glut_key.c │ ├── glut_keyup.c │ ├── glut_modifier.c │ ├── glutbitmap.h │ ├── glutstroke.h │ ├── glut_tablet.c │ ├── glut_stroke.c │ ├── glut_space.c │ ├── glut_bwidth.c │ ├── glut_swap.c │ ├── layerutil.h │ ├── glut_glxext.c │ └── glut_wglext.c ├── filter ├── venice.jpg ├── rooster.tga ├── head_slice.jpg ├── man_on_moon.jpg ├── valentine_candy.jpg └── ReadMe.txt ├── common ├── stb │ ├── stb_image_write.c │ └── ReadMe.txt ├── read_text_file.h ├── boost.cpp ├── request_vsync.h ├── countof.h ├── read_text_file.c ├── read_text_file.cpp ├── showfps.h └── request_vsync.c ├── glui-2.35 ├── www │ ├── image1.png │ ├── title.jpg │ ├── screen2.png │ ├── screen3.png │ └── valid-html401.png └── src │ ├── doc │ └── glui_manual.pdf │ ├── glui_img_listbox_up.ppm │ ├── glui_img_listbox_down.ppm │ ├── glui_img_listbox_up_dis.ppm │ ├── tools │ ├── ppm.h │ └── ppm2array.cpp │ ├── devcpp │ ├── example1.dev │ ├── example2.dev │ ├── example3.dev │ ├── example4.dev │ └── example5.dev │ ├── glui_internal_control.h │ ├── glui_window.cpp │ ├── glui_img_spinup_0.c │ ├── glui_img_spinup_1.c │ ├── glui_img_spindown_0.c │ ├── glui_img_spindown_1.c │ ├── glui_img_spinup_dis.c │ └── glui_img_spindown_dis.c ├── mandelbrot ├── gradient4.dds ├── shaders │ ├── vertex.glsl │ └── mandelbrot.glsl ├── mandelbrot.sln ├── showfps.h └── ReadMe.txt ├── particles ├── ReadMe.txt └── particles.cs ├── README.md ├── tessellation ├── green.glslf ├── gumbo.hpp ├── pass_thru.glslf ├── pass_thru.glslv ├── diffuse.glslf ├── teapot.hpp ├── monkey.hpp ├── tri_adaptive_lod.glsltc ├── phong.glslf ├── bicubic_texcoord_lod.glsltc ├── tri_texcoord_lod.glsltc ├── tricubic_texcoord_lod.glsltc ├── cp_transform.glslv ├── ReadMe.txt └── quad_texcoord_lod.glsltc ├── .gitignore ├── GNUmakefile ├── ReadMe.txt ├── cg4cpp ├── examples │ └── test │ │ └── matrix.cpp ├── include │ └── Cg │ │ ├── double.hpp │ │ ├── assert.hpp │ │ ├── matrix │ │ ├── rows.hpp │ │ ├── 0based.hpp │ │ ├── 1based.hpp │ │ ├── columns.hpp │ │ └── elements.hpp │ │ ├── vector │ │ ├── rgba.hpp │ │ ├── stpq.hpp │ │ └── xyzw.hpp │ │ ├── sampler.hpp │ │ ├── samplerBUF.hpp │ │ ├── transpose.hpp │ │ ├── inverse.hpp │ │ ├── sampler3D.hpp │ │ ├── all.hpp │ │ ├── any.hpp │ │ ├── samplerCUBE.hpp │ │ ├── upper1x1.hpp │ │ ├── upper1x2.hpp │ │ ├── upper1x3.hpp │ │ ├── upper1x4.hpp │ │ ├── upper2x1.hpp │ │ ├── upper2x2.hpp │ │ ├── upper2x3.hpp │ │ ├── upper2x4.hpp │ │ ├── upper3x1.hpp │ │ ├── upper3x2.hpp │ │ ├── upper3x3.hpp │ │ ├── upper3x4.hpp │ │ ├── upper4x1.hpp │ │ ├── upper4x2.hpp │ │ ├── upper4x3.hpp │ │ ├── upper4x4.hpp │ │ ├── sampler1D.hpp │ │ ├── samplerRECT.hpp │ │ ├── sampler2DARRAY.hpp │ │ ├── sampler1DARRAY.hpp │ │ ├── sampler2D.hpp │ │ ├── degrees.hpp │ │ ├── normalize.hpp │ │ ├── radians.hpp │ │ ├── frexp.hpp │ │ ├── sign.hpp │ │ ├── length.hpp │ │ ├── cos.hpp │ │ ├── sin.hpp │ │ ├── acos.hpp │ │ ├── exp.hpp │ │ ├── log.hpp │ │ ├── tan.hpp │ │ ├── asin.hpp │ │ ├── atan.hpp │ │ ├── ceil.hpp │ │ ├── cosh.hpp │ │ ├── sinh.hpp │ │ ├── sqrt.hpp │ │ ├── tanh.hpp │ │ ├── floor.hpp │ │ ├── rsqrt.hpp │ │ ├── frac.hpp │ │ ├── exp2.hpp │ │ ├── round.hpp │ │ ├── log2.hpp │ │ ├── log10.hpp │ │ ├── trunc.hpp │ │ ├── floatToRawIntBits.hpp │ │ ├── intBitsToFloat.hpp │ │ ├── distance.hpp │ │ ├── isnan.hpp │ │ ├── isinf.hpp │ │ ├── saturate.hpp │ │ └── isfinite.hpp ├── test │ ├── test_cos.cpp │ ├── test_sse.cpp │ ├── test_inout_dot.cpp │ ├── glprocs.h │ ├── test_inverse.cpp │ ├── test_dot.cpp │ └── test_fresnel.cpp ├── vs2005 │ ├── cg4cpp_StepOver.reg │ └── GNUmakefile ├── src │ ├── all.cpp │ ├── any.cpp │ ├── iostream.cpp │ ├── intBitsToFloat.cpp │ ├── floatToIntBits.cpp │ ├── floatToRawIntBits.cpp │ ├── cg4cpp_2008.sln │ ├── cross.cpp │ ├── lit.cpp │ ├── sampler2D_state.hpp │ ├── Android.mk │ ├── isinf.cpp │ ├── length.cpp │ ├── normalize.cpp │ └── fmod.cpp └── util │ └── itt.cpp └── glew ├── Makefile.glewlib ├── Makefile.glewinfo ├── Makefile.glew └── Makefile.visualinfo /glut/lib/glut/ObjectType.mk: -------------------------------------------------------------------------------- 1 | LDOPTS = $(LDOPTS_32) 2 | CSTYLE = $(CSTYLE_32) 3 | -------------------------------------------------------------------------------- /filter/venice.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markkilgard/opengl4_examples/HEAD/filter/venice.jpg -------------------------------------------------------------------------------- /filter/rooster.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markkilgard/opengl4_examples/HEAD/filter/rooster.tga -------------------------------------------------------------------------------- /common/stb/stb_image_write.c: -------------------------------------------------------------------------------- 1 | #define STB_IMAGE_WRITE_IMPLEMENTATION 2 | #include "stb_image_write.h" 3 | -------------------------------------------------------------------------------- /filter/head_slice.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markkilgard/opengl4_examples/HEAD/filter/head_slice.jpg -------------------------------------------------------------------------------- /filter/man_on_moon.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markkilgard/opengl4_examples/HEAD/filter/man_on_moon.jpg -------------------------------------------------------------------------------- /glui-2.35/www/image1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markkilgard/opengl4_examples/HEAD/glui-2.35/www/image1.png -------------------------------------------------------------------------------- /glui-2.35/www/title.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markkilgard/opengl4_examples/HEAD/glui-2.35/www/title.jpg -------------------------------------------------------------------------------- /mandelbrot/gradient4.dds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markkilgard/opengl4_examples/HEAD/mandelbrot/gradient4.dds -------------------------------------------------------------------------------- /filter/valentine_candy.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markkilgard/opengl4_examples/HEAD/filter/valentine_candy.jpg -------------------------------------------------------------------------------- /glui-2.35/www/screen2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markkilgard/opengl4_examples/HEAD/glui-2.35/www/screen2.png -------------------------------------------------------------------------------- /glui-2.35/www/screen3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markkilgard/opengl4_examples/HEAD/glui-2.35/www/screen3.png -------------------------------------------------------------------------------- /glui-2.35/www/valid-html401.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markkilgard/opengl4_examples/HEAD/glui-2.35/www/valid-html401.png -------------------------------------------------------------------------------- /glui-2.35/src/doc/glui_manual.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markkilgard/opengl4_examples/HEAD/glui-2.35/src/doc/glui_manual.pdf -------------------------------------------------------------------------------- /glui-2.35/src/glui_img_listbox_up.ppm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markkilgard/opengl4_examples/HEAD/glui-2.35/src/glui_img_listbox_up.ppm -------------------------------------------------------------------------------- /glui-2.35/src/glui_img_listbox_down.ppm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markkilgard/opengl4_examples/HEAD/glui-2.35/src/glui_img_listbox_down.ppm -------------------------------------------------------------------------------- /glui-2.35/src/glui_img_listbox_up_dis.ppm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markkilgard/opengl4_examples/HEAD/glui-2.35/src/glui_img_listbox_up_dis.ppm -------------------------------------------------------------------------------- /common/read_text_file.h: -------------------------------------------------------------------------------- 1 | #ifndef __READ_TEXT_FILE_H__ 2 | #define __READ_TEXT_FILE_H__ 3 | 4 | extern char *read_text_file(const char *filename); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /mandelbrot/shaders/vertex.glsl: -------------------------------------------------------------------------------- 1 | varying vec2 position; 2 | 3 | void main() 4 | { 5 | gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; 6 | position = gl_Vertex.st; 7 | } -------------------------------------------------------------------------------- /particles/ReadMe.txt: -------------------------------------------------------------------------------- 1 | 2 | OpenGL 4.3 Compute Shader particle system example 3 | 4 | This example was developed by Mike Bailey @ Oregon State University. 5 | http://eecs.oregonstate.edu/people/bailey 6 | 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # opengl4_examples 2 | OpenGL 4 examples 3 | 4 | ## Accompanying Presentation 5 | 6 | SIGGRAPH 2012: NVIDIA OpenGL for 2012 7 | 8 | http://www.slideshare.net/Mark_Kilgard/siggraph-2012-nvidia-opengl-for-2012 9 | -------------------------------------------------------------------------------- /tessellation/green.glslf: -------------------------------------------------------------------------------- 1 | 2 | // green.glslf 3 | 4 | // DESCRIPTION: GLSL fragment shader to generate solid green. 5 | 6 | // To off-line compile this code to assembly with Cg 3.0, use: 7 | // cgc -profile gp5fp -oglsl green.glslf 8 | 9 | void main(void) 10 | { 11 | gl_FragColor = vec4(0,1,0,1); 12 | } 13 | -------------------------------------------------------------------------------- /tessellation/gumbo.hpp: -------------------------------------------------------------------------------- 1 | 2 | // gumbo.hpp - header for bezier patches for Ed Catmull's elephant named gumbo 3 | 4 | #include 5 | 6 | extern const int gumboPatchCount; 7 | extern const int gumboPatch[128][16]; 8 | extern const int gumboVertexCount; 9 | extern const Cg::float3 gumboVertex[1010]; 10 | -------------------------------------------------------------------------------- /tessellation/pass_thru.glslf: -------------------------------------------------------------------------------- 1 | 2 | // pass_thru.glslf 3 | 4 | // DESCRIPTION: GLSL fragment shader to pass thru interpolated color. 5 | 6 | // To off-line compile this code to assembly with Cg 3.0, use: 7 | // cgc -profile gp5fp -oglsl pass_thru.glslf 8 | 9 | void main(void) 10 | { 11 | gl_FragColor = gl_Color; 12 | } 13 | -------------------------------------------------------------------------------- /common/stb/ReadMe.txt: -------------------------------------------------------------------------------- 1 | 2 | http://nothings.org/stb_image.c 3 | http://nothings.org/stb_image_write.h 4 | 5 | Comment from Sean Barrett' http://nothings.org/ 6 | 7 | free C source code -- I have placed all this code in the public domain, so you can use it in any way. (To be explicit: I am the sole author of these works and I disavow any copyright claim over them.) 8 | 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | *.obj 6 | 7 | # Precompiled Headers 8 | *.gch 9 | *.pch 10 | 11 | # Compiled Dynamic libraries 12 | *.so 13 | *.dylib 14 | *.dll 15 | 16 | # Fortran module files 17 | *.mod 18 | 19 | # Compiled Static libraries 20 | *.lai 21 | *.la 22 | *.a 23 | *.lib 24 | 25 | # Executables 26 | *.exe 27 | *.out 28 | *.app 29 | -------------------------------------------------------------------------------- /tessellation/pass_thru.glslv: -------------------------------------------------------------------------------- 1 | // pass_thru.glslv - GLSL vertex shader to pass thru interpolated color 2 | 3 | void main(void) 4 | { 5 | gl_Position = gl_Vertex; 6 | gl_TexCoord[0] = gl_MultiTexCoord0; 7 | gl_TexCoord[1] = gl_MultiTexCoord1; 8 | gl_TexCoord[2] = gl_MultiTexCoord2; 9 | gl_TexCoord[3] = gl_MultiTexCoord3; 10 | gl_TexCoord[4] = gl_MultiTexCoord4; 11 | } 12 | -------------------------------------------------------------------------------- /GNUmakefile: -------------------------------------------------------------------------------- 1 | # LOG_PREFIX is a string prefix used for non-warning, non-error build output 2 | export LOG_PREFIX := ' :::' 3 | 4 | # how to get to this directory from cglang directory 5 | SOLNDIR := ../../../../pvt/mjk/src/opengl4_examples 6 | 7 | PROJECTS := 8 | PROJECTS += tessellation 9 | PROJECTS += mandelbrot 10 | 11 | include ../../../../cg/main/src/build_tools/cg/common.mk 12 | -------------------------------------------------------------------------------- /common/boost.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | namespace boost 8 | { 9 | // Exceptionless default exception handler for boost purposes. 10 | // We don't expect to ever get here. 11 | 12 | void 13 | throw_exception(std::exception const &e) 14 | { 15 | assert(0); 16 | exit(0); 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /filter/ReadMe.txt: -------------------------------------------------------------------------------- 1 | 2 | OpenGL 4.3 Compute Shader image filter example 3 | 4 | This demo exercises OpenGL 4.3 compute shaders to implement image filters. 5 | 6 | Implemented filters: 7 | * general convolution 8 | * separable convolution 9 | * median filter 10 | 11 | The linear filters support Gaussian, uniform, and Sobel horizontal and 12 | vertical kernels. 13 | 14 | - Mark Kilgard 15 | August 16, 2012 16 | -------------------------------------------------------------------------------- /tessellation/diffuse.glslf: -------------------------------------------------------------------------------- 1 | 2 | // diffuse.glslf 3 | 4 | // DESCRIPTION: GLSL fragment shader to generate diffuse. 5 | 6 | // To off-line compile this code to assembly with Cg 3.0, use: 7 | // cgc -profile gp5fp -oglsl diffuse.glslf 8 | 9 | void main(void) 10 | { 11 | if (gl_FrontFacing) { 12 | gl_FragColor = gl_TexCoord[0].zzzz; 13 | } else { 14 | gl_FragColor = -gl_TexCoord[0].zzzz; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /tessellation/teapot.hpp: -------------------------------------------------------------------------------- 1 | 2 | /* Adapted from http://www.sjbaker.org/teapot/teaset.tgz 3 | See also http://en.wikipedia.org/wiki/Utah_teapot */ 4 | 5 | /* NOTE: the indices in teapotPath[][] are based from zero */ 6 | 7 | #include 8 | 9 | extern const int teapotPatchCount; 10 | extern const int teapotPatch[32][16]; 11 | extern const int teapotVertexCount; 12 | extern const Cg::float3 teapotVertex[306]; 13 | -------------------------------------------------------------------------------- /common/request_vsync.h: -------------------------------------------------------------------------------- 1 | 2 | /* request_vsync.h - request buffer swap synchroization with vertical sync */ 3 | 4 | /* NVIDIA Corporation, Copyright 2007-2010 */ 5 | 6 | /* enableSync true means synchronize buffer swaps to monitor refresh; 7 | false means do NOT synchornize. */ 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | extern void requestSynchornizedSwapBuffers(int enableSync); 14 | 15 | #ifdef __cplusplus 16 | } 17 | #endif 18 | 19 | -------------------------------------------------------------------------------- /ReadMe.txt: -------------------------------------------------------------------------------- 1 | 2 | These are OpenGL 4.x examples. 3 | 4 | * tessellation - OpenGL 4.0 tessellation example 5 | * mandelbrot - OpenGL 4.0 double precision shader example 6 | * filter - OpenGL 4.3 Compute Shader image filtering example 7 | * particles - OpenGL 4.3 Compute Shader particle system example 8 | 9 | Particle system demo was developed by Mike Bailey @ Oregon State 10 | University. http://eecs.oregonstate.edu/people/bailey 11 | 12 | - Mark Kilgard 13 | NVIDIA Corporation 14 | August 6, 2012 15 | -------------------------------------------------------------------------------- /tessellation/monkey.hpp: -------------------------------------------------------------------------------- 1 | 2 | // monkey.hpp - header for triangles for monkey head 3 | 4 | #include 5 | 6 | using namespace Cg; 7 | 8 | extern const int MonkeyHead_num_of_vertices; 9 | extern const int MonkeyHead_num_of_triangles; 10 | extern const float3 MonkeyHead_vertices[]; 11 | extern const float3 MonkeyHead_normals[]; 12 | extern const int3 MonkeyHead_triangles[]; 13 | 14 | void makeEdgeMap(int num_tris, const int3 tri_ndxs[], 15 | int num_verts, const float3 v[]); 16 | -------------------------------------------------------------------------------- /cg4cpp/examples/test/matrix.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #define OUTPUT(_x) std::cout << #_x << "=" << (_x) << std::endl 9 | 10 | using namespace Cg; 11 | 12 | int main(int argc, char **argv) 13 | { 14 | float4 a = float4(0), 15 | b = float4(1); 16 | 17 | OUTPUT(a); 18 | OUTPUT(b); 19 | a.yz = b.zy; 20 | OUTPUT(a); 21 | OUTPUT(b); 22 | getchar(); 23 | } -------------------------------------------------------------------------------- /cg4cpp/include/Cg/double.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #ifndef __Cg_double_hpp__ 9 | #define __Cg_double_hpp__ 10 | 11 | /* Only defines __Cg_double_hpp__ so other headers can know double support 12 | is desired. */ 13 | 14 | #endif // __Cg_double_hpp__ 15 | -------------------------------------------------------------------------------- /cg4cpp/include/Cg/assert.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005-2006 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #ifndef __Cg_assert_hpp__ 9 | #define __Cg_assert_hpp__ 10 | 11 | #ifndef __CG_NO_ASSERT 12 | #include 13 | #define __CGassert(x) assert(x) 14 | #else 15 | #define __CGassert(x) 16 | #endif 17 | 18 | #endif // __Cg_assert_hpp__ 19 | -------------------------------------------------------------------------------- /cg4cpp/include/Cg/matrix/rows.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #ifndef __Cg_matrix_rows_hpp__ 9 | #define __Cg_matrix_rows_hpp__ 10 | 11 | /* Only defines __Cg_matrix_rows_hpp__ so the header 12 | can know matrix support for rows is desired. */ 13 | 14 | #endif // __Cg_matrix_rows_hpp__ 15 | 16 | -------------------------------------------------------------------------------- /cg4cpp/include/Cg/vector/rgba.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2006 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #ifndef __Cg_vector_rgba_hpp__ 9 | #define __Cg_vector_rgba_hpp__ 10 | 11 | /* Only defines __Cg_vector_rgba_hpp__ so the header 12 | can know rgba vector support is desired. */ 13 | 14 | #endif // __Cg_vector_rgba_hpp__ 15 | 16 | -------------------------------------------------------------------------------- /cg4cpp/include/Cg/vector/stpq.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2006 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #ifndef __Cg_vector_stpq_hpp__ 9 | #define __Cg_vector_stpq_hpp__ 10 | 11 | /* Only defines __Cg_vector_stpq_hpp__ so the header 12 | can know stpq vector support is desired. */ 13 | 14 | #endif // __Cg_vector_stpq_hpp__ 15 | 16 | -------------------------------------------------------------------------------- /cg4cpp/include/Cg/vector/xyzw.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2006 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #ifndef __Cg_vector_xyzw_hpp__ 9 | #define __Cg_vector_xyzw_hpp__ 10 | 11 | /* Only defines __Cg_vector_xyzw_hpp__ so the header 12 | can know xyzw vector support is desired. */ 13 | 14 | #endif // __Cg_vector_xyzw_hpp__ 15 | 16 | -------------------------------------------------------------------------------- /cg4cpp/include/Cg/matrix/0based.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #ifndef __Cg_matrix_0based_hpp__ 9 | #define __Cg_matrix_0based_hpp__ 10 | 11 | /* Only defines __Cg_matrix_0based_hpp__ so the header 12 | can know matrix support indexed from zero is desired. */ 13 | 14 | #endif // __Cg_matrix_0based_hpp__ 15 | 16 | -------------------------------------------------------------------------------- /cg4cpp/include/Cg/matrix/1based.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #ifndef __Cg_matrix_1based_hpp__ 9 | #define __Cg_matrix_1based_hpp__ 10 | 11 | /* Only defines __Cg_matrix_1based_hpp__ so the header 12 | can know matrix support indexed from one is desired. */ 13 | 14 | #endif // __Cg_matrix_1based_hpp__ 15 | 16 | -------------------------------------------------------------------------------- /cg4cpp/include/Cg/matrix/columns.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #ifndef __Cg_matrix_columns_hpp__ 9 | #define __Cg_matrix_columns_hpp__ 10 | 11 | /* Only defines __Cg_matrix_columns_hpp__ so the header 12 | can know matrix support for columns is desired. */ 13 | 14 | #endif // __Cg_matrix_columns_hpp__ 15 | 16 | -------------------------------------------------------------------------------- /cg4cpp/include/Cg/matrix/elements.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #ifndef __Cg_matrix_elements_hpp__ 9 | #define __Cg_matrix_elements_hpp__ 10 | 11 | /* Only defines __Cg_matrix_elements_hpp__ so the header 12 | can know matrix support for elements is desired. */ 13 | 14 | #endif // __Cg_matrix_elements_hpp__ 15 | 16 | -------------------------------------------------------------------------------- /glut/lib/glut/glut_warp.c: -------------------------------------------------------------------------------- 1 | 2 | /* Copyright (c) Mark J. Kilgard, 1996, 1997. */ 3 | 4 | /* This program is freely distributable without licensing fees 5 | and is provided without guarantee or warrantee expressed or 6 | implied. This program is -not- in the public domain. */ 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #include "glutint.h" 13 | 14 | /* CENTRY */ 15 | void GLUTAPIENTRY 16 | glutWarpPointer(int x, int y) 17 | { 18 | XWarpPointer(__glutDisplay, None, __glutCurrentWindow->win, 19 | 0, 0, 0, 0, x, y); 20 | XFlush(__glutDisplay); 21 | } 22 | 23 | /* ENDCENTRY */ 24 | -------------------------------------------------------------------------------- /glui-2.35/src/tools/ppm.h: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // File : ppm.hpp 3 | //------------------------------------------------------------------------------ 4 | //============================================================================ 5 | // ppm.hpp : Portable Pixel Map image format module 6 | //============================================================================ 7 | 8 | void LoadPPM(const char *FileName, unsigned char* &Color, int &Width, int &Height); 9 | void WritePPM(const char *FileName, unsigned char* Color, int Width, int Height); 10 | void VFlip(unsigned char * Pix, int width, int height, int chan=3); 11 | -------------------------------------------------------------------------------- /cg4cpp/include/Cg/sampler.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #ifndef __sampler_hpp__ 9 | #define __sampler_hpp__ 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #endif // __sampler_hpp__ 21 | -------------------------------------------------------------------------------- /cg4cpp/test/test_cos.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | using namespace Cg; 10 | 11 | #define OUTPUT(_x) std::cout << #_x << "=" << (_x) << std::endl 12 | 13 | float4 cos_stuff(float4 a, float4 b, In c, In d) 14 | { 15 | OUTPUT(cos(c)); 16 | OUTPUT(cos(d)); 17 | return sqrt(a) + sqrt(b); 18 | } 19 | 20 | void test_cos() 21 | { 22 | float4 f4 = float4(1,2,3,4); 23 | float4 f4a = float4(0,1,2,3); 24 | half4 h = half4(-1,-2,-3,-5); 25 | 26 | OUTPUT(cos(3.4f)); 27 | 28 | float4 r = cos_stuff(f4, f4a, 3.4f, h); 29 | } 30 | -------------------------------------------------------------------------------- /cg4cpp/vs2005/cg4cpp_StepOver.reg: -------------------------------------------------------------------------------- 1 | REGEDIT4 2 | 3 | [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0\NativeDE\StepOver] 4 | "Cg for C++ everything"="Cg\\:\\:.*" 5 | "Cg for C++ vector constructors"="Cg\\:\\:__CGvector\\<.*\\>" 6 | "Cg for C++ matrix constructors"="Cg\\:\\:__CGmatrix\\<.*\\>" 7 | "Cg for C++ operators"="Cg\\:\\:.*operator\\oper:.*" 8 | "Cg for C++ In"="Cg\\:\\:In\\<.*\\>" 9 | "Cg for C++ Out"="Cg\\:\\:Out\\<.*\\>" 10 | "Cg for C++ InOut"="Cg\\:\\:InOut\\<.*\\>" 11 | "Cg for C++ wrap type"="Cg\\:\\:__CGwrap_type\\<.*\\>" 12 | "Cg for C++ cast operators"="Cg\\:\\:.*\\:\\:operator .*" 13 | "Cg for C++ half"="Cg\\:\\:__CGcustom_float\\<.*\\>" 14 | "Cg for C++ fixed"="Cg\\:\\:__CGcustom_fixed\\<.*\\>" 15 | -------------------------------------------------------------------------------- /cg4cpp/vs2005/GNUmakefile: -------------------------------------------------------------------------------- 1 | 2 | TARGET = generate_cg4cpp_autoexp 3 | 4 | UNAME := $(shell uname) 5 | 6 | SRCS = $(TARGET:=.c) 7 | OBJS = $(SRCS:.c=.o) 8 | 9 | CC = gcc 10 | CFLAGS += -Wall 11 | 12 | ifeq ($(UNAME), Darwin) 13 | else 14 | ifeq ($(findstring CYGWIN, $(UNAME)), CYGWIN) 15 | EXE = .exe 16 | else 17 | endif 18 | endif 19 | 20 | BINARY := $(TARGET:=$(EXE)) 21 | 22 | all: cg4cpp_autoexp.txt 23 | 24 | cg4cpp_autoexp.txt : $(BINARY) 25 | $(RM) $@ 26 | ./$(BINARY) > $@ 27 | 28 | $(BINARY) : $(OBJS) 29 | $(CC) $(CFLAGS) -o $@ $(OBJS) $(CLINKFLAGS) 30 | 31 | clean: 32 | $(RM) $(BINARIES) $(OBJS) 33 | 34 | clobber: clean 35 | $(RM) *.bak *.o *~ 36 | 37 | .PHONY: all clean clobber 38 | -------------------------------------------------------------------------------- /cg4cpp/src/all.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2006 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | namespace Cg { 14 | 15 | bool1 all(bool1 v) 16 | { 17 | return all<1>(v); 18 | } 19 | 20 | bool1 all(bool2 v) 21 | { 22 | return all<2>(v); 23 | } 24 | 25 | bool1 all(bool3 v) 26 | { 27 | return all<3>(v); 28 | } 29 | 30 | bool1 all(bool4 v) 31 | { 32 | return all<4>(v); 33 | } 34 | 35 | } // namespace Cg 36 | 37 | -------------------------------------------------------------------------------- /cg4cpp/src/any.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2006 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | namespace Cg { 14 | 15 | bool1 any(bool1 v) 16 | { 17 | return any<1>(v); 18 | } 19 | 20 | bool1 any(bool2 v) 21 | { 22 | return any<2>(v); 23 | } 24 | 25 | bool1 any(bool3 v) 26 | { 27 | return any<3>(v); 28 | } 29 | 30 | bool1 any(bool4 v) 31 | { 32 | return any<4>(v); 33 | } 34 | 35 | } // namespace Cg 36 | 37 | -------------------------------------------------------------------------------- /cg4cpp/src/iostream.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2006 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #include 13 | 14 | namespace Cg { 15 | 16 | std::ostream & operator << (std::ostream & o, const half & v) { 17 | const float fv = v; 18 | o << fv; 19 | return o; 20 | } 21 | 22 | std::ostream & operator << (std::ostream & o, const fixed & v) { 23 | const float fv = v; 24 | o << fv; 25 | return o; 26 | } 27 | 28 | } // namespace Cg 29 | 30 | -------------------------------------------------------------------------------- /glut/lib/glut/makefile.nvmk: -------------------------------------------------------------------------------- 1 | ############################################################################## 2 | # //sw/apps/gpu/drivers/opengl/glut/lib/glut/makefile.nvmk 3 | # 4 | # unix-build/nvmake makefile for building libglut.a; based on 5 | # //sw/apps/gpu/drivers/opengl/glut/lib/glut/GNUmakefile 6 | ############################################################################## 7 | 8 | include $(NV_SOURCE)/common/build/nvCommon.nvmk 9 | 10 | NV_MODULE_LOGGING_NAME = "apps/glut" 11 | 12 | LIBGLUT = $(OUTPUTDIR)/libglut.a 13 | 14 | include $(NV_SOURCE)/gpu/drivers/opengl/glut/lib/glut/glut.nvmk 15 | 16 | build:: $(LIBGLUT) 17 | 18 | $(LIBGLUT): $(OBJECTS) 19 | $(call quiet_cmd,AR) cr $@ $(OBJECTS) 20 | 21 | include $(NV_SOURCE)/common/build/gcc-4.1.1as2.nvmk 22 | include $(NV_SOURCE)/common/build/nvCommonRules.nvmk 23 | -------------------------------------------------------------------------------- /cg4cpp/test/test_sse.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | using namespace Cg; 9 | 10 | #define OUTPUT(_x) std::cout << #_x << "=" << (_x) << std::endl 11 | 12 | float4 sse_stuff(float4 a, float4 b) 13 | { 14 | float4 d = a*b; 15 | float4 c = float4(1.1f,2.2f,3.3f,4.4f); 16 | return d + c; 17 | } 18 | 19 | void test_sse(void) 20 | { 21 | float4 m = float4(2,3,5,6); 22 | float4 n = float4(-2,8,-2,7); 23 | float4 r = sse_stuff(m, n); 24 | OUTPUT(m); 25 | OUTPUT(n); 26 | OUTPUT(r); 27 | 28 | float2 c = float2(4,5); 29 | float2 foo2 = float2(-1,1); 30 | float2 var = lerp(c, -c, float2(foo2 < 0)); 31 | OUTPUT(c); 32 | OUTPUT(foo2); 33 | OUTPUT(var); 34 | } 35 | -------------------------------------------------------------------------------- /glut/lib/glut/glut_keyctrl.c: -------------------------------------------------------------------------------- 1 | 2 | /* Copyright (c) Mark J. Kilgard, 1996, 1997. */ 3 | 4 | /* This program is freely distributable without licensing fees 5 | and is provided without guarantee or warrantee expressed or 6 | implied. This program is -not- in the public domain. */ 7 | 8 | #include "glutint.h" 9 | 10 | /* CENTRY */ 11 | void GLUTAPIENTRY 12 | glutIgnoreKeyRepeat(int ignore) 13 | { 14 | __glutCurrentWindow->ignoreKeyRepeat = ignore; 15 | } 16 | 17 | void GLUTAPIENTRY 18 | glutSetKeyRepeat(int repeatMode) 19 | { 20 | #if !defined(_WIN32) 21 | XKeyboardControl values; 22 | 23 | /* GLUT's repeatMode #define's match the Xlib API values. */ 24 | values.auto_repeat_mode = repeatMode; 25 | XChangeKeyboardControl(__glutDisplay, KBAutoRepeatMode, &values); 26 | #endif 27 | } 28 | 29 | /* ENDCENTRY */ 30 | -------------------------------------------------------------------------------- /glut/lib/glut/glut_dials.c: -------------------------------------------------------------------------------- 1 | 2 | /* Copyright (c) Mark J. Kilgard, 1994. */ 3 | 4 | /* This program is freely distributable without licensing fees 5 | and is provided without guarantee or warrantee expressed or 6 | implied. This program is -not- in the public domain. */ 7 | 8 | #include "glutint.h" 9 | 10 | void GLUTAPIENTRY 11 | glutButtonBoxFunc(GLUTbuttonBoxCB buttonBoxFunc) 12 | { 13 | __glutCurrentWindow->buttonBox = buttonBoxFunc; 14 | __glutUpdateInputDeviceMaskFunc = __glutUpdateInputDeviceMask; 15 | __glutPutOnWorkList(__glutCurrentWindow, 16 | GLUT_DEVICE_MASK_WORK); 17 | } 18 | 19 | void GLUTAPIENTRY 20 | glutDialsFunc(GLUTdialsCB dialsFunc) 21 | { 22 | __glutCurrentWindow->dials = dialsFunc; 23 | __glutUpdateInputDeviceMaskFunc = __glutUpdateInputDeviceMask; 24 | __glutPutOnWorkList(__glutCurrentWindow, 25 | GLUT_DEVICE_MASK_WORK); 26 | } 27 | -------------------------------------------------------------------------------- /glut/lib/glut/glut_key.c: -------------------------------------------------------------------------------- 1 | 2 | /* Copyright (c) Mark J. Kilgard, 1997. */ 3 | 4 | /* This program is freely distributable without licensing fees 5 | and is provided without guarantee or warrantee expressed or 6 | implied. This program is -not- in the public domain. */ 7 | 8 | #include 9 | 10 | #include "glutint.h" 11 | 12 | /* CENTRY */ 13 | void GLUTAPIENTRY 14 | glutKeyboardFunc(GLUTkeyboardCB keyboardFunc) 15 | { 16 | __glutChangeWindowEventMask(KeyPressMask, 17 | keyboardFunc != NULL || __glutCurrentWindow->special != NULL); 18 | __glutCurrentWindow->keyboard = keyboardFunc; 19 | } 20 | 21 | void GLUTAPIENTRY 22 | glutSpecialFunc(GLUTspecialCB specialFunc) 23 | { 24 | __glutChangeWindowEventMask(KeyPressMask, 25 | specialFunc != NULL || __glutCurrentWindow->keyboard != NULL); 26 | __glutCurrentWindow->special = specialFunc; 27 | } 28 | 29 | /* ENDCENTRY */ 30 | -------------------------------------------------------------------------------- /cg4cpp/src/intBitsToFloat.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2006 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #include 9 | 10 | namespace Cg { 11 | 12 | float intBitsToFloat(int v) 13 | { 14 | return intBitsToFloat(v); 15 | } 16 | 17 | float1 intBitsToFloat(int1 v) 18 | { 19 | return intBitsToFloat(v); 20 | } 21 | 22 | float2 intBitsToFloat(int2 v) 23 | { 24 | return intBitsToFloat(v); 25 | } 26 | 27 | float3 intBitsToFloat(int3 v) 28 | { 29 | return intBitsToFloat(v); 30 | } 31 | 32 | float4 intBitsToFloat(int4 v) 33 | { 34 | return intBitsToFloat(v); 35 | } 36 | 37 | } // namespace Cg 38 | -------------------------------------------------------------------------------- /cg4cpp/src/floatToIntBits.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2006 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #include 9 | 10 | namespace Cg { 11 | 12 | int floatToIntBits(float v) 13 | { 14 | return floatToIntBits(v); 15 | } 16 | 17 | int1 floatToIntBits(float1 v) 18 | { 19 | return floatToIntBits(v); 20 | } 21 | 22 | int2 floatToIntBits(float2 v) 23 | { 24 | return floatToIntBits(v); 25 | } 26 | 27 | int3 floatToIntBits(float3 v) 28 | { 29 | return floatToIntBits(v); 30 | } 31 | 32 | int4 floatToIntBits(float4 v) 33 | { 34 | return floatToIntBits(v); 35 | } 36 | 37 | } // namespace Cg 38 | -------------------------------------------------------------------------------- /glut/lib/glut/glut_keyup.c: -------------------------------------------------------------------------------- 1 | 2 | /* Copyright (c) Mark J. Kilgard, 1997. */ 3 | 4 | /* This program is freely distributable without licensing fees 5 | and is provided without guarantee or warrantee expressed or 6 | implied. This program is -not- in the public domain. */ 7 | 8 | #include 9 | 10 | #include "glutint.h" 11 | 12 | /* CENTRY */ 13 | void GLUTAPIENTRY 14 | glutKeyboardUpFunc(GLUTkeyboardCB keyboardUpFunc) 15 | { 16 | __glutChangeWindowEventMask(KeyReleaseMask, 17 | keyboardUpFunc != NULL || __glutCurrentWindow->specialUp != NULL); 18 | __glutCurrentWindow->keyboardUp = keyboardUpFunc; 19 | } 20 | 21 | void GLUTAPIENTRY 22 | glutSpecialUpFunc(GLUTspecialCB specialUpFunc) 23 | { 24 | __glutChangeWindowEventMask(KeyReleaseMask, 25 | specialUpFunc != NULL || __glutCurrentWindow->keyboardUp != NULL); 26 | __glutCurrentWindow->specialUp = specialUpFunc; 27 | } 28 | 29 | /* ENDCENTRY */ 30 | -------------------------------------------------------------------------------- /glut/lib/glut/glut_modifier.c: -------------------------------------------------------------------------------- 1 | 2 | /* Copyright (c) Mark J. Kilgard, 1994. */ 3 | 4 | /* This program is freely distributable without licensing fees 5 | and is provided without guarantee or warrantee expressed or 6 | implied. This program is -not- in the public domain. */ 7 | 8 | #include "glutint.h" 9 | 10 | /* CENTRY */ 11 | int GLUTAPIENTRY 12 | glutGetModifiers(void) 13 | { 14 | int modifiers; 15 | 16 | if(__glutModifierMask == (unsigned int) ~0) { 17 | __glutWarning( 18 | "glutCurrentModifiers: do not call outside core input callback."); 19 | return 0; 20 | } 21 | modifiers = 0; 22 | if(__glutModifierMask & (ShiftMask|LockMask)) 23 | modifiers |= GLUT_ACTIVE_SHIFT; 24 | if(__glutModifierMask & ControlMask) 25 | modifiers |= GLUT_ACTIVE_CTRL; 26 | if(__glutModifierMask & Mod1Mask) 27 | modifiers |= GLUT_ACTIVE_ALT; 28 | return modifiers; 29 | } 30 | 31 | /* ENDCENTRY */ 32 | -------------------------------------------------------------------------------- /cg4cpp/src/floatToRawIntBits.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2006 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #include 9 | 10 | namespace Cg { 11 | 12 | int floatToRawIntBits(float v) 13 | { 14 | return floatToRawIntBits(v); 15 | } 16 | 17 | int1 floatToRawIntBits(float1 v) 18 | { 19 | return floatToRawIntBits(v); 20 | } 21 | 22 | int2 floatToRawIntBits(float2 v) 23 | { 24 | return floatToRawIntBits(v); 25 | } 26 | 27 | int3 floatToRawIntBits(float3 v) 28 | { 29 | return floatToRawIntBits(v); 30 | } 31 | 32 | int4 floatToRawIntBits(float4 v) 33 | { 34 | return floatToRawIntBits(v); 35 | } 36 | 37 | } // namespace Cg 38 | -------------------------------------------------------------------------------- /cg4cpp/test/test_inout_dot.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | using namespace Cg; 9 | 10 | #define OUTPUT(_x) std::cout << #_x << "=" << (_x) << std::endl 11 | 12 | float dotme(In a, In b, float c, In ci, Out ao, Out oc) 13 | { 14 | OUTPUT(dot(a,b)); 15 | OUTPUT(dot(c,a)); 16 | OUTPUT(dot(b,c)); 17 | OUTPUT(dot(ci,a)); 18 | OUTPUT(dot(b,ci)); 19 | OUTPUT(dot(c,c)); 20 | OUTPUT(dot(ci,ci)); 21 | ao = float3(-1,-2,4); 22 | oc = dot(a,ao); 23 | return oc; 24 | } 25 | 26 | void test_inout_dot() 27 | { 28 | float3 a = float3(1,2,3); 29 | float3 b = float3(1,2,3); 30 | float c = 3; 31 | float3 aao; 32 | float cco; 33 | 34 | OUTPUT(dot(a,b)); 35 | float g = dotme(a, b, c, c, aao, cco); 36 | OUTPUT(g); 37 | OUTPUT(aao); 38 | OUTPUT(cco); 39 | } 40 | -------------------------------------------------------------------------------- /common/countof.h: -------------------------------------------------------------------------------- 1 | 2 | /* countof.hpp - robust macro to count array elements. */ 3 | 4 | #ifndef __countof_hpp__ 5 | #define __countof_hpp__ 6 | 7 | #if defined(_MSC_VER) && (_MSC_VER >= 1020) 8 | # pragma once 9 | #endif 10 | 11 | #if !defined(UNALIGNED) 12 | # if defined(_MSC_VER) 13 | # if defined(_M_IA64) || defined(_M_AMD64) 14 | # define UNALIGNED __unaligned 15 | # else 16 | # define UNALIGNED 17 | # endif 18 | # else 19 | # define UNALIGNED 20 | # endif 21 | #endif 22 | #if !defined(countof) 23 | # if !defined(__cplusplus) 24 | # define _countof(_Array) (sizeof(_Array) / sizeof(_Array[0])) 25 | # else 26 | // Safe C++ countof macro 27 | extern "C++" 28 | { 29 | template 30 | char (*countof_helper(UNALIGNED CountofType (&Array)[SizeOfArray]))[SizeOfArray]; 31 | # define countof(Array) sizeof(*countof_helper(Array)) 32 | } 33 | # endif 34 | #endif 35 | 36 | #endif /* __countof__ */ 37 | -------------------------------------------------------------------------------- /cg4cpp/src/cg4cpp_2008.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 10.00 3 | # Visual Studio 2008 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cg4cpp_2008", "cg4cpp_2008.vcproj", "{DD69089E-81D7-4BB2-8A3D-CBE3C94A8684}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Release|Win32 = Release|Win32 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {DD69089E-81D7-4BB2-8A3D-CBE3C94A8684}.Debug|Win32.ActiveCfg = Debug|Win32 13 | {DD69089E-81D7-4BB2-8A3D-CBE3C94A8684}.Debug|Win32.Build.0 = Debug|Win32 14 | {DD69089E-81D7-4BB2-8A3D-CBE3C94A8684}.Release|Win32.ActiveCfg = Release|Win32 15 | {DD69089E-81D7-4BB2-8A3D-CBE3C94A8684}.Release|Win32.Build.0 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /mandelbrot/mandelbrot.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual C++ Express 2010 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mandelbrot", "mandelbrot.vcxproj", "{DBEC12F9-1F0A-4EED-B353-4457DC2A9681}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Release|Win32 = Release|Win32 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {DBEC12F9-1F0A-4EED-B353-4457DC2A9681}.Debug|Win32.ActiveCfg = Debug|Win32 13 | {DBEC12F9-1F0A-4EED-B353-4457DC2A9681}.Debug|Win32.Build.0 = Debug|Win32 14 | {DBEC12F9-1F0A-4EED-B353-4457DC2A9681}.Release|Win32.ActiveCfg = Release|Win32 15 | {DBEC12F9-1F0A-4EED-B353-4457DC2A9681}.Release|Win32.Build.0 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /glut/lib/glut/glutbitmap.h: -------------------------------------------------------------------------------- 1 | #ifndef __glutbitmap_h__ 2 | #define __glutbitmap_h__ 3 | 4 | /* Copyright (c) Mark J. Kilgard, 1994, 1998. */ 5 | 6 | /* This program is freely distributable without licensing fees 7 | and is provided without guarantee or warrantee expressed or 8 | implied. This program is -not- in the public domain. */ 9 | 10 | #define GLUT_NO_LIB_PRAGMA /* Avoid auto library linking when building 11 | the GLUT library itself. */ 12 | #include 13 | 14 | typedef struct { 15 | const GLsizei width; 16 | const GLsizei height; 17 | const GLfloat xorig; 18 | const GLfloat yorig; 19 | const GLfloat advance; 20 | const GLubyte *bitmap; 21 | } BitmapCharRec, *BitmapCharPtr; 22 | 23 | typedef struct { 24 | const int num_chars; 25 | const int first; 26 | const BitmapCharRec * const *ch; 27 | } BitmapFontRec, *BitmapFontPtr; 28 | 29 | typedef void *GLUTbitmapFont; 30 | 31 | #endif /* __glutbitmap_h__ */ 32 | -------------------------------------------------------------------------------- /cg4cpp/include/Cg/samplerBUF.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #ifndef __samplerBUF_hpp__ 9 | #define __samplerBUF_hpp__ 10 | 11 | #include 12 | 13 | namespace Cg { 14 | 15 | class __CGsamplerBUF_state; 16 | 17 | class samplerBUF { 18 | __CGsamplerBUF_state *state; 19 | 20 | public: 21 | samplerBUF(); 22 | samplerBUF(int texUnit); 23 | samplerBUF(const samplerBUF &src); 24 | ~samplerBUF(); 25 | samplerBUF & operator = (const samplerBUF &rhs); 26 | float4 sample(float4 strq, float lod); 27 | }; 28 | 29 | // Cg Standard Library texture functions 30 | 31 | float4 texBUF(samplerBUF, float1 s); 32 | 33 | } // namespace Cg 34 | 35 | #endif // __samplerBUF_hpp__ 36 | -------------------------------------------------------------------------------- /cg4cpp/include/Cg/transpose.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2006 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #ifndef __Cg_transpose_hpp__ 9 | #define __Cg_transpose_hpp__ 10 | 11 | #ifdef __Cg_stdlib_hpp__ 12 | #pragma message("error: include this header file (" __FILE__ ") before ") 13 | #endif 14 | 15 | #include 16 | 17 | namespace Cg { 18 | 19 | template 20 | static inline __CGmatrix transpose(const __CGmatrix & m) 21 | { 22 | __CGmatrix rv; 23 | for (int i=0; i 9 | #include 10 | #include 11 | #include 12 | 13 | namespace Cg { 14 | 15 | float3 cross(float3 a, float3 b) 16 | { 17 | return cross(a, b); 18 | } 19 | 20 | // int3 version not officially part of Cg runtime 21 | int3 cross(int3 a, int3 b) 22 | { 23 | return cross(a, b); 24 | } 25 | 26 | double3 cross(double3 a, double3 b) 27 | { 28 | return cross(a, b); 29 | } 30 | 31 | half3 cross(half3 a, half3 b) 32 | { 33 | return cross(a, b); 34 | } 35 | 36 | fixed3 cross(fixed3 a, fixed3 b) 37 | { 38 | return cross(a, b); 39 | } 40 | 41 | } // namespace Cg 42 | 43 | -------------------------------------------------------------------------------- /common/read_text_file.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | 6 | #include "read_text_file.h" 7 | 8 | char *read_text_file(const char *filename) 9 | { 10 | #if defined(_WIN32) 11 | struct _stat f_stat; 12 | #define statfunc _stat 13 | #else 14 | struct stat f_stat; 15 | #define statfunc stat 16 | #endif 17 | 18 | if (!filename) 19 | return 0; 20 | 21 | if (statfunc(filename, &f_stat) == 0) { 22 | FILE *fp = 0; 23 | if (!(fp = fopen(filename, "r"))) { 24 | fprintf(stderr,"Cannot open \"%s\" for read!\n", filename); 25 | return 0; 26 | } 27 | 28 | long size = f_stat.st_size; 29 | char * buf = new char[size+1]; 30 | 31 | size_t bytes; 32 | bytes = fread(buf, 1, size, fp); 33 | 34 | buf[bytes] = 0; 35 | 36 | fclose(fp); 37 | return buf; 38 | } 39 | 40 | fprintf(stderr,"Cannot open \"%s\" for stat read!\n", filename); 41 | 42 | return 0; 43 | } 44 | -------------------------------------------------------------------------------- /common/read_text_file.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | 6 | #include "read_text_file.h" 7 | 8 | char *read_text_file(const char *filename) 9 | { 10 | #if defined(_WIN32) 11 | struct _stat f_stat; 12 | #define statfunc _stat 13 | #else 14 | struct stat f_stat; 15 | #define statfunc stat 16 | #endif 17 | 18 | if (!filename) 19 | return 0; 20 | 21 | if (statfunc(filename, &f_stat) == 0) { 22 | FILE *fp = 0; 23 | if (!(fp = fopen(filename, "r"))) { 24 | fprintf(stderr,"Cannot open \"%s\" for read!\n", filename); 25 | return 0; 26 | } 27 | 28 | long size = f_stat.st_size; 29 | char * buf = new char[size+1]; 30 | 31 | size_t bytes; 32 | bytes = fread(buf, 1, size, fp); 33 | 34 | buf[bytes] = 0; 35 | 36 | fclose(fp); 37 | return buf; 38 | } 39 | 40 | fprintf(stderr,"Cannot open \"%s\" for stat read!\n", filename); 41 | 42 | return 0; 43 | } 44 | -------------------------------------------------------------------------------- /cg4cpp/include/Cg/inverse.hpp: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2006 by NVIDIA Corporation. All rights reserved. All 4 | * information contained herein is proprietary and confidential to NVIDIA 5 | * Corporation. Any use, reproduction, or disclosure without the written 6 | * permission of NVIDIA Corporation is prohibited. 7 | */ 8 | 9 | #ifndef __Cg_inverse_hpp__ 10 | #define __Cg_inveres_hpp__ 11 | 12 | #ifdef __Cg_stdlib_hpp__ 13 | #pragma message("error: include this header file (" __FILE__ ") before ") 14 | #endif 15 | 16 | #include 17 | 18 | namespace Cg { 19 | 20 | extern float1x1 inverse(float1x1 a); 21 | extern float2x2 inverse(float2x2 a); 22 | extern float3x3 inverse(float3x3 a); 23 | extern float4x4 inverse(float4x4 a); 24 | 25 | #ifdef __Cg_double_hpp__ 26 | extern double1x1 inverse(double1x1 a); 27 | extern double2x2 inverse(double2x2 a); 28 | extern double3x3 inverse(double3x3 a); 29 | extern double4x4 inverse(double4x4 a); 30 | #endif 31 | 32 | } // namespace Cg 33 | 34 | #endif // __Cg_inverse_hpp__ 35 | -------------------------------------------------------------------------------- /cg4cpp/include/Cg/sampler3D.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #ifndef __sampler3D_hpp__ 9 | #define __sampler3D_hpp__ 10 | 11 | #include 12 | 13 | namespace Cg { 14 | 15 | class __CGsampler3D_state; 16 | 17 | class sampler3D { 18 | __CGsampler3D_state *state; 19 | 20 | public: 21 | sampler3D(); 22 | sampler3D(int texUnit); 23 | sampler3D(const sampler3D &src); 24 | ~sampler3D(); 25 | sampler3D & operator = (const sampler3D &rhs); 26 | float4 sample(float4 strq, float lod); 27 | }; 28 | 29 | // Cg Standard Library texture functions 30 | 31 | float4 tex3D(sampler3D, float3 str); 32 | float4 tex3D(sampler3D, float3 str, float3 dx, float3 dy); 33 | float4 tex3Dproj(sampler3D, float4 strq); 34 | 35 | } // namespace Cg 36 | 37 | #endif // __sampler3D_hpp__ 38 | -------------------------------------------------------------------------------- /cg4cpp/include/Cg/all.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #ifndef __Cg_all_hpp__ 9 | #define __Cg_all_hpp__ 10 | 11 | #ifdef __Cg_stdlib_hpp__ 12 | #pragma message("error: include this header file (" __FILE__ ") before ") 13 | #endif 14 | 15 | #include 16 | 17 | namespace Cg { 18 | 19 | template 20 | static inline bool1 all(const __CGvector & v) 21 | { 22 | bool1 rv = v[0]; 23 | for (int i=1; i 29 | static inline bool1 all(const __CGvector_usage & v) 30 | { 31 | bool1 rv = v[0]; 32 | for (int i=1; i") 13 | #endif 14 | 15 | #include 16 | 17 | namespace Cg { 18 | 19 | template 20 | static inline bool1 any(const __CGvector & v) 21 | { 22 | bool1 rv = v[0]; 23 | for (int i=1; i 29 | static inline bool1 any(const __CGvector_usage & v) 30 | { 31 | bool1 rv = v[0]; 32 | for (int i=1; i 0.0 ? max(0.0,pow(dot(H,N),30)) : 0.0; 23 | 24 | const vec3 surface_color = vec3(0.9,0.1,0.1); // reddish 25 | const vec3 ambient_color = 0.2 * surface_color; 26 | const vec3 diffuse_color = 0.8 * surface_color; 27 | const vec3 specular_color = 0.5*vec3(1); 28 | 29 | vec3 illuminance = specular*specular_color + diffuse*diffuse_color + ambient_color; 30 | gl_FragColor = vec4(illuminance, 1); 31 | } 32 | -------------------------------------------------------------------------------- /cg4cpp/include/Cg/samplerCUBE.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #ifndef __samplerCUBE_hpp__ 9 | #define __samplerCUBE_hpp__ 10 | 11 | #include 12 | 13 | namespace Cg { 14 | 15 | class __CGsamplerCUBE_state; 16 | 17 | class samplerCUBE { 18 | __CGsamplerCUBE_state *state; 19 | 20 | public: 21 | samplerCUBE(); 22 | samplerCUBE(int texUnit); 23 | samplerCUBE(const samplerCUBE &src); 24 | ~samplerCUBE(); 25 | samplerCUBE & operator = (const samplerCUBE &rhs); 26 | float4 sample(float4 strq, float lod); 27 | }; 28 | 29 | // Cg Standard Library texture functions 30 | 31 | float4 texCUBE(samplerCUBE, float3 str); 32 | float4 texCUBE(samplerCUBE, float3 str, float3 dx, float3 dy); 33 | float4 texCUBEproj(samplerCUBE, float4 strq); 34 | 35 | } // namespace Cg 36 | 37 | #endif // __samplerCUBE_hpp__ 38 | -------------------------------------------------------------------------------- /glut/lib/glut/glutstroke.h: -------------------------------------------------------------------------------- 1 | #ifndef __glutstroke_h__ 2 | #define __glutstroke_h__ 3 | 4 | /* Copyright (c) Mark J. Kilgard, 1994. */ 5 | 6 | /* This program is freely distributable without licensing fees 7 | and is provided without guarantee or warrantee expressed or 8 | implied. This program is -not- in the public domain. */ 9 | 10 | #ifdef _WIN32 11 | #pragma warning (disable:4244) /* disable bogus conversion warnings */ 12 | #pragma warning (disable:4305) /* VC++ 5.0 version of above warning. */ 13 | #endif 14 | 15 | typedef struct { 16 | float x; 17 | float y; 18 | } CoordRec, *CoordPtr; 19 | 20 | typedef struct { 21 | int num_coords; 22 | const CoordRec *coord; 23 | } StrokeRec, *StrokePtr; 24 | 25 | typedef struct { 26 | int num_strokes; 27 | const StrokeRec *stroke; 28 | float center; 29 | float right; 30 | } StrokeCharRec, *StrokeCharPtr; 31 | 32 | typedef struct { 33 | const char *name; 34 | int num_chars; 35 | const StrokeCharRec *ch; 36 | float top; 37 | float bottom; 38 | } StrokeFontRec, *StrokeFontPtr; 39 | 40 | typedef void *GLUTstrokeFont; 41 | 42 | #endif /* __glutstroke_h__ */ 43 | -------------------------------------------------------------------------------- /cg4cpp/include/Cg/upper1x1.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2009 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #ifndef __Cg_upper1x1_hpp__ 9 | #define __Cg_upper1x1_hpp__ 10 | 11 | #ifdef __Cg_stdlib_hpp__ 12 | #pragma message("error: include this header file (" __FILE__ ") before ") 13 | #endif 14 | 15 | #include 16 | 17 | namespace Cg { 18 | 19 | template 20 | __CGmatrix upper1x1(const __CGmatrix &m) 21 | { 22 | const int COLS = 1, 23 | ROWS = 1; 24 | __CGmatrix rv; 25 | for (int i=0; i") 13 | #endif 14 | 15 | #include 16 | 17 | namespace Cg { 18 | 19 | template 20 | __CGmatrix upper1x2(const __CGmatrix &m) 21 | { 22 | const int COLS = 1, 23 | ROWS = 2; 24 | __CGmatrix rv; 25 | for (int i=0; i") 13 | #endif 14 | 15 | #include 16 | 17 | namespace Cg { 18 | 19 | template 20 | __CGmatrix upper1x3(const __CGmatrix &m) 21 | { 22 | const int COLS = 1, 23 | ROWS = 3; 24 | __CGmatrix rv; 25 | for (int i=0; i") 13 | #endif 14 | 15 | #include 16 | 17 | namespace Cg { 18 | 19 | template 20 | __CGmatrix upper1x4(const __CGmatrix &m) 21 | { 22 | const int COLS = 1, 23 | ROWS = 4; 24 | __CGmatrix rv; 25 | for (int i=0; i") 13 | #endif 14 | 15 | #include 16 | 17 | namespace Cg { 18 | 19 | template 20 | __CGmatrix upper2x1(const __CGmatrix &m) 21 | { 22 | const int COLS = 2, 23 | ROWS = 1; 24 | __CGmatrix rv; 25 | for (int i=0; i") 13 | #endif 14 | 15 | #include 16 | 17 | namespace Cg { 18 | 19 | template 20 | __CGmatrix upper2x2(const __CGmatrix &m) 21 | { 22 | const int COLS = 2, 23 | ROWS = 2; 24 | __CGmatrix rv; 25 | for (int i=0; i") 13 | #endif 14 | 15 | #include 16 | 17 | namespace Cg { 18 | 19 | template 20 | __CGmatrix upper2x3(const __CGmatrix &m) 21 | { 22 | const int COLS = 2, 23 | ROWS = 3; 24 | __CGmatrix rv; 25 | for (int i=0; i") 13 | #endif 14 | 15 | #include 16 | 17 | namespace Cg { 18 | 19 | template 20 | __CGmatrix upper2x4(const __CGmatrix &m) 21 | { 22 | const int COLS = 2, 23 | ROWS = 4; 24 | __CGmatrix rv; 25 | for (int i=0; i") 13 | #endif 14 | 15 | #include 16 | 17 | namespace Cg { 18 | 19 | template 20 | __CGmatrix upper3x1(const __CGmatrix &m) 21 | { 22 | const int COLS = 3, 23 | ROWS = 1; 24 | __CGmatrix rv; 25 | for (int i=0; i") 13 | #endif 14 | 15 | #include 16 | 17 | namespace Cg { 18 | 19 | template 20 | __CGmatrix upper3x2(const __CGmatrix &m) 21 | { 22 | const int COLS = 3, 23 | ROWS = 2; 24 | __CGmatrix rv; 25 | for (int i=0; i") 13 | #endif 14 | 15 | #include 16 | 17 | namespace Cg { 18 | 19 | template 20 | __CGmatrix upper3x3(const __CGmatrix &m) 21 | { 22 | const int COLS = 3, 23 | ROWS = 3; 24 | __CGmatrix rv; 25 | for (int i=0; i") 13 | #endif 14 | 15 | #include 16 | 17 | namespace Cg { 18 | 19 | template 20 | __CGmatrix upper3x4(const __CGmatrix &m) 21 | { 22 | const int COLS = 3, 23 | ROWS = 4; 24 | __CGmatrix rv; 25 | for (int i=0; i") 13 | #endif 14 | 15 | #include 16 | 17 | namespace Cg { 18 | 19 | template 20 | __CGmatrix upper4x1(const __CGmatrix &m) 21 | { 22 | const int COLS = 4, 23 | ROWS = 1; 24 | __CGmatrix rv; 25 | for (int i=0; i") 13 | #endif 14 | 15 | #include 16 | 17 | namespace Cg { 18 | 19 | template 20 | __CGmatrix upper4x2(const __CGmatrix &m) 21 | { 22 | const int COLS = 4, 23 | ROWS = 2; 24 | __CGmatrix rv; 25 | for (int i=0; i") 13 | #endif 14 | 15 | #include 16 | 17 | namespace Cg { 18 | 19 | template 20 | __CGmatrix upper4x3(const __CGmatrix &m) 21 | { 22 | const int COLS = 4, 23 | ROWS = 3; 24 | __CGmatrix rv; 25 | for (int i=0; i") 13 | #endif 14 | 15 | #include 16 | 17 | namespace Cg { 18 | 19 | template 20 | __CGmatrix upper4x4(const __CGmatrix &m) 21 | { 22 | const int COLS = 4, 23 | ROWS = 4; 24 | __CGmatrix rv; 25 | for (int i=0; i 9 | 10 | #include "glutint.h" 11 | 12 | void GLUTAPIENTRY 13 | glutTabletMotionFunc(GLUTtabletMotionCB tabletMotionFunc) 14 | { 15 | __glutCurrentWindow->tabletMotion = tabletMotionFunc; 16 | __glutUpdateInputDeviceMaskFunc = __glutUpdateInputDeviceMask; 17 | __glutPutOnWorkList(__glutCurrentWindow, 18 | GLUT_DEVICE_MASK_WORK); 19 | /* If deinstalling callback, invalidate tablet position. */ 20 | if (tabletMotionFunc == NULL) { 21 | __glutCurrentWindow->tabletPos[0] = -1; 22 | __glutCurrentWindow->tabletPos[1] = -1; 23 | } 24 | } 25 | 26 | void GLUTAPIENTRY 27 | glutTabletButtonFunc(GLUTtabletButtonCB tabletButtonFunc) 28 | { 29 | __glutCurrentWindow->tabletButton = tabletButtonFunc; 30 | __glutUpdateInputDeviceMaskFunc = __glutUpdateInputDeviceMask; 31 | __glutPutOnWorkList(__glutCurrentWindow, 32 | GLUT_DEVICE_MASK_WORK); 33 | } 34 | -------------------------------------------------------------------------------- /glui-2.35/src/devcpp/example1.dev: -------------------------------------------------------------------------------- 1 | [Project] 2 | FileName=example1.dev 3 | Name=example1 4 | Ver=1 5 | IsCpp=1 6 | Type=1 7 | Compiler= 8 | CppCompiler= 9 | Includes=../ 10 | Linker=-lglui -lglut32 -lglu32 -lopengl32 -lstdc++_@@_ 11 | Libs=. 12 | UnitCount=1 13 | Folders= 14 | ObjFiles= 15 | PrivateResource= 16 | ResourceIncludes= 17 | MakeIncludes= 18 | Icon= 19 | ExeOutput=./ 20 | ObjectOutput=./ 21 | OverrideOutput=0 22 | OverrideOutputName=example1.exe 23 | HostApplication= 24 | CommandLine= 25 | UseCustomMakefile=0 26 | CustomMakefile= 27 | IncludeVersionInfo=0 28 | SupportXPThemes=0 29 | CompilerSet=0 30 | CompilerSettings=0000000000000000000 31 | 32 | [Unit1] 33 | FileName=..\example1.cpp 34 | Folder= 35 | Compile=1 36 | CompileCpp=1 37 | Link=1 38 | Priority=1000 39 | OverrideBuildCmd=0 40 | BuildCmd= 41 | 42 | [VersionInfo] 43 | Major=0 44 | Minor=1 45 | Release=1 46 | Build=1 47 | LanguageID=1033 48 | CharsetID=1252 49 | CompanyName= 50 | FileVersion=0.1 51 | FileDescription=Developed using the Dev-C++ IDE 52 | InternalName= 53 | LegalCopyright= 54 | LegalTrademarks= 55 | OriginalFilename=example1.exe 56 | ProductName=example1 57 | ProductVersion=0.1 58 | AutoIncBuildNr=0 59 | 60 | -------------------------------------------------------------------------------- /glui-2.35/src/devcpp/example2.dev: -------------------------------------------------------------------------------- 1 | [Project] 2 | FileName=example2.dev 3 | Name=example2 4 | Ver=1 5 | IsCpp=1 6 | Type=1 7 | Compiler= 8 | CppCompiler= 9 | Includes=../ 10 | Linker=-lglui -lglut32 -lglu32 -lopengl32 -lstdc++_@@_ 11 | Libs=. 12 | UnitCount=1 13 | Folders= 14 | ObjFiles= 15 | PrivateResource= 16 | ResourceIncludes= 17 | MakeIncludes= 18 | Icon= 19 | ExeOutput=./ 20 | ObjectOutput=./ 21 | OverrideOutput=0 22 | OverrideOutputName=example2.exe 23 | HostApplication= 24 | CommandLine= 25 | UseCustomMakefile=0 26 | CustomMakefile= 27 | IncludeVersionInfo=0 28 | SupportXPThemes=0 29 | CompilerSet=0 30 | CompilerSettings=0000000000000000000 31 | 32 | [Unit1] 33 | FileName=..\example2.cpp 34 | Folder= 35 | Compile=1 36 | CompileCpp=1 37 | Link=1 38 | Priority=1000 39 | OverrideBuildCmd=0 40 | BuildCmd= 41 | 42 | [VersionInfo] 43 | Major=0 44 | Minor=1 45 | Release=1 46 | Build=1 47 | LanguageID=1033 48 | CharsetID=1252 49 | CompanyName= 50 | FileVersion=0.1 51 | FileDescription=Developed using the Dev-C++ IDE 52 | InternalName= 53 | LegalCopyright= 54 | LegalTrademarks= 55 | OriginalFilename=example2.exe 56 | ProductName=example2 57 | ProductVersion=0.1 58 | AutoIncBuildNr=0 59 | 60 | -------------------------------------------------------------------------------- /glui-2.35/src/devcpp/example3.dev: -------------------------------------------------------------------------------- 1 | [Project] 2 | FileName=example3.dev 3 | Name=example3 4 | Ver=1 5 | IsCpp=1 6 | Type=1 7 | Compiler= 8 | CppCompiler= 9 | Includes=../ 10 | Linker=-lglui -lglut32 -lglu32 -lopengl32 -lstdc++_@@_ 11 | Libs=. 12 | UnitCount=1 13 | Folders= 14 | ObjFiles= 15 | PrivateResource= 16 | ResourceIncludes= 17 | MakeIncludes= 18 | Icon= 19 | ExeOutput=./ 20 | ObjectOutput=./ 21 | OverrideOutput=0 22 | OverrideOutputName=example3.exe 23 | HostApplication= 24 | CommandLine= 25 | UseCustomMakefile=0 26 | CustomMakefile= 27 | IncludeVersionInfo=0 28 | SupportXPThemes=0 29 | CompilerSet=0 30 | CompilerSettings=0000000000000000000 31 | 32 | [Unit1] 33 | FileName=..\example3.cpp 34 | Folder= 35 | Compile=1 36 | CompileCpp=1 37 | Link=1 38 | Priority=1000 39 | OverrideBuildCmd=0 40 | BuildCmd= 41 | 42 | [VersionInfo] 43 | Major=0 44 | Minor=1 45 | Release=1 46 | Build=1 47 | LanguageID=1033 48 | CharsetID=1252 49 | CompanyName= 50 | FileVersion=0.1 51 | FileDescription=Developed using the Dev-C++ IDE 52 | InternalName= 53 | LegalCopyright= 54 | LegalTrademarks= 55 | OriginalFilename=example3.exe 56 | ProductName=example3 57 | ProductVersion=0.1 58 | AutoIncBuildNr=0 59 | 60 | -------------------------------------------------------------------------------- /glui-2.35/src/devcpp/example4.dev: -------------------------------------------------------------------------------- 1 | [Project] 2 | FileName=example4.dev 3 | Name=example4 4 | Ver=1 5 | IsCpp=1 6 | Type=1 7 | Compiler= 8 | CppCompiler= 9 | Includes=../ 10 | Linker=-lglui -lglut32 -lglu32 -lopengl32 -lstdc++_@@_ 11 | Libs=. 12 | UnitCount=1 13 | Folders= 14 | ObjFiles= 15 | PrivateResource= 16 | ResourceIncludes= 17 | MakeIncludes= 18 | Icon= 19 | ExeOutput=./ 20 | ObjectOutput=./ 21 | OverrideOutput=0 22 | OverrideOutputName=example4.exe 23 | HostApplication= 24 | CommandLine= 25 | UseCustomMakefile=0 26 | CustomMakefile= 27 | IncludeVersionInfo=0 28 | SupportXPThemes=0 29 | CompilerSet=0 30 | CompilerSettings=0000000000000000000 31 | 32 | [Unit1] 33 | FileName=..\example4.cpp 34 | Folder= 35 | Compile=1 36 | CompileCpp=1 37 | Link=1 38 | Priority=1000 39 | OverrideBuildCmd=0 40 | BuildCmd= 41 | 42 | [VersionInfo] 43 | Major=0 44 | Minor=1 45 | Release=1 46 | Build=1 47 | LanguageID=1033 48 | CharsetID=1252 49 | CompanyName= 50 | FileVersion=0.1 51 | FileDescription=Developed using the Dev-C++ IDE 52 | InternalName= 53 | LegalCopyright= 54 | LegalTrademarks= 55 | OriginalFilename=example4.exe 56 | ProductName=example4 57 | ProductVersion=0.1 58 | AutoIncBuildNr=0 59 | 60 | -------------------------------------------------------------------------------- /glui-2.35/src/devcpp/example5.dev: -------------------------------------------------------------------------------- 1 | [Project] 2 | FileName=example5.dev 3 | Name=example5 4 | Ver=1 5 | IsCpp=1 6 | Type=1 7 | Compiler= 8 | CppCompiler= 9 | Includes=../ 10 | Linker=-lglui -lglut32 -lglu32 -lopengl32 -lstdc++_@@_ 11 | Libs=. 12 | UnitCount=1 13 | Folders= 14 | ObjFiles= 15 | PrivateResource= 16 | ResourceIncludes= 17 | MakeIncludes= 18 | Icon= 19 | ExeOutput=./ 20 | ObjectOutput=./ 21 | OverrideOutput=0 22 | OverrideOutputName=example5.exe 23 | HostApplication= 24 | CommandLine= 25 | UseCustomMakefile=0 26 | CustomMakefile= 27 | IncludeVersionInfo=0 28 | SupportXPThemes=0 29 | CompilerSet=0 30 | CompilerSettings=0000000000000000000 31 | 32 | [Unit1] 33 | FileName=..\example5.cpp 34 | Folder= 35 | Compile=1 36 | CompileCpp=1 37 | Link=1 38 | Priority=1000 39 | OverrideBuildCmd=0 40 | BuildCmd= 41 | 42 | [VersionInfo] 43 | Major=0 44 | Minor=1 45 | Release=1 46 | Build=1 47 | LanguageID=1033 48 | CharsetID=1252 49 | CompanyName= 50 | FileVersion=0.1 51 | FileDescription=Developed using the Dev-C++ IDE 52 | InternalName= 53 | LegalCopyright= 54 | LegalTrademarks= 55 | OriginalFilename=example5.exe 56 | ProductName=example5 57 | ProductVersion=0.1 58 | AutoIncBuildNr=0 59 | 60 | -------------------------------------------------------------------------------- /cg4cpp/include/Cg/sampler1D.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #ifndef __sampler1D_hpp__ 9 | #define __sampler1D_hpp__ 10 | 11 | #include 12 | 13 | namespace Cg { 14 | 15 | class __CGsampler1D_state; 16 | 17 | class sampler1D { 18 | __CGsampler1D_state *state; 19 | 20 | public: 21 | sampler1D(); 22 | sampler1D(int texUnit); 23 | sampler1D(const sampler1D &src); 24 | ~sampler1D(); 25 | sampler1D & operator = (const sampler1D &rhs); 26 | float4 sample(float4 strq, float lod); 27 | }; 28 | 29 | // Cg Standard Library texture functions 30 | 31 | float4 tex1D(sampler1D, float1 s); 32 | float4 tex1D(sampler1D, float1 s, float1 dx, float1 dy); 33 | float4 tex1D(sampler1D, float2 st); 34 | float4 tex1D(sampler1D, float2 st, float1 dx, float1 dy); 35 | float4 tex1Dproj(sampler1D, float2 sq); 36 | float4 tex1Dproj(sampler1D, float3 srq); 37 | 38 | } // namespace Cg 39 | 40 | #endif // __sampler1D_hpp__ 41 | -------------------------------------------------------------------------------- /glut/lib/glut/glut_stroke.c: -------------------------------------------------------------------------------- 1 | 2 | /* Copyright (c) Mark J. Kilgard, 1994, 2001. */ 3 | 4 | /* This program is freely distributable without licensing fees 5 | and is provided without guarantee or warrantee expressed or 6 | implied. This program is -not- in the public domain. */ 7 | 8 | #include "glutint.h" 9 | #include "glutstroke.h" 10 | 11 | void GLUTAPIENTRY 12 | glutStrokeCharacter(GLUTstrokeFont font, int c) 13 | { 14 | const StrokeCharRec *ch; 15 | const StrokeRec *stroke; 16 | const CoordRec *coord; 17 | StrokeFontPtr fontinfo; 18 | int i, j; 19 | 20 | 21 | #if defined(_WIN32) 22 | fontinfo = (StrokeFontPtr) __glutFont(font); 23 | #else 24 | fontinfo = (StrokeFontPtr) font; 25 | #endif 26 | 27 | if (c < 0 || c >= fontinfo->num_chars) { 28 | return; 29 | } 30 | ch = &(fontinfo->ch[c]); 31 | if (ch) { 32 | for (i = ch->num_strokes, stroke = ch->stroke; 33 | i > 0; i--, stroke++) { 34 | glBegin(GL_LINE_STRIP); 35 | for (j = stroke->num_coords, coord = stroke->coord; 36 | j > 0; j--, coord++) { 37 | glVertex2f(coord->x, coord->y); 38 | } 39 | glEnd(); 40 | } 41 | glTranslatef(ch->right, 0.0, 0.0); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /cg4cpp/include/Cg/samplerRECT.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #ifndef __samplerRECT_hpp__ 9 | #define __samplerRECT_hpp__ 10 | 11 | #include 12 | 13 | namespace Cg { 14 | 15 | class __CGsamplerRECT_state; 16 | 17 | class samplerRECT { 18 | __CGsamplerRECT_state *state; 19 | 20 | public: 21 | samplerRECT(); 22 | samplerRECT(int texUnit); 23 | samplerRECT(const samplerRECT &src); 24 | ~samplerRECT(); 25 | samplerRECT & operator = (const samplerRECT &rhs); 26 | float4 sample(float4 strq, float lod); 27 | }; 28 | 29 | // Cg Standard Library texture functions 30 | 31 | float4 texRECT(samplerRECT, float2 st); 32 | float4 texRECT(samplerRECT, float2 st, float2 dx, float2 dy); 33 | float4 texRECT(samplerRECT, float3 str); 34 | float4 texRECT(samplerRECT, float3 str, float3 dx, float3 dy); 35 | float4 texRECTproj(samplerRECT, float4 strq); 36 | 37 | } // namespace Cg 38 | 39 | #endif // __samplerRECT_hpp__ 40 | -------------------------------------------------------------------------------- /cg4cpp/test/glprocs.h: -------------------------------------------------------------------------------- 1 | 2 | /* glprocs.h - header for OpenGL entry point function pointers */ 3 | 4 | #if __APPLE__ 5 | #include 6 | #else 7 | #include 8 | #include 9 | #endif 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | #ifndef __APPLE__ 16 | 17 | /* OpenGL 1.3 minimal multitexture API */ 18 | extern PFNGLACTIVETEXTUREPROC glActiveTexture; 19 | extern PFNGLCLIENTACTIVETEXTUREPROC glClientActiveTexture; 20 | extern PFNGLLOADTRANSPOSEMATRIXFPROC glLoadTransposeMatrixf; 21 | 22 | /* OpenGL 1.5 minimal buffer object API */ 23 | extern PFNGLBINDBUFFERPROC glBindBuffer; 24 | extern PFNGLBUFFERDATAPROC glBufferData; 25 | extern PFNGLDELETEBUFFERSPROC glDeleteBuffers; 26 | extern PFNGLGENBUFFERSPROC glGenBuffers; 27 | 28 | /* OpenGL 2.0 two-sided stencil */ 29 | extern PFNGLSTENCILFUNCSEPARATEPROC glStencilFuncSeparate; 30 | extern PFNGLSTENCILOPSEPARATEPROC glStencilOpSeparate; 31 | extern PFNGLSTENCILMASKSEPARATEPROC glStencilMaskSeparate; 32 | 33 | /* EXT_texture_buffer_object */ 34 | extern PFNGLTEXBUFFEREXTPROC glTexBufferEXT; 35 | 36 | #endif /* __APPLE__ */ 37 | 38 | extern void init_glprocs(void); 39 | 40 | #ifdef __cplusplus 41 | } 42 | #endif 43 | -------------------------------------------------------------------------------- /glut/lib/glut/glut_space.c: -------------------------------------------------------------------------------- 1 | 2 | /* Copyright (c) Mark J. Kilgard, 1994. */ 3 | 4 | /* This program is freely distributable without licensing fees 5 | and is provided without guarantee or warrantee expressed or 6 | implied. This program is -not- in the public domain. */ 7 | 8 | #include "glutint.h" 9 | 10 | void GLUTAPIENTRY 11 | glutSpaceballMotionFunc(GLUTspaceMotionCB spaceMotionFunc) 12 | { 13 | __glutCurrentWindow->spaceMotion = spaceMotionFunc; 14 | __glutUpdateInputDeviceMaskFunc = __glutUpdateInputDeviceMask; 15 | __glutPutOnWorkList(__glutCurrentWindow, 16 | GLUT_DEVICE_MASK_WORK); 17 | } 18 | 19 | void GLUTAPIENTRY 20 | glutSpaceballRotateFunc(GLUTspaceRotateCB spaceRotateFunc) 21 | { 22 | __glutCurrentWindow->spaceRotate = spaceRotateFunc; 23 | __glutUpdateInputDeviceMaskFunc = __glutUpdateInputDeviceMask; 24 | __glutPutOnWorkList(__glutCurrentWindow, 25 | GLUT_DEVICE_MASK_WORK); 26 | } 27 | 28 | void GLUTAPIENTRY 29 | glutSpaceballButtonFunc(GLUTspaceButtonCB spaceButtonFunc) 30 | { 31 | __glutCurrentWindow->spaceButton = spaceButtonFunc; 32 | __glutUpdateInputDeviceMaskFunc = __glutUpdateInputDeviceMask; 33 | __glutPutOnWorkList(__glutCurrentWindow, 34 | GLUT_DEVICE_MASK_WORK); 35 | } 36 | -------------------------------------------------------------------------------- /tessellation/bicubic_texcoord_lod.glsltc: -------------------------------------------------------------------------------- 1 | 2 | // bicubic_texcoord_lod.glsltc 3 | 4 | // DESCRIPTION: GLSL tessellation control shader passing 5 | // through 16 control points to form a quadrilateral bicubic patch with the 6 | // outer level-of-detail specified by the (s,t,p,q) of texture coordinate 7 | // set 0 and the inner level-of-detail specified by (s,t) of texture 8 | // coordinate set 1. 9 | 10 | #version 400 compatibility 11 | layout(vertices=16) out; // bicubic quadrilateral patch 12 | 13 | #define TID gl_InvocationID // thread ID 14 | 15 | in vec3 eye_space_pos[]; 16 | 17 | out vec3 eye_space_pos2[]; 18 | 19 | void main(void) 20 | { 21 | eye_space_pos2[TID] = eye_space_pos[TID]; 22 | 23 | // The following statements only need to execute on thread 0 (TID == 0)... 24 | // But it is more efficient to simply have all threads execute them. 25 | 26 | // Outer LOD 27 | gl_TessLevelOuter[0] = gl_in[0].gl_TexCoord[0].s; 28 | gl_TessLevelOuter[1] = gl_in[0].gl_TexCoord[0].t; 29 | gl_TessLevelOuter[2] = gl_in[0].gl_TexCoord[0].p; 30 | gl_TessLevelOuter[3] = gl_in[0].gl_TexCoord[0].q; 31 | // Inner LOD 32 | gl_TessLevelInner[0] = gl_in[0].gl_TexCoord[1].s; 33 | gl_TessLevelInner[1] = gl_in[0].gl_TexCoord[1].t; 34 | } -------------------------------------------------------------------------------- /cg4cpp/util/itt.cpp: -------------------------------------------------------------------------------- 1 | 2 | class weird { 3 | union { 4 | __CGswizzle x; 5 | __CGswizzle r; 6 | __CGswizzle s; 7 | __CG_SWIZZLE4_STARTING_WITH_X(x,y,z,w); 8 | __CG_SWIZZLE4_STARTING_WITH_X(r,g,b,a); 9 | __CG_SWIZZLE4_STARTING_WITH_X(s,t,p,q); 10 | }; 11 | union { 12 | __CGswizzle y; 13 | __CGswizzle g; 14 | __CGswizzle t; 15 | __CG_SWIZZLE3_STARTING_WITH_Y_NOT_X(y,z,w); 16 | __CG_SWIZZLE3_STARTING_WITH_Y_NOT_X(g,b,a); 17 | __CG_SWIZZLE3_STARTING_WITH_Y_NOT_X(t,p,q); 18 | }; 19 | union { 20 | __CGswizzle z; 21 | __CGswizzle b; 22 | __CGswizzle p; 23 | __CG_SWIZZLE2_STARTING_WITH_Z_NOT_XY(z,w); 24 | __CG_SWIZZLE2_STARTING_WITH_Z_NOT_XY(b,a); 25 | __CG_SWIZZLE2_STARTING_WITH_Z_NOT_XY(p,q); 26 | }; 27 | union { 28 | __CGswizzle w; 29 | __CGswizzle a; 30 | __CGswizzle q; 31 | __CG_SWIZZLE1_STARTING_WITH_W_NOT_XYZ(z,w); 32 | __CG_SWIZZLE1_STARTING_WITH_W_NOT_XYZ(b,a); 33 | __CG_SWIZZLE1_STARTING_WITH_W_NOT_XYZ(p,q); 34 | }; 35 | }; 36 | -------------------------------------------------------------------------------- /tessellation/tri_texcoord_lod.glsltc: -------------------------------------------------------------------------------- 1 | 2 | // tri_texcoord_lod.glsltc 3 | 4 | // DESCRIPTION: GLSL tessellation control shader passing 5 | // through 3 control points to form a triangle patch with the 6 | // outer level-of-detail specified by the (s,t,p,q) of texture coordinate 7 | // set 0 and the inner level-of-detail specified by (s,t) of texture 8 | // coordinate set 1. 9 | 10 | // To off-line compile this code to assembly with Cg 3.0, use: 11 | // cgc -profile gp5tcp -oglsl -po InputPatchSize=3 -po PATCH_3 tri_texcoord_lod.glsltc 12 | 13 | #version 400 compatibility 14 | layout(vertices=3) out; // linear triangle patch 15 | 16 | #define TID gl_InvocationID // thread ID 17 | 18 | in vec3 eye_space_pos[]; 19 | 20 | out vec3 eye_space_pos2[]; 21 | 22 | void main(void) 23 | { 24 | eye_space_pos2[TID] = eye_space_pos[TID]; 25 | 26 | // The following statements only need to execute on thread 0 (TID == 0)... 27 | // But it is more efficient to simply have all threads execute them. 28 | 29 | // Outer LOD 30 | gl_TessLevelOuter[0] = gl_in[0].gl_TexCoord[0].s; 31 | gl_TessLevelOuter[1] = gl_in[0].gl_TexCoord[0].t; 32 | gl_TessLevelOuter[2] = gl_in[0].gl_TexCoord[0].p; 33 | // Inner LOD 34 | gl_TessLevelInner[0] = gl_in[0].gl_TexCoord[1].s; 35 | } -------------------------------------------------------------------------------- /cg4cpp/include/Cg/sampler2DARRAY.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #ifndef __sampler2DARRAY_hpp__ 9 | #define __sampler2DARRAY_hpp__ 10 | 11 | #include 12 | 13 | namespace Cg { 14 | 15 | class __CGsampler2DARRAY_state; 16 | 17 | class sampler2DARRAY { 18 | __CGsampler2DARRAY_state *state; 19 | 20 | public: 21 | sampler2DARRAY(); 22 | sampler2DARRAY(int texUnit); 23 | sampler2DARRAY(const sampler2DARRAY &src); 24 | ~sampler2DARRAY(); 25 | sampler2DARRAY & operator = (const sampler2DARRAY &rhs); 26 | float4 sample(float4 strq, float lod); 27 | }; 28 | 29 | // Cg Standard Library texture functions 30 | 31 | float4 tex2DARRAY(sampler2DARRAY, float3 str); 32 | float4 tex2DARRAY(sampler2DARRAY, float4 strq); 33 | float4 tex2DARRAY(sampler2DARRAY, float3 str, float3 dx, float3 dy); 34 | float4 tex2DARRAY(sampler2DARRAY, float4 strq, float4 dx, float4 dy); 35 | float4 tex2DARRAYproj(sampler2DARRAY, float4 strq); 36 | 37 | } // namespace Cg 38 | 39 | #endif // __sampler2DARRAY_hpp__ 40 | -------------------------------------------------------------------------------- /cg4cpp/include/Cg/sampler1DARRAY.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #ifndef __sampler1DARRAY_hpp__ 9 | #define __sampler1DARRAY_hpp__ 10 | 11 | #include 12 | 13 | namespace Cg { 14 | 15 | class __CGsampler1DARRAY_state; 16 | 17 | class sampler1DARRAY { 18 | __CGsampler1DARRAY_state *state; 19 | 20 | public: 21 | sampler1DARRAY(); 22 | sampler1DARRAY(const sampler1DARRAY &src); 23 | ~sampler1DARRAY(); 24 | sampler1DARRAY & operator = (const sampler1DARRAY &rhs); 25 | float4 sample(float4 strq, float lod); 26 | }; 27 | 28 | // Cg Standard Library texture functions 29 | 30 | float4 tex1DARRAY(sampler1DARRAY, float2 st); 31 | float4 tex1DARRAY(sampler1DARRAY, float2 st, float2 dx, float2 dy); 32 | float4 tex1DARRAY(sampler1DARRAY, float3 str); 33 | float4 tex1DARRAY(sampler1DARRAY, float3 str, float3 dx, float3 dy); 34 | float4 tex1DARRAYproj(sampler1DARRAY, float3 str); 35 | float4 tex1DARRAYproj(sampler1DARRAY, float4 strq); 36 | 37 | } // namespace Cg 38 | 39 | #endif // __sampler1DARRAY_hpp__ 40 | -------------------------------------------------------------------------------- /tessellation/tricubic_texcoord_lod.glsltc: -------------------------------------------------------------------------------- 1 | 2 | // tricubic_texcoord_lod.glsltc 3 | 4 | // DESCRIPTION: GLSL tessellation control shader passing 5 | // through 16 control points to form a quadrilateral bicubic patch with the 6 | // outer level-of-detail specified by the (s,t,p,q) of texture coordinate 7 | // set 0 and the inner level-of-detail specified by (s,t) of texture 8 | // coordinate set 1. 9 | 10 | // To off-line compile this code to assembly with Cg 3.0, use: 11 | // cgc -profile gp5tcp -oglsl -po InputPatchSize=10 -po PATCH_10 tricubic_texcoord_lod.glsltc 12 | 13 | #version 400 compatibility 14 | layout(vertices=10) out; // bicubic quadrilateral patch 15 | 16 | #define TID gl_InvocationID // thread ID 17 | 18 | in vec3 eye_space_pos[]; 19 | 20 | out vec3 eye_space_pos2[]; 21 | 22 | void main(void) 23 | { 24 | eye_space_pos2[TID] = eye_space_pos[TID]; 25 | 26 | // The following statements only need to execute on thread 0 (TID == 0)... 27 | // But it is more efficient to simply have all threads execute them. 28 | 29 | // Outer LOD 30 | gl_TessLevelOuter[0] = gl_in[0].gl_TexCoord[0].s; 31 | gl_TessLevelOuter[1] = gl_in[0].gl_TexCoord[0].t; 32 | gl_TessLevelOuter[2] = gl_in[0].gl_TexCoord[0].p; 33 | // Inner LOD 34 | gl_TessLevelInner[0] = gl_in[0].gl_TexCoord[1].s; 35 | } -------------------------------------------------------------------------------- /cg4cpp/include/Cg/sampler2D.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #ifndef __sampler2D_hpp__ 9 | #define __sampler2D_hpp__ 10 | 11 | #include 12 | 13 | namespace Cg { 14 | 15 | class __CGsampler2D_state; 16 | 17 | class __CGsampler2D_factory { 18 | public: 19 | virtual __CGsampler2D_state *construct() = 0; 20 | }; 21 | 22 | class sampler2D { 23 | __CGsampler2D_state *state; 24 | 25 | public: 26 | sampler2D(); 27 | sampler2D(const sampler2D &src); 28 | sampler2D(__CGsampler2D_factory &src); 29 | ~sampler2D(); 30 | sampler2D & operator = (const sampler2D &rhs); 31 | float4 sample(float4 strq, float lod); 32 | void update(); 33 | }; 34 | 35 | // Cg Standard Library texture functions 36 | 37 | float4 tex2D(sampler2D, float2 st); 38 | float4 tex2D(sampler2D, float2 st, float2 dx, float2 dy); 39 | float4 tex2D(sampler2D, float3 str); 40 | float4 tex2D(sampler2D, float3 str, float3 dx, float3 dy); 41 | float4 tex2Dproj(sampler2D, float3 str); 42 | float4 tex2Dproj(sampler2D, float4 strq); 43 | 44 | } // namespace Cg 45 | 46 | #endif // __sampler2D_hpp__ 47 | -------------------------------------------------------------------------------- /common/showfps.h: -------------------------------------------------------------------------------- 1 | #ifndef SHOWFPS_H 2 | #define SHOWFPS_H 3 | 4 | /* showfps.h - OpenGL code for rendering frames per second */ 5 | 6 | /* Call handleFPS in your GLUT display callback every frame. */ 7 | 8 | #ifdef __APPLE__ 9 | #include 10 | #else 11 | #include 12 | #endif 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | #define MAX_FPS_QUADS (12*4) 19 | 20 | typedef enum { 21 | FPS_USAGE_TEXTURE, 22 | FPS_USAGE_BITMAP 23 | } FPSusage; 24 | 25 | typedef struct _FPScontext { 26 | FPSusage usage; 27 | int width, height; 28 | GLuint fps_text_texture; 29 | double last_fpsRate; 30 | float last_scale; 31 | GLint count; 32 | GLfloat varray[4*MAX_FPS_QUADS]; 33 | } FPScontext; 34 | 35 | extern void initFPScontext(FPScontext *, FPSusage); 36 | extern void reshapeFPScontext(FPScontext *ctx, int w, int h); 37 | extern void releaseFPScontext(FPScontext *ctx); 38 | 39 | extern double just_handleFPS(void); 40 | extern double handleFPS(FPScontext *); 41 | extern void toggleFPS(); 42 | extern void enableFPS(); 43 | extern void disableFPS(); 44 | extern void colorFPS(float r, float g, float b); 45 | extern void scaleFPS(float new_scale); 46 | extern double getElapsedTime(); 47 | extern void invalidateFPS(); 48 | 49 | #ifdef __cplusplus 50 | } 51 | #endif 52 | 53 | #endif /* SHOWFPS_H */ 54 | -------------------------------------------------------------------------------- /mandelbrot/showfps.h: -------------------------------------------------------------------------------- 1 | #ifndef SHOWFPS_H 2 | #define SHOWFPS_H 3 | 4 | /* showfps.h - OpenGL code for rendering frames per second */ 5 | 6 | /* Call handleFPS in your GLUT display callback every frame. */ 7 | 8 | #ifdef __APPLE__ 9 | #include 10 | #else 11 | #include 12 | #endif 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | #define MAX_FPS_QUADS (12*4) 19 | 20 | typedef enum { 21 | FPS_USAGE_TEXTURE, 22 | FPS_USAGE_BITMAP 23 | } FPSusage; 24 | 25 | typedef struct _FPScontext { 26 | FPSusage usage; 27 | int width, height; 28 | GLuint fps_text_texture; 29 | double last_fpsRate; 30 | float last_scale; 31 | GLint count; 32 | GLfloat varray[4*MAX_FPS_QUADS]; 33 | } FPScontext; 34 | 35 | extern void initFPScontext(FPScontext *, FPSusage); 36 | extern void reshapeFPScontext(FPScontext *ctx, int w, int h); 37 | extern void releaseFPScontext(FPScontext *ctx); 38 | 39 | extern double just_handleFPS(void); 40 | extern double handleFPS(FPScontext *); 41 | extern void toggleFPS(); 42 | extern void enableFPS(); 43 | extern void disableFPS(); 44 | extern void colorFPS(float r, float g, float b); 45 | extern void scaleFPS(float new_scale); 46 | extern double getElapsedTime(); 47 | extern void invalidateFPS(); 48 | 49 | #ifdef __cplusplus 50 | } 51 | #endif 52 | 53 | #endif /* SHOWFPS_H */ 54 | -------------------------------------------------------------------------------- /cg4cpp/include/Cg/degrees.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #ifndef __Cg_degrees_hpp__ 9 | #define __Cg_degrees_hpp__ 10 | 11 | #ifdef __Cg_stdlib_hpp__ 12 | #pragma message("error: include this header file (" __FILE__ ") before ") 13 | #endif 14 | 15 | #include 16 | 17 | namespace Cg { 18 | 19 | template 20 | static inline __CGvector::realType,N> degrees(const __CGvector & v) 21 | { 22 | return T(57.29577951) * v; 23 | } 24 | template 25 | static inline __CGvector::realType,N> degrees(const __CGvector_usage & v) 26 | { 27 | __CGvector rv; 28 | for (int i=0; i 33 | static inline __CGvector::realType,1> degrees(const T & v) 34 | { 35 | __CGvector::realType,1> rv(T(57.29577951) * static_cast(v)); 36 | return rv; 37 | } 38 | 39 | } // namespace Cg 40 | 41 | #endif // __Cg_degrees_hpp__ 42 | -------------------------------------------------------------------------------- /cg4cpp/include/Cg/normalize.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #ifndef __Cg_normalize_hpp__ 9 | #define __Cg_normalize_hpp__ 10 | 11 | #ifdef __Cg_stdlib_hpp__ 12 | #pragma message("error: include this header file (" __FILE__ ") before ") 13 | #endif 14 | 15 | #include 16 | 17 | #include // for ::sqrt 18 | 19 | namespace Cg { 20 | 21 | template 22 | static inline __CGvector::realType,N> normalize(const __CGvector & v) 23 | { 24 | typename __CGtype_trait::dotType sum = v[0] * v[0]; 25 | for (int i=1; i(v / ::sqrt(sum)); 28 | } 29 | template 30 | static inline __CGvector::realType,N> normalize(const __CGvector_usage & v) 31 | { 32 | typename __CGtype_trait::dotType sum = v[0] * v[0]; 33 | for (int i=1; i(v / ::sqrt(sum)); 36 | } 37 | 38 | } // namespace Cg 39 | 40 | #endif // __Cg_normalize_hpp__ 41 | -------------------------------------------------------------------------------- /cg4cpp/include/Cg/radians.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #ifndef __Cg_radians_hpp__ 9 | #define __Cg_radians_hpp__ 10 | 11 | #ifdef __Cg_stdlib_hpp__ 12 | #pragma message("error: include this header file (" __FILE__ ") before ") 13 | #endif 14 | 15 | #include 16 | 17 | namespace Cg { 18 | 19 | template 20 | static inline __CGvector::realType,N> radians(const __CGvector & v) 21 | { 22 | return T(0.017453292) * v; 23 | } 24 | template 25 | static inline __CGvector::realType,N> radians(const __CGvector_usage & v) 26 | { 27 | __CGvector rv; 28 | for (int i=0; i 33 | static inline __CGvector::realType,1> radians(const T & v) 34 | { 35 | __CGvector::realType,1> rv(T(0.017453292) * static_cast(v)); 36 | return rv; 37 | } 38 | 39 | } // namespace Cg 40 | 41 | #endif // __Cg_radians_hpp__ 42 | -------------------------------------------------------------------------------- /cg4cpp/include/Cg/frexp.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2009 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #ifndef __Cg_frexp_hpp__ 9 | #define __Cg_frexp_hpp__ 10 | 11 | #ifdef __Cg_stdlib_hpp__ 12 | #pragma message("error: include this header file (" __FILE__ ") before ") 13 | #endif 14 | 15 | #include 16 | 17 | #include // for ::frexp 18 | 19 | namespace Cg { 20 | 21 | template 22 | static inline __CGvector frexp(__CGvector x, __CGvector& expOut) 23 | { 24 | __CGvector rv; 25 | 26 | for (int i=0; i 34 | static inline __CGvector frexp(__CGvector x, __CGvector_usage& expOut) 35 | { 36 | __CGvector rv; 37 | 38 | for (int i=0; i") 13 | #endif 14 | 15 | #include 16 | 17 | namespace Cg { 18 | 19 | template 20 | static inline __CGvector::numericType,N> sign(const __CGvector & v) 21 | { 22 | typedef __CGvector ResultType; 23 | return ResultType(v > 0) - ResultType(v < 0); 24 | } 25 | template 26 | static inline __CGvector::numericType,N> sign(const __CGvector_usage & v) 27 | { 28 | typedef __CGvector ResultType; 29 | return ResultType(v > 0) - ResultType(v < 0); 30 | } 31 | template 32 | static inline __CGvector::numericType,1> sign(const T & v) 33 | { 34 | typedef __CGvector ResultType; 35 | return ResultType(static_cast(v) > 0) - ResultType(static_cast(v) < 0); 36 | } 37 | 38 | } // namespace Cg 39 | 40 | #endif // __Cg_sign_hpp__ 41 | -------------------------------------------------------------------------------- /cg4cpp/include/Cg/length.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #ifndef __Cg_length_hpp__ 9 | #define __Cg_length_hpp__ 10 | 11 | #ifdef __Cg_stdlib_hpp__ 12 | #pragma message("error: include this header file (" __FILE__ ") before ") 13 | #endif 14 | 15 | #include 16 | 17 | #include // for ::sqrt 18 | 19 | namespace Cg { 20 | 21 | template 22 | static inline __CGvector::realType,1> length(const __CGvector & v) 23 | { 24 | typename __CGtype_trait::dotType sum = v[0] * v[0]; 25 | for (int i=1; i::realType,1>(::sqrt(sum)); 28 | } 29 | template 30 | static inline __CGvector::realType,1> length(const __CGvector_usage & v) 31 | { 32 | typename __CGtype_trait::dotType sum = v[0] * v[0]; 33 | for (int i=1; i::realType,1>(::sqrt(sum)); 36 | } 37 | 38 | } // namespace Cg 39 | 40 | #endif // __Cg_length_hpp__ 41 | -------------------------------------------------------------------------------- /cg4cpp/test/test_inverse.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | using namespace Cg; 12 | 13 | #define OUTPUT(_x) std::cout << #_x << "=" << (_x) << std::endl 14 | 15 | float4x4 ident4() 16 | { 17 | float4x4 r = 0; 18 | 19 | for (int i=0; i<4; i++) { 20 | r[i][i] = 1.0f; 21 | } 22 | return r; 23 | } 24 | 25 | float4x4 translate(float3 xyz) 26 | { 27 | float4x4 r = ident4(); 28 | 29 | r._14_24_34 = xyz; 30 | return r; 31 | } 32 | 33 | void 34 | test_inverse() 35 | { 36 | float4x4 i4 = ident4(); 37 | float4x4 z = float4x4(-3,0.2f,4,1,-0.4f,5,9,-2,1,-1,0,8.2f,0,0,-1,1); 38 | float4x4 inv_z = inverse(z); 39 | float4x4 ii4 = mul(z,inv_z); 40 | OUTPUT(ii4); 41 | 42 | ii4 = mul(inv_z,z); 43 | OUTPUT(ii4); 44 | ii4 = transpose(inverse(z)); 45 | OUTPUT(ii4); 46 | 47 | OUTPUT(z); 48 | OUTPUT(inverse(z)); 49 | OUTPUT(mul(z,inverse(z))); 50 | OUTPUT(mul(inverse(z),z)); 51 | 52 | OUTPUT(i4); 53 | float4x4 inv_i4 = inverse(i4); 54 | OUTPUT(inv_i4); 55 | 56 | float4x4 a = translate(float3(-2,4,0.5)); 57 | OUTPUT(a); 58 | OUTPUT(inverse(a)); 59 | OUTPUT(a*inverse(a)); 60 | OUTPUT(inverse(a)*a); 61 | } -------------------------------------------------------------------------------- /common/request_vsync.c: -------------------------------------------------------------------------------- 1 | 2 | /* request_vsync.h - request buffer swap synchroization with vertical sync */ 3 | 4 | /* NVIDIA Corporation, Copyright 2007-2010 */ 5 | 6 | #if defined(__APPLE__) 7 | # include 8 | #elif defined(_WIN32) 9 | # include 10 | # ifndef WGL_EXT_swap_control 11 | typedef int (APIENTRY * PFNWGLSWAPINTERVALEXTPROC)(int); 12 | # endif 13 | #else 14 | # include 15 | # ifndef GLX_SGI_swap_control 16 | typedef int ( * PFNGLXSWAPINTERVALSGIPROC) (int interval); 17 | # endif 18 | #endif 19 | 20 | /* enableSync true means synchronize buffer swaps to monitor refresh; 21 | false means do NOT synchornize. */ 22 | void requestSynchornizedSwapBuffers(int enableSync) 23 | { 24 | #if defined(__APPLE__) 25 | #ifdef GL_VERSION_1_2 26 | const GLint sync = enableSync; 27 | #else 28 | const long sync = enableSync; 29 | #endif 30 | CGLSetParameter(CGLGetCurrentContext(), kCGLCPSwapInterval, &sync); 31 | #elif defined(_WIN32) 32 | PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT = 33 | (PFNWGLSWAPINTERVALEXTPROC) wglGetProcAddress("wglSwapIntervalEXT"); 34 | 35 | if (wglSwapIntervalEXT) { 36 | wglSwapIntervalEXT(enableSync); 37 | } 38 | #else 39 | PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalSGI = 40 | (PFNGLXSWAPINTERVALSGIPROC) glXGetProcAddressARB((const GLubyte*)"glXSwapIntervalSGI"); 41 | if (glXSwapIntervalSGI) { 42 | glXSwapIntervalSGI(enableSync); 43 | } 44 | #endif 45 | } 46 | 47 | -------------------------------------------------------------------------------- /glew/Makefile.glewlib: -------------------------------------------------------------------------------- 1 | # 2 | # Additional compilation flags may be passed via CFLAGS, CXXFLAGS and CLINKFLAGS 3 | # 4 | # Linux: 5 | # make CFLAGS=-m32 6 | # make CFLAGS=-m64 7 | # 8 | # Ubuntu 9.04 64-bit 9 | # make CFLAGS=-m32 CXXFLAGS=-m32 CLINKFLAGS="-L/lib32 -L/usr/lib32 -Wl,-rpath-link,/lib32:/usr/lib32" 10 | # 11 | # OSX: 12 | # make 'CFLAGS=-arch ppc' 'CXXFLAGS=-arch ppc' 13 | # make 'CFLAGS=-arch i386' 'CXXFLAGS=-arch i386' 14 | # make 'CFLAGS=-arch x86_64' 'CXXFLAGS=-arch x86_64' 15 | 16 | UNAME := $(shell uname) 17 | 18 | C_SOURCE := src/glew.c 19 | OBJ := $(C_SOURCE:.c=.o) 20 | BIN := libglewlib.a 21 | 22 | CC = gcc 23 | C_FLAGS += -Wall 24 | C_FLAGS += -I"include" 25 | C_FLAGS += -DGLEW_STATIC 26 | C_FLAGS += -DGLEW_BUILD 27 | 28 | ifeq ($(UNAME), Darwin) 29 | else 30 | ifeq ($(findstring CYGWIN, $(UNAME)), CYGWIN) 31 | BIN = glewlib.lib 32 | C_FLAGS += -D_WIN32 33 | C_FLAGS += -mno-cygwin 34 | LINKFLAGS += -mno-cygwin 35 | else 36 | ifeq ($(UNAME), SunOS) 37 | C_FLAGS += -fPIC 38 | else 39 | endif 40 | endif 41 | endif 42 | 43 | override CFLAGS := $(CFLAGS) $(C_FLAGS) 44 | 45 | all: glewlib 46 | 47 | glewlib: $(OBJ) 48 | $(AR) -rc $(BIN) $(OBJ) 49 | 50 | test: 51 | 52 | run: all 53 | 54 | clean: 55 | $(RM) $(BIN) $(OBJ) 56 | 57 | clobber: clean 58 | $(RM) *.bak *.o *~ 59 | 60 | .PHONY: all test run clean clobber 61 | -------------------------------------------------------------------------------- /cg4cpp/include/Cg/cos.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #ifndef __Cg_cos_hpp__ 9 | #define __Cg_cos_hpp__ 10 | 11 | #ifdef __Cg_stdlib_hpp__ 12 | #pragma message("error: include this header file (" __FILE__ ") before ") 13 | #endif 14 | 15 | #include 16 | 17 | #include // for ::cos 18 | 19 | namespace Cg { 20 | 21 | template 22 | static inline __CGvector::realType,N> cos(const __CGvector & v) 23 | { 24 | __CGvector rv; 25 | for (int i=0; i 30 | static inline __CGvector::realType,N> cos(const __CGvector_usage & v) 31 | { 32 | __CGvector rv; 33 | for (int i=0; i 38 | static inline __CGvector::realType,1> cos(const T & v) 39 | { 40 | __CGvector::realType,1> rv(::cos(static_cast(v))); 41 | return rv; 42 | } 43 | 44 | } // namespace Cg 45 | 46 | #endif // __Cg_cos_hpp__ 47 | -------------------------------------------------------------------------------- /cg4cpp/include/Cg/sin.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #ifndef __Cg_sin_hpp__ 9 | #define __Cg_sin_hpp__ 10 | 11 | #ifdef __Cg_stdlib_hpp__ 12 | #pragma message("error: include this header file (" __FILE__ ") before ") 13 | #endif 14 | 15 | #include 16 | 17 | #include // for ::sin 18 | 19 | namespace Cg { 20 | 21 | template 22 | static inline __CGvector::realType,N> sin(const __CGvector & v) 23 | { 24 | __CGvector rv; 25 | for (int i=0; i 30 | static inline __CGvector::realType,N> sin(const __CGvector_usage & v) 31 | { 32 | __CGvector rv; 33 | for (int i=0; i 38 | static inline __CGvector::realType,1> sin(const T & v) 39 | { 40 | __CGvector::realType,1> rv(::sin(static_cast(v))); 41 | return rv; 42 | } 43 | 44 | } // namespace Cg 45 | 46 | #endif // __Cg_sin_hpp__ 47 | -------------------------------------------------------------------------------- /cg4cpp/src/lit.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2006 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include // for std::pow 14 | 15 | namespace Cg { 16 | 17 | template 18 | static inline __CGvector lit(const __CGvector & NdotL, const __CGvector & NdotH, const __CGvector & m) // XXXmjk should be vectors?? 19 | { 20 | __CGvector rv; 21 | rv.x = T(1); 22 | if (NdotL < 0) { 23 | rv.y = 0; 24 | rv.z = 0; 25 | } else { 26 | rv.y = NdotL; 27 | if (NdotH < 0) { 28 | rv.z = 0; 29 | } else { 30 | rv.z = std::pow(float1(NdotH), float1(m)); // revisit for double 31 | } 32 | } 33 | rv.w = 1; 34 | return rv; 35 | } 36 | 37 | float4 lit(float1 NdotL, float1 NdotH, float1 m) 38 | { 39 | return lit(NdotL, NdotH, m); 40 | } 41 | 42 | half4 lit(half1 NdotL, half1 NdotH, half1 m) 43 | { 44 | return lit(NdotL, NdotH, m); 45 | } 46 | 47 | fixed4 lit(fixed1 NdotL, fixed1 NdotH, fixed1 m) 48 | { 49 | return lit(NdotL, NdotH, m); 50 | } 51 | 52 | } // namespace Cg 53 | 54 | -------------------------------------------------------------------------------- /cg4cpp/src/sampler2D_state.hpp: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2006 by NVIDIA Corporation. All rights reserved. All 4 | * information contained herein is proprietary and confidential to NVIDIA 5 | * Corporation. Any use, reproduction, or disclosure without the written 6 | * permission of NVIDIA Corporation is prohibited. 7 | */ 8 | /* 9 | * Copyright 2005 by NVIDIA Corporation. All rights reserved. All 10 | * information contained herein is proprietary and confidential to NVIDIA 11 | * Corporation. Any use, reproduction, or disclosure without the written 12 | * permission of NVIDIA Corporation is prohibited. 13 | */ 14 | 15 | #include "sampler_state.hpp" 16 | 17 | namespace Cg { 18 | 19 | class __CGsampler2D_state : public __CGsampler_state { 20 | __CGimage image[maxLevels]; 21 | 22 | virtual void initImages(); 23 | 24 | virtual ~__CGsampler2D_state() { } 25 | 26 | virtual float4 linearFilter(int level, float4 strq); 27 | virtual float4 nearestFilter(int level, float4 strq); 28 | 29 | virtual float4 nearest(const __CGimage &image, float4 strq); 30 | virtual float4 linear(const __CGimage &image, float4 strq); 31 | 32 | public: 33 | __CGsampler2D_state() { 34 | initDerivedSampler(GL_TEXTURE_2D); 35 | } 36 | __CGsampler2D_state(int unit) { 37 | initDerivedSampler(GL_TEXTURE_2D, unit); 38 | } 39 | float4 sample(float4 strq, float lod); 40 | int3 size(int1 lod); 41 | }; 42 | 43 | } // namespace Cg 44 | -------------------------------------------------------------------------------- /cg4cpp/include/Cg/acos.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #ifndef __Cg_acos_hpp__ 9 | #define __Cg_acos_hpp__ 10 | 11 | #ifdef __Cg_stdlib_hpp__ 12 | #pragma message("error: include this header file (" __FILE__ ") before ") 13 | #endif 14 | 15 | #include 16 | 17 | #include // for ::acos 18 | 19 | namespace Cg { 20 | 21 | template 22 | static inline __CGvector::realType,N> acos(const __CGvector & v) 23 | { 24 | __CGvector rv; 25 | for (int i=0; i 30 | static inline __CGvector::realType,N> acos(const __CGvector_usage & v) 31 | { 32 | __CGvector rv; 33 | for (int i=0; i 38 | static inline __CGvector::realType,1> acos(const T & v) 39 | { 40 | __CGvector::realType,1> rv(::acos(static_cast(v))); 41 | return rv; 42 | } 43 | 44 | } // namespace Cg 45 | 46 | #endif // __Cg_acos_hpp__ 47 | -------------------------------------------------------------------------------- /cg4cpp/include/Cg/exp.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #ifndef __Cg_exp_hpp__ 9 | #define __Cg_exp_hpp__ 10 | 11 | #ifdef __Cg_stdlib_hpp__ 12 | #pragma message("error: include this header file (" __FILE__ ") before ") 13 | #endif 14 | 15 | #include 16 | 17 | #include // for std::exp 18 | 19 | namespace Cg { 20 | 21 | template 22 | static inline __CGvector::realType,N> exp(const __CGvector & v) 23 | { 24 | __CGvector rv; 25 | for (int i=0; i 30 | static inline __CGvector::realType,N> exp(const __CGvector_usage & v) 31 | { 32 | __CGvector rv; 33 | for (int i=0; i 38 | static inline __CGvector::realType,1> exp(const T & v) 39 | { 40 | __CGvector::realType,1> rv(std::exp(static_cast(v))); 41 | return rv; 42 | } 43 | 44 | } // namespace Cg 45 | 46 | #endif // __Cg_exp_hpp__ 47 | -------------------------------------------------------------------------------- /cg4cpp/include/Cg/log.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #ifndef __Cg_log_hpp__ 9 | #define __Cg_log_hpp__ 10 | 11 | #ifdef __Cg_stdlib_hpp__ 12 | #pragma message("error: include this header file (" __FILE__ ") before ") 13 | #endif 14 | 15 | #include 16 | 17 | #include // for std::log 18 | 19 | namespace Cg { 20 | 21 | template 22 | static inline __CGvector::realType,N> log(const __CGvector & v) 23 | { 24 | __CGvector rv; 25 | for (int i=0; i 30 | static inline __CGvector::realType,N> log(const __CGvector_usage & v) 31 | { 32 | __CGvector rv; 33 | for (int i=0; i 38 | static inline __CGvector::realType,1> log(const T & v) 39 | { 40 | __CGvector::realType,1> rv(std::log(static_cast(v))); 41 | return rv; 42 | } 43 | 44 | } // namespace Cg 45 | 46 | #endif // __Cg_log_hpp__ 47 | -------------------------------------------------------------------------------- /cg4cpp/include/Cg/tan.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #ifndef __Cg_tan_hpp__ 9 | #define __Cg_tan_hpp__ 10 | 11 | #ifdef __Cg_stdlib_hpp__ 12 | #pragma message("error: include this header file (" __FILE__ ") before ") 13 | #endif 14 | 15 | #include 16 | 17 | #include // for std::tan 18 | 19 | namespace Cg { 20 | 21 | template 22 | static inline __CGvector::realType,N> tan(const __CGvector & v) 23 | { 24 | __CGvector rv; 25 | for (int i=0; i 30 | static inline __CGvector::realType,N> tan(const __CGvector_usage & v) 31 | { 32 | __CGvector rv; 33 | for (int i=0; i 38 | static inline __CGvector::realType,1> tan(const T & v) 39 | { 40 | __CGvector::realType,1> rv(std::tan(static_cast(v))); 41 | return rv; 42 | } 43 | 44 | } // namespace Cg 45 | 46 | #endif // __Cg_tan_hpp__ 47 | -------------------------------------------------------------------------------- /cg4cpp/include/Cg/asin.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #ifndef __Cg_asin_hpp__ 9 | #define __Cg_asin_hpp__ 10 | 11 | #ifdef __Cg_stdlib_hpp__ 12 | #pragma message("error: include this header file (" __FILE__ ") before ") 13 | #endif 14 | 15 | #include 16 | 17 | #include // for std::asin 18 | 19 | namespace Cg { 20 | 21 | template 22 | static inline __CGvector::realType,N> asin(const __CGvector & v) 23 | { 24 | __CGvector rv; 25 | for (int i=0; i 30 | static inline __CGvector::realType,N> asin(const __CGvector_usage & v) 31 | { 32 | __CGvector rv; 33 | for (int i=0; i 38 | static inline __CGvector::realType,1> asin(const T & v) 39 | { 40 | __CGvector::realType,1> rv(std::asin(static_cast(v))); 41 | return rv; 42 | } 43 | 44 | } // namespace Cg 45 | 46 | #endif // __Cg_asin_hpp__ 47 | -------------------------------------------------------------------------------- /cg4cpp/include/Cg/atan.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #ifndef __Cg_atan_hpp__ 9 | #define __Cg_atan_hpp__ 10 | 11 | #ifdef __Cg_stdlib_hpp__ 12 | #pragma message("error: include this header file (" __FILE__ ") before ") 13 | #endif 14 | 15 | #include 16 | 17 | #include // for std::atan 18 | 19 | namespace Cg { 20 | 21 | template 22 | static inline __CGvector::realType,N> atan(const __CGvector & v) 23 | { 24 | __CGvector rv; 25 | for (int i=0; i 30 | static inline __CGvector::realType,N> atan(const __CGvector_usage & v) 31 | { 32 | __CGvector rv; 33 | for (int i=0; i 38 | static inline __CGvector::realType,1> atan(const T & v) 39 | { 40 | __CGvector::realType,1> rv(std::atan(static_cast(v))); 41 | return rv; 42 | } 43 | 44 | } // namespace Cg 45 | 46 | #endif // __Cg_atan_hpp__ 47 | -------------------------------------------------------------------------------- /cg4cpp/include/Cg/ceil.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #ifndef __Cg_ceil_hpp__ 9 | #define __Cg_ceil_hpp__ 10 | 11 | #ifdef __Cg_stdlib_hpp__ 12 | #pragma message("error: include this header file (" __FILE__ ") before ") 13 | #endif 14 | 15 | #include 16 | 17 | #include // for std::ceil 18 | 19 | namespace Cg { 20 | 21 | template 22 | static inline __CGvector::realType,N> ceil(const __CGvector & v) 23 | { 24 | __CGvector rv; 25 | for (int i=0; i 30 | static inline __CGvector::realType,N> ceil(const __CGvector_usage & v) 31 | { 32 | __CGvector rv; 33 | for (int i=0; i 38 | static inline __CGvector::realType,1> ceil(const T & v) 39 | { 40 | __CGvector::realType,1> rv(std::ceil(static_cast(v))); 41 | return rv; 42 | } 43 | 44 | } // namespace Cg 45 | 46 | #endif // __Cg_ceil_hpp__ 47 | -------------------------------------------------------------------------------- /cg4cpp/include/Cg/cosh.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #ifndef __Cg_cosh_hpp__ 9 | #define __Cg_cosh_hpp__ 10 | 11 | #ifdef __Cg_stdlib_hpp__ 12 | #pragma message("error: include this header file (" __FILE__ ") before ") 13 | #endif 14 | 15 | #include 16 | 17 | #include // for std::cosh 18 | 19 | namespace Cg { 20 | 21 | template 22 | static inline __CGvector::realType,N> cosh(const __CGvector & v) 23 | { 24 | __CGvector rv; 25 | for (int i=0; i 30 | static inline __CGvector::realType,N> cosh(const __CGvector_usage & v) 31 | { 32 | __CGvector rv; 33 | for (int i=0; i 38 | static inline __CGvector::realType,1> cosh(const T & v) 39 | { 40 | __CGvector::realType,1> rv(std::cosh(static_cast(v))); 41 | return rv; 42 | } 43 | 44 | } // namespace Cg 45 | 46 | #endif // __Cg_cosh_hpp__ 47 | -------------------------------------------------------------------------------- /cg4cpp/include/Cg/sinh.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #ifndef __Cg_sinh_hpp__ 9 | #define __Cg_sinh_hpp__ 10 | 11 | #ifdef __Cg_stdlib_hpp__ 12 | #pragma message("error: include this header file (" __FILE__ ") before ") 13 | #endif 14 | 15 | #include 16 | 17 | #include // for std::sinh 18 | 19 | namespace Cg { 20 | 21 | template 22 | static inline __CGvector::realType,N> sinh(const __CGvector & v) 23 | { 24 | __CGvector rv; 25 | for (int i=0; i 30 | static inline __CGvector::realType,N> sinh(const __CGvector_usage & v) 31 | { 32 | __CGvector rv; 33 | for (int i=0; i 38 | static inline __CGvector::realType,1> sinh(const T & v) 39 | { 40 | __CGvector::realType,1> rv(std::sinh(static_cast(v))); 41 | return rv; 42 | } 43 | 44 | } // namespace Cg 45 | 46 | #endif // __Cg_sinh_hpp__ 47 | -------------------------------------------------------------------------------- /cg4cpp/include/Cg/sqrt.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #ifndef __Cg_sqrt_hpp__ 9 | #define __Cg_sqrt_hpp__ 10 | 11 | #ifdef __Cg_stdlib_hpp__ 12 | #pragma message("error: include this header file (" __FILE__ ") before ") 13 | #endif 14 | 15 | #include 16 | 17 | #include // for std::sqrt 18 | 19 | namespace Cg { 20 | 21 | template 22 | static inline __CGvector::realType,N> sqrt(const __CGvector & v) 23 | { 24 | __CGvector rv; 25 | for (int i=0; i 30 | static inline __CGvector::realType,N> sqrt(const __CGvector_usage & v) 31 | { 32 | __CGvector rv; 33 | for (int i=0; i 38 | static inline __CGvector::realType,1> sqrt(const T & v) 39 | { 40 | __CGvector::realType,1> rv(std::sqrt(static_cast(v))); 41 | return rv; 42 | } 43 | 44 | } // namespace Cg 45 | 46 | #endif // __Cg_sqrt_hpp__ 47 | -------------------------------------------------------------------------------- /cg4cpp/include/Cg/tanh.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #ifndef __Cg_tanh_hpp__ 9 | #define __Cg_tanh_hpp__ 10 | 11 | #ifdef __Cg_stdlib_hpp__ 12 | #pragma message("error: include this header file (" __FILE__ ") before ") 13 | #endif 14 | 15 | #include 16 | 17 | #include // for std::tanh 18 | 19 | namespace Cg { 20 | 21 | template 22 | static inline __CGvector::realType,N> tanh(const __CGvector & v) 23 | { 24 | __CGvector rv; 25 | for (int i=0; i 30 | static inline __CGvector::realType,N> tanh(const __CGvector_usage & v) 31 | { 32 | __CGvector rv; 33 | for (int i=0; i 38 | static inline __CGvector::realType,1> tanh(const T & v) 39 | { 40 | __CGvector::realType,1> rv(std::tanh(static_cast(v))); 41 | return rv; 42 | } 43 | 44 | } // namespace Cg 45 | 46 | #endif // __Cg_tanh_hpp__ 47 | -------------------------------------------------------------------------------- /cg4cpp/include/Cg/floor.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #ifndef __Cg_floor_hpp__ 9 | #define __Cg_floor_hpp__ 10 | 11 | #ifdef __Cg_stdlib_hpp__ 12 | #pragma message("error: include this header file (" __FILE__ ") before ") 13 | #endif 14 | 15 | #include 16 | 17 | #include // for std::floor 18 | 19 | namespace Cg { 20 | 21 | template 22 | static inline __CGvector::realType,N> floor(const __CGvector & v) 23 | { 24 | __CGvector rv; 25 | for (int i=0; i 30 | static inline __CGvector::realType,N> floor(const __CGvector_usage & v) 31 | { 32 | __CGvector rv; 33 | for (int i=0; i 38 | static inline __CGvector::realType,1> floor(const T & v) 39 | { 40 | __CGvector::realType,1> rv(std::floor(static_cast(v))); 41 | return rv; 42 | } 43 | 44 | } // namespace Cg 45 | 46 | #endif // __Cg_floor_hpp__ 47 | -------------------------------------------------------------------------------- /cg4cpp/include/Cg/rsqrt.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #ifndef __Cg_rsqrt_hpp__ 9 | #define __Cg_rsqrt_hpp__ 10 | 11 | #ifdef __Cg_stdlib_hpp__ 12 | #pragma message("error: include this header file (" __FILE__ ") before ") 13 | #endif 14 | 15 | #include 16 | 17 | #include // for std::sqrt 18 | 19 | namespace Cg { 20 | 21 | template 22 | static inline __CGvector::realType,N> rsqrt(const __CGvector & v) 23 | { 24 | __CGvector rv; 25 | for (int i=0; i 30 | static inline __CGvector::realType,N> rsqrt(const __CGvector_usage & v) 31 | { 32 | __CGvector rv; 33 | for (int i=0; i 38 | static inline __CGvector::realType,1> rsqrt(const T & v) 39 | { 40 | __CGvector::realType,1> rv(1 / std::sqrt(static_cast(v))); 41 | return rv; 42 | } 43 | 44 | } // namespace Cg 45 | 46 | #endif // __Cg_rsqrt_hpp__ 47 | -------------------------------------------------------------------------------- /cg4cpp/test/test_dot.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | using namespace Cg; 10 | 11 | #define OUTPUT(_x) std::cout << #_x << "=" << (_x) << std::endl 12 | 13 | float4 dot_stuff(float4 a, float4 b, int3 c, int3 d) 14 | { 15 | float rd = dot(a,b); 16 | int ri = dot(c,d); 17 | return float4(rd,float(ri),rd,float(ri)); 18 | } 19 | 20 | struct myfloat { 21 | myfloat(float _v) : v(_v) { } 22 | float v; 23 | }; 24 | 25 | void test_dot() 26 | { 27 | float4 f4 = float4(1,2,3,4); 28 | float4 f4a = float4(0,1,2,3); 29 | int3 i3 = int3(1,2,3); 30 | int3 i3a = int3(-1,0,1); 31 | int1 i1 = int(9); 32 | int2 i2 = int2(7,8); 33 | 34 | half hh0 = 1.0; 35 | half hh = 3.0; 36 | half hh1 = 2.0; 37 | half hh2 = 6.0; 38 | half hh6 = -6.0; 39 | half hh7 = -12.0; 40 | half hh3 = 12.0; 41 | half4 vhh3 = half4(0.0, 1.1, 12.23, 12.0); 42 | half inf = 400000000000.0; 43 | 44 | f4 += f4.yyxz; 45 | 46 | half x = 1.0, y = 1.0; 47 | for (int i=0; i<27; i++) { 48 | x /= 2; 49 | y *= 2; 50 | OUTPUT(x); 51 | OUTPUT(y); 52 | } 53 | 54 | half a = x * y; 55 | float af = x * y; 56 | float inff = 1.0f / x; 57 | OUTPUT(a); 58 | OUTPUT(af); 59 | OUTPUT(inff); 60 | 61 | myfloat ggg(4.5); 62 | 63 | dot_stuff(f4, f4a, i3, i3a); 64 | } 65 | -------------------------------------------------------------------------------- /glui-2.35/src/glui_internal_control.h: -------------------------------------------------------------------------------- 1 | /* 2 | Header file for use by GLUI controls. 3 | Everything you need is right here. 4 | 5 | 6 | */ 7 | #ifndef __GLUI_INTERNAL_CONTROL_H 8 | #define __GLUI_INTERNAL_CONTROL_H 9 | 10 | /* This is the main GLUI external header */ 11 | #include "GL/glui.h" 12 | 13 | /* Here's some utility routines */ 14 | #include "glui_internal.h" 15 | 16 | 17 | /** 18 | A GLUI_Control-drawing sentinal object. 19 | On creation, saves the current draw buffer and window. 20 | On destruction, restores draw buffer and window. 21 | This is way nicer than calling save/restore manually. 22 | */ 23 | class GLUI_DrawingSentinal { 24 | int orig_buf, orig_win; 25 | GLUI_Control *c; 26 | public: 27 | /** The constructor sets up the drawing system */ 28 | GLUI_DrawingSentinal(GLUI_Control *c_); 29 | /** The destructor cleans up drawing back how it was */ 30 | ~GLUI_DrawingSentinal(); 31 | 32 | // Do-nothing routine to avoid compiler warning about unused variable 33 | inline void avoid_warning(void) {} 34 | }; 35 | /** Just drop a GLUI_DRAWINGSENTINAL_IDIOM at the start of your draw methods, 36 | and they'll return if we can't be drawn, and 37 | automatically save and restore all needed state. 38 | */ 39 | #define GLUI_DRAWINGSENTINAL_IDIOM if (NOT can_draw()) return; GLUI_DrawingSentinal drawSentinal(this); drawSentinal.avoid_warning(); 40 | 41 | 42 | /** Return the time, in seconds. */ 43 | inline double GLUI_Time(void) {return 0.001*glutGet(GLUT_ELAPSED_TIME);} 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /glui-2.35/src/glui_window.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | glui_window.cpp - GLUI_Button control class 4 | 5 | GLUI User Interface Toolkit (LGPL) 6 | Copyright (c) 1998 Paul Rademacher 7 | 8 | WWW: http://sourceforge.net/projects/glui/ 9 | Forums: http://sourceforge.net/forum/?group_id=92496 10 | 11 | This library is free software; you can redistribute it and/or 12 | modify it under the terms of the GNU Lesser General Public 13 | License as published by the Free Software Foundation; either 14 | version 2.1 of the License, or (at your option) any later version. 15 | 16 | This library is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | Lesser General Public License for more details. 20 | 21 | You should have received a copy of the GNU Lesser General Public 22 | License along with this library; if not, write to the Free Software 23 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 | 25 | */ 26 | 27 | #include "GL/glui.h" 28 | #include "glui_internal.h" 29 | 30 | GLUI_Glut_Window::GLUI_Glut_Window() 31 | : GLUI_Node(), 32 | 33 | glut_window_id(0), 34 | glut_keyboard_CB(NULL), 35 | glut_special_CB(NULL), 36 | glut_reshape_CB(NULL), 37 | glut_passive_motion_CB(NULL), 38 | glut_mouse_CB(NULL), 39 | glut_visibility_CB(NULL), 40 | glut_motion_CB(NULL), 41 | glut_display_CB(NULL), 42 | glut_entry_CB(NULL) 43 | { 44 | } 45 | -------------------------------------------------------------------------------- /cg4cpp/include/Cg/frac.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #ifndef __Cg_frac_hpp__ 9 | #define __Cg_frac_hpp__ 10 | 11 | #ifdef __Cg_stdlib_hpp__ 12 | #pragma message("error: include this header file (" __FILE__ ") before ") 13 | #endif 14 | 15 | #include 16 | 17 | #include // for std::frac 18 | 19 | namespace Cg { 20 | 21 | template 22 | static inline __CGvector::realType,N> frac(const __CGvector & v) 23 | { 24 | __CGvector rv; 25 | for (int i=0; i 30 | static inline __CGvector::realType,N> frac(const __CGvector_usage & v) 31 | { 32 | __CGvector rv; 33 | for (int i=0; i 38 | static inline __CGvector::realType,1> frac(const T & v) 39 | { 40 | __CGvector::realType,1> rv(v - std::floor(static_cast(v))); 41 | return rv; 42 | } 43 | 44 | } // namespace Cg 45 | 46 | #endif // __Cg_frac_hpp__ 47 | -------------------------------------------------------------------------------- /cg4cpp/include/Cg/exp2.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #ifndef __Cg_exp2_hpp__ 9 | #define __Cg_exp2_hpp__ 10 | 11 | #ifdef __Cg_stdlib_hpp__ 12 | #pragma message("error: include this header file (" __FILE__ ") before ") 13 | #endif 14 | 15 | #include 16 | 17 | #include // for ::pow 18 | 19 | namespace Cg { 20 | 21 | template 22 | static inline __CGvector::realType,N> exp2(const __CGvector & v) 23 | { 24 | __CGvector rv; 25 | for (int i=0; i 30 | static inline __CGvector::realType,N> exp2(const __CGvector_usage & v) 31 | { 32 | __CGvector rv; 33 | for (int i=0; i 38 | static inline __CGvector::realType,1> exp2(const T & v) 39 | { 40 | __CGvector::realType,1> rv(::pow(typename __CGtype_trait::realType(2), static_cast(v))); 41 | return rv; 42 | } 43 | 44 | } // namespace Cg 45 | 46 | #endif // __Cg_exp2_hpp__ 47 | -------------------------------------------------------------------------------- /cg4cpp/include/Cg/round.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #ifndef __Cg_round_hpp__ 9 | #define __Cg_round_hpp__ 10 | 11 | #ifdef __Cg_stdlib_hpp__ 12 | #pragma message("error: include this header file (" __FILE__ ") before ") 13 | #endif 14 | 15 | #include 16 | 17 | #include // for std::floor 18 | 19 | namespace Cg { 20 | 21 | template 22 | static inline __CGvector::realType,N> round(const __CGvector & v) 23 | { 24 | __CGvector rv; 25 | for (int i=0; i 30 | static inline __CGvector::realType,N> round(const __CGvector_usage & v) 31 | { 32 | __CGvector rv; 33 | for (int i=0; i 38 | static inline __CGvector::realType,1> round(const T & v) 39 | { 40 | __CGvector::realType,1> rv(std::floor(static_cast(v)) + T(0.5)); 41 | return rv; 42 | } 43 | 44 | } // namespace Cg 45 | 46 | #endif // __Cg_round_hpp__ 47 | -------------------------------------------------------------------------------- /cg4cpp/include/Cg/log2.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #ifndef __Cg_log2_hpp__ 9 | #define __Cg_log2_hpp__ 10 | 11 | #ifdef __Cg_stdlib_hpp__ 12 | #pragma message("error: include this header file (" __FILE__ ") before ") 13 | #endif 14 | 15 | #include 16 | 17 | #include // for std::log 18 | 19 | namespace Cg { 20 | 21 | template 22 | static inline __CGvector::realType,N> log2(const __CGvector & v) 23 | { 24 | __CGvector rv; 25 | for (int i=0; i 30 | static inline __CGvector::realType,N> log2(const __CGvector_usage & v) 31 | { 32 | __CGvector rv; 33 | for (int i=0; i 38 | static inline __CGvector::realType,1> log2(const T & v) 39 | { 40 | __CGvector::realType,1> rv(T(1.44269504088896340737) * std::log(static_cast(v))); 41 | return rv; 42 | } 43 | 44 | } // namespace Cg 45 | 46 | #endif // __Cg_log2_hpp__ 47 | -------------------------------------------------------------------------------- /cg4cpp/src/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | 5 | LOCAL_ARM_MODE := arm 6 | LOCAL_MODULE := libcg4cpp 7 | LOCAL_MODULE_TAGS := optional 8 | 9 | LOCAL_C_INCLUDES := \ 10 | $(LOCAL_PATH)/../include 11 | 12 | ifneq ($(BUILD_FOR_NDK), true) 13 | LOCAL_C_INCLUDES += \ 14 | $(TOP)/external/stlport/stlport \ 15 | $(TOP)/bionic 16 | endif 17 | 18 | LOCAL_SRC_FILES := \ 19 | abs.cpp acos.cpp all.cpp any.cpp asin.cpp atan.cpp atan2.cpp ceil.cpp \ 20 | clamp.cpp cos.cpp cosh.cpp cross.cpp degrees.cpp determinant.cpp \ 21 | distance.cpp dot.cpp exp.cpp exp2.cpp faceforward.cpp floor.cpp \ 22 | fmod.cpp frac.cpp fresnel.cpp frexp.cpp iostream.cpp \ 23 | isfinite.cpp isinf.cpp isnan.cpp ldexp.cpp length.cpp lerp.cpp \ 24 | lit.cpp log.cpp log10.cpp log2.cpp max.cpp min.cpp modf.cpp \ 25 | mul.cpp normalize.cpp pow.cpp radians.cpp reflect.cpp \ 26 | refract.cpp round.cpp rsqrt.cpp \ 27 | saturate.cpp \ 28 | inverse.cpp \ 29 | sign.cpp sin.cpp sincos.cpp sinh.cpp smoothstep.cpp sqrt.cpp \ 30 | step.cpp tan.cpp tanh.cpp transpose.cpp trunc.cpp \ 31 | floatToIntBits.cpp \ 32 | floatToRawIntBits.cpp \ 33 | intBitsToFloat.cpp 34 | 35 | # Sources that use 36 | # sampler1D.cpp 37 | # sampler1DARRAY.cpp 38 | # sampler2D.cpp 39 | # sampler2DARRAY.cpp 40 | # sampler3D.cpp 41 | # samplerBUF.cpp 42 | # samplerCUBE.cpp 43 | # samplerRECT.cpp 44 | # sampler_state.cpp 45 | # sampler_gl.cpp 46 | 47 | ifeq ($(BUILD_FOR_NDK), true) 48 | LOCAL_CFLAGS := \ 49 | -mfpu=neon 50 | endif 51 | 52 | include $(BUILD_STATIC_LIBRARY) 53 | -------------------------------------------------------------------------------- /cg4cpp/include/Cg/log10.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #ifndef __Cg_log10_hpp__ 9 | #define __Cg_log10_hpp__ 10 | 11 | #ifdef __Cg_stdlib_hpp__ 12 | #pragma message("error: include this header file (" __FILE__ ") before ") 13 | #endif 14 | 15 | #include 16 | 17 | #include // for std::log 18 | 19 | namespace Cg { 20 | 21 | template 22 | static inline __CGvector::realType,N> log10(const __CGvector & v) 23 | { 24 | __CGvector rv; 25 | for (int i=0; i 30 | static inline __CGvector::realType,N> log10(const __CGvector_usage & v) 31 | { 32 | __CGvector rv; 33 | for (int i=0; i 38 | static inline __CGvector::realType,1> log10(const T & v) 39 | { 40 | __CGvector::realType,1> rv(T(0.43429448190325182765) * std::log(static_cast(v))); 41 | return rv; 42 | } 43 | 44 | } // namespace Cg 45 | 46 | #endif // __Cg_log10_hpp__ 47 | -------------------------------------------------------------------------------- /cg4cpp/include/Cg/trunc.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #ifndef __Cg_trunc_hpp__ 9 | #define __Cg_trunc_hpp__ 10 | 11 | #ifdef __Cg_stdlib_hpp__ 12 | #pragma message("error: include this header file (" __FILE__ ") before ") 13 | #endif 14 | 15 | #include 16 | 17 | #include // for std::floor 18 | 19 | namespace Cg { 20 | 21 | template 22 | static inline __CGvector::realType,N> trunc(const __CGvector & v) 23 | { 24 | __CGvector rv; 25 | for (int i=0; i 30 | static inline __CGvector::realType,N> trunc(const __CGvector_usage & v) 31 | { 32 | __CGvector rv; 33 | for (int i=0; i 38 | static inline __CGvector::realType,1> trunc(const T & v) 39 | { 40 | __CGvector::realType,1> rv(v < T(0) ? -std::floor(-v) : std::floor(v)); 41 | return rv; 42 | } 43 | 44 | } // namespace Cg 45 | 46 | #endif // __Cg_trunc_hpp__ 47 | -------------------------------------------------------------------------------- /glut/lib/glut/glut_bwidth.c: -------------------------------------------------------------------------------- 1 | 2 | /* Copyright (c) Mark J. Kilgard, 1994. */ 3 | 4 | /* This program is freely distributable without licensing fees 5 | and is provided without guarantee or warrantee expressed or 6 | implied. This program is -not- in the public domain. */ 7 | 8 | #include "glutint.h" 9 | #include "glutbitmap.h" 10 | 11 | /* CENTRY */ 12 | int GLUTAPIENTRY 13 | glutBitmapWidth(GLUTbitmapFont font, int c) 14 | { 15 | BitmapFontPtr fontinfo; 16 | const BitmapCharRec *ch; 17 | 18 | #ifdef _WIN32 19 | fontinfo = (BitmapFontPtr) __glutFont(font); 20 | #else 21 | fontinfo = (BitmapFontPtr) font; 22 | #endif 23 | 24 | if (c < fontinfo->first || c >= fontinfo->first + fontinfo->num_chars) { 25 | return 0; 26 | } 27 | ch = fontinfo->ch[c - fontinfo->first]; 28 | if (ch) { 29 | return ch->advance; 30 | } else { 31 | return 0; 32 | } 33 | } 34 | 35 | int GLUTAPIENTRY 36 | glutBitmapLength(GLUTbitmapFont font, const unsigned char *string) 37 | { 38 | int c, length; 39 | BitmapFontPtr fontinfo; 40 | const BitmapCharRec *ch; 41 | 42 | #ifdef _WIN32 43 | fontinfo = (BitmapFontPtr) __glutFont(font); 44 | #else 45 | fontinfo = (BitmapFontPtr) font; 46 | #endif 47 | 48 | length = 0; 49 | for (; *string != '\0'; string++) { 50 | c = *string; 51 | if (c >= fontinfo->first && c < fontinfo->first + fontinfo->num_chars) { 52 | ch = fontinfo->ch[c - fontinfo->first]; 53 | if (ch) { 54 | length += ch->advance; 55 | } 56 | } 57 | } 58 | return length; 59 | } 60 | 61 | /* ENDCENTRY */ 62 | -------------------------------------------------------------------------------- /glui-2.35/src/glui_img_spinup_0.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | int glui_img_spinup_0[] = { 12, 8, /* width, height */ 4 | 255,255,255, 127,127,127, 127,127,127, 127,127,127, 127,127,127, 5 | 127,127,127, 127,127,127, 127,127,127, 127,127,127, 127,127,127, 6 | 127,127,127, 0, 0, 0, 255,255,255, 191,191,191, 191,191,191, 7 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 8 | 191,191,191, 191,191,191, 127,127,127, 0, 0, 0, 255,255,255, 9 | 191,191,191, 191,191,191, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10 | 0, 0, 0, 0, 0, 0, 127,127,127, 191,191,191, 127,127,127, 11 | 0, 0, 0, 255,255,255, 191,191,191, 191,191,191, 191,191,191, 12 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 127,127,127, 191,191,191, 13 | 191,191,191, 127,127,127, 0, 0, 0, 255,255,255, 191,191,191, 14 | 191,191,191, 191,191,191, 191,191,191, 0, 0, 0, 127,127,127, 15 | 191,191,191, 191,191,191, 191,191,191, 127,127,127, 0, 0, 0, 16 | 255,255,255, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 17 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 18 | 127,127,127, 0, 0, 0, 255,255,255, 191,191,191, 191,191,191, 19 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 20 | 191,191,191, 191,191,191, 191,191,191, 0, 0, 0, 255,255,255, 21 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 22 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 23 | 255,255,255, 24 | }; 25 | -------------------------------------------------------------------------------- /glui-2.35/src/glui_img_spinup_1.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | int glui_img_spinup_1[] = { 12, 8, /* width, height */ 4 | 0, 0, 0, 127,127,127, 255,255,255, 255,255,255, 255,255,255, 5 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 6 | 255,255,255, 255,255,255, 0, 0, 0, 127,127,127, 191,191,191, 7 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 8 | 191,191,191, 191,191,191, 191,191,191, 255,255,255, 0, 0, 0, 9 | 127,127,127, 191,191,191, 127,127,127, 0, 0, 0, 0, 0, 0, 10 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 191,191,191, 191,191,191, 11 | 255,255,255, 0, 0, 0, 127,127,127, 191,191,191, 191,191,191, 12 | 127,127,127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 191,191,191, 13 | 191,191,191, 191,191,191, 255,255,255, 0, 0, 0, 127,127,127, 14 | 191,191,191, 191,191,191, 191,191,191, 127,127,127, 0, 0, 0, 15 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 255,255,255, 16 | 0, 0, 0, 127,127,127, 191,191,191, 191,191,191, 191,191,191, 17 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 18 | 191,191,191, 255,255,255, 0, 0, 0, 127,127,127, 127,127,127, 19 | 127,127,127, 127,127,127, 127,127,127, 127,127,127, 127,127,127, 20 | 127,127,127, 127,127,127, 191,191,191, 255,255,255, 0, 0, 0, 21 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 22 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23 | 255,255,255, 24 | }; 25 | -------------------------------------------------------------------------------- /glui-2.35/src/glui_img_spindown_0.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | int glui_img_spindown_0[] = { 12, 8, /* width, height */ 4 | 255,255,255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6 | 0, 0, 0, 0, 0, 0, 255,255,255, 127,127,127, 127,127,127, 7 | 127,127,127, 127,127,127, 127,127,127, 127,127,127, 127,127,127, 8 | 127,127,127, 127,127,127, 127,127,127, 0, 0, 0, 255,255,255, 9 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 10 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 127,127,127, 11 | 0, 0, 0, 255,255,255, 191,191,191, 191,191,191, 191,191,191, 12 | 191,191,191, 0, 0, 0, 127,127,127, 191,191,191, 191,191,191, 13 | 191,191,191, 127,127,127, 0, 0, 0, 255,255,255, 191,191,191, 14 | 191,191,191, 191,191,191, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15 | 127,127,127, 191,191,191, 191,191,191, 127,127,127, 0, 0, 0, 16 | 255,255,255, 191,191,191, 191,191,191, 0, 0, 0, 0, 0, 0, 17 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 127,127,127, 191,191,191, 18 | 127,127,127, 0, 0, 0, 255,255,255, 191,191,191, 191,191,191, 19 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 20 | 191,191,191, 191,191,191, 127,127,127, 0, 0, 0, 255,255,255, 21 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 22 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 23 | 0, 0, 0, 24 | }; 25 | -------------------------------------------------------------------------------- /glui-2.35/src/glui_img_spindown_1.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | int glui_img_spindown_1[] = { 12, 8, /* width, height */ 4 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 5 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 6 | 255,255,255, 255,255,255, 0, 0, 0, 127,127,127, 191,191,191, 7 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 8 | 191,191,191, 191,191,191, 191,191,191, 255,255,255, 0, 0, 0, 9 | 127,127,127, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 10 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 11 | 255,255,255, 0, 0, 0, 127,127,127, 191,191,191, 191,191,191, 12 | 191,191,191, 127,127,127, 0, 0, 0, 191,191,191, 191,191,191, 13 | 191,191,191, 191,191,191, 255,255,255, 0, 0, 0, 127,127,127, 14 | 191,191,191, 191,191,191, 127,127,127, 0, 0, 0, 0, 0, 0, 15 | 0, 0, 0, 191,191,191, 191,191,191, 191,191,191, 255,255,255, 16 | 0, 0, 0, 127,127,127, 191,191,191, 127,127,127, 0, 0, 0, 17 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 191,191,191, 18 | 191,191,191, 255,255,255, 0, 0, 0, 127,127,127, 191,191,191, 19 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 20 | 191,191,191, 191,191,191, 191,191,191, 255,255,255, 0, 0, 0, 21 | 127,127,127, 127,127,127, 127,127,127, 127,127,127, 127,127,127, 22 | 127,127,127, 127,127,127, 127,127,127, 127,127,127, 191,191,191, 23 | 255,255,255, 24 | }; 25 | -------------------------------------------------------------------------------- /glui-2.35/src/glui_img_spinup_dis.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | int glui_img_spinup_dis[] = { 12, 8, /* width, height */ 4 | 255,255,255, 127,127,127, 127,127,127, 127,127,127, 127,127,127, 5 | 127,127,127, 127,127,127, 127,127,127, 127,127,127, 127,127,127, 6 | 127,127,127, 64, 64, 64, 255,255,255, 191,191,191, 191,191,191, 7 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 8 | 191,191,191, 191,191,191, 127,127,127, 64, 64, 64, 255,255,255, 9 | 191,191,191, 191,191,191, 127,127,127, 127,127,127, 127,127,127, 10 | 127,127,127, 127,127,127, 255,255,255, 191,191,191, 127,127,127, 11 | 64, 64, 64, 255,255,255, 191,191,191, 191,191,191, 191,191,191, 12 | 127,127,127, 127,127,127, 127,127,127, 255,255,255, 191,191,191, 13 | 191,191,191, 127,127,127, 64, 64, 64, 255,255,255, 191,191,191, 14 | 191,191,191, 191,191,191, 191,191,191, 127,127,127, 255,255,255, 15 | 191,191,191, 191,191,191, 191,191,191, 127,127,127, 64, 64, 64, 16 | 255,255,255, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 17 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 18 | 127,127,127, 64, 64, 64, 255,255,255, 191,191,191, 191,191,191, 19 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 20 | 191,191,191, 191,191,191, 191,191,191, 64, 64, 64, 255,255,255, 21 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 22 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 23 | 255,255,255, 24 | }; 25 | -------------------------------------------------------------------------------- /tessellation/cp_transform.glslv: -------------------------------------------------------------------------------- 1 | 2 | // cp_transform2.glslv 3 | 4 | // DESCRIPTION: GLSL vertex shader to transform patch control points 5 | // by the current concatenation of the OpenGL modelview and projection matrices 6 | // and pass through the first two texture coordinate sets. 7 | 8 | // To off-line compile this code to assembly with Cg 3.0, use: 9 | // cgc -profile gp5vp -oglsl cp_transform2.glslv 10 | 11 | #version 400 compatibility 12 | 13 | // Multiply XYZ vertex by 4x3 modelview matrix (assumed non-projective) 14 | precise vec3 transform(precise vec3 v) 15 | { 16 | precise vec3 r; 17 | // Remember: GLSL is oddly column-major so [col][row] 18 | for (int i=0; i<3; i++) { 19 | r[i] = v[0] * gl_ModelViewMatrix[0][i] + 20 | v[1] * gl_ModelViewMatrix[1][i] + 21 | v[2] * gl_ModelViewMatrix[2][i] + 22 | gl_ModelViewMatrix[3][i]; 23 | } 24 | return r; 25 | } 26 | 27 | uniform vec2 wh; // scaled width and height of screen 28 | 29 | out precise vec3 eye_space_pos; 30 | out precise vec2 scaled_window_space_pos; 31 | out precise vec3 eye_normal; 32 | 33 | void main(void) 34 | { 35 | eye_space_pos = transform(gl_Vertex.xyz); 36 | 37 | precise vec4 ndc_pos = gl_ModelViewProjectionMatrix * vec4(gl_Vertex.xyz,1); 38 | scaled_window_space_pos = wh*(ndc_pos.xy / ndc_pos.w); 39 | 40 | // Pass along two sets of texture coordinates... 41 | gl_TexCoord[0] = gl_MultiTexCoord0; 42 | gl_TexCoord[1] = gl_MultiTexCoord1; 43 | 44 | precise mat3 nm = gl_NormalMatrix; 45 | precise vec3 n = gl_Normal; 46 | eye_normal = normalize(nm * n); 47 | } -------------------------------------------------------------------------------- /glui-2.35/src/glui_img_spindown_dis.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | int glui_img_spindown_dis[] = { 12, 8, /* width, height */ 4 | 255,255,255, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 5 | 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 6 | 64, 64, 64, 64, 64, 64, 255,255,255, 127,127,127, 127,127,127, 7 | 127,127,127, 127,127,127, 127,127,127, 127,127,127, 127,127,127, 8 | 127,127,127, 127,127,127, 127,127,127, 64, 64, 64, 255,255,255, 9 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 10 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 127,127,127, 11 | 64, 64, 64, 255,255,255, 191,191,191, 191,191,191, 191,191,191, 12 | 191,191,191, 127,127,127, 255,255,255, 191,191,191, 191,191,191, 13 | 191,191,191, 127,127,127, 64, 64, 64, 255,255,255, 191,191,191, 14 | 191,191,191, 191,191,191, 127,127,127, 127,127,127, 127,127,127, 15 | 255,255,255, 191,191,191, 191,191,191, 127,127,127, 64, 64, 64, 16 | 255,255,255, 191,191,191, 191,191,191, 127,127,127, 127,127,127, 17 | 127,127,127, 127,127,127, 127,127,127, 255,255,255, 191,191,191, 18 | 127,127,127, 64, 64, 64, 255,255,255, 191,191,191, 191,191,191, 19 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 20 | 191,191,191, 191,191,191, 127,127,127, 64, 64, 64, 255,255,255, 21 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 22 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 23 | 64, 64, 64, 24 | }; 25 | -------------------------------------------------------------------------------- /tessellation/ReadMe.txt: -------------------------------------------------------------------------------- 1 | 2 | This example demonstrates programmable tessellation introduced by 3 | OpenGL 4. 4 | 5 | The demo requires a Fermi-based NVIDIA GPU to run. Be sure to download 6 | the latest NVIDIA OpenGL 4.1 (or later) driver from: 7 | 8 | http://developer.nvidia.com/object/opengl_driver.html 9 | 10 | Demo cheat sheet: 11 | 12 | 'p' -- cycle scenes: (elephant->teapot->PN triangle monkey 13 | head->faceted monkey head->bicubic cube->bezier triangle->single 14 | bicubic patch->linear triangle->linear quadrilateral) 15 | 16 | 'n' -- turn off any overlaid mesh and control points (normal rendeirng 17 | mode) 18 | 19 | 'm' -- cycle through shading (diffuse->phong->UV visualization) 20 | 21 | 'c' -- cycle visualization of control points 22 | 23 | 'w' -- cycle visualize of tessellated mesh 24 | 25 | Arrow keys -- moves yellow light source in Phong mode 26 | 27 | 'x' -- toggle adaptive (initial) vs. explicit tessellation 28 | 29 | 'f' -- toggle frame rate counter 30 | 31 | 'v' -- toggle vertical retrace synchronization 32 | 33 | '+' -- zoom in 34 | '-' -- zoom out 35 | 36 | Right mouse -- spin scene 37 | Ctrl+Right mouse -- zoom in/out scene 38 | Middle mouse -- drag control points 39 | Left mouse -- pop up menu 40 | 41 | The demo includes an implementation of adaptive PN triangles (the monkey 42 | head scene). 43 | 44 | The demo also includes shaders for bicubic quadrilateral patches 45 | (teapot and elephant scenes), Bezier triangles, and linear triangle and 46 | quadrilateral patches. 47 | 48 | - Mark Kilgard 49 | mjk@nvidia.com 50 | August 3, 2010 51 | -------------------------------------------------------------------------------- /cg4cpp/include/Cg/floatToRawIntBits.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #ifndef __Cg_floatToRawIntBits_hpp__ 9 | #define __Cg_floatToRawIntBits_hpp__ 10 | 11 | #ifdef __Cg_stdlib_hpp__ 12 | #pragma message("error: include this header file (" __FILE__ ") before ") 13 | #endif 14 | 15 | #include 16 | 17 | namespace Cg { 18 | 19 | template 20 | static inline __CGvector floatToRawIntBits(const __CGvector & iv) 21 | { 22 | __CGvector v = __CGvector(iv); 23 | __CGvector rv; 24 | for (int i=0; i 32 | static inline __CGvector floatToRawIntBits(const __CGvector_usage & iv) 33 | { 34 | __CGvector v = __CGvector(iv); 35 | __CGvector rv; 36 | for (int i=0; i floatToRawIntBits(const float & v) 44 | { 45 | union { float f; int i; } combo; 46 | combo.f = v; 47 | __CGvector rv(combo.i); 48 | return rv; 49 | } 50 | 51 | } // namespace Cg 52 | 53 | #endif // __Cg_floatToRawIntBits_hpp__ 54 | -------------------------------------------------------------------------------- /cg4cpp/include/Cg/intBitsToFloat.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #ifndef __Cg_intBitsToFloat_hpp__ 9 | #define __Cg_intBitsToFloat_hpp__ 10 | 11 | #ifdef __Cg_stdlib_hpp__ 12 | #pragma message("error: include this header file (" __FILE__ ") before ") 13 | #endif 14 | 15 | #include 16 | 17 | namespace Cg { 18 | 19 | template 20 | static inline __CGvector intBitsToFloat(const __CGvector & iv) 21 | { 22 | __CGvector v = __CGvector(iv); 23 | __CGvector rv; 24 | for (int i=0; i 32 | static inline __CGvector intBitsToFloat(const __CGvector_usage & iv) 33 | { 34 | __CGvector v = __CGvector(iv); 35 | __CGvector rv; 36 | for (int i=0; i intBitsToFloat(const int & v) 44 | { 45 | union { float f; int i; } combo; 46 | combo.i = int(v); 47 | __CGvector rv(combo.f); 48 | return rv; 49 | } 50 | 51 | } // namespace Cg 52 | 53 | #endif // __Cg_intBitsToFloat_hpp__ 54 | -------------------------------------------------------------------------------- /glew/Makefile.glewinfo: -------------------------------------------------------------------------------- 1 | # 2 | # Additional compilation flags may be passed via CFLAGS, CXXFLAGS and CLINKFLAGS 3 | # 4 | # Linux: 5 | # make CFLAGS=-m32 6 | # make CFLAGS=-m64 7 | # 8 | # Ubuntu 9.04 64-bit 9 | # make CFLAGS=-m32 CXXFLAGS=-m32 CLINKFLAGS="-L/lib32 -L/usr/lib32 -Wl,-rpath-link,/lib32:/usr/lib32" 10 | # 11 | # OSX: 12 | # make 'CFLAGS=-arch ppc' 'CXXFLAGS=-arch ppc' 13 | # make 'CFLAGS=-arch i386' 'CXXFLAGS=-arch i386' 14 | # make 'CFLAGS=-arch x86_64' 'CXXFLAGS=-arch x86_64' 15 | 16 | UNAME := $(shell uname) 17 | 18 | C_SOURCE := src/glewinfo.c 19 | OBJ := $(C_SOURCE:.c=.o) 20 | BIN := glewinfo 21 | LINKFLAGS += -L. -lglewlib 22 | 23 | CC = gcc 24 | C_FLAGS += -Wall 25 | C_FLAGS += -I"include" 26 | C_FLAGS += -DGLEW_STATIC 27 | 28 | ifeq ($(UNAME), Darwin) 29 | LINKFLAGS += -framework OpenGL 30 | LINKFLAGS += -framework AGL 31 | else 32 | ifeq ($(findstring CYGWIN, $(UNAME)), CYGWIN) 33 | BIN = glewinfo.exe 34 | C_FLAGS += -D_WIN32 35 | C_FLAGS += -mno-cygwin 36 | LINKFLAGS += -mno-cygwin 37 | LINKFLAGS += -lglu32 -lopengl32 -lgdi32 38 | else 39 | ifeq ($(UNAME), SunOS) 40 | C_FLAGS += -fPIC 41 | LINKFLAGS += -lGLU -lGL 42 | else 43 | LINKFLAGS += -lGLU -lGL 44 | endif 45 | endif 46 | endif 47 | 48 | override CFLAGS := $(CFLAGS) $(C_FLAGS) 49 | 50 | all: glewinfo 51 | 52 | glewinfo: $(OBJ) 53 | $(CC) $(CFLAGS) $(OBJ) -o $(BIN) $(LINKFLAGS) $(CLINKFLAGS) 54 | 55 | test: 56 | ./$(BIN) 57 | 58 | run: all 59 | ./$(BIN) 60 | 61 | clean: 62 | $(RM) $(BIN) $(OBJ) 63 | 64 | clobber: clean 65 | $(RM) *.bak *.o *~ 66 | 67 | .PHONY: all test run clean clobber 68 | -------------------------------------------------------------------------------- /glew/Makefile.glew: -------------------------------------------------------------------------------- 1 | # 2 | # Additional compilation flags may be passed via CFLAGS, CXXFLAGS and CLINKFLAGS 3 | # 4 | # Linux: 5 | # make CFLAGS=-m32 6 | # make CFLAGS=-m64 7 | # 8 | # Ubuntu 9.04 64-bit 9 | # make CFLAGS=-m32 CXXFLAGS=-m32 CLINKFLAGS="-L/lib32 -L/usr/lib32 -Wl,-rpath-link,/lib32:/usr/lib32" 10 | # 11 | # OSX: 12 | # make 'CFLAGS=-arch ppc' 'CXXFLAGS=-arch ppc' 13 | # make 'CFLAGS=-arch i386' 'CXXFLAGS=-arch i386' 14 | # make 'CFLAGS=-arch x86_64' 'CXXFLAGS=-arch x86_64' 15 | 16 | UNAME := $(shell uname) 17 | 18 | C_SOURCE := src/glew.c 19 | OBJ := $(C_SOURCE:.c=.o) 20 | BIN := libGLEW.so 21 | 22 | CC = gcc 23 | C_FLAGS += -Wall 24 | C_FLAGS += -I"include" 25 | C_FLAGS += -DGLEW_EXPORTS 26 | C_FLAGS += -DGLEW_BUILD 27 | 28 | ifeq ($(UNAME), Darwin) 29 | BIN = libGLEW.dylib 30 | LINKFLAGS += -dynamiclib 31 | LINKFLAGS += -framework OpenGL 32 | else 33 | LINKFLAGS += -shared 34 | ifeq ($(findstring CYGWIN, $(UNAME)), CYGWIN) 35 | BIN = glew32.dll 36 | C_FLAGS += -D_WIN32 37 | C_FLAGS += -mno-cygwin 38 | LINKFLAGS += -mno-cygwin 39 | LINKFLAGS += -lglu32 -lopengl32 -lgdi32 40 | else 41 | ifeq ($(UNAME), SunOS) 42 | C_FLAGS += -fPIC 43 | LINKFLAGS += -lGLU -lGL 44 | else 45 | LINKFLAGS += -lGLU -lGL 46 | endif 47 | endif 48 | endif 49 | 50 | override CFLAGS := $(CFLAGS) $(C_FLAGS) 51 | 52 | all: glew 53 | 54 | glew: $(OBJ) 55 | $(CC) $(CFLAGS) $(OBJ) -o $(BIN) $(LINKFLAGS) $(CLINKFLAGS) 56 | 57 | test: 58 | 59 | run: all 60 | 61 | clean: 62 | $(RM) $(BIN) $(OBJ) 63 | 64 | clobber: clean 65 | $(RM) *.bak *.o *~ 66 | 67 | .PHONY: all test run clean clobber 68 | -------------------------------------------------------------------------------- /glew/Makefile.visualinfo: -------------------------------------------------------------------------------- 1 | # 2 | # Additional compilation flags may be passed via CFLAGS, CXXFLAGS and CLINKFLAGS 3 | # 4 | # Linux: 5 | # make CFLAGS=-m32 6 | # make CFLAGS=-m64 7 | # 8 | # Ubuntu 9.04 64-bit 9 | # make CFLAGS=-m32 CXXFLAGS=-m32 CLINKFLAGS="-L/lib32 -L/usr/lib32 -Wl,-rpath-link,/lib32:/usr/lib32" 10 | # 11 | # OSX: 12 | # make 'CFLAGS=-arch ppc' 'CXXFLAGS=-arch ppc' 13 | # make 'CFLAGS=-arch i386' 'CXXFLAGS=-arch i386' 14 | # make 'CFLAGS=-arch x86_64' 'CXXFLAGS=-arch x86_64' 15 | 16 | UNAME := $(shell uname) 17 | 18 | C_SOURCE := src/visualinfo.c 19 | OBJ := $(C_SOURCE:.c=.o) 20 | BIN := visualinfo 21 | LINKFLAGS += -L. -lglewlib 22 | 23 | CC = gcc 24 | C_FLAGS += -Wall 25 | C_FLAGS += -I"include" 26 | C_FLAGS += -DGLEW_STATIC 27 | 28 | ifeq ($(UNAME), Darwin) 29 | LINKFLAGS += -framework OpenGL 30 | LINKFLAGS += -framework AGL 31 | else 32 | ifeq ($(findstring CYGWIN, $(UNAME)), CYGWIN) 33 | BIN = visualinfo.exe 34 | C_FLAGS += -D_WIN32 35 | C_FLAGS += -mno-cygwin 36 | LINKFLAGS += -mno-cygwin 37 | LINKFLAGS += -lglu32 -lopengl32 -lgdi32 38 | else 39 | ifeq ($(UNAME), SunOS) 40 | C_FLAGS += -fPIC 41 | LINKFLAGS += -lGLU -lGL 42 | else 43 | LINKFLAGS += -lGLU -lGL 44 | endif 45 | endif 46 | endif 47 | 48 | override CFLAGS := $(CFLAGS) $(C_FLAGS) 49 | 50 | all: visualinfo 51 | 52 | visualinfo: $(OBJ) 53 | $(CC) $(CFLAGS) $(OBJ) -o $(BIN) $(LINKFLAGS) $(CLINKFLAGS) 54 | 55 | test: 56 | ./$(BIN) 57 | 58 | run: all 59 | ./$(BIN) 60 | 61 | clean: 62 | $(RM) $(BIN) $(OBJ) 63 | 64 | clobber: clean 65 | $(RM) *.bak *.o *~ 66 | 67 | .PHONY: all test run clean clobber 68 | -------------------------------------------------------------------------------- /glui-2.35/src/tools/ppm2array.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | Converts a PPM source image into a byte array, for use in 3 | glui_bitmap_img_data.cpp. 4 | 5 | */ 6 | #include "ppm.h" 7 | 8 | #include 9 | #include 10 | 11 | int main( int argc, char *argv[] ) 12 | { 13 | int i; 14 | unsigned char* img = 0; 15 | int w, h; 16 | FILE *output; 17 | char basename[200]; 18 | 19 | if ( argc != 2 && argc != 3 ) { 20 | fprintf( stderr, "USAGE: %s input.ppm [output.cpp]\n", argv[0] ); 21 | return 1; 22 | } 23 | 24 | LoadPPM( argv[1], img, w, h ); 25 | 26 | if ( img ) { 27 | strcpy( basename, argv[1] ); 28 | basename[ strlen(basename)-4 ] = '\0'; 29 | 30 | if (argc == 3) 31 | output = fopen( argv[2], "w" ); 32 | else 33 | output = stdout; 34 | if ( !output ) { 35 | fprintf( stderr, "ERROR: File '%s' could not be opened for writing\n", 36 | argv[2] ); 37 | return 1; 38 | } 39 | 40 | VFlip(img,w,h); /* Opengl bitmaps are specified bottom-to-top */ 41 | 42 | fprintf( output, "\n\n"); 43 | fprintf( output, "int %s[] = {", basename ); 44 | fprintf( output, " %d, %d, /* width, height */\n", w, h); 45 | 46 | fprintf( output, " " ); 47 | for( i=0; irenderWin == window->win) { 17 | if (__glutCurrentWindow->treatAsSingle) { 18 | /* Pretend the double buffered window is single buffered, 19 | so treat glutSwapBuffers as a no-op. */ 20 | return; 21 | } 22 | } else { 23 | if (__glutCurrentWindow->overlay->treatAsSingle) { 24 | /* Pretend the double buffered overlay is single 25 | buffered, so treat glutSwapBuffers as a no-op. */ 26 | return; 27 | } 28 | } 29 | 30 | /* For the MESA_SWAP_HACK. */ 31 | window->usedSwapBuffers = 1; 32 | 33 | SWAP_BUFFERS_LAYER(__glutCurrentWindow); 34 | 35 | /* I considered putting the window being swapped on the 36 | GLUT_FINISH_WORK work list because you could call 37 | glutSwapBuffers from an idle callback which doesn't call 38 | __glutSetWindow which normally adds indirect rendering 39 | windows to the GLUT_FINISH_WORK work list. Not being put 40 | on the list could lead to the buffering up of multiple 41 | redisplays and buffer swaps and hamper interactivity. I 42 | consider this an application bug due to not using 43 | glutPostRedisplay to trigger redraws. If 44 | glutPostRedisplay were used, __glutSetWindow would be 45 | called and a glFinish to throttle buffering would occur. */ 46 | } 47 | /* ENDCENTRY */ 48 | -------------------------------------------------------------------------------- /cg4cpp/include/Cg/distance.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #ifndef __Cg_distance_hpp__ 9 | #define __Cg_distance_hpp__ 10 | 11 | #ifdef __Cg_stdlib_hpp__ 12 | #pragma message("error: include this header file (" __FILE__ ") before ") 13 | #endif 14 | 15 | #include 16 | 17 | #include // for ::sqrt 18 | 19 | namespace Cg { 20 | 21 | template 22 | static inline __CGvector::numericType,1> distance(const __CGvector & a, 23 | const __CGvector & b) 24 | { 25 | typename __CGtype_trait::dotType distsq = (a[0] - b[0])*(a[0] - b[0]); 26 | for (int i=1; i::numericType,1>(::sqrt(distsq)); 29 | } 30 | template 31 | static inline __CGvector::numericType,1> distance(const __CGvector_usage & a, 32 | const __CGvector_usage & b) 33 | { 34 | typename __CGtype_trait::dotType distsq = (a[0] - b[0])*(a[0] - b[0]); 35 | for (int i=1; i::numericType,1>(::sqrt(distsq)); 38 | } 39 | 40 | } // namespace Cg 41 | 42 | #endif // __Cg_distance_hpp__ 43 | -------------------------------------------------------------------------------- /cg4cpp/src/isinf.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2006 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | namespace Cg { 14 | 15 | bool1 isinf(float1 v) 16 | { 17 | return isinf(v); 18 | } 19 | 20 | bool2 isinf(float2 v) 21 | { 22 | return isinf(v); 23 | } 24 | 25 | bool3 isinf(float3 v) 26 | { 27 | return isinf(v); 28 | } 29 | 30 | bool4 isinf(float4 v) 31 | { 32 | return isinf(v); 33 | } 34 | 35 | bool1 isinf(double1 v) 36 | { 37 | return isinf(v); 38 | } 39 | 40 | bool2 isinf(double2 v) 41 | { 42 | return isinf(v); 43 | } 44 | 45 | bool3 isinf(double3 v) 46 | { 47 | return isinf(v); 48 | } 49 | 50 | bool4 isinf(double4 v) 51 | { 52 | return isinf(v); 53 | } 54 | 55 | bool1 isinf(half1 v) 56 | { 57 | return isinf(v); 58 | } 59 | 60 | bool2 isinf(half2 v) 61 | { 62 | return isinf(v); 63 | } 64 | 65 | bool3 isinf(half3 v) 66 | { 67 | return isinf(v); 68 | } 69 | 70 | bool4 isinf(half4 v) 71 | { 72 | return isinf(v); 73 | } 74 | 75 | bool1 isinf(fixed1 v) 76 | { 77 | return isinf(v); 78 | } 79 | 80 | bool2 isinf(fixed2 v) 81 | { 82 | return isinf(v); 83 | } 84 | 85 | bool3 isinf(fixed3 v) 86 | { 87 | return isinf(v); 88 | } 89 | 90 | bool4 isinf(fixed4 v) 91 | { 92 | return isinf(v); 93 | } 94 | 95 | } // namespace Cg 96 | 97 | -------------------------------------------------------------------------------- /cg4cpp/src/length.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2006 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | namespace Cg { 14 | 15 | float1 length(float1 v) 16 | { 17 | return length(v); 18 | } 19 | 20 | float1 length(float2 v) 21 | { 22 | return length(v); 23 | } 24 | 25 | float1 length(float3 v) 26 | { 27 | return length(v); 28 | } 29 | 30 | float1 length(float4 v) 31 | { 32 | return length(v); 33 | } 34 | 35 | double1 length(double1 v) 36 | { 37 | return v; 38 | } 39 | 40 | double1 length(double2 v) 41 | { 42 | return length(v); 43 | } 44 | 45 | double1 length(double3 v) 46 | { 47 | return length(v); 48 | } 49 | 50 | double1 length(double4 v) 51 | { 52 | return length(v); 53 | } 54 | 55 | half1 length(half1 v) 56 | { 57 | return v; 58 | } 59 | 60 | half1 length(half2 v) 61 | { 62 | return length(v); 63 | } 64 | 65 | half1 length(half3 v) 66 | { 67 | return length(v); 68 | } 69 | 70 | half1 length(half4 v) 71 | { 72 | return length(v); 73 | } 74 | 75 | fixed1 length(fixed1 v) 76 | { 77 | return v; 78 | } 79 | 80 | fixed1 length(fixed2 v) 81 | { 82 | return length(v); 83 | } 84 | 85 | fixed1 length(fixed3 v) 86 | { 87 | return length(v); 88 | } 89 | 90 | fixed1 length(fixed4 v) 91 | { 92 | return length(v); 93 | } 94 | 95 | } // namespace Cg 96 | 97 | -------------------------------------------------------------------------------- /cg4cpp/include/Cg/isnan.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #ifndef __Cg_isnan_hpp__ 9 | #define __Cg_isnan_hpp__ 10 | 11 | #ifdef __Cg_stdlib_hpp__ 12 | #pragma message("error: include this header file (" __FILE__ ") before ") 13 | #endif 14 | 15 | #include 16 | 17 | #undef isnan // g++ header may have defined this 18 | 19 | namespace Cg { 20 | 21 | template 22 | static inline __CGvector isnan(const __CGvector & v) 23 | { 24 | __CGvector rv; 25 | for (int i=0; i::realType s = v[i]; 27 | // By IEEE 754 rule, NaN is not equal to NaN 28 | rv[i] = s != s; 29 | } 30 | return rv; 31 | } 32 | template 33 | static inline __CGvector isnan(const __CGvector_usage & v) 34 | { 35 | __CGvector rv; 36 | for (int i=0; i::realType s = v[i]; 38 | // By IEEE 754 rule, NaN is not equal to NaN 39 | rv[i] = s != s; 40 | } 41 | return rv; 42 | } 43 | template 44 | static inline __CGvector::boolType,1> isnan(const T & v) 45 | { 46 | const typename __CGtype_trait::realType s = static_cast(v); 47 | // By IEEE 754 rule, NaN is not equal to NaN 48 | __CGvector::boolType,1> rv(s != s); 49 | return rv; 50 | } 51 | 52 | } // namespace Cg 53 | 54 | #endif // __Cg_isnan_hpp__ 55 | -------------------------------------------------------------------------------- /cg4cpp/test/test_fresnel.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include // needed for inout-using fresnel routine 6 | #include 7 | #include 8 | 9 | using namespace Cg; 10 | 11 | #define OUTPUT(_x) std::cout << #_x << "=" << (_x) << std::endl 12 | 13 | static void test() 14 | { 15 | float3 a = normalize(float3(1,2,3)); 16 | float3 b = normalize(float3(-2,-3,7)); 17 | float c = 0.4f; 18 | float d; 19 | float3 e; 20 | float3 f; 21 | float3 r; 22 | //r = fresnel(a, b, c, d, e, f); 23 | r = float3(fresnel(a, b, c, d, e, f)); 24 | OUTPUT(r); 25 | OUTPUT(d); 26 | OUTPUT(e); 27 | OUTPUT(f); 28 | //r = fresnel(a, b, c); 29 | r = float3(fresnel(a, b, c)); 30 | OUTPUT(r); 31 | //r = fresnel(a, b, c, d); 32 | r = float3(fresnel(a, b, c, d)); 33 | OUTPUT(r); 34 | OUTPUT(d); 35 | //r = fresnel(a, b, c, e, f); 36 | r = float3(fresnel(a, b, c, e, f)); 37 | OUTPUT(r); 38 | OUTPUT(e); 39 | OUTPUT(f); 40 | 41 | float3 aa = float3(0.0f, 3.14159f, 0.2f); 42 | float3 cc, ss; 43 | sincos(aa, cc, ss); 44 | OUTPUT(aa); 45 | OUTPUT(cc); 46 | OUTPUT(ss); 47 | 48 | float4 xxx = float4(1024, 1000, 34, 0.4f); 49 | float4 frac, exp; 50 | frac = frexp(xxx, exp); 51 | OUTPUT(xxx); 52 | OUTPUT(frac); 53 | OUTPUT(exp); 54 | OUTPUT(exp2(exp)); 55 | OUTPUT(frac * exp2(exp)); 56 | 57 | float4 yyy = float4(3.14159f, 0.0, 1000, 56.23f); 58 | float4 frac2, integer2; 59 | frac2 = modf(yyy, integer2); 60 | OUTPUT(yyy); 61 | OUTPUT(frac2); 62 | OUTPUT(integer2); 63 | OUTPUT(frac2 + integer2); 64 | } 65 | 66 | void test_fresnel(void) 67 | { 68 | test(); 69 | } 70 | -------------------------------------------------------------------------------- /glut/lib/glut/layerutil.h: -------------------------------------------------------------------------------- 1 | #ifndef __layerutil_h__ 2 | #define __layerutil_h__ 3 | 4 | /* Copyright (c) Mark J. Kilgard, 1993, 1994. */ 5 | 6 | /* This program is freely distributable without licensing fees 7 | and is provided without guarantee or warrantee expressed or 8 | implied. This program is -not- in the public domain. */ 9 | 10 | /* Based on XLayerUtil.h: Revision: 1.3 */ 11 | 12 | #ifndef _WIN32 13 | #include 14 | #include 15 | #include 16 | #endif /* !_WIN32 */ 17 | 18 | /* Transparent type values */ 19 | /* None 0 */ 20 | #define TransparentPixel 1 21 | #define TransparentMask 2 22 | 23 | /* layered visual info template flags */ 24 | #define VisualLayerMask 0x200 25 | #define VisualTransparentType 0x400 26 | #define VisualTransparentValue 0x800 27 | #define VisualAllLayerMask 0xFFF 28 | 29 | /* layered visual info structure */ 30 | typedef struct _XLayerVisualInfo { 31 | XVisualInfo vinfo; 32 | long layer; 33 | long type; 34 | unsigned long value; 35 | } XLayerVisualInfo; 36 | 37 | /* SERVER_OVERLAY_VISUALS property element */ 38 | typedef struct _OverlayInfo { 39 | /* Avoid 64-bit portability problems by being careful to use 40 | longs due to the way XGetWindowProperty is specified. Note 41 | that these parameters are passed as CARD32s over X 42 | protocol. */ 43 | long overlay_visual; 44 | long transparent_type; 45 | long value; 46 | long layer; 47 | } OverlayInfo; 48 | 49 | extern int __glutGetTransparentPixel(Display *, XVisualInfo *); 50 | extern XLayerVisualInfo *__glutXGetLayerVisualInfo(Display *, 51 | long, XLayerVisualInfo *, int *); 52 | extern Status __glutXMatchLayerVisualInfo(Display *, 53 | int, int, int, int, XLayerVisualInfo *); 54 | 55 | #endif /* __layerutil_h__ */ 56 | -------------------------------------------------------------------------------- /cg4cpp/include/Cg/isinf.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #ifndef __Cg_isinf_hpp__ 9 | #define __Cg_isinf_hpp__ 10 | 11 | #ifdef __Cg_stdlib_hpp__ 12 | #pragma message("error: include this header file (" __FILE__ ") before ") 13 | #endif 14 | 15 | #include 16 | 17 | #undef isinf // g++ header may have defined this 18 | 19 | namespace Cg { 20 | 21 | template 22 | static inline __CGvector isinf(const __CGvector & v) 23 | { 24 | __CGvector rv; 25 | for (int i=0; i::realType s = v[i]; 27 | // By IEEE 754 rule, 2*Inf equals Inf 28 | rv[i] = (2*s == s) && (s != 0); 29 | } 30 | return rv; 31 | } 32 | template 33 | static inline __CGvector isinf(const __CGvector_usage & v) 34 | { 35 | __CGvector rv; 36 | for (int i=0; i::realType s = v[i]; 38 | // By IEEE 754 rule, 2*Inf equals Inf 39 | rv[i] = (2*s == s) && (s != 0); 40 | } 41 | return rv; 42 | } 43 | template 44 | static inline __CGvector::boolType,1> isinf(const T & v) 45 | { 46 | const typename __CGtype_trait::realType s = static_cast(v); 47 | // By IEEE 754 rule, 2*Inf equals Inf 48 | __CGvector::boolType,1> rv((2*s == s) && (s != 0)); 49 | return rv; 50 | } 51 | 52 | } // namespace Cg 53 | 54 | #endif // __Cg_isinf_hpp__ 55 | -------------------------------------------------------------------------------- /glut/lib/glut/glut_glxext.c: -------------------------------------------------------------------------------- 1 | 2 | /* Copyright (c) Mark J. Kilgard, 1997, 2001. */ 3 | 4 | /* This program is freely distributable without licensing fees 5 | and is provided without guarantee or warrantee expressed or 6 | implied. This program is -not- in the public domain. */ 7 | 8 | #include 9 | #include 10 | #include "glutint.h" 11 | 12 | /* Some Mesa versions define GLX_VERSION_1_2 without defining 13 | GLX_VERSION_1_1. */ 14 | #if defined(GLX_VERSION_1_2) && !defined(GLX_VERSION_1_1) 15 | # define GLX_VERSION_1_1 1 16 | #endif 17 | 18 | int 19 | __glutIsSupportedByGLX(const char *extension) 20 | { 21 | #if defined(GLX_VERSION_1_1) 22 | static const char *extensions = NULL; 23 | const char *start; 24 | char *where, *terminator; 25 | int major, minor; 26 | 27 | glXQueryVersion(__glutDisplay, &major, &minor); 28 | /* Be careful not to call glXQueryExtensionsString if it 29 | looks like the server doesn't support GLX 1.1. 30 | Unfortunately, the original GLX 1.0 didn't have the notion 31 | of GLX extensions. */ 32 | if ((major == 1 && minor >= 1) || (major > 1)) { 33 | if (!extensions) { 34 | extensions = glXQueryExtensionsString(__glutDisplay, __glutScreen); 35 | } 36 | /* It takes a bit of care to be fool-proof about parsing 37 | the GLX extensions string. Don't be fooled by 38 | sub-strings, etc. */ 39 | start = extensions; 40 | for (;;) { 41 | where = strstr(start, extension); 42 | if (!where) { 43 | return 0; 44 | } 45 | terminator = where + strlen(extension); 46 | if (where == start || *(where - 1) == ' ') { 47 | if (*terminator == ' ' || *terminator == '\0') { 48 | return 1; 49 | } 50 | } 51 | start = terminator; 52 | } 53 | } 54 | #endif 55 | return 0; 56 | } 57 | -------------------------------------------------------------------------------- /particles/particles.cs: -------------------------------------------------------------------------------- 1 | #version 430 compatibility 2 | #extension GL_ARB_compute_shader : enable 3 | #extension GL_ARB_shader_storage_buffer_object : enable 4 | 5 | struct pos 6 | { 7 | vec4 pxyzw; // positions 8 | }; 9 | 10 | struct vel 11 | { 12 | vec4 vxyzw; // velocities 13 | }; 14 | 15 | struct color 16 | { 17 | vec4 crgba; // colors 18 | }; 19 | 20 | layout( std140, binding=4 ) buffer Pos { 21 | struct pos Positions[ ]; // array of structures 22 | }; 23 | 24 | layout( std140, binding=5 ) buffer Vel { 25 | struct vel Velocities[ ]; // array of structures 26 | }; 27 | 28 | layout( std140, binding=6 ) buffer Col { 29 | struct color Colors[ ]; // array of structures 30 | }; 31 | 32 | layout( local_size_x = 128, local_size_y = 1, local_size_z = 1 ) in; 33 | 34 | 35 | vec3 36 | Bounce( vec3 vin, vec3 n ) 37 | { 38 | vec3 vout = reflect( vin, n ); 39 | return vout; 40 | } 41 | 42 | vec3 43 | BounceSphere( vec3 p, vec3 v, vec4 s ) 44 | { 45 | vec3 n = normalize( p - s.xyz ); 46 | return Bounce( v, n ); 47 | } 48 | 49 | bool 50 | IsInsideSphere( vec3 p, vec4 s ) 51 | { 52 | float r = length( p - s.xyz ); 53 | return ( r < s.w ); 54 | } 55 | 56 | 57 | void 58 | main( ) 59 | { 60 | const vec3 G = vec3( 0., -9.8, 0. ); 61 | const float DT = 0.1; 62 | const vec4 SPHERE = vec4( -100., -800., 0., 600. ); 63 | 64 | uint gid = gl_GlobalInvocationID.x; // the .y and .z are both 1 in this case 65 | 66 | vec3 p = Positions[ gid ].pxyzw.xyz; 67 | vec3 v = Velocities[ gid ].vxyzw.xyz; 68 | 69 | vec3 pp = p + v*DT + .5*DT*DT*G; 70 | vec3 vp = v + G*DT; 71 | 72 | if( IsInsideSphere( pp, SPHERE ) ) 73 | { 74 | vp = BounceSphere( p, v, SPHERE ); 75 | pp = p + vp*DT + .5*DT*DT*G; 76 | } 77 | 78 | Positions[ gid ].pxyzw = vec4( pp, 1. ); 79 | Velocities[ gid ].vxyzw.xyz = vp; 80 | } 81 | -------------------------------------------------------------------------------- /mandelbrot/shaders/mandelbrot.glsl: -------------------------------------------------------------------------------- 1 | #version 400 2 | 3 | #if defined(USE_DOUBLE_PRECISION) 4 | #define VECTOR_TYPE dvec2 5 | #define VECTOR3_TYPE dvec3 6 | #define MATRIX_TYPE dmat2x3 7 | #define SCALAR_TYPE double 8 | #else 9 | #define VECTOR_TYPE vec2 10 | #define VECTOR3_TYPE vec3 11 | #define MATRIX_TYPE mat2x3 12 | #define SCALAR_TYPE float 13 | #endif 14 | 15 | in vec2 position; 16 | out vec4 color; 17 | 18 | uniform vec2 aspectRatio; 19 | uniform SCALAR_TYPE scale; 20 | uniform VECTOR_TYPE offset; 21 | uniform float max_iterations; 22 | uniform sampler1D lut; 23 | uniform bool julia; 24 | uniform vec2 juliaOffsets; 25 | 26 | uniform MATRIX_TYPE matrix; 27 | 28 | struct result { 29 | float iterations; 30 | VECTOR_TYPE z; 31 | }; 32 | 33 | result mandel_julia(VECTOR_TYPE c, VECTOR_TYPE z) 34 | { 35 | result res; 36 | res.iterations = 0.0; 37 | res.z = z; 38 | 39 | for (; res.iterations < max_iterations; res.iterations++) { 40 | SCALAR_TYPE zx2 = res.z.x * res.z.x; 41 | SCALAR_TYPE zy2 = res.z.y * res.z.y; 42 | 43 | if (zx2 + zy2 > 4.0) 44 | break; 45 | 46 | res.z = VECTOR_TYPE(zx2 - zy2, 2.0 * res.z.x * res.z.y) + c; 47 | } 48 | return res; 49 | } 50 | 51 | void main() 52 | { 53 | VECTOR_TYPE pos; 54 | pos.x = dot(matrix[0],VECTOR3_TYPE(position,1)); 55 | pos.y = dot(matrix[1],VECTOR3_TYPE(position,1)); 56 | pos = pos * aspectRatio * scale + offset; 57 | 58 | result res; 59 | if (julia) 60 | res = mandel_julia(juliaOffsets, pos); 61 | else 62 | res = mandel_julia(pos, VECTOR_TYPE(0.0)); 63 | 64 | float s = res.iterations / max_iterations; 65 | color = texture(lut, s); 66 | 67 | //float f = (res.iterations - log2(log2(length(vec2(res.z))))) / max_iterations; 68 | //color = vec4(0.0, f, f, 1.0); 69 | } 70 | -------------------------------------------------------------------------------- /tessellation/quad_texcoord_lod.glsltc: -------------------------------------------------------------------------------- 1 | 2 | // quad_texcoord_lod.glsltc 3 | 4 | // DESCRIPTION: GLSL tessellation control shader passing 5 | // through 4 control points to form a linear quadrilateral patch with the 6 | // outer level-of-detail specified by the (s,t,p,q) of texture coordinate 7 | // set 0 and the inner level-of-detail specified by (s,t) of texture 8 | // coordinate set 1. 9 | 10 | // To off-line compile this code to assembly with Cg 3.0, use: 11 | // cgc -profile gp5tcp -oglsl -po InputPatchSize=4 -po PATCH_4 quad_texcoord_lod.glsltc 12 | 13 | #version 400 compatibility 14 | layout(vertices=4) out; // linear quadrilateral patch 15 | 16 | #define TID gl_InvocationID // thread ID 17 | 18 | in vec3 eye_space_pos[]; 19 | 20 | out vec3 eye_space_pos2[]; 21 | out vec3 eye_space_normal[]; 22 | 23 | // Vertices are in "loop" order, so: 24 | // 25 | // v3 <-- v2 26 | // | ^ 27 | // v | 28 | // v0 --> v1 29 | 30 | void main(void) 31 | { 32 | eye_space_pos2[TID] = eye_space_pos[TID]; 33 | 34 | vec3 dpda = eye_space_pos[TID] - eye_space_pos[(TID+1)%4]; 35 | vec3 dpdb = eye_space_pos[TID] - eye_space_pos[(TID+3)%4]; 36 | eye_space_normal[TID] = cross(dpda, dpdb); 37 | 38 | // The following statements only need to execute on thread 0 (TID == 0)... 39 | // But it is more efficient to simply have all threads execute them. 40 | 41 | // Outer LOD 42 | gl_TessLevelOuter[0] = gl_in[0].gl_TexCoord[0].s; // U=0 edge 43 | gl_TessLevelOuter[1] = gl_in[0].gl_TexCoord[0].t; // V=0 edge 44 | gl_TessLevelOuter[2] = gl_in[0].gl_TexCoord[0].p; // U=1 edge 45 | gl_TessLevelOuter[3] = gl_in[0].gl_TexCoord[0].q; // V=0 edge 46 | // Inner LOD 47 | gl_TessLevelInner[0] = gl_in[0].gl_TexCoord[1].s; // U direction integral spacing 48 | gl_TessLevelInner[1] = gl_in[0].gl_TexCoord[1].t; // V direction integral spaceing 49 | } -------------------------------------------------------------------------------- /glut/lib/glut/glut_wglext.c: -------------------------------------------------------------------------------- 1 | 2 | /* Copyright (c) Mark J. Kilgard, 1997, 2001. */ 3 | 4 | /* This program is freely distributable without licensing fees 5 | and is provided without guarantee or warrantee expressed or 6 | implied. This program is -not- in the public domain. */ 7 | 8 | #include 9 | #include 10 | #include "glutint.h" 11 | 12 | int 13 | __glutIsSupportedByWGL(const char *extension) 14 | { 15 | if (wglGetExtensionsStringARB) { 16 | static const GLubyte *extensions = NULL; 17 | const GLubyte *start; 18 | GLubyte *where, *terminator; 19 | 20 | /* Extension names should not have spaces. */ 21 | where = (GLubyte *) strchr(extension, ' '); 22 | if (where || *extension == '\0') { 23 | return 0; 24 | } 25 | 26 | if (!extensions) { 27 | extensions = (const GLubyte *) wglGetExtensionsStringARB(GetDC(0)); 28 | } 29 | 30 | if (extensions) { 31 | /* It takes a bit of care to be fool-proof about parsing the 32 | OpenGL extensions string. Don't be fooled by sub-strings, 33 | etc. */ 34 | start = extensions; 35 | for (;;) { 36 | /* If your application crashes in the strstr routine below, 37 | you are probably calling glutExtensionSupported without 38 | having a current window. Calling glGetString without 39 | a current OpenGL context has unpredictable results. 40 | Please fix your program. */ 41 | where = (GLubyte *) strstr((const char *) start, extension); 42 | if (!where) { 43 | break; 44 | } 45 | terminator = where + strlen(extension); 46 | if (where == start || *(where - 1) == ' ') { 47 | if (*terminator == ' ' || *terminator == '\0') { 48 | return 1; 49 | } 50 | } 51 | start = terminator; 52 | } 53 | } 54 | } 55 | 56 | return 0; 57 | } 58 | 59 | -------------------------------------------------------------------------------- /cg4cpp/include/Cg/saturate.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #ifndef __Cg_saturate_hpp__ 9 | #define __Cg_saturate_hpp__ 10 | 11 | #ifdef __Cg_stdlib_hpp__ 12 | #pragma message("error: include this header file (" __FILE__ ") before ") 13 | #endif 14 | 15 | #include 16 | 17 | namespace Cg { 18 | 19 | template 20 | static inline __CGvector::numericType,N> saturate(const __CGvector & v) 21 | { 22 | __CGvector rv; 23 | for (int i=0; i 35 | static inline __CGvector::numericType,N> saturate(const __CGvector_usage & v) 36 | { 37 | __CGvector rv; 38 | for (int i=0; i 50 | static inline __CGvector::numericType,1> saturate(const T & v) 51 | { 52 | __CGvector::numericType,1> rv; 53 | if (T(1) < v) { 54 | rv = T(1); 55 | } else if (T(0) < v) { 56 | rv = v; 57 | } else { 58 | rv = T(0); 59 | } 60 | return rv; 61 | } 62 | 63 | } // namespace Cg 64 | 65 | #endif // __Cg_saturate_hpp__ 66 | -------------------------------------------------------------------------------- /cg4cpp/src/normalize.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2006 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | namespace Cg { 14 | 15 | float1 normalize(float1 v) 16 | { 17 | return normalize(v); 18 | } 19 | 20 | float2 normalize(float2 v) 21 | { 22 | return normalize(v); 23 | } 24 | 25 | float3 normalize(float3 v) 26 | { 27 | return normalize(v); 28 | } 29 | 30 | float4 normalize(float4 v) 31 | { 32 | return normalize(v); 33 | } 34 | 35 | double1 normalize(double1 v) 36 | { 37 | return normalize(v); 38 | } 39 | 40 | double2 normalize(double2 v) 41 | { 42 | return normalize(v); 43 | } 44 | 45 | double3 normalize(double3 v) 46 | { 47 | return normalize(v); 48 | } 49 | 50 | double4 normalize(double4 v) 51 | { 52 | return normalize(v); 53 | } 54 | 55 | half1 normalize(half1 v) 56 | { 57 | return normalize(v); 58 | } 59 | 60 | half2 normalize(half2 v) 61 | { 62 | return normalize(v); 63 | } 64 | 65 | half3 normalize(half3 v) 66 | { 67 | return normalize(v); 68 | } 69 | 70 | half4 normalize(half4 v) 71 | { 72 | return normalize(v); 73 | } 74 | 75 | fixed1 normalize(fixed1 v) 76 | { 77 | return normalize(v); 78 | } 79 | 80 | fixed2 normalize(fixed2 v) 81 | { 82 | return normalize(v); 83 | } 84 | 85 | fixed3 normalize(fixed3 v) 86 | { 87 | return normalize(v); 88 | } 89 | 90 | fixed4 normalize(fixed4 v) 91 | { 92 | return normalize(v); 93 | } 94 | 95 | } // namespace Cg 96 | 97 | -------------------------------------------------------------------------------- /cg4cpp/include/Cg/isfinite.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #ifndef __Cg_isfinite_hpp__ 9 | #define __Cg_isfinite_hpp__ 10 | 11 | #ifdef __Cg_stdlib_hpp__ 12 | #pragma message("error: include this header file (" __FILE__ ") before ") 13 | #endif 14 | 15 | #undef isfinite // g++ headers may defined this 16 | 17 | #include 18 | 19 | #undef isfinite // g++ header may have defined this 20 | 21 | namespace Cg { 22 | 23 | template 24 | static inline __CGvector isfinite(const __CGvector & v) 25 | { 26 | __CGvector rv; 27 | for (int i=0; i::realType s = v[i]; 29 | // By IEEE 754 rule, 2*Inf equals Inf 30 | rv[i] = (s == s) && ((s == 0) || (s != 2*s)); 31 | } 32 | return rv; 33 | } 34 | template 35 | static inline __CGvector isfinite(const __CGvector_usage & v) 36 | { 37 | __CGvector rv; 38 | for (int i=0; i::realType s = v[i]; 40 | // By IEEE 754 rule, 2*Inf equals Inf 41 | rv[i] = (s == s) && ((s == 0) || (s != 2*s)); 42 | } 43 | return rv; 44 | } 45 | template 46 | static inline __CGvector::boolType,1> isfinite(const T & v) 47 | { 48 | const typename __CGtype_trait::realType s = static_cast(v); 49 | // By IEEE 754 rule, 2*Inf equals Inf 50 | __CGvector::boolType,1> rv((s == s) && ((s == 0) || (s != 2*s))); 51 | return rv; 52 | } 53 | 54 | } // namespace Cg 55 | 56 | #endif // __Cg_isfinite_hpp__ 57 | -------------------------------------------------------------------------------- /mandelbrot/ReadMe.txt: -------------------------------------------------------------------------------- 1 | 2 | Interactive mandelbrot set explorer 3 | by Jason Allen 4 | enhanced by Mark Kilgard 5 | 6 | This demo explores the Mandelbrot and Julian sets. 7 | 8 | Demo cheat sheet: 9 | 10 | 'q' - quit 11 | 12 | Esc - quit 13 | 14 | 'r' - reset settings 15 | 16 | left-mouse-drag - zoom/rotate around the initially clicked point, 17 | dragging down zooms in, 18 | dragging up zooms out, 19 | dragging right rotates clockwise, 20 | dragging left rotates counterclockwise. 21 | 22 | Ctrl-left-mouse-drag - up/down zooms without rotating 23 | 24 | Shift-left-mouse-drag - left/right rotates without zooming 25 | 26 | middle-mouse-drag - pans or translates 27 | 28 | Shift-middle-mouse-drag - modifies the (x,y) offsets for the Julian set 29 | 30 | 'j' - toggles showing the Mandelbrot and Julian sets, initially Mandelbrot 31 | 32 | 'm' - toggles use per-sample shading versus multisampling 33 | 34 | 'a' - increase maximum iterations by 10 35 | 36 | 'z' - decrease maximum iterations by 10 37 | 38 | 'p' - cycle through precision modes, initially single precision: 39 | 1) single precsion 40 | 2) double precision 41 | 3) vertical split screen 42 | 4) horizontal split screen 43 | 5) 5x5 checkboard split screen 44 | 45 | '1' - single precision mode 46 | '2' - double precision mode 47 | '3' - vertical split screen 48 | '4' - horizontal split screen 49 | '4' - 5x5 checkboard split screen 50 | 51 | 's' - toggle frames/second display, initially on 52 | 53 | Issue: If you resize the window while zoomed in significantly, you'll find 54 | you lose track of where you are in the fractal. I don't quite understand 55 | this effect but it seems to do with the limitations of single-precision 56 | texture coordinates. Resize the window larger before you zoooom in a lot. 57 | 58 | - Mark Kilgard 59 | September 14, 2010 60 | -------------------------------------------------------------------------------- /cg4cpp/src/fmod.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2006 by NVIDIA Corporation. All rights reserved. All 3 | * information contained herein is proprietary and confidential to NVIDIA 4 | * Corporation. Any use, reproduction, or disclosure without the written 5 | * permission of NVIDIA Corporation is prohibited. 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | namespace Cg { 14 | 15 | float1 fmod(float1 x, float1 y) 16 | { 17 | return fmod(x, y); 18 | } 19 | 20 | float2 fmod(float2 x, float2 y) 21 | { 22 | return fmod(x, y); 23 | } 24 | 25 | float3 fmod(float3 x, float3 y) 26 | { 27 | return fmod(x, y); 28 | } 29 | 30 | float4 fmod(float4 x, float4 y) 31 | { 32 | return fmod(x, y); 33 | } 34 | 35 | double1 fmod(double1 x, double1 y) 36 | { 37 | return fmod(x, y); 38 | } 39 | 40 | double2 fmod(double2 x, double2 y) 41 | { 42 | return fmod(x, y); 43 | } 44 | 45 | double3 fmod(double3 x, double3 y) 46 | { 47 | return fmod(x, y); 48 | } 49 | 50 | double4 fmod(double4 x, double4 y) 51 | { 52 | return fmod(x, y); 53 | } 54 | 55 | half1 fmod(half1 x, half1 y) 56 | { 57 | return fmod(x, y); 58 | } 59 | 60 | half2 fmod(half2 x, half2 y) 61 | { 62 | return fmod(x, y); 63 | } 64 | 65 | half3 fmod(half3 x, half3 y) 66 | { 67 | return fmod(x, y); 68 | } 69 | 70 | half4 fmod(half4 x, half4 y) 71 | { 72 | return fmod(x, y); 73 | } 74 | 75 | fixed1 fmod(fixed1 x, fixed1 y) 76 | { 77 | return fmod(x, y); 78 | } 79 | 80 | fixed2 fmod(fixed2 x, fixed2 y) 81 | { 82 | return fmod(x, y); 83 | } 84 | 85 | fixed3 fmod(fixed3 x, fixed3 y) 86 | { 87 | return fmod(x, y); 88 | } 89 | 90 | fixed4 fmod(fixed4 x, fixed4 y) 91 | { 92 | return fmod(x, y); 93 | } 94 | 95 | } // namespace Cg 96 | 97 | --------------------------------------------------------------------------------