Go Back   nV News Forums > Linux Support Forums > NVIDIA Linux

Newegg Daily Deals

Reply
 
Thread Tools
Old 08-03-07, 12:25 AM   #1
AndreasM
Registered User
 
Join Date: Aug 2007
Posts: 1
Default Problem with glUniform1f in 100.14.11 on 8800GTS

For some reason I'm unable to pass floats to shaders. Whatever values i use for the second argument in glUniform1f the float variable it sets inside the shader stays zero. I'm using version 100.14.11 of the drivers on a 8800GTS 320mb.

This test program should draw a yellow triangle, but only draws a green one because glUniform1f fails to set var1 to 1.0.
Code:
#include <GL/gl.h>
#include <GL/glx.h>
#include <stdio.h>
#include <stdlib.h>

GLuint program = 0;

static void redraw( Display *dpy, Window w )
{
   printf("Redraw event\n");

   glClear( GL_COLOR_BUFFER_BIT );

   glTranslatef(-1.5f,0.0f,-6.0f);
   glLoadIdentity();

   glUseProgram(program);

   glUniform1f(glGetUniformLocation(program, "var1"), 1.0f);
   glUniform1i(glGetUniformLocation(program, "var2"), 1);

   glBegin(GL_TRIANGLES);

	glVertex3f( 0.0f, 1.0f, 0.0f);
	glVertex3f(-1.0f,-1.0f, 0.0f);
	glVertex3f( 1.0f,-1.0f, 0.0f);

   glEnd();

   glXSwapBuffers( dpy, w );
}



static void resize( unsigned int width, unsigned int height )
{
   printf("Resize event\n");
   glViewport( 0, 0, width, height );
   glMatrixMode( GL_PROJECTION );
   glLoadIdentity();
   glOrtho( -1.0, 1.0, -1.0, 1.0, -1.0, 1.0 );
}



static Window make_rgb_db_window( Display *dpy,
				  unsigned int width, unsigned int height )
{
   int attrib[] = { GLX_RGBA,
		    GLX_RED_SIZE, 1,
		    GLX_GREEN_SIZE, 1,
		    GLX_BLUE_SIZE, 1,
		    GLX_DOUBLEBUFFER,
		    None };
   int scrnum;
   XSetWindowAttributes attr;
   unsigned long mask;
   Window root;
   Window win;
   GLXContext ctx;
   XVisualInfo *visinfo;

   scrnum = DefaultScreen( dpy );
   root = RootWindow( dpy, scrnum );

   visinfo = glXChooseVisual( dpy, scrnum, attrib );
   if (!visinfo) {
      printf("Error: couldn't get an RGB, Double-buffered visual\n");
      exit(1);
   }

   /* window attributes */
   attr.background_pixel = 0;
   attr.border_pixel = 0;
   attr.colormap = XCreateColormap( dpy, root, visinfo->visual, AllocNone);
   attr.event_mask = StructureNotifyMask | ExposureMask;
   mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;

   win = XCreateWindow( dpy, root, 0, 0, width, height,
		        0, visinfo->depth, InputOutput,
		        visinfo->visual, mask, &attr );

   ctx = glXCreateContext( dpy, visinfo, NULL, True );
   if (!ctx) {
      printf("Error: glXCreateContext failed\n");
      exit(1);
   }

   glXMakeCurrent( dpy, win, ctx );

   return win;
}


static void event_loop( Display *dpy )
{
   XEvent event;

   while (1) {
      XNextEvent( dpy, &event );

      switch (event.type) {
	 case Expose:
	    redraw( dpy, event.xany.window );
	    break;
	 case ConfigureNotify:
	    resize( event.xconfigure.width, event.xconfigure.height );
	    break;
      }
   }
}

static const char *shadercode = 
"uniform float var1;\
uniform int var2;\
\
void main(void)\
{\
   gl_FragColor = vec4(var1, var2, 0.0, 1.0);\
}";

int main( int argc, char *argv[] )
{
   Display *dpy;
   Window win;
   GLuint shader;

   dpy = XOpenDisplay(NULL);

   win = make_rgb_db_window( dpy, 300, 300 );

   shader = glCreateShader(GL_FRAGMENT_SHADER);

   program = glCreateProgram();

   glShaderSource(shader, 1, &shadercode, NULL);

   glCompileShader(shader);

   glAttachShader(program, shader);

   glLinkProgram(program);
   glDeleteShader(shader);

   XMapWindow( dpy, win );

   event_loop( dpy );
   return 0;
}
Attached Files
File Type: log nvidia-bug-report.log (131.6 KB, 255 views)
AndreasM is offline   Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem connecting Pioneer VSX-S300 to Nvidia Ion - flat panel scaling solves it? wild_oscar NVIDIA Linux 3 06-17-12 07:18 AM
Post working out problem with 40.xx trying to work problem out, ONLY system specs b5fan NVIDIA Windows Graphics Drivers 11 10-19-02 09:17 AM
nv30 problem rumor bob747b Rumor Mill 37 10-10-02 03:14 PM
kswapd kernel problem and the NVdriver kwaz NVIDIA Linux 2 09-25-02 08:33 PM
Nvidia Go on laptop, black border within XFree86 problem raxip NVIDIA Linux 3 07-31-02 10:58 AM

All times are GMT -5. The time now is 03:31 AM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright 1998 - 2014, nV News.