diff options
-rw-r--r-- | progs/SConscript | 1 | ||||
-rw-r--r-- | progs/demos/SConscript | 26 | ||||
-rw-r--r-- | progs/demos/fogcoord.c | 28 | ||||
-rw-r--r-- | progs/demos/gloss.c | 2 | ||||
-rw-r--r-- | progs/demos/multiarb.c | 2 | ||||
-rw-r--r-- | progs/demos/rain.cxx | 2 | ||||
-rw-r--r-- | progs/demos/stex3d.c | 4 | ||||
-rw-r--r-- | progs/demos/winpos.c | 18 | ||||
-rw-r--r-- | progs/trivial/fs-tri.c | 39 | ||||
-rw-r--r-- | progs/util/SConscript | 15 | ||||
-rw-r--r-- | scons/generic.py | 40 | ||||
-rw-r--r-- | src/gallium/drivers/nv20/nv20_clear.c | 1 | ||||
-rw-r--r-- | src/gallium/drivers/nv20/nv20_context.c | 24 | ||||
-rw-r--r-- | src/gallium/drivers/nv20/nv20_state_emit.c | 13 | ||||
-rw-r--r-- | src/gallium/drivers/nv20/nv20_vbo.c | 1 |
15 files changed, 126 insertions, 90 deletions
diff --git a/progs/SConscript b/progs/SConscript index ffb6de4f16c..631923a38ff 100644 --- a/progs/SConscript +++ b/progs/SConscript @@ -1,4 +1,5 @@ SConscript([ + 'util/SConscript', 'demos/SConscript', 'trivial/SConscript', 'vp/SConscript', diff --git a/progs/demos/SConscript b/progs/demos/SConscript index 112da7bedb1..bc166dd7895 100644 --- a/progs/demos/SConscript +++ b/progs/demos/SConscript @@ -1,11 +1,22 @@ -Import('env') +Import('*') if not env['GLUT']: Return() env = env.Clone() -env.Prepend(LIBS = ['$GLUT_LIB']) +env.Prepend(CPPPATH = [ + '../util', +]) + +env.Prepend(LIBS = [ + util, + '$GLUT_LIB' +]) + +if env['platform'] == 'windows': + env.Append(CPPDEFINES = ['NOMINMAX']) + env.Prepend(LIBS = ['winmm']) progs = [ 'arbfplight', @@ -38,7 +49,6 @@ progs = [ 'multiarb', 'paltex', 'pointblast', - 'rain', 'ray', 'readpix', 'reflect', @@ -65,7 +75,15 @@ progs = [ ] for prog in progs: - prog = env.Program( + env.Program( target = prog, source = prog + '.c', ) + +env.Program( + target = 'rain', + source = [ + 'rain.cxx', + 'particles.cxx', + ] +) diff --git a/progs/demos/fogcoord.c b/progs/demos/fogcoord.c index 00c73c6f048..6f50993c98f 100644 --- a/progs/demos/fogcoord.c +++ b/progs/demos/fogcoord.c @@ -7,19 +7,16 @@ * Daniel Borca */ -#define GL_GLEXT_PROTOTYPES #include <stdio.h> #include <stdlib.h> #include <math.h> +#include <GL/glew.h> #include <GL/glut.h> #define DEPTH 5.0f -static PFNGLFOGCOORDFEXTPROC glFogCoordf_ext; static PFNGLFOGCOORDPOINTEREXTPROC glFogCoordPointer_ext; -static GLboolean have_fog_coord; - static GLfloat camz; static GLint fogMode; @@ -45,10 +42,11 @@ Reset(void) } -static void APIENTRY -glFogCoordf_nop (GLfloat f) +static void +glFogCoordf_ext (GLfloat f) { - (void)f; + if (fogCoord) + glFogCoordfEXT(f); } @@ -120,14 +118,11 @@ SetFogMode(GLint fogMode) static GLboolean SetFogCoord(GLboolean fogCoord) { - glFogCoordf_ext = glFogCoordf_nop; - - if (!have_fog_coord) { + if (!GLEW_EXT_fog_coord) { return GL_FALSE; } if (fogCoord) { - glFogCoordf_ext = (PFNGLFOGCOORDFEXTPROC)glutGetProcAddress("glFogCoordfEXT"); glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FOG_COORDINATE_EXT); } else { @@ -340,7 +335,7 @@ Key( unsigned char key, int x, int y ) SetFogMode(fogMode); break; case 'c': - fogCoord = SetFogCoord(fogCoord ^ GL_TRUE); + fogCoord = SetFogCoord(fogCoord ^ GL_TRUE); break; case 't': Texture = !Texture; @@ -372,8 +367,7 @@ Init(void) printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); - have_fog_coord = glutExtensionSupported("GL_EXT_fog_coord"); - if (!have_fog_coord) { + if (!GLEW_EXT_fog_coord) { printf("GL_EXT_fog_coord not supported!\n"); } @@ -400,10 +394,9 @@ Init(void) glEnableClientState(GL_TEXTURE_COORD_ARRAY); glTexCoordPointer(2, GL_FLOAT, 0, texcoord_pointer); - if (have_fog_coord) { - glFogCoordPointer_ext = (PFNGLFOGCOORDPOINTEREXTPROC)glutGetProcAddress("glFogCoordPointerEXT"); + if (GLEW_EXT_fog_coord) { glEnableClientState(GL_FOG_COORDINATE_ARRAY_EXT); - glFogCoordPointer_ext(GL_FLOAT, 0, fogcoord_pointer); + glFogCoordPointerEXT(GL_FLOAT, 0, fogcoord_pointer); } Reset(); @@ -417,6 +410,7 @@ main( int argc, char *argv[] ) glutInitWindowSize( 600, 600 ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutDisplayFunc( Display ); diff --git a/progs/demos/gloss.c b/progs/demos/gloss.c index 9974f0dab2e..b2126e32678 100644 --- a/progs/demos/gloss.c +++ b/progs/demos/gloss.c @@ -22,6 +22,7 @@ #include <stdlib.h> #include <math.h> #include <string.h> +#include <GL/glew.h> #include <GL/glut.h> #include "readtex.h" @@ -438,6 +439,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize(WinWidth, WinHeight); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); glutCreateWindow(argv[0] ); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutDisplayFunc( Display ); diff --git a/progs/demos/multiarb.c b/progs/demos/multiarb.c index 451fd11efe1..85c4e3a266c 100644 --- a/progs/demos/multiarb.c +++ b/progs/demos/multiarb.c @@ -14,6 +14,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <GL/glew.h> #include <GL/glut.h> #include "readtex.h" @@ -326,6 +327,7 @@ int main( int argc, char *argv[] ) glutInitWindowPosition( 0, 0 ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); glutCreateWindow(argv[0] ); + glewInit(); Init( argc, argv ); diff --git a/progs/demos/rain.cxx b/progs/demos/rain.cxx index 59b6471ef8f..265d90cd95f 100644 --- a/progs/demos/rain.cxx +++ b/progs/demos/rain.cxx @@ -24,8 +24,6 @@ extern "C" { #ifdef _WIN32 #include <windows.h> #include <mmsystem.h> -#include "particles.cxx" -#include "readtex.c" #endif #ifdef XMESA diff --git a/progs/demos/stex3d.c b/progs/demos/stex3d.c index 83ae3684ae2..c0bbea0960f 100644 --- a/progs/demos/stex3d.c +++ b/progs/demos/stex3d.c @@ -18,7 +18,7 @@ #include <stdio.h> #include <stdlib.h> #include <math.h> -#include <GL/gl.h> +#include <GL/glew.h> #include <GL/glut.h> @@ -662,6 +662,8 @@ main(int argc, char **argv) exit(0); } + glewInit(); + init(); printHelp(); diff --git a/progs/demos/winpos.c b/progs/demos/winpos.c index b58e3308643..13a9c7e9a8f 100644 --- a/progs/demos/winpos.c +++ b/progs/demos/winpos.c @@ -11,7 +11,7 @@ #ifdef _WIN32 #include <windows.h> #endif -#define GL_GLEXT_PROTOTYPES +#include "GL/glew.h" #include "GL/glut.h" #include "readtex.h" @@ -29,8 +29,7 @@ static GLubyte *Image; static int ImgWidth, ImgHeight; static GLenum ImgFormat; -typedef void (APIENTRY * PFNWINDOWPOSFUNC)(GLfloat x, GLfloat y); -static PFNWINDOWPOSFUNC WindowPosFunc; +static PFNGLWINDOWPOS2FPROC WindowPosFunc; static void draw( void ) { @@ -71,19 +70,16 @@ static void reshape( int width, int height ) static void init( void ) { -#ifdef GL_ARB_window_pos - if (glutExtensionSupported("GL_ARB_window_pos")) { + if (GLEW_ARB_window_pos) { printf("Using GL_ARB_window_pos\n"); - WindowPosFunc = &glWindowPos2fARB; + WindowPosFunc = glWindowPos2fARB; } else -#elif defined(GL_MESA_window_pos) - if (glutExtensionSupported("GL_MESA_window_pos")) { + if (GLEW_MESA_window_pos) { printf("Using GL_MESA_window_pos\n"); - WindowPosFunc = &glWindowPos2fMESA; + WindowPosFunc = glWindowPos2fMESA; } else -#endif { printf("Sorry, GL_ARB/MESA_window_pos extension not available.\n"); exit(1); @@ -109,6 +105,8 @@ int main( int argc, char *argv[] ) exit(0); } + glewInit(); + init(); glutReshapeFunc( reshape ); diff --git a/progs/trivial/fs-tri.c b/progs/trivial/fs-tri.c index 3be4d42e54c..6e86df1dcfa 100644 --- a/progs/trivial/fs-tri.c +++ b/progs/trivial/fs-tri.c @@ -5,10 +5,8 @@ #include <stdio.h> #include <stdlib.h> #include <math.h> -#include <GL/gl.h> +#include <GL/glew.h> #include <GL/glut.h> -#include <GL/glext.h> -#include "extfuncs.h" static GLuint fragShader; @@ -56,9 +54,9 @@ Reshape(int width, int height) static void CleanUp(void) { - glDeleteShader_func(fragShader); - glDeleteShader_func(vertShader); - glDeleteProgram_func(program); + glDeleteShader(fragShader); + glDeleteShader(vertShader); + glDeleteProgram(program); glutDestroyWindow(win); } @@ -110,15 +108,15 @@ LoadAndCompileShader(GLuint shader, const char *text) { GLint stat; - glShaderSource_func(shader, 1, (const GLchar **) &text, NULL); + glShaderSource(shader, 1, (const GLchar **) &text, NULL); - glCompileShader_func(shader); + glCompileShader(shader); - glGetShaderiv_func(shader, GL_COMPILE_STATUS, &stat); + glGetShaderiv(shader, GL_COMPILE_STATUS, &stat); if (!stat) { GLchar log[1000]; GLsizei len; - glGetShaderInfoLog_func(shader, 1000, &len, log); + glGetShaderInfoLog(shader, 1000, &len, log); fprintf(stderr, "fslight: problem compiling shader:\n%s\n", log); exit(1); } @@ -129,11 +127,11 @@ static void CheckLink(GLuint prog) { GLint stat; - glGetProgramiv_func(prog, GL_LINK_STATUS, &stat); + glGetProgramiv(prog, GL_LINK_STATUS, &stat); if (!stat) { GLchar log[1000]; GLsizei len; - glGetProgramInfoLog_func(prog, 1000, &len, log); + glGetProgramInfoLog(prog, 1000, &len, log); fprintf(stderr, "Linker error:\n%s\n", log); } } @@ -165,24 +163,22 @@ Init(void) exit(1); } - GetExtensionFuncs(); - - fragShader = glCreateShader_func(GL_FRAGMENT_SHADER); + fragShader = glCreateShader(GL_FRAGMENT_SHADER); LoadAndCompileShader(fragShader, fragShaderText); #if 0 - vertShader = glCreateShader_func(GL_VERTEX_SHADER); + vertShader = glCreateShader(GL_VERTEX_SHADER); LoadAndCompileShader(vertShader, vertShaderText); #endif - program = glCreateProgram_func(); - glAttachShader_func(program, fragShader); + program = glCreateProgram(); + glAttachShader(program, fragShader); #if 0 - glAttachShader_func(program, vertShader); + glAttachShader(program, vertShader); #endif - glLinkProgram_func(program); + glLinkProgram(program); CheckLink(program); - glUseProgram_func(program); + glUseProgram(program); assert(glGetError() == 0); @@ -200,6 +196,7 @@ main(int argc, char *argv[]) glutInitWindowSize(200, 200); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); win = glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc(Reshape); glutKeyboardFunc(Key); glutSpecialFunc(SpecialKey); diff --git a/progs/util/SConscript b/progs/util/SConscript new file mode 100644 index 00000000000..8ad2466291d --- /dev/null +++ b/progs/util/SConscript @@ -0,0 +1,15 @@ +Import('env') + +env = env.Clone() + +util = env.StaticLibrary( + target = ['util'], + source = [ + 'readtex.c', + 'trackball.c', + 'showbuffer.c', + 'shaderutil.c', + ], +) + +Export('util') diff --git a/scons/generic.py b/scons/generic.py index df7ef42402e..05f7356b762 100644 --- a/scons/generic.py +++ b/scons/generic.py @@ -303,7 +303,7 @@ def generate(env): #'_UNICODE', #'UNICODE', # http://msdn2.microsoft.com/en-us/library/6dwk3a1z.aspx, - 'WIN32_LEAN_AND_MEAN', + #'WIN32_LEAN_AND_MEAN', 'VC_EXTRALEAN', '_CRT_SECURE_NO_DEPRECATE', ] @@ -362,24 +362,26 @@ def generate(env): ]) # C compiler options - cflags = [] + cflags = [] # C + cxxflags = [] # C++ + ccflags = [] # C & C++ if gcc: if debug: - cflags += ['-O0', '-g3'] + ccflags += ['-O0', '-g3'] else: - cflags += ['-O3', '-g0'] + ccflags += ['-O3', '-g0'] if env['profile']: - cflags += ['-pg'] + ccflags += ['-pg'] if env['machine'] == 'x86': - cflags += [ + ccflags += [ '-m32', #'-march=pentium4', '-mmmx', '-msse', '-msse2', # enable SIMD intrinsics #'-mfpmath=sse', ] if env['machine'] == 'x86_64': - cflags += ['-m64'] - cflags += [ + ccflags += ['-m64'] + ccflags += [ '-Wall', '-Wmissing-prototypes', '-Wno-long-long', @@ -387,43 +389,46 @@ def generate(env): '-pedantic', '-fmessage-length=0', # be nice to Eclipse ] + cflags += [ + '-Wmissing-prototypes', + ] if msvc: # See also: # - http://msdn.microsoft.com/en-us/library/19z1t1wy.aspx # - cl /? if debug: - cflags += [ + ccflags += [ '/Od', # disable optimizations '/Oi', # enable intrinsic functions '/Oy-', # disable frame pointer omission ] else: - cflags += [ + ccflags += [ '/Ox', # maximum optimizations '/Oi', # enable intrinsic functions '/Ot', # favor code speed #'/fp:fast', # fast floating point ] if env['profile']: - cflags += [ + ccflags += [ '/Gh', # enable _penter hook function '/GH', # enable _pexit hook function ] - cflags += [ + ccflags += [ '/W3', # warning level #'/Wp64', # enable 64 bit porting warnings ] if env['machine'] == 'x86': - cflags += [ + ccflags += [ #'/QIfist', # Suppress _ftol #'/arch:SSE2', # use the SSE2 instructions ] if platform == 'windows': - cflags += [ + ccflags += [ # TODO ] if platform == 'winddk': - cflags += [ + ccflags += [ '/Zl', # omit default library name in .OBJ '/Zp8', # 8bytes struct member alignment '/Gy', # separate functions for linker @@ -442,7 +447,7 @@ def generate(env): ] if platform == 'wince': # See also C:\WINCE600\public\common\oak\misc\makefile.def - cflags += [ + ccflags += [ '/Zl', # omit default library name in .OBJ '/GF', # enable read-only string pooling '/GR-', # disable C++ RTTI @@ -459,8 +464,9 @@ def generate(env): # See http://scons.tigris.org/issues/show_bug.cgi?id=1656 env.EnsureSConsVersion(0, 98, 0) env['PDB'] = '${TARGET.base}.pdb' + env.Append(CCFLAGS = ccflags) env.Append(CFLAGS = cflags) - env.Append(CXXFLAGS = cflags) + env.Append(CXXFLAGS = cxxflags) if env['platform'] == 'windows' and msvc: # Choose the appropriate MSVC CRT diff --git a/src/gallium/drivers/nv20/nv20_clear.c b/src/gallium/drivers/nv20/nv20_clear.c index 81b6f3e78ac..29f4afd87c9 100644 --- a/src/gallium/drivers/nv20/nv20_clear.c +++ b/src/gallium/drivers/nv20/nv20_clear.c @@ -9,4 +9,5 @@ nv20_clear(struct pipe_context *pipe, struct pipe_surface *ps, unsigned clearValue) { pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, clearValue); + ps->status = PIPE_SURFACE_STATUS_CLEAR; } diff --git a/src/gallium/drivers/nv20/nv20_context.c b/src/gallium/drivers/nv20/nv20_context.c index d3aca8d937a..1659aec8fab 100644 --- a/src/gallium/drivers/nv20/nv20_context.c +++ b/src/gallium/drivers/nv20/nv20_context.c @@ -263,7 +263,7 @@ static void nv20_init_hwctx(struct nv20_context *nv20) BEGIN_RING(kelvin, NV20TCL_DEPTH_FUNC, 1); OUT_RING (NV20TCL_DEPTH_FUNC_LESS); BEGIN_RING(kelvin, NV20TCL_DEPTH_WRITE_ENABLE, 1); - OUT_RING (1); + OUT_RING (0); BEGIN_RING(kelvin, NV20TCL_DEPTH_TEST_ENABLE, 1); OUT_RING (0); BEGIN_RING(kelvin, NV20TCL_POLYGON_OFFSET_FACTOR, 2); @@ -349,7 +349,7 @@ static void nv20_init_hwctx(struct nv20_context *nv20) memset(projectionmatrix, 0, sizeof(projectionmatrix)); projectionmatrix[0*4+0] = 1.0; projectionmatrix[1*4+1] = 1.0; - projectionmatrix[2*4+2] = 1.0; + projectionmatrix[2*4+2] = 16777215.0; projectionmatrix[3*4+3] = 1.0; BEGIN_RING(kelvin, NV20TCL_PROJECTION_MATRIX(0), 16); for (i = 0; i < 16; i++) { @@ -357,20 +357,20 @@ static void nv20_init_hwctx(struct nv20_context *nv20) } BEGIN_RING(kelvin, NV20TCL_DEPTH_RANGE_NEAR, 2); - OUT_RINGf (0.0); - OUT_RINGf (16777216.0); /* bpp dependant? */ + OUT_RINGf (0.0); + OUT_RINGf (16777216.0); /* [0, 1] scaled approx to [0, 2^24] */ BEGIN_RING(kelvin, NV20TCL_VIEWPORT_SCALE0_X, 4); - OUT_RINGf (0.0); /* x-offset */ - OUT_RINGf (0.0); /* y-offset */ - OUT_RINGf (16777215.0 * 0.5); - OUT_RING (0); + OUT_RINGf (0.0); /* x-offset, w/2 + 1.031250 */ + OUT_RINGf (0.0); /* y-offset, h/2 + 0.030762 */ + OUT_RINGf (0.0); + OUT_RINGf (16777215.0); BEGIN_RING(kelvin, NV20TCL_VIEWPORT_SCALE1_X, 4); - OUT_RINGf (0.0); /* no effect? */ - OUT_RINGf (0.0); /* no effect? */ - OUT_RINGf (16777215.0 * 0.5); - OUT_RINGf (65535.0); + OUT_RINGf (0.0); /* no effect?, w/2 */ + OUT_RINGf (0.0); /* no effect?, h/2 */ + OUT_RINGf (16777215.0 * 0.5); + OUT_RINGf (65535.0); FIRE_RING (NULL); } diff --git a/src/gallium/drivers/nv20/nv20_state_emit.c b/src/gallium/drivers/nv20/nv20_state_emit.c index cbdc674b09d..ea20078a50a 100644 --- a/src/gallium/drivers/nv20/nv20_state_emit.c +++ b/src/gallium/drivers/nv20/nv20_state_emit.c @@ -73,6 +73,9 @@ static void nv20_state_emit_dsa(struct nv20_context* nv20) BEGIN_RING(kelvin, NV20TCL_DEPTH_TEST_ENABLE, 1); OUT_RING (d->depth.test_enable); + BEGIN_RING(kelvin, NV20TCL_DEPTH_UNK17D8, 1); + OUT_RING (1); + #if 0 BEGIN_RING(kelvin, NV20TCL_STENCIL_ENABLE, 1); OUT_RING (d->stencil.enable); @@ -352,16 +355,14 @@ nv20_emit_hw_state(struct nv20_context *nv20) */ /* Render target */ -/* XXX figre out who's who for NV10TCL_DMA_* and fill accordingly - * BEGIN_RING(kelvin, NV20TCL_DMA_COLOR0, 1); - * OUT_RELOCo(nv20->rt[0], NOUVEAU_BO_VRAM | NOUVEAU_BO_WR); */ + BEGIN_RING(kelvin, NV20TCL_DMA_COLOR, 1); + OUT_RELOCo(nv20->rt[0], NOUVEAU_BO_VRAM | NOUVEAU_BO_WR); BEGIN_RING(kelvin, NV20TCL_COLOR_OFFSET, 1); OUT_RELOCl(nv20->rt[0], 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR); if (nv20->zeta) { -/* XXX - * BEGIN_RING(kelvin, NV20TCL_DMA_ZETA, 1); - * OUT_RELOCo(nv20->zeta, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR); */ + BEGIN_RING(kelvin, NV20TCL_DMA_ZETA, 1); + OUT_RELOCo(nv20->zeta, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR); BEGIN_RING(kelvin, NV20TCL_ZETA_OFFSET, 1); OUT_RELOCl(nv20->zeta, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR); /* XXX for when we allocate LMA on nv17 */ diff --git a/src/gallium/drivers/nv20/nv20_vbo.c b/src/gallium/drivers/nv20/nv20_vbo.c index 4edc4efebd8..24d8f4bef09 100644 --- a/src/gallium/drivers/nv20/nv20_vbo.c +++ b/src/gallium/drivers/nv20/nv20_vbo.c @@ -64,6 +64,7 @@ boolean nv20_draw_elements( struct pipe_context *pipe, draw_set_mapped_element_buffer(draw, 0, NULL); } + draw_flush(nv20->draw); return TRUE; } |