From 3bee7610bef4c201a93e0ad8f670acc1b324e71d Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 27 Oct 2009 16:46:07 -0600 Subject: progs/tests: added new blitfb.c test Tests glBlitFramebuffer() between two texture/renderbuffer surfaces. In particular, blit from level[1] of a cube map face to a 2D texture. Used to find/fix bug in intel do_copy_texsubimage(). See commit aef1ab1073f3e30d699b99dae17518ed48b57c72 --- progs/tests/SConscript | 1 + 1 file changed, 1 insertion(+) (limited to 'progs/tests/SConscript') diff --git a/progs/tests/SConscript b/progs/tests/SConscript index bb6a1d2b8a..3a0da62717 100644 --- a/progs/tests/SConscript +++ b/progs/tests/SConscript @@ -52,6 +52,7 @@ progs = [ 'blendminmax', 'blendsquare', 'blendxor', + 'blitfb', 'bufferobj', 'bug_3050', 'bug_3101', -- cgit v1.2.3 From 08d145e1d7479aab125013d6852968fa09ad6fb3 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 30 Dec 2009 21:41:37 -0700 Subject: progs/tests: added conditional rendering test program --- progs/tests/Makefile | 1 + progs/tests/SConscript | 1 + progs/tests/condrender.c | 242 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 244 insertions(+) create mode 100644 progs/tests/condrender.c (limited to 'progs/tests/SConscript') diff --git a/progs/tests/Makefile b/progs/tests/Makefile index 3e2541186b..6f5df2e81e 100644 --- a/progs/tests/Makefile +++ b/progs/tests/Makefile @@ -37,6 +37,7 @@ SOURCES = \ bug_3195.c \ bug_texstore_i8.c \ calibrate_rast.c \ + condrender.c \ copypixrate.c \ crossbar.c \ cva.c \ diff --git a/progs/tests/SConscript b/progs/tests/SConscript index 3a0da62717..38c28a9fe6 100644 --- a/progs/tests/SConscript +++ b/progs/tests/SConscript @@ -59,6 +59,7 @@ progs = [ 'bug_3195', 'bug_texstore_i8', 'calibrate_rast', + 'condrender', 'copypixrate', 'crossbar', 'cva', diff --git a/progs/tests/condrender.c b/progs/tests/condrender.c new file mode 100644 index 0000000000..1db8a7c15a --- /dev/null +++ b/progs/tests/condrender.c @@ -0,0 +1,242 @@ +/* + * Test GL_NV_conditional_render + * + * Brian Paul + * 30 Dec 2009 + * + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include +#include +#include +#include +#include +#include +#include + +#define TEST_DISPLAY_LISTS 0 + +static GLboolean Anim = GL_TRUE; +static GLfloat Xpos = 0; +static GLuint OccQuery; +static GLint Win = 0; + + +static void Idle(void) +{ + static int lastTime = 0; + static int sign = +1; + int time = glutGet(GLUT_ELAPSED_TIME); + float step; + + if (lastTime == 0) + lastTime = time; + else if (time - lastTime < 20) /* 50Hz update */ + return; + + step = (time - lastTime) / 1000.0 * sign; + lastTime = time; + + Xpos += step; + + if (Xpos > 2.5) { + Xpos = 2.5; + sign = -1; + } + else if (Xpos < -2.5) { + Xpos = -2.5; + sign = +1; + } + glutPostRedisplay(); +} + + +static void Display( void ) +{ + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + + glEnable(GL_DEPTH_TEST); + + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glFrustum( -1.0, 1.0, -1.0, 1.0, 5.0, 25.0 ); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + glTranslatef( 0.0, 0.0, -15.0 ); + + /* draw the occluding polygons */ + glColor3f(0, 0.6, 0.8); + glBegin(GL_QUADS); + glVertex2f(-1.6, -1.5); + glVertex2f(-0.4, -1.5); + glVertex2f(-0.4, 1.5); + glVertex2f(-1.6, 1.5); + + glVertex2f( 0.4, -1.5); + glVertex2f( 1.6, -1.5); + glVertex2f( 1.6, 1.5); + glVertex2f( 0.4, 1.5); + glEnd(); + + /* draw the test polygon with occlusion testing */ + glPushMatrix(); + glTranslatef(Xpos, 0, -0.5); + glScalef(0.3, 0.3, 1.0); + glRotatef(-90.0 * Xpos, 0, 0, 1); + +#if TEST_DISPLAY_LISTS + glNewList(10, GL_COMPILE); + glBeginQueryARB(GL_SAMPLES_PASSED_ARB, OccQuery); + glEndList(); + glCallList(10); +#else + glBeginQueryARB(GL_SAMPLES_PASSED_ARB, OccQuery); +#endif + + glColorMask(0, 0, 0, 0); + glDepthMask(GL_FALSE); + + glBegin(GL_POLYGON); + glVertex3f(-1, -1, 0); + glVertex3f( 1, -1, 0); + glVertex3f( 1, 1, 0); + glVertex3f(-1, 1, 0); + glEnd(); + +#if TEST_DISPLAY_LISTS + glNewList(11, GL_COMPILE); + glEndQueryARB(GL_SAMPLES_PASSED_ARB); + glEndList(); + glCallList(11); +#else + glEndQueryARB(GL_SAMPLES_PASSED_ARB); +#endif + + glColorMask(1, 1, 1, 1); + glDepthMask(GL_TRUE); + + /* Note: disable depth test here so that we'll always see the orange + * box, except when it's totally culled. + */ + glDisable(GL_DEPTH_TEST); + + glBeginConditionalRenderNV(OccQuery, GL_QUERY_WAIT_NV); + /* draw the orange rect, so we can see what's going on */ + glColor3f(0.8, 0.5, 0); + glBegin(GL_POLYGON); + glVertex3f(-1, -1, 0); + glVertex3f( 1, -1, 0); + glVertex3f( 1, 1, 0); + glVertex3f(-1, 1, 0); + glEnd(); + glEndConditionalRenderNV(); + + /* always draw white outline around orange box */ + glColor3f(1.0, 1.0, 1.0); + glBegin(GL_LINE_LOOP); + glVertex3f(-1, -1, 0); + glVertex3f( 1, -1, 0); + glVertex3f( 1, 1, 0); + glVertex3f(-1, 1, 0); + glEnd(); + + glPopMatrix(); + + glutSwapBuffers(); +} + + +static void Reshape( int width, int height ) +{ + glViewport( 0, 0, width, height ); +} + + +static void Key( unsigned char key, int x, int y ) +{ + (void) x; + (void) y; + switch (key) { + case 27: + glDeleteQueriesARB(1, &OccQuery); + glutDestroyWindow(Win); + exit(0); + break; + case ' ': + Anim = !Anim; + if (Anim) + glutIdleFunc(Idle); + else + glutIdleFunc(NULL); + break; + } + glutPostRedisplay(); +} + + +static void SpecialKey( int key, int x, int y ) +{ + const GLfloat step = 0.1; + (void) x; + (void) y; + switch (key) { + case GLUT_KEY_LEFT: + Xpos -= step; + break; + case GLUT_KEY_RIGHT: + Xpos += step; + break; + } + glutPostRedisplay(); +} + + +static void Init( void ) +{ + if (!glutExtensionSupported("GL_ARB_occlusion_query") || + !glutExtensionSupported("GL_NV_conditional_render")) { + printf("Sorry, this demo requires the extensions:\n"); + printf(" GL_ARB_occlusion_query\n"); + printf(" GL_NV_conditional_render\n"); + exit(-1); + } + + glGenQueriesARB(1, &OccQuery); + assert(OccQuery > 0); +} + + +int main( int argc, char *argv[] ) +{ + glutInitWindowSize( 400, 400 ); + glutInit( &argc, argv ); + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); + Win = glutCreateWindow(argv[0]); + glewInit(); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutSpecialFunc( SpecialKey ); + glutIdleFunc( Idle ); + glutDisplayFunc( Display ); + Init(); + glutMainLoop(); + return 0; +} -- cgit v1.2.3 From 34075d0219edc2cedb5122eb0f82ee0b105b3abd Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 31 Dec 2009 08:46:36 -0700 Subject: progs/tests: added test for GL_EXT_draw_buffers2 Render into two color buffers (render targets). Display half of each buffer in the window. Use different color masks for each render target. Only enable blending for the second render target. --- progs/tests/Makefile | 1 + progs/tests/SConscript | 1 + progs/tests/drawbuffers2.c | 364 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 366 insertions(+) create mode 100644 progs/tests/drawbuffers2.c (limited to 'progs/tests/SConscript') diff --git a/progs/tests/Makefile b/progs/tests/Makefile index 6f5df2e81e..836396b249 100644 --- a/progs/tests/Makefile +++ b/progs/tests/Makefile @@ -42,6 +42,7 @@ SOURCES = \ crossbar.c \ cva.c \ drawbuffers.c \ + drawbuffers2.c \ exactrast.c \ ext422square.c \ floattex.c \ diff --git a/progs/tests/SConscript b/progs/tests/SConscript index 38c28a9fe6..ae6488b3e6 100644 --- a/progs/tests/SConscript +++ b/progs/tests/SConscript @@ -64,6 +64,7 @@ progs = [ 'crossbar', 'cva', 'drawbuffers', + 'drawbuffers2', 'exactrast', 'ext422square', 'fbotest1', diff --git a/progs/tests/drawbuffers2.c b/progs/tests/drawbuffers2.c new file mode 100644 index 0000000000..7b8cc5ca6a --- /dev/null +++ b/progs/tests/drawbuffers2.c @@ -0,0 +1,364 @@ +/* + * Test GL_ARB_draw_buffers2, GL_ARB_draw_buffers, GL_EXT_framebuffer_object + * and GLSL's gl_FragData[]. + * + * We draw to two color buffers and show the left half of the first + * color buffer on the left side of the window, and show the right + * half of the second color buffer on the right side of the window. + * + * Different color masks are used for the two color buffers. + * Blending is enabled for the second buffer only. + * + * Brian Paul + * 31 Dec 2009 + */ + + +#include +#include +#include +#include +#include +#include +#include "extfuncs.h" + +static int Win; +static int Width = 400, Height = 400; +static GLuint FBobject, RBobjects[3]; +static GLfloat Xrot = 0.0, Yrot = 0.0; +static GLuint Program; +static GLboolean Anim = GL_TRUE; + + +static void +CheckError(int line) +{ + GLenum err = glGetError(); + if (err) { + printf("GL Error 0x%x at line %d\n", (int) err, line); + } +} + + +static void +Display(void) +{ + GLubyte *buffer = malloc(Width * Height * 4); + static const GLenum buffers[2] = { + GL_COLOR_ATTACHMENT0_EXT, + GL_COLOR_ATTACHMENT1_EXT + }; + + glUseProgram_func(Program); + + glEnable(GL_DEPTH_TEST); + + /* draw to user framebuffer */ + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, FBobject); + + /* Clear color buffer 0 (blue) */ + glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT); + glClear(GL_COLOR_BUFFER_BIT); + + /* Clear color buffer 1 (1 - blue) */ + glDrawBuffer(GL_COLOR_ATTACHMENT1_EXT); + glClear(GL_COLOR_BUFFER_BIT); + + glClear(GL_DEPTH_BUFFER_BIT); + + /* draw to two buffers w/ fragment shader */ + glDrawBuffersARB(2, buffers); + + /* different color masks for each buffer */ + if (1) { + glColorMaskIndexedEXT(0, GL_TRUE, GL_FALSE, GL_FALSE, GL_FALSE); + glColorMaskIndexedEXT(1, GL_FALSE, GL_TRUE, GL_FALSE, GL_FALSE); + } + + glPushMatrix(); + glRotatef(Xrot, 1, 0, 0); + glRotatef(Yrot, 0, 1, 0); + glPushMatrix(); + glTranslatef(1, 0, 0); + glutSolidTorus(1.0, 2.0, 10, 20); + glPopMatrix(); + glPushMatrix(); + glTranslatef(-1, 0, 0); + glRotatef(90, 1, 0, 0); + glutSolidTorus(1.0, 2.0, 10, 20); + glPopMatrix(); + glPopMatrix(); + + /* restore default color masks */ + glColorMaskIndexedEXT(0, GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + glColorMaskIndexedEXT(1, GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + + /* read from user framebuffer */ + /* left half = colorbuffer 0 */ + glReadBuffer(GL_COLOR_ATTACHMENT0_EXT); + glPixelStorei(GL_PACK_ROW_LENGTH, Width); + glPixelStorei(GL_PACK_SKIP_PIXELS, 0); + glReadPixels(0, 0, Width / 2, Height, GL_RGBA, GL_UNSIGNED_BYTE, + buffer); + + /* right half = colorbuffer 1 */ + glReadBuffer(GL_COLOR_ATTACHMENT1_EXT); + glPixelStorei(GL_PACK_SKIP_PIXELS, Width / 2); + glReadPixels(Width / 2, 0, Width - Width / 2, Height, + GL_RGBA, GL_UNSIGNED_BYTE, + buffer); + + /* draw to window */ + glUseProgram_func(0); + glDisable(GL_DEPTH_TEST); + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); + glWindowPos2iARB(0, 0); + glDrawPixels(Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, buffer); + + free(buffer); + glutSwapBuffers(); + CheckError(__LINE__); +} + + +static void +Idle(void) +{ + Xrot = glutGet(GLUT_ELAPSED_TIME) * 0.05; + glutPostRedisplay(); +} + + +static void +Reshape(int width, int height) +{ + float ar = (float) width / (float) height; + + glViewport(0, 0, width, height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum(-ar, ar, -1.0, 1.0, 5.0, 35.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0, 0.0, -20.0); + + Width = width; + Height = height; + + glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, RBobjects[0]); + glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGB, Width, Height); + glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, RBobjects[1]); + glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGB, Width, Height); + glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, RBobjects[2]); + glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, + Width, Height); +} + + +static void +CleanUp(void) +{ + glDeleteFramebuffersEXT(1, &FBobject); + glDeleteRenderbuffersEXT(3, RBobjects); + glutDestroyWindow(Win); + exit(0); +} + + +static void +Key(unsigned char key, int x, int y) +{ + (void) x; + (void) y; + switch (key) { + case ' ': + Anim = !Anim; + glutIdleFunc(Anim ? Idle : NULL); + break; + case 'x': + Xrot += 5.0; + break; + case 'X': + Xrot -= 5.0; + break; + case 'y': + Yrot += 5.0; + break; + case 'Y': + Yrot -= 5.0; + break; + case 27: + CleanUp(); + break; + } + glutPostRedisplay(); +} + + +static void +CheckExtensions(void) +{ + const char *req[] = { + "GL_EXT_framebuffer_object", + "GL_ARB_draw_buffers", + "GL_EXT_draw_buffers2" + }; + + const char *version = (const char *) glGetString(GL_VERSION); + GLint numBuf; + GLint i; + + for (i = 0; i < 3; i++) { + if (!glutExtensionSupported(req[i])) { + printf("Sorry, %s extension is required!\n", req[i]); + exit(1); + } + } + if (version[0] != '2') { + printf("Sorry, OpenGL 2.0 is required!\n"); + exit(1); + } + + glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB, &numBuf); + printf("GL_MAX_DRAW_BUFFERS_ARB = %d\n", numBuf); + if (numBuf < 2) { + printf("Sorry, GL_MAX_DRAW_BUFFERS_ARB needs to be >= 2\n"); + exit(1); + } + + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); +} + + +static void +SetupRenderbuffers(void) +{ + glGenFramebuffersEXT(1, &FBobject); + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, FBobject); + + glGenRenderbuffersEXT(3, RBobjects); + + glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, RBobjects[0]); + glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGB, Width, Height); + + glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, RBobjects[1]); + glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGB, Width, Height); + + glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, RBobjects[2]); + glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, + Width, Height); + + glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, + GL_RENDERBUFFER_EXT, RBobjects[0]); + glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT1_EXT, + GL_RENDERBUFFER_EXT, RBobjects[1]); + glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, + GL_RENDERBUFFER_EXT, RBobjects[2]); + + CheckError(__LINE__); +} + + +static GLuint +LoadAndCompileShader(GLenum target, const char *text) +{ + GLint stat; + GLuint shader = glCreateShader_func(target); + glShaderSource_func(shader, 1, (const GLchar **) &text, NULL); + glCompileShader_func(shader); + glGetShaderiv_func(shader, GL_COMPILE_STATUS, &stat); + if (!stat) { + GLchar log[1000]; + GLsizei len; + glGetShaderInfoLog_func(shader, 1000, &len, log); + fprintf(stderr, "drawbuffers: problem compiling shader:\n%s\n", log); + exit(1); + } + return shader; +} + + +static void +CheckLink(GLuint prog) +{ + GLint stat; + glGetProgramiv_func(prog, GL_LINK_STATUS, &stat); + if (!stat) { + GLchar log[1000]; + GLsizei len; + glGetProgramInfoLog_func(prog, 1000, &len, log); + fprintf(stderr, "drawbuffers: shader link error:\n%s\n", log); + } +} + + +static void +SetupShaders(void) +{ + /* emit same color to both draw buffers */ + static const char *fragShaderText = + "void main() {\n" + " gl_FragData[0] = gl_Color; \n" + " gl_FragData[1] = gl_Color; \n" + "}\n"; + + GLuint fragShader; + + fragShader = LoadAndCompileShader(GL_FRAGMENT_SHADER, fragShaderText); + Program = glCreateProgram_func(); + + glAttachShader_func(Program, fragShader); + glLinkProgram_func(Program); + CheckLink(Program); + glUseProgram_func(Program); +} + + +static void +SetupLighting(void) +{ + static const GLfloat ambient[4] = { 0.0, 0.0, 0.0, 0.0 }; + static const GLfloat diffuse[4] = { 1.0, 1.0, 1.0, 0.75 }; + + glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambient); + glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, ambient); + glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diffuse); + + glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 0); + glEnable(GL_LIGHT0); + glEnable(GL_LIGHTING); +} + + +static void +Init(void) +{ + CheckExtensions(); + GetExtensionFuncs(); + SetupRenderbuffers(); + SetupShaders(); + SetupLighting(); + glEnable(GL_DEPTH_TEST); + + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnableIndexedEXT(GL_BLEND, 1); +} + + +int +main(int argc, char *argv[]) +{ + glutInit(&argc, argv); + glutInitWindowPosition(0, 0); + glutInitWindowSize(Width, Height); + glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE); + Win = glutCreateWindow(argv[0]); + glewInit(); + glutIdleFunc(Anim ? Idle : NULL); + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Display); + Init(); + glutMainLoop(); + return 0; +} -- cgit v1.2.3 From 7bbf7f94ea786e41ff1364cedaf7dd5c0bbf605a Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 31 Dec 2009 21:10:25 +0000 Subject: scons: Build progs together with everything else. This is a substantial reorganization, This particular commit enables: - building the progs for unices platforms - glew is now built as a shared library (it is the default, and it is inconvenient and pointless to shift away from that default) - all progs get built by default --- SConstruct | 8 ++- docs/install.html | 9 ---- progs/SConscript | 38 +++++++++++++++ progs/SConstruct | 65 ------------------------- progs/demos/SConscript | 124 ++++++++++++++++++++--------------------------- progs/fp/SConscript | 15 +----- progs/glsl/SConscript | 20 +------- progs/perf/SConscript | 11 +---- progs/redbook/SConscript | 20 +------- progs/samples/SConscript | 20 +------- progs/tests/SConscript | 20 +------- progs/trivial/SConscript | 11 +---- progs/vp/SConscript | 11 +---- progs/vpglsl/SConscript | 11 +---- progs/wgl/SConscript | 14 ++---- src/glew/SConscript | 31 ++++++++---- src/glut/glx/SConscript | 66 ++++++++++++++++--------- 17 files changed, 180 insertions(+), 314 deletions(-) delete mode 100644 progs/SConstruct (limited to 'progs/tests/SConscript') diff --git a/SConstruct b/SConstruct index 0a545d5c92..ed92518eec 100644 --- a/SConstruct +++ b/SConstruct @@ -177,7 +177,7 @@ if env['platform'] != common.default_platform: SConscript( 'src/glsl/SConscript', - variant_dir = env['build'] + '/host', + variant_dir = os.path.join(env['build'], 'host'), duplicate = 0, # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html exports={'env':host_env}, ) @@ -187,3 +187,9 @@ SConscript( variant_dir = env['build'], duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html ) + +SConscript( + 'progs/SConscript', + variant_dir = os.path.join('progs', env['build']), + duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html +) diff --git a/docs/install.html b/docs/install.html index 8c24cee7a3..5aea92e0b5 100644 --- a/docs/install.html +++ b/docs/install.html @@ -351,20 +351,11 @@ example linux or windows, machine is x86 or x86_64, optionally followed by -debug for debug builds.

-

-The sample programs are built seperately. To build them do -

-    scons -C progs
-
-And the build output will be placed in progs/build/... -

-

To build Mesa with SCons for Windows on Linux using the MinGW crosscompiler toolchain do

     scons platform=windows toolchain=crossmingw machine=x86 statetrackers=mesa drivers=softpipe,trace winsys=gdi
-    scons -C progs platform=windows toolchain=crossmingw machine=x86 -k
 

This will create: diff --git a/progs/SConscript b/progs/SConscript index 66eaf9e541..3b180d00bc 100644 --- a/progs/SConscript +++ b/progs/SConscript @@ -1,5 +1,43 @@ SConscript([ 'util/SConscript', +]) + +Import('*') + +progs_env = env.Clone() + +if progs_env['platform'] == 'windows': + progs_env.Append(CPPDEFINES = ['NOMINMAX']) + progs_env.Prepend(LIBS = [ + 'winmm', + 'kernel32', + 'user32', + 'gdi32', + ]) + +# OpenGL +if progs_env['platform'] == 'windows': + progs_env.Prepend(LIBS = ['glu32', 'opengl32']) +else: + progs_env.Prepend(LIBS = ['GLU', 'GL']) + +# Glut +progs_env.Prepend(LIBS = [glut]) + +# GLEW +progs_env.Prepend(LIBS = [glew]) + +progs_env.Prepend(CPPPATH = [ + '#progs/util', +]) + +progs_env.Prepend(LIBS = [ + util, +]) + +Export('progs_env') + +SConscript([ 'demos/SConscript', 'glsl/SConscript', 'redbook/SConscript', diff --git a/progs/SConstruct b/progs/SConstruct deleted file mode 100644 index 4d268cc6d7..0000000000 --- a/progs/SConstruct +++ /dev/null @@ -1,65 +0,0 @@ -import os -import os.path -import sys - -env = Environment( - tools = ['generic'], - toolpath = ['../scons'], - ENV = os.environ, -) - - -# Use Mesa's headers and libs -if 1: - build_topdir = 'build' - build_subdir = env['platform'] - if env['machine'] != 'generic': - build_subdir += '-' + env['machine'] - if env['debug']: - build_subdir += "-debug" - if env['profile']: - build_subdir += "-profile" - build_dir = os.path.join(build_topdir, build_subdir) - - env.Append(CPPDEFINES = ['GLEW_STATIC']) - env.Append(CPPPATH = ['#../include']) - env.Append(LIBPATH = [ - '#../' + build_dir + '/glew/', - '#../' + build_dir + '/glut/glx', - ]) - - -conf = Configure(env) - -# OpenGL -if env['platform'] == 'windows': - env.Prepend(LIBS = ['glu32', 'opengl32']) -else: - env.Prepend(LIBS = ['GLU', 'GL']) - -# Glut -env['GLUT'] = False -if conf.CheckCHeader('GL/glut.h'): - if env['platform'] == 'windows': - env['GLUT_LIB'] = 'glut32' - else: - env['GLUT_LIB'] = 'glut' - env['GLUT'] = True - -# GLEW -env['GLEW'] = False -if conf.CheckCHeader('GL/glew.h'): - env['GLEW_LIB'] = 'glew' - env['GLEW'] = True - env.Prepend(LIBS = ['glew']) - -conf.Finish() - - -Export('env') - -SConscript( - 'SConscript', - build_dir = env['build'], - duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html -) diff --git a/progs/demos/SConscript b/progs/demos/SConscript index f851870bcf..742dd66f36 100644 --- a/progs/demos/SConscript +++ b/progs/demos/SConscript @@ -1,84 +1,66 @@ Import('*') -if not env['GLUT']: - Return() - -env = env.Clone() - -env.Prepend(CPPPATH = [ - '../util', -]) - -env.Prepend(LIBS = [ - util, - '$GLUT_LIB' -]) - -if env['platform'] == 'windows': - env.Append(CPPDEFINES = ['NOMINMAX']) - env.Prepend(LIBS = ['winmm']) - progs = [ - 'arbfplight', - 'arbfslight', - 'arbocclude', - 'bounce', - 'clearspd', - 'copypix', - 'cubemap', - 'drawpix', - 'engine', - 'fbo_firecube', - 'fire', - 'fogcoord', - 'fplight', - 'fslight', - 'gamma', - 'gearbox', - 'gears', - 'geartrain', - 'glinfo', - 'gloss', - 'gltestperf', - 'ipers', - 'isosurf', - 'lodbias', - 'morph3d', - 'multiarb', - 'paltex', - 'pointblast', - 'ray', - 'readpix', - 'reflect', - 'renormal', - 'shadowtex', - 'singlebuffer', - 'spectex', - 'spriteblast', - 'stex3d', - 'teapot', - 'terrain', - 'tessdemo', - 'texcyl', - 'texenv', - 'textures', - 'trispd', - 'tunnel', - 'tunnel2', - 'vao_demo', - 'winpos', - 'dinoshade', - 'fbotexture', - 'projtex', + 'arbfplight', + 'arbfslight', + 'arbocclude', + 'bounce', + 'clearspd', + 'copypix', + 'cubemap', + 'drawpix', + 'engine', + 'fbo_firecube', + 'fire', + 'fogcoord', + 'fplight', + 'fslight', + 'gamma', + 'gearbox', + 'gears', + 'geartrain', + 'glinfo', + 'gloss', + 'gltestperf', + 'ipers', + 'isosurf', + 'lodbias', + 'morph3d', + 'multiarb', + 'paltex', + 'pointblast', + 'ray', + 'readpix', + 'reflect', + 'renormal', + 'shadowtex', + 'singlebuffer', + 'spectex', + 'spriteblast', + 'stex3d', + 'teapot', + 'terrain', + 'tessdemo', + 'texcyl', + 'texenv', + 'textures', + 'trispd', + 'tunnel', + 'tunnel2', + 'vao_demo', + 'winpos', + 'dinoshade', + 'fbotexture', + 'projtex', ] for prog in progs: - env.Program( + progs_env.Program( target = prog, source = prog + '.c', ) -env.Program( +progs_env.Program( target = 'rain', source = [ 'rain.cxx', diff --git a/progs/fp/SConscript b/progs/fp/SConscript index a78318542c..113e11ab54 100644 --- a/progs/fp/SConscript +++ b/progs/fp/SConscript @@ -1,15 +1,4 @@ -Import('env') - -if not env['GLUT']: - Return() - -env = env.Clone() - -env.Prepend(CPPPATH = [ - '../util', -]) - -env.Prepend(LIBS = ['$GLUT_LIB']) +Import('*') progs = [ 'fp-tri', @@ -24,7 +13,7 @@ progs = [ ] for prog in progs: - env.Program( + progs_env.Program( target = prog, source = [prog + '.c'], ) diff --git a/progs/glsl/SConscript b/progs/glsl/SConscript index 7a4549cd70..8f2ebcf69c 100644 --- a/progs/glsl/SConscript +++ b/progs/glsl/SConscript @@ -1,23 +1,5 @@ Import('*') -if not env['GLUT']: - Return() - -env = env.Clone() - -env.Prepend(CPPPATH = [ - '../util', -]) - -env.Prepend(LIBS = [ - util, - '$GLUT_LIB' -]) - -if env['platform'] == 'windows': - env.Append(CPPDEFINES = ['NOMINMAX']) - env.Prepend(LIBS = ['winmm']) - progs = [ 'array', 'bitmap', @@ -48,7 +30,7 @@ progs = [ ] for prog in progs: - env.Program( + progs_env.Program( target = prog, source = prog + '.c', ) diff --git a/progs/perf/SConscript b/progs/perf/SConscript index a5ec9a7c2a..691478ab64 100644 --- a/progs/perf/SConscript +++ b/progs/perf/SConscript @@ -1,11 +1,4 @@ -Import('env') - -if not env['GLUT']: - Return() - -env = env.Clone() - -env.Prepend(LIBS = ['$GLUT_LIB']) +Import('*') progs = [ 'copytex', @@ -21,7 +14,7 @@ progs = [ ] for prog in progs: - env.Program( + progs_env.Program( target = prog, source = [ prog + '.c', diff --git a/progs/redbook/SConscript b/progs/redbook/SConscript index 242cb6647f..24d7cff1b6 100644 --- a/progs/redbook/SConscript +++ b/progs/redbook/SConscript @@ -1,23 +1,5 @@ Import('*') -if not env['GLUT']: - Return() - -env = env.Clone() - -env.Prepend(CPPPATH = [ - '../util', -]) - -env.Prepend(LIBS = [ - util, - '$GLUT_LIB' -]) - -if env['platform'] == 'windows': - env.Append(CPPDEFINES = ['NOMINMAX']) - env.Prepend(LIBS = ['winmm']) - progs = [ 'aaindex', 'aapoly', @@ -85,7 +67,7 @@ progs = [ ] for prog in progs: - env.Program( + progs_env.Program( target = prog, source = prog + '.c', ) diff --git a/progs/samples/SConscript b/progs/samples/SConscript index 7a8a0d62d8..134dfa9980 100644 --- a/progs/samples/SConscript +++ b/progs/samples/SConscript @@ -1,23 +1,5 @@ Import('*') -if not env['GLUT']: - Return() - -env = env.Clone() - -env.Prepend(CPPPATH = [ - '../util', -]) - -env.Prepend(LIBS = [ - util, - '$GLUT_LIB' -]) - -if env['platform'] == 'windows': - env.Append(CPPDEFINES = ['NOMINMAX']) - env.Prepend(LIBS = ['winmm']) - progs = [ 'accum', 'bitmap1', @@ -52,7 +34,7 @@ progs = [ ] for prog in progs: - env.Program( + progs_env.Program( target = prog, source = prog + '.c', ) diff --git a/progs/tests/SConscript b/progs/tests/SConscript index ae6488b3e6..e2c6538288 100644 --- a/progs/tests/SConscript +++ b/progs/tests/SConscript @@ -1,23 +1,5 @@ Import('*') -if not env['GLUT']: - Return() - -env = env.Clone() - -env.Prepend(CPPPATH = [ - '../util', -]) - -env.Prepend(LIBS = [ - util, - '$GLUT_LIB' -]) - -if env['platform'] == 'windows': - env.Append(CPPDEFINES = ['NOMINMAX']) - env.Prepend(LIBS = ['winmm']) - linux_progs = [ 'api_speed', ] @@ -140,7 +122,7 @@ progs = [ ] for prog in progs: - env.Program( + progs_env.Program( target = prog, source = prog + '.c', ) diff --git a/progs/trivial/SConscript b/progs/trivial/SConscript index 9a1f3575bd..613383c77b 100644 --- a/progs/trivial/SConscript +++ b/progs/trivial/SConscript @@ -1,11 +1,4 @@ -Import('env') - -if not env['GLUT']: - Return() - -env = env.Clone() - -env.Prepend(LIBS = ['$GLUT_LIB']) +Import('*') progs = [ 'clear-fbo-tex', @@ -154,7 +147,7 @@ progs = [ ] for prog in progs: - prog = env.Program( + prog = progs_env.Program( target = prog, source = prog + '.c', ) diff --git a/progs/vp/SConscript b/progs/vp/SConscript index 640c5dd847..787cb793af 100644 --- a/progs/vp/SConscript +++ b/progs/vp/SConscript @@ -1,13 +1,6 @@ -Import('env') +Import('*') -if not env['GLUT']: - Return() - -env = env.Clone() - -env.Prepend(LIBS = ['$GLUT_LIB']) - -env.Program( +progs_env.Program( target = 'vp-tris', source = ['vp-tris.c'], ) diff --git a/progs/vpglsl/SConscript b/progs/vpglsl/SConscript index 640c5dd847..787cb793af 100644 --- a/progs/vpglsl/SConscript +++ b/progs/vpglsl/SConscript @@ -1,13 +1,6 @@ -Import('env') +Import('*') -if not env['GLUT']: - Return() - -env = env.Clone() - -env.Prepend(LIBS = ['$GLUT_LIB']) - -env.Program( +progs_env.Program( target = 'vp-tris', source = ['vp-tris.c'], ) diff --git a/progs/wgl/SConscript b/progs/wgl/SConscript index 31f61676de..248cc53a8d 100644 --- a/progs/wgl/SConscript +++ b/progs/wgl/SConscript @@ -1,25 +1,17 @@ Import('*') -if env['platform'] != 'windows': +if progs_env['platform'] != 'windows': Return() -env = env.Clone() - -env.Append(LIBS = [ - 'kernel32', - 'user32', - 'gdi32', -]) - progs = [ 'sharedtex_mt', 'wglthreads', ] for prog in progs: - env.Program( + progs_env.Program( target = prog, source = prog + '/' + prog + '.c', ) -env.Program('wglinfo', ['wglinfo.c']) +progs_env.Program('wglinfo', ['wglinfo.c']) diff --git a/src/glew/SConscript b/src/glew/SConscript index 1161be6e63..b4541a7c26 100644 --- a/src/glew/SConscript +++ b/src/glew/SConscript @@ -7,7 +7,7 @@ env = env.Clone() env.Append(CPPDEFINES = [ 'GLEW_BUILD', - 'GLEW_STATIC', + #'GLEW_STATIC', #'GLEW_MX', # Multiple Rendering Contexts support ]) @@ -15,15 +15,6 @@ env.PrependUnique(CPPPATH = [ '#/include', ]) -glew = env.StaticLibrary( - target = 'glew', - source = [ - 'glew.c', - ], -) - -env = env.Clone() - if env['platform'] == 'windows': env.PrependUnique(LIBS = [ 'glu32', @@ -37,6 +28,24 @@ else: 'GL', 'X11', ]) + +if env['platform'] == 'windows': + target = 'glew' +else: + target = 'GLEW' + +glew = env.SharedLibrary( + target = target, + source = [ + 'glew.c', + ], +) + +if env['platform'] == 'windows': + glew = env.FindIxes(glew, 'LIBPREFIX', 'LIBSUFFIX') + +env = env.Clone() + env.Prepend(LIBS = [glew]) env.Program( @@ -48,3 +57,5 @@ env.Program( target = 'visualinfo', source = ['visualinfo.c'], ) + +Export('glew') diff --git a/src/glut/glx/SConscript b/src/glut/glx/SConscript index 938fec03df..5234e6d58a 100644 --- a/src/glut/glx/SConscript +++ b/src/glut/glx/SConscript @@ -2,11 +2,6 @@ Import('*') env = env.Clone() -if env['platform'] != 'windows': - Return() - -target = 'glut32' - env.Replace(CPPDEFINES = [ 'BUILD_GLUT32', 'GLUT_BUILDING_LIB', @@ -18,14 +13,6 @@ env.AppendUnique(CPPPATH = [ '#/include', ]) -env.PrependUnique(LIBS = [ - 'winmm', - 'gdi32', - 'user32', - 'opengl32', - 'glu32', -]) - sources = [ 'glut_bitmap.c', 'glut_bwidth.c', @@ -61,12 +48,6 @@ sources = [ 'glut_warp.c', 'glut_win.c', 'glut_winmisc.c', - - 'win32_glx.c', - 'win32_menu.c', - 'win32_util.c', - 'win32_winproc.c', - 'win32_x11.c', 'glut_8x13.c', 'glut_9x15.c', @@ -77,11 +58,52 @@ sources = [ 'glut_roman.c', 'glut_tr10.c', 'glut_tr24.c', - - 'glut.def', ] -env.SharedLibrary( +if env['platform'] == 'windows': + env.PrependUnique(LIBS = [ + 'winmm', + 'gdi32', + 'user32', + 'opengl32', + 'glu32', + ]) + target = 'glut32' + sources += [ + 'win32_glx.c', + 'win32_menu.c', + 'win32_util.c', + 'win32_winproc.c', + 'win32_x11.c', + 'glut.def', + ] +else: + env.PrependUnique(LIBS = [ + 'GLU', + 'GL', + 'X11', + 'Xext', + 'Xmu', + 'Xi', + ]) + target = 'glut' + sources += [ + 'glut_fcb.c', + 'glut_menu.c', + 'glut_menu2.c', + 'glut_glxext.c', + 'layerutil.c', + ] + + +glut = env.SharedLibrary( target = target, source = sources, ) + +env.InstallSharedLibrary(glut, version=(3, 7, 1)) + +if env['platform'] == 'windows': + glut = env.FindIxes(glut, 'LIBPREFIX', 'LIBSUFFIX') + +Export('glut') -- cgit v1.2.3