It is currently Mon Jul 24, 2017 7:48 pm

All times are UTC - 5 hours




 Page 1 of 1 [ 11 posts ] 
Author Message
 Post subject: Shader VMK 29 - Shader Manager
PostPosted: Mon Aug 12, 2013 5:53 am 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1102
Location: Ontario Canada
In this VMK the Shader Manager class is created and all the supporting functionality is implemented so that you will be able to load vertex and fragment shaders into your game very easily.


Offline
 Profile  
 
 Post subject: Re: Shader VMK 29 - Shader Manager
PostPosted: Mon Aug 12, 2013 10:58 pm 

Joined: Sat Aug 16, 2008 7:58 am
Posts: 448
Just finished the video, it took some time to get done, mostly from the distractions around the house, so I had to go back and watch the video 2-3 times just to find all the small little bugs, but I got it to compile, build, run and exit with no errors. Great Video.


Offline
 Profile  
 
 Post subject: Re: Shader VMK 29 - Shader Manager
PostPosted: Sun Nov 30, 2014 9:03 pm 

Joined: Fri Aug 22, 2014 3:54 pm
Posts: 17
I've been struggling with this VMK for a while now. No matter how many times I look over the code and compare it to the video, I can't see where it is failing at.
I keep on having the Exception thrown


Error [2014/11/30 | 18:57:54.946] key::ShaderManager::_ProcessAttributes
Errors were found with ATTRIBUTE variables in ShaderProg 0
inColor Variable{1} of type {float_vec4} is not verified.
Press any key to continue . . .

I can at least get the program to now throw a exception by removing all calls involving color. Meaning I have to remove color from the VERT and FRAG shader and I have to remove all color enabler and disabler calls in GAme.cpp.

My code is only slightly different (naming conventions differ) but the logic is the same. My shader files are below.
*VERT
#version 330

in vec3 inPosition;
in vec4 inColor;

out vec4 exColor;

uniform mat4 modelViewProjectionMatrix;

void main(){
   gl_Position = modelViewProjectionMatrix * vec4(inPosition, 1.0);
   exColor= inColor;
} // main


*FRAG
Quote:
#version 330
precision highp float;

in vec4 exColor;

out vec4 outFragColor;

void main(){
outFragColor = exColor;
}


http://pastebin.com/sfpJw6Cq

MY main code can be found there for the ShaderManager class.

Any suggestions would be grateful,I've been stuck on this for 4 days now.


Offline
 Profile  
 
 Post subject: Re: Shader VMK 29 - Shader Manager
PostPosted: Sun Nov 30, 2014 9:15 pm 

Joined: Mon Mar 24, 2014 2:25 pm
Posts: 69
Hey Celestial, would you also post your ShaderProgramSettings code from your game code. This will help us look at the attributes setup.


Offline
 Profile  
 
 Post subject: Re: Shader VMK 29 - Shader Manager
PostPosted: Sun Nov 30, 2014 10:38 pm 

Joined: Fri Aug 22, 2014 3:54 pm
Posts: 17
ShaderProgramSettings.h http://pastebin.com/ffaZcXhp
ShaderProgramSettings.cpp http://pastebin.com/gZYyuuZZ
ShaderVariable.h http://pastebin.com/mc8C0LtM
ShaderVariable.cpp http://pastebin.com/diCppqDa

Game.cpp http://pastebin.com/Yad85eJZ


Those are the main files I believe that would relate to it. Thank you for your help, this is so frustrating.


Offline
 Profile  
 
 Post subject: Re: Shader VMK 29 - Shader Manager
PostPosted: Sun Nov 30, 2014 11:12 pm 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1102
Location: Ontario Canada
When you step through your code in the debugger, do you see the color attribute being marked as verified? If so, why is it dropping into the if statement that says it is not verified?

Oh wait, I just looked at your game .cpp file. You define a myColor attribute but in the shader you use inColor.


Offline
 Profile  
 
 Post subject: Re: Shader VMK 29 - Shader Manager
PostPosted: Mon Dec 01, 2014 12:40 am 

Joined: Fri Aug 22, 2014 3:54 pm
Posts: 17
Sorry about that. It was from when I was testing. I assure you they match up while I'm testing. I walk through the code and I am able to pull the location of inColor and I am able to find it in the shader. But for some reason,it fails to verify it. I modified the code to spout out a bit more intermediate information temporarily.

The code is at this link for ShaderManager.cpp.
http://pastebin.com/DR7vrki6

When I run it, What shows up is below.


GL_ACTIVE_ATTRIBUTES returns 2
Attrib List[0]: inPosition Position: 0
Attrib List[1]: inColor Position: 1
Current attrib inPosition vs inPosition
Found attrib inPosition
Verified attrib inPosition
Current attrib inColor vs inPosition
Error   [2014/11/30 | 22:34:18.478] key::ShaderManager::_ProcessAttributes
Errors were found with ATTRIBUTE variables in ShaderProg 0
inColor Variable{1} of type {float_vec4} is not verified.
Press any key to continue . . .


I still can't narrow down where it is failing.
1. It finds all variables in the shader file, so the file is being parsed and compiled successfully
2. It parses the fragment well too
3. It finds inPosition stored in array perfectly fine.
4. It verifies the inPosition location in shader perfectly fine.
5. It finds the inColor stored in array fine.
6. It fails on comparison/verification part.
7. I belive this code chunk is somehow failing since it never even attempts to verify or mismatch
if(it->strName == pAttributeName.get()){
            bFound = true;
            std::cout << "Found attrib " << pAttributeName.get() << "\n";
            if(it->shaderVariable._eType != eAttributeType){
               str << "Type missmatch in " << pAttributeName.get() << ". "
                  << it->shaderVariable << " was defined, but shader used type{" << GetShaderTypeName(eAttributeType) << "}.\n";
            } else {
               std::cout << "Verified attrib " << pAttributeName.get() << "\n";
               it->isVerified = true;
            }
         }


Is there any way I can get a working copy of the source for this part so I can compare and see what is going wrong? I'm at almost a stand still trying to figure out what is wrong. This project had a lot of moving parts without incremental builds, so I feel like that hurt me somewhere.


Offline
 Profile  
 
 Post subject: Re: Shader VMK 29 - Shader Manager
PostPosted: Mon Dec 01, 2014 8:52 am 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1102
Location: Ontario Canada
Celestialkey wrote:
5. It finds the inColor stored in array fine.


According to the console output I don't see the above happening. It looks to me like your vAttribs does not contain "inColor". Put a break point in your for loop and run your code in the debugger and take a look at your member variables. Watch http://www.marekknows.com/downloads.php?vmk=cpp13 if you need a refresher on how to use the debugger to analyze your variables while your program is running.


Offline
 Profile  
 
 Post subject: Re: Shader VMK 29 - Shader Manager
PostPosted: Mon Dec 01, 2014 9:31 am 

Joined: Mon Mar 24, 2014 2:25 pm
Posts: 69
Quote:
GL_ACTIVE_ATTRIBUTES returns 2
Attrib List[0]: inPosition Position: 0
Attrib List[1]: inColor Position: 1
Current attrib inPosition vs inPosition
Found attrib inPosition
Verified attrib inPosition
Current attrib inColor vs inPosition
Error   [2014/11/30 | 22:34:18.478] key::ShaderManager::_ProcessAttributes
Errors were found with ATTRIBUTE variables in ShaderProg 0
inColor Variable{1} of type {float_vec4} is not verified.
Press any key to continue . . .


In general your code is failing while still evaluating the first variable in your vector of attributes by: Current attrib inColor vs inPosition.

Also you disabled your "EnableAttribute" for A_COLOR in setting up the VAO/VBO.


Offline
 Profile  
 
 Post subject: Re: Shader VMK 29 - Shader Manager
PostPosted: Mon Dec 01, 2014 7:55 pm 

Joined: Fri Aug 22, 2014 3:54 pm
Posts: 17
FINALLY!!! I discovered what it was!

So the reason it was failing was because it never made it to the inColor variable to actually search for it.

Apparently, I had a bracket in the wrong spot causing the application to search for the first variable, find it, then go and check if all variables had been verified. I move the bracket to before the verification so the for loop did not include it and everything seems to work now... That was so exhausting, and such a relief to figure it out.

Thanks for your help in the matter.


Offline
 Profile  
 
 Post subject: Re: Shader VMK 29 - Shader Manager
PostPosted: Tue Dec 02, 2014 3:32 am 

Joined: Mon Mar 24, 2014 2:25 pm
Posts: 69
Glad you got it figured out. While alot of people don't like the space, I always stick to Allman with each brace on it's own line to help organize things.


Offline
 Profile  
 
Display posts from previous:  Sort by  
 Page 1 of 1 [ 11 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Jump to:  

cron