summaryrefslogtreecommitdiff
path: root/progs/samples
diff options
context:
space:
mode:
authorJosé Fonseca <jfonseca@vmware.com>2010-01-08 15:42:57 +0000
committerJosé Fonseca <jfonseca@vmware.com>2010-01-08 15:42:57 +0000
commit080c40ab32b2abd6d8381b4a0cc143d36a1652b2 (patch)
treee173767ebc5a82d81b9fc086449d915e29348976 /progs/samples
parent9cdf6f025b2ed55cfb13dd09f870f01d0c7947d3 (diff)
parenta1de400e8de06a80ab140bb0fa950e990607572d (diff)
Merge remote branch 'origin/master' into lp-binning
Conflicts: src/gallium/auxiliary/util/u_surface.c src/gallium/drivers/llvmpipe/Makefile src/gallium/drivers/llvmpipe/SConscript src/gallium/drivers/llvmpipe/lp_bld_arit.c src/gallium/drivers/llvmpipe/lp_bld_flow.c src/gallium/drivers/llvmpipe/lp_bld_interp.c src/gallium/drivers/llvmpipe/lp_clear.c src/gallium/drivers/llvmpipe/lp_context.c src/gallium/drivers/llvmpipe/lp_context.h src/gallium/drivers/llvmpipe/lp_draw_arrays.c src/gallium/drivers/llvmpipe/lp_jit.c src/gallium/drivers/llvmpipe/lp_jit.h src/gallium/drivers/llvmpipe/lp_prim_vbuf.c src/gallium/drivers/llvmpipe/lp_setup.c src/gallium/drivers/llvmpipe/lp_setup_point.c src/gallium/drivers/llvmpipe/lp_state.h src/gallium/drivers/llvmpipe/lp_state_blend.c src/gallium/drivers/llvmpipe/lp_state_derived.c src/gallium/drivers/llvmpipe/lp_state_fs.c src/gallium/drivers/llvmpipe/lp_state_sampler.c src/gallium/drivers/llvmpipe/lp_state_surface.c src/gallium/drivers/llvmpipe/lp_tex_cache.c src/gallium/drivers/llvmpipe/lp_tex_cache.h src/gallium/drivers/llvmpipe/lp_tex_sample.h src/gallium/drivers/llvmpipe/lp_tile_cache.c
Diffstat (limited to 'progs/samples')
-rw-r--r--progs/samples/.gitignore1
-rw-r--r--progs/samples/Makefile2
-rw-r--r--progs/samples/SConscript20
-rw-r--r--progs/samples/olympic.c20
-rw-r--r--progs/samples/overlay.c18
-rw-r--r--progs/samples/rgbtoppm.c42
-rw-r--r--progs/samples/sphere.c30
-rw-r--r--progs/samples/star.c20
-rw-r--r--progs/samples/stretch.c20
-rw-r--r--progs/samples/wave.c2
10 files changed, 88 insertions, 87 deletions
diff --git a/progs/samples/.gitignore b/progs/samples/.gitignore
index f60d6e94ea..c15b886b88 100644
--- a/progs/samples/.gitignore
+++ b/progs/samples/.gitignore
@@ -36,6 +36,7 @@ prim
quad
readtex.c
readtex.h
+rgbtoppm
select
shape
sphere
diff --git a/progs/samples/Makefile b/progs/samples/Makefile
index b300e38b9c..64fa47addb 100644
--- a/progs/samples/Makefile
+++ b/progs/samples/Makefile
@@ -10,7 +10,7 @@ LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) $(T
LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
PROGS = accum bitmap1 bitmap2 blendeq blendxor copy cursor depth eval fog \
- font line logo nurb olympic overlay point prim quad select \
+ font line logo nurb olympic overlay point prim rgbtoppm quad select \
shape sphere star stencil stretch texture tri wave
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/samples/olympic.c b/progs/samples/olympic.c
index 5385e48702..209a8c141b 100644
--- a/progs/samples/olympic.c
+++ b/progs/samples/olympic.c
@@ -74,7 +74,7 @@ int iters[RINGS];
GLuint theTorus;
-void FillTorus(float rc, int numc, float rt, int numt)
+static void FillTorus(float rc, int numc, float rt, int numt)
{
int i, j, k;
double s, t;
@@ -106,7 +106,7 @@ void FillTorus(float rc, int numc, float rt, int numt)
}
}
-float Clamp(int iters_left, float t)
+static float Clamp(int iters_left, float t)
{
if (iters_left < 3) {
return 0.0;
@@ -114,7 +114,7 @@ float Clamp(int iters_left, float t)
return (iters_left-2)*t/iters_left;
}
-void DrawScene(void)
+static void DrawScene(void)
{
int i, j;
GLboolean goIdle;
@@ -172,7 +172,7 @@ void DrawScene(void)
}
}
-float MyRand(void)
+static float MyRand(void)
{
return 10.0 * ( (float) rand() / (float) RAND_MAX - 0.5 );
}
@@ -181,12 +181,12 @@ float MyRand(void)
#define GLUTCALLBACK
#endif
-void GLUTCALLBACK glut_post_redisplay_p(void)
+static void GLUTCALLBACK glut_post_redisplay_p(void)
{
glutPostRedisplay();
}
-void ReInit(void)
+static void ReInit(void)
{
int i;
float deviation;
@@ -206,7 +206,7 @@ void ReInit(void)
glutIdleFunc(glut_post_redisplay_p);
}
-void Init(void)
+static void Init(void)
{
float base, height;
float aspect, x, y;
@@ -312,13 +312,13 @@ void Init(void)
glMatrixMode(GL_MODELVIEW);
}
-void Reshape(int width, int height)
+static void Reshape(int width, int height)
{
glViewport(0, 0, width, height);
}
-void Key(unsigned char key, int x, int y)
+static void Key(unsigned char key, int x, int y)
{
switch (key) {
@@ -330,7 +330,7 @@ void Key(unsigned char key, int x, int y)
}
}
-GLenum Args(int argc, char **argv)
+static GLenum Args(int argc, char **argv)
{
GLint i;
diff --git a/progs/samples/overlay.c b/progs/samples/overlay.c
index 23b5a4793b..6087cef281 100644
--- a/progs/samples/overlay.c
+++ b/progs/samples/overlay.c
@@ -69,19 +69,19 @@ starRec stars[MAXSTARS];
float sinTable[MAXANGLES];
-float Sin(float angle)
+static float Sin(float angle)
{
return (sinTable[(GLint)angle]);
}
-float Cos(float angle)
+static float Cos(float angle)
{
return (sinTable[((GLint)angle+(MAXANGLES/4))%MAXANGLES]);
}
-void NewStar(GLint n, GLint d)
+static void NewStar(GLint n, GLint d)
{
if (rand()%4 == 0) {
@@ -103,7 +103,7 @@ void NewStar(GLint n, GLint d)
}
}
-void RotatePoint(float *x, float *y, float rotation)
+static void RotatePoint(float *x, float *y, float rotation)
{
float tmpX, tmpY;
@@ -113,7 +113,7 @@ void RotatePoint(float *x, float *y, float rotation)
*y = tmpY;
}
-void MoveStars(void)
+static void MoveStars(void)
{
float offset;
GLint n;
@@ -134,7 +134,7 @@ void MoveStars(void)
}
}
-GLenum StarPoint(GLint n)
+static GLenum StarPoint(GLint n)
{
float x0, y0, x1, y1, width;
GLint i;
@@ -182,7 +182,7 @@ GLenum StarPoint(GLint n)
}
}
-void ShowStars(void)
+static void ShowStars(void)
{
GLint n;
@@ -221,7 +221,7 @@ static void Init(void)
glDisable(GL_DITHER);
}
-void Reshape(int width, int height)
+static void Reshape(int width, int height)
{
windW = (GLint)width;
@@ -262,7 +262,7 @@ static void Key(unsigned char key, int x, int y)
}
}
-void Idle(void)
+static void Idle(void)
{
if (overlayInit == GL_FALSE) {
diff --git a/progs/samples/rgbtoppm.c b/progs/samples/rgbtoppm.c
index 116d9a8cfa..403578ef42 100644
--- a/progs/samples/rgbtoppm.c
+++ b/progs/samples/rgbtoppm.c
@@ -3,6 +3,7 @@
/* texload is a simplistic routine for reading an SGI .rgb image file. */
+#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -25,7 +26,7 @@ typedef struct _ImageRec {
int *rowSize;
} ImageRec;
-void
+static void
rgbtorgb(unsigned char *r,unsigned char *g,unsigned char *b,unsigned char *l,int n) {
while(n--) {
l[0] = r[0];
@@ -72,6 +73,7 @@ static ImageRec *ImageOpen(char *fileName)
ImageRec *image;
int swapFlag;
int x;
+ int result;
endianTest.testWord = 1;
if (endianTest.testByte[0] == 1) {
@@ -86,13 +88,20 @@ static ImageRec *ImageOpen(char *fileName)
exit(1);
}
if ((image->file = fopen(fileName, "rb")) == NULL) {
- return NULL;
+ free(image);
+ return NULL;
}
- fread(image, 1, 12, image->file);
+ result = fread(image, 1, 12, image->file);
+ assert(result == 12);
if (swapFlag) {
- ConvertShort(&image->imagic, 6);
+ ConvertShort(&image->imagic, 1);
+ ConvertShort(&image->type, 1);
+ ConvertShort(&image->dim, 1);
+ ConvertShort(&image->xsize, 1);
+ ConvertShort(&image->ysize, 1);
+ ConvertShort(&image->zsize, 1);
}
image->tmp = (unsigned char *)malloc(image->xsize*256);
@@ -111,8 +120,10 @@ static ImageRec *ImageOpen(char *fileName)
}
image->rleEnd = 512 + (2 * x);
fseek(image->file, 512, SEEK_SET);
- fread(image->rowStart, 1, x, image->file);
- fread(image->rowSize, 1, x, image->file);
+ result = fread(image->rowStart, 1, x, image->file);
+ assert(result == x);
+ result = fread(image->rowSize, 1, x, image->file);
+ assert(result == x);
if (swapFlag) {
ConvertUint(image->rowStart, x/(int) sizeof(unsigned));
ConvertUint((unsigned *)image->rowSize, x/(int) sizeof(int));
@@ -132,11 +143,13 @@ static void
ImageGetRow(ImageRec *image, unsigned char *buf, int y, int z) {
unsigned char *iPtr, *oPtr, pixel;
int count;
+ int result;
if ((image->type & 0xFF00) == 0x0100) {
fseek(image->file, (long) image->rowStart[y+z*image->ysize], SEEK_SET);
- fread(image->tmp, 1, (unsigned int)image->rowSize[y+z*image->ysize],
- image->file);
+ result = fread(image->tmp, 1, (unsigned int)image->rowSize[y+z*image->ysize],
+ image->file);
+ assert(result == (unsigned int)image->rowSize[y+z*image->ysize]);
iPtr = image->tmp;
oPtr = buf;
@@ -160,11 +173,13 @@ ImageGetRow(ImageRec *image, unsigned char *buf, int y, int z) {
} else {
fseek(image->file, 512+(y*image->xsize)+(z*image->xsize*image->ysize),
SEEK_SET);
- fread(buf, 1, image->xsize, image->file);
+ result = fread(buf, 1, image->xsize, image->file);
+ assert(result == image->xsize);
}
}
-GLubyte *
+#if 0
+static GLubyte *
read_alpha_texture(char *name, int *width, int *height)
{
unsigned char *base, *lptr;
@@ -193,8 +208,9 @@ read_alpha_texture(char *name, int *width, int *height)
return (unsigned char *) base;
}
+#endif
-GLubyte *
+static GLubyte *
read_rgb_texture(char *name, int *width, int *height)
{
unsigned char *base, *ptr;
@@ -224,6 +240,7 @@ read_rgb_texture(char *name, int *width, int *height)
if (gbuf) free(gbuf);
if (bbuf) free(bbuf);
if (abuf) free(abuf);
+ ImageClose(image);
return NULL;
}
ptr = base;
@@ -254,7 +271,8 @@ read_rgb_texture(char *name, int *width, int *height)
int main(int argc, char **argv)
{
- int width, height;
+ int width = 0;
+ int height = 0;
GLubyte *data;
char buff[32];
int n;
diff --git a/progs/samples/sphere.c b/progs/samples/sphere.c
index 7d0508dee9..23d4fe32c0 100644
--- a/progs/samples/sphere.c
+++ b/progs/samples/sphere.c
@@ -445,7 +445,7 @@ GLfloat identity[16] = {
};
-void BuildCylinder(int numEdges)
+static void BuildCylinder(int numEdges)
{
int i, top = 1.0, bottom = -1.0;
float x[100], y[100], angle;
@@ -481,7 +481,7 @@ void BuildCylinder(int numEdges)
glEndList();
}
-void BuildTorus(float rc, int numc, float rt, int numt)
+static void BuildTorus(float rc, int numc, float rt, int numt)
{
int i, j, k;
double s, t;
@@ -515,7 +515,7 @@ void BuildTorus(float rc, int numc, float rt, int numt)
glEndList();
}
-void BuildCage(void)
+static void BuildCage(void)
{
int i;
float inc;
@@ -609,7 +609,7 @@ void BuildCage(void)
glEndList();
}
-void BuildCube(void)
+static void BuildCube(void)
{
int i, j;
@@ -628,7 +628,7 @@ void BuildCube(void)
glEndList();
}
-void BuildLists(void)
+static void BuildLists(void)
{
cube = glGenLists(1);
@@ -646,7 +646,7 @@ void BuildLists(void)
genericObject = torus;
}
-void SetDefaultSettings(void)
+static void SetDefaultSettings(void)
{
magFilter = nnearest;
@@ -657,7 +657,7 @@ void SetDefaultSettings(void)
autoRotate = GL_TRUE;
}
-unsigned char *AlphaPadImage(int bufSize, unsigned char *inData, int alpha)
+static unsigned char *AlphaPadImage(int bufSize, unsigned char *inData, int alpha)
{
unsigned char *outData, *out_ptr, *in_ptr;
int i;
@@ -677,7 +677,7 @@ unsigned char *AlphaPadImage(int bufSize, unsigned char *inData, int alpha)
return outData;
}
-void Init(void)
+static void Init(void)
{
float ambient[] = {0.0, 0.0, 0.0, 1.0};
float diffuse[] = {1.0, 1.0, 1.0, 1.0};
@@ -753,7 +753,7 @@ void Init(void)
BuildLists();
}
-void ReInit(void)
+static void ReInit(void)
{
if (genericObject == torus) {
glEnable(GL_DEPTH_TEST);
@@ -773,7 +773,7 @@ void ReInit(void)
glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, textureEnvironment);
}
-void Draw(void)
+static void Draw(void)
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
@@ -806,7 +806,7 @@ void Draw(void)
glutSwapBuffers();
}
-void Reshape(int width, int height)
+static void Reshape(int width, int height)
{
W = width;
H = height;
@@ -818,7 +818,7 @@ void Reshape(int width, int height)
glMatrixMode(GL_MODELVIEW);
}
-void Idle(void)
+static void Idle(void)
{
static double t0 = -1.;
double t, dt;
@@ -833,7 +833,7 @@ void Idle(void)
glutPostRedisplay();
}
-void Key2(int key, int x, int y)
+static void Key2(int key, int x, int y)
{
switch (key) {
@@ -863,7 +863,7 @@ void Key2(int key, int x, int y)
glutPostRedisplay();
}
-void Key(unsigned char key, int x, int y)
+static void Key(unsigned char key, int x, int y)
{
switch (key) {
@@ -950,7 +950,7 @@ void Key(unsigned char key, int x, int y)
glutPostRedisplay();
}
-GLenum Args(int argc, char **argv)
+static GLenum Args(int argc, char **argv)
{
GLint i;
diff --git a/progs/samples/star.c b/progs/samples/star.c
index 2cf470e2a2..2c44ebfd49 100644
--- a/progs/samples/star.c
+++ b/progs/samples/star.c
@@ -67,19 +67,19 @@ starRec stars[MAXSTARS];
float sinTable[MAXANGLES];
-float Sin(float angle)
+static float Sin(float angle)
{
return (sinTable[(GLint)angle]);
}
-float Cos(float angle)
+static float Cos(float angle)
{
return (sinTable[((GLint)angle+(MAXANGLES/4))%MAXANGLES]);
}
-void NewStar(GLint n, GLint d)
+static void NewStar(GLint n, GLint d)
{
if (rand()%4 == 0) {
@@ -101,7 +101,7 @@ void NewStar(GLint n, GLint d)
}
}
-void RotatePoint(float *x, float *y, float rotation)
+static void RotatePoint(float *x, float *y, float rotation)
{
float tmpX, tmpY;
@@ -111,7 +111,7 @@ void RotatePoint(float *x, float *y, float rotation)
*y = tmpY;
}
-void MoveStars(void)
+static void MoveStars(void)
{
float offset;
GLint n;
@@ -142,7 +142,7 @@ void MoveStars(void)
}
}
-GLenum StarPoint(GLint n)
+static GLenum StarPoint(GLint n)
{
float x0, y0, x1, y1, width;
GLint i;
@@ -190,7 +190,7 @@ GLenum StarPoint(GLint n)
}
}
-void ShowStars(void)
+static void ShowStars(void)
{
GLint n;
@@ -229,7 +229,7 @@ static void Init(void)
glDisable(GL_DITHER);
}
-void Reshape(int width, int height)
+static void Reshape(int width, int height)
{
windW = (GLint)width;
@@ -260,7 +260,7 @@ static void Key(unsigned char key, int x, int y)
}
}
-void Draw(void)
+static void Draw(void)
{
MoveStars();
@@ -307,7 +307,7 @@ static GLenum Args(int argc, char **argv)
#define GLUTCALLBACK
#endif
-void GLUTCALLBACK glut_post_redisplay_p(void)
+static void GLUTCALLBACK glut_post_redisplay_p(void)
{
glutPostRedisplay();
}
diff --git a/progs/samples/stretch.c b/progs/samples/stretch.c
index 1fd015d794..11201dca23 100644
--- a/progs/samples/stretch.c
+++ b/progs/samples/stretch.c
@@ -67,7 +67,7 @@ int cCount, cIndex[2], cStep;
GLenum op = OP_NOOP;
-void DrawImage(void)
+static void DrawImage(void)
{
glRasterPos2i(0, 0);
@@ -84,7 +84,7 @@ void DrawImage(void)
image->data);
}
-void DrawPoint(void)
+static void DrawPoint(void)
{
int i;
@@ -102,7 +102,7 @@ void DrawPoint(void)
}
}
-void InitVList(void)
+static void InitVList(void)
{
vList[0].x = 0.0;
@@ -141,7 +141,7 @@ void InitVList(void)
vList[4].tY = cList[0].y / (float)imageSizeY;
}
-void ScaleImage(int sizeX, int sizeY)
+static void ScaleImage(int sizeX, int sizeY)
{
GLubyte *buf;
@@ -154,7 +154,7 @@ void ScaleImage(int sizeX, int sizeY)
image->sizeY = sizeY;
}
-void SetPoint(int x, int y)
+static void SetPoint(int x, int y)
{
cList[cCount].x = (float)x;
@@ -162,7 +162,7 @@ void SetPoint(int x, int y)
cCount++;
}
-void Stretch(void)
+static void Stretch(void)
{
glBegin(GL_TRIANGLES);
@@ -221,7 +221,7 @@ void Stretch(void)
}
}
-void Key(unsigned char key, int x, int y)
+static void Key(unsigned char key, int x, int y)
{
switch (key) {
@@ -245,7 +245,7 @@ void Key(unsigned char key, int x, int y)
glutPostRedisplay();
}
-void Mouse(int button, int state, int mouseX, int mouseY)
+static void Mouse(int button, int state, int mouseX, int mouseY)
{
if (state != GLUT_DOWN)
@@ -263,7 +263,7 @@ void Mouse(int button, int state, int mouseX, int mouseY)
glutPostRedisplay();
}
-void Animate(void)
+static void Animate(void)
{
static double t0 = -1.;
double t, dt;
@@ -322,7 +322,7 @@ static GLenum Args(int argc, char **argv)
#define GLUTCALLBACK
#endif
-void GLUTCALLBACK glut_post_redisplay_p(void)
+static void GLUTCALLBACK glut_post_redisplay_p(void)
{
glutPostRedisplay();
}
diff --git a/progs/samples/wave.c b/progs/samples/wave.c
index d3c4687459..396a6943e3 100644
--- a/progs/samples/wave.c
+++ b/progs/samples/wave.c
@@ -92,7 +92,7 @@ GLubyte contourTexture2[] = {
#endif
-void GLUTCALLBACK glut_post_redisplay_p(void)
+static void GLUTCALLBACK glut_post_redisplay_p(void)
{
static double t0 = -1.;
double t, dt;