Results 1 to 4 of 4

Thread: Opengl Vertex Shaders doesn't display anything

  1. #1
    Newbie Newbie
    Join Date
    Jul 2014
    Posts
    2

    Opengl Vertex Shaders doesn't display anything

    EDIT : sorry i redid the whole post as i found the error was comming from somthing else :

    I am using OpenGL with vertices and shaders, nothing got displayed on my screen so i used glGetError to debug : I got an error 1281(bad value) on one of my buffer called color_array_buffer, here is the section i am talking about :


    Code :
    		GLenum error =  glGetError();
    	if(error) {
    		cout << error << endl; 
    		return ;
    	} else {
    		cout << "no error yet" << endl;
    	}
    //no error
    	if (!(bufferLoaded)) {
    		std::cout << "Loading default buffers" << std::endl;
    		if(textured)
    			loadAssImp("cube.obj");	
    		else {
    			std::cout << "cant load any object to draw, not colored has not been defined yet" << std::endl;
    			// loadBufferArrays(vertices_default, color_default, elements_default);
    		}
    	}
    	if (textured) {
     
    	// Get a handle for our "myTextureSampler" uniform
    		GLuint TextureID  = glGetUniformLocation(shaderProgram, "myTextureSampler");
    		if(!TextureID)
    			cout << "TextureID not found ..." << endl;
     
    	// Bind our texture in Texture Unit 0
    		glActiveTexture(GL_TEXTURE0);
    		sf::Texture::bind(texture);
    	// Set our "myTextureSampler" sampler to user Texture Unit 0
    		glUniform1i(TextureID, 0);
    	// 2nd attribute buffer : UVs
    		GLuint vertexUVID = glGetAttribLocation(shaderProgram, "color");
    		if(!vertexUVID)
    			cout << "vertexUVID not found ..." << endl;
    		glEnableVertexAttribArray(vertexUVID);
    		glBindBuffer(GL_ARRAY_BUFFER, color_array_buffer);
    		glVertexAttribPointer(vertexUVID, 2, GL_FLOAT, GL_FALSE, 0, 0);
     
    	} else {
     
    		GLint colortexAttrib;
    		colortexAttrib = glGetAttribLocation(shaderProgram, "color");
    		if(!colortexAttrib)
    			cout << "colortexAttrib not found ..." << endl;
    		glBindBuffer(GL_ARRAY_BUFFER, color_array_buffer);
    		glEnableVertexAttribArray(colortexAttrib);
    		glVertexAttribPointer(colortexAttrib, 3, GL_FLOAT, GL_FALSE, 0, 0);
     
    	}
    	error =  glGetError();
    	if(error) {
    		cout << error << endl; 
    		return ;
    	}
    //error 1281

    And here is the code where i link my buffer to the array :

    Code :
    		if (textured) {
    			texture = new sf::Texture();
    		if(!texture->loadFromFile("textures/simple.jpeg"/*,sf::IntRect(0, 0, 128, 128)*/))
    			std::cout << "Error loading texture !!" << std::endl;
    			glGenBuffers(1, &color_array_buffer);
    			glBindBuffer(GL_ARRAY_BUFFER, color_array_buffer);
    			glBufferData(GL_ARRAY_BUFFER, uvs.size() * sizeof(glm::vec3), &uvs[0], GL_STATIC_DRAW);
    		}

    and my values of uvs :
    uvs[0] : 0.748573-0.750412
    uvs[1] : 0.749279-0.501284
    uvs[2] : 0.99911-0.501077
    uvs[3] : 0.999455-0.75038
    uvs[4] : 0.250471-0.500702
    uvs[5] : 0.249682-0.749677
    uvs[6] : 0.001085-0.75038
    uvs[7] : 0.001517-0.499994
    uvs[8] : 0.499422-0.500239
    uvs[9] : 0.500149-0.750166
    uvs[10] : 0.748355-0.99823
    uvs[11] : 0.500193-0.998728
    uvs[12] : 0.498993-0.250415
    uvs[13] : 0.748953-0.25092

    Am i doing something wrong, if someone could help me that would be great.

  2. #2
    Newbie Frequent Contributor
    Join Date
    Mar 2016
    Posts
    896
    Uhm, you don't seem to describe what problem exactly you are running into, that makes it very difficult to help.

  3. #3
    Newbie Newbie
    Join Date
    Jul 2014
    Posts
    2
    Quote Originally Posted by carsten neumann View Post
    Uhm, you don't seem to describe what problem exactly you are running into, that makes it very difficult to help.
    yes sorry i rewrote the whole thread, i hope it looks clearer to you.

  4. #4
    Newbie Frequent Contributor
    Join Date
    Mar 2016
    Posts
    896
    It's usually much easier to find the problem once you have found out which OpenGL call exactly is causing the error. There's a number of ways to find that information:
    - glDebugMessageCallback and related functions (possibly in combination with a debug context).
    - run under an OpenGL debugger/tracing tool, e.g. gDEBugger, apitrace, or debug tools from AMD/NVidia.
    - Sprinkle the code with glGetError - probably the most tedious option, can be made slightly less painful through the use of a macro or so.

    Looking over the code nothing jumped out at me, so it would be helpful if you can narrow it down more.

Similar Threads

  1. Loading 2 textures in 2 shaders - 1 doesn't work?
    By Jossos in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 11-27-2014, 05:17 AM
  2. Debugging shaders with glslDevil doesn't work
    By fred_em in forum OpenGL: GLSL
    Replies: 0
    Last Post: 07-23-2010, 10:04 AM
  3. OpenGL Display Lists and Shaders
    By jleffelm in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 10-29-2003, 05:59 AM
  4. OpenGL 1.4 Vertex Shaders etc...
    By sckoobs in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 07-26-2002, 07:46 AM
  5. Official OpenGL mechanism for vertex/pixel "shaders"
    By timfoleysama in forum OpenGL: General
    Replies: 33
    Last Post: 12-15-2000, 03:32 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