Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Create Shader returns 0

  1. #1
    Member Contributor
    Join Date
    Jun 2015
    Posts
    60

    Create Shader returns 0

    I am trying to add some text an OpenGL context. I found an example on the internet that uses GLEW and GLUT. I need to create three different windows, so I cant use these wrappers. I believe I have correctly integrated the code into my program that draws three windows on three different screens. The screens are just filled with a simple green quad. I want to overlay the text. The text rendering code comes from "OpenGL Programming/Modern OpenGL Tutorial Text Rendering 01" on wikibooks.org

    I will attach the files.

    When I run it, it correctly creates the three windows, the prints out the below output:

    Code :
    $ ./helloglx
    CODE is >#version 120
     
    attribute vec4 coord;
    varying vec2 texpos;
     
    void main(void) {
      gl_Position = vec4(coord.xy, 0, 1);
      texpos = coord.zw;
    }<
    text.v.glsl:printlog: Not a shader or a program
    ^C

    How do I check the shader version that is loaded on my system? Maybe I don't have this version to use.

    Thank you for any help you can provide.
    Attached Files Attached Files

  2. #2
    Member Contributor
    Join Date
    Jun 2015
    Posts
    60
    added a check for return on shader. It does return 0, and perror("") prints "Resource temporarily unavailable"

    What does that mean?

  3. #3
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    Posts
    3,101
    Quote Originally Posted by advorak View Post
    I am trying to add some text an OpenGL context. I found an example on the internet that uses GLEW and GLUT. I need to create three different windows, so I cant use these wrappers.
    GLUT can create multiple windows. If you need other features not available in GLUT, I'd suggest using GTK, Qt or wxWidgets rather than trying to use Xlib or XCB directly.

    Quote Originally Posted by advorak View Post
    How do I check the shader version that is loaded on my system? Maybe I don't have this version to use.
    glGetString(GL_VERSION) and glGetString(GL_SHADING_LANGUAGE_VERSION) return the OpenGL and GLSL versions as a string. See glGetString for the syntax.

    You'll need OpenGL 2.0 in order to use shaders or even query the GLSL version. Older versions may support the ARB_shader_objects extension, but there are significant differences between that extension and the shader support in OpenGL 2.0.

  4. #4
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    Posts
    3,101
    Quote Originally Posted by advorak View Post
    added a check for return on shader. It does return 0, and perror("") prints "Resource temporarily unavailable"

    What does that mean?
    glCreateShader() returns zero if there is an error. OpenGL functions don't generally set errno so perror() is of no use. Call glGetError() to retrieve the OpenGL error status.

  5. #5
    Member Contributor
    Join Date
    Jun 2015
    Posts
    60
    added the calls to glGetString for GL_VERSION and GL_SHADING_LANGUAGE_VERSION. see code below

    Code :
    	const GLubyte *version_string = glGetString( GL_VERSION );
    	const GLubyte *lang_version_string = glGetString( GL_SHADING_LANGUAGE_VERSION );
     
    	if((res = glCreateShader(type)) == 0)
    	{
    	  fprintf( stderr, "CreateShader returned 0.\n" );
    	  error_val = glGetError();
    	  fprintf( stderr, "glGetError returned %d.\n", error_val );
    	  fprintf( stderr, "%s\n", version_string );
    	  fprintf( stderr, "%s\n", lang_version_string );
    	  return 0;
    	}

    output looks like this

    CreateShader returned 0.
    glGetError returned 0.
    (null)
    (null)
    Got a call into NVIDIA

    I am going to try setting the context to the proper window, and call the init routine for each context. I think this could be an issue.

  6. #6
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    Posts
    3,101
    You're calling init_resources() before calling glXMakeCurrent(), i.e. there's no context bound.

    Also, you're creating the contexts with sharelist set to NULL, so the contexts won't share anything. You'll have to create any objects (shaders, buffers, textures etc) separately for each context. You'll also need to store separate values (program, vbo, etc) for each context.

    Even if the contexts are made to share data, not all object types can be shared (e.g. VAOs can't), so you'll probably need to end up storing some data on a per-context basis. So you'll probably want some kind of struct to hold data specific to each window.

  7. #7
    Member Contributor
    Join Date
    Jun 2015
    Posts
    60
    The plan is to have a single thread, and only one window will be text intensive. I will look into sharelist to share the shader across contexts. Thank you. I will post any results I get.

  8. #8
    Member Contributor
    Join Date
    Jun 2015
    Posts
    60
    made necessary objects arrays, and it now prints to the first two screens, but not the third.

    I will look for an index error

  9. #9
    Member Contributor
    Join Date
    Jun 2015
    Posts
    60
    all right, im stumped. Cant see any errors in the index passed. It is in a loop, so if it works for the first, it should work for the last.

    I am including the latest c file


    The monitor type on screen 2 and screen 3 are the same. Could that cause glXChooseVisual to assign the same visual to the two displays? that could cause the glXCreateContext to return the same context for the last two screens.

    Just guessing at this point.
    Attached Files Attached Files

  10. #10
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    Posts
    3,101
    Quote Originally Posted by advorak View Post
    The monitor type on screen 2 and screen 3 are the same. Could that cause glXChooseVisual to assign the same visual to the two displays? that could cause the glXCreateContext to return the same context for the last two screens.
    glXCreateContext() always creates a new context.

    Incidentally, do you actually have 4 screens? Because X numbers screens starting at 0, so if you have 3 screens they would be 0, 1, and 2.

Page 1 of 2 12 LastLast

Similar Threads

  1. How I can create hqx or xBR shader in GLSL?
    By Edwin Youn in forum OpenGL: GLSL
    Replies: 1
    Last Post: 01-03-2019, 09:14 AM
  2. shader storage block length returns zero or less
    By svcop3 in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 08-07-2016, 05:48 PM
  3. Replies: 2
    Last Post: 08-17-2013, 03:31 PM
  4. Replies: 3
    Last Post: 01-22-2013, 08:29 AM
  5. glGetUniformLocation returns -1? Texture in shader
    By omdown in forum OpenGL: GLSL
    Replies: 31
    Last Post: 01-07-2010, 06:59 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean