Commit 54a5e50c authored by Chad Versace's avatar Chad Versace

texline: Remove test

The texline test did not probe any pixels and was not listed in all.tests.
It was not a test at all.

This patch also removes directory tests/mesa, because the utility
functions defined there were only used by texline.

CC: Eric Anholt <eric@anholt.net>
Reviewed-by: Brian Paul's avatarBrian Paul <brianp@vmware.com>
Signed-off-by: default avatarChad Versace <chad.versace@linux.intel.com>
parent f63c6796
......@@ -28,7 +28,3 @@ ENDIF(OPENGL_egl_LIBRARY)
IF(BUILD_CL_TESTS)
add_subdirectory (cl)
ENDIF(BUILD_CL_TESTS)
IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
add_subdirectory (mesa)
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
add_subdirectory (util)
add_subdirectory (tests)
include_directories(
${GLEXT_INCLUDE_DIR}
${OPENGL_INCLUDE_PATH}
${PNG_INCLUDE_DIR}
${piglit_SOURCE_DIR}/tests/mesa/util
)
link_libraries (
${OPENGL_gl_LIBRARY}
${OPENGL_glu_LIBRARY}
${PNG_LIBRARIES}
mesautil
)
add_definitions (
${PNG_DEFINITIONS}
)
piglit_add_executable (texline texline.c)
IF (UNIX)
target_link_libraries (texline m)
ENDIF (UNIX)
# vim: ft=cmake:
/* $Id: texline.c,v 1.5 2004/01/28 10:07:48 keithw Exp $ */
/*
* Test textured lines.
*
* Brian Paul
* September 2000
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <GL/glut.h>
#include "../util/readtex.h"
#include "../util/writeimg.h"
#define TEXTURE_FILE "mesa/girl.rgb"
static int Width = 400, Height = 300;
static int Automatic = 0;
static const char* ScreenshotFile = 0;
static void DoStar(int texture)
{
int l;
glPushMatrix();
glScalef(0.5, 0.5, 1.0);
glTranslatef(1.0, 1.0, 0.0);
glBegin(GL_LINES);
for(l = 0; l < 30; ++l) {
double rad = l*M_PI/15.0;
double dx = cos(rad);
double dy = sin(rad);
if (texture >= 1)
glTexCoord2f(l/30.0, 0.0);
if (texture >= 2)
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0, l/30.0);
if (texture == 0)
glColor3f(0, 1, 0);
glVertex2f(dx*0.2, dy*0.2);
if (texture >= 1)
glTexCoord2f(l/30.0, 1.0);
if (texture >= 2)
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 1.0, l/30.0);
if (texture == 0)
glColor3f(1, 0, 1);
glVertex2f(dx*0.8, dy*0.8);
}
glEnd();
glColor3f(1,1,1);
glPopMatrix();
}
static void DoFrame(void)
{
int texture;
glClearColor(0.0, 0.0, 0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
for(texture = 0; texture < 3; ++texture) {
glPushMatrix();
glTranslatef(0, texture, 0);
if (texture == 0) {
glActiveTextureARB(GL_TEXTURE0_ARB);
glDisable(GL_TEXTURE_2D);
glActiveTextureARB(GL_TEXTURE1_ARB);
glDisable(GL_TEXTURE_2D);
}
else if (texture == 1) {
glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
glActiveTextureARB(GL_TEXTURE1_ARB);
glDisable(GL_TEXTURE_2D);
}
else {
glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);
}
glDisable(GL_LINE_SMOOTH);
glDisable(GL_BLEND);
glDisable(GL_LINE_STIPPLE);
DoStar(texture);
glTranslatef(1, 0, 0);
glEnable(GL_LINE_STIPPLE);
DoStar(texture);
glTranslatef(1, 0, 0);
glEnable(GL_LINE_SMOOTH);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDisable(GL_LINE_STIPPLE);
DoStar(texture);
glTranslatef(1, 0, 0);
glEnable(GL_LINE_STIPPLE);
DoStar(texture);
glPopMatrix();
}
glutSwapBuffers();
}
static void Screenshot(void)
{
GLubyte shot[400][300][3];
glReadBuffer(GL_FRONT);
glReadPixels(0, 0, 400, 300, GL_RGB, GL_UNSIGNED_BYTE, shot);
WritePNGImage(ScreenshotFile, GL_RGB, 400, 300, (GLubyte*)shot, 1);
}
static void Display(void)
{
DoFrame();
if (Automatic) {
Screenshot();
printf("PIGLIT: { }\n");
exit(0);
}
}
static void Reshape(int width, int height)
{
Width = width;
Height = height;
glViewport(0, 0, Width, Height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 4.0, 0.0, 3.0, -1.0, 1.0);
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
}
static void Key( unsigned char key, int x, int y )
{
(void) x;
(void) y;
switch (key) {
case 27:
exit(0);
break;
}
}
static void Init( int argc, char *argv[] )
{
GLuint u;
for (u = 0; u < 2; u++) {
char filename[256];
glActiveTextureARB(GL_TEXTURE0_ARB + u);
glBindTexture(GL_TEXTURE_2D, 10+u);
if (u == 0)
glEnable(GL_TEXTURE_2D);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
if (u == 0)
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
else
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
if (getenv("DATADIR"))
snprintf(filename, sizeof(filename), "%s/%s",
getenv("DATADIR"), TEXTURE_FILE);
else
strcpy(filename, TEXTURE_FILE);
if (!LoadRGBMipmaps(filename, GL_RGB)) {
printf("Error: couldn't load texture image\n");
if (Automatic)
printf("PIGLIT: {'result': 'fail' }\n");
exit(1);
}
}
glLineStipple(1, 0xff);
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
printf("GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
printf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS));
Reshape(Width, Height);
}
int main( int argc, char *argv[] )
{
glutInit( &argc, argv );
if (argc == 3 && !strcmp(argv[1], "-auto")) {
Automatic = 1;
ScreenshotFile = argv[2];
}
glutInitWindowPosition(0, 0);
glutInitWindowSize(Width, Height);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
glutCreateWindow("texline");
Init(argc, argv);
glutReshapeFunc(Reshape);
glutKeyboardFunc(Key);
glutDisplayFunc(Display);
glutMainLoop();
return 0;
}
include_directories (
${GLEXT_INCLUDE_DIR}
${OPENGL_INCLUDE_PATH}
${PNG_INCLUDE_DIR}
)
link_libraries (
piglitutil_${piglit_target_api}
${OPENGL_gl_LIBRARY}
${OPENGL_glu_LIBRARY}
${PNG_LIBRARIES}
)
add_definitions (
${PNG_DEFINITIONS}
)
piglit_add_library (mesautil
readtex.c
writeimg.c
)
# vim: ft=cmake:
piglit_include_target_api()
This diff is collapsed.
/* readtex.h */
#ifndef READTEX_H
#define READTEX_H
#include <GL/gl.h>
extern GLboolean
LoadRGBMipmaps( const char *imageFile, GLint intFormat );
extern GLboolean
LoadRGBMipmaps2( const char *imageFile, GLenum target,
GLint intFormat, GLint *width, GLint *height );
extern GLubyte *
LoadRGBImage( const char *imageFile,
GLint *width, GLint *height, GLenum *format );
extern GLushort *
LoadYUVImage( const char *imageFile, GLint *width, GLint *height );
#endif
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <png.h>
#include <GL/gl.h>
static void abortf(const char * s, ...)
{
va_list args;
va_start(args, s);
vfprintf(stderr, s, args);
fprintf(stderr, "\n");
va_end(args);
abort();
}
/**
* Write RGB or RGBA data to a PNG file.
* format must be GL_RGB or GL_RGBA.
*/
void WritePNGImage(const char* filename,
GLenum format, int width, int height, GLubyte* data, int reverse)
{
FILE* fp;
png_structp png;
png_infop info;
int bytes;
int colortype;
int y;
GLubyte* row;
if (format == GL_RGBA) {
colortype = PNG_COLOR_TYPE_RGB_ALPHA;
bytes = 4;
} else if (format == GL_RGB) {
colortype = PNG_COLOR_TYPE_RGB;
bytes = 3;
} else {
abortf("Unknown format %04x", format);
}
fp = fopen(filename, "wb");
if (!fp)
abortf("Failed to open %s", filename);
png = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (!png)
abortf("png_create_write_struct failed");
info = png_create_info_struct(png);
if (!info)
abortf("png_create_info_struct failed");
if (setjmp(png_jmpbuf(png)))
abortf("png_init_io failed");
png_init_io(png, fp);
/* write header */
if (setjmp(png_jmpbuf(png)))
abortf("Write error");
png_set_IHDR(png, info, width, height,
8, colortype, PNG_INTERLACE_NONE,
PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
png_write_info(png, info);
if (reverse)
row = data + (height*width*bytes);
else
row = data;
for(y = 0; y < height; ++y) {
if (reverse)
row -= width*bytes;
png_write_row(png, row);
if (!reverse)
row += width*bytes;
}
png_write_end(png, 0);
fclose(fp);
}
#ifndef writeimg_h
#define writeimg_h
void WritePNGImage(const char* filename,
GLenum format, int width, int height, GLubyte* data, int reverse);
#endif /* writeimg_h */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment