58 lines
1.8 KiB
C
58 lines
1.8 KiB
C
/*
|
|
* shaders implementation
|
|
*
|
|
* Copyright 2002-2003 Jason Edmeades
|
|
* Copyright 2002-2003 Raphael Junqueira
|
|
* Copyright 2005 Oliver Stieber
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
* License along with this library; if not, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
*/
|
|
|
|
#include "config.h"
|
|
#include <string.h>
|
|
#include <stdio.h>
|
|
#include "wined3d_private.h"
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader);
|
|
|
|
int shader_addline(
|
|
SHADER_BUFFER* buffer,
|
|
const char *format, ...) {
|
|
|
|
char* base = buffer->buffer + buffer->bsize;
|
|
int rc;
|
|
|
|
va_list args;
|
|
va_start(args, format);
|
|
rc = vsnprintf(base, SHADER_PGMSIZE - 1 - buffer->bsize, format, args);
|
|
va_end(args);
|
|
|
|
if (rc < 0 || /* C89 */
|
|
rc > SHADER_PGMSIZE - 1 - buffer->bsize) { /* C99 */
|
|
|
|
ERR("The buffer allocated for the shader program string "
|
|
"is too small at %d bytes.\n", SHADER_PGMSIZE);
|
|
buffer->bsize = SHADER_PGMSIZE - 1;
|
|
return -1;
|
|
}
|
|
|
|
buffer->bsize += rc;
|
|
buffer->lineNo++;
|
|
TRACE("GL HW (%u, %u) : %s", buffer->lineNo, buffer->bsize, base);
|
|
return 0;
|
|
}
|
|
|
|
/* TODO: Move other shared code here */
|