Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: uniform struct not working  (Read 2501 times)

0 Members and 1 Guest are viewing this topic.

Cuban-Pete

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
uniform struct not working
« on: July 10, 2011, 02:21:59 pm »
I got this in program:

Code: [Select]
shader.SetParameter("text.n",400.0f);

In shader:

Code: [Select]

uniform struct someStruct {
  float t[800];
  float n;
} text;



I'm not reaching the shader...  :(

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
uniform struct not working
« Reply #1 on: July 10, 2011, 02:25:14 pm »
I don't know, sorry. I've never used structures in GLSL shaders. You should rather try to find a good tutorial/reference on it, we won't be very helpful here.
Laurent Gomila - SFML developer

Cuban-Pete

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
uniform struct not working
« Reply #2 on: July 10, 2011, 02:40:02 pm »
Okay. Thanks for the quick reply.

Will SFML contain in the future perhaps a function to write the shader log to a text file? I have some code that the shader is not compiling, but have no idea where the mistake is.

Perhaps someone knows a program/editor that can check if the shader code has errors?

Cuban-Pete

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
uniform struct not working
« Reply #3 on: July 10, 2011, 05:01:58 pm »
Never mind this. Shaders are a pain to work with, they don't even support 2D/3D arrays. I will solve my problem with using sprites and multiple coloured images.  :)

mercurio7891

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
uniform struct not working
« Reply #4 on: July 10, 2011, 05:19:51 pm »
hi i think you can't write the uniform qualifier when declaring the struct.

i think this would work:
Code: [Select]

struct SomeStruct
{
    float t[800];
    float n;
};

uniform SomeStruct text;


What is the problem you are trying to solve that need 2D/3D arrays? Maybe there is a alternative to it??

regards

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
uniform struct not working
« Reply #5 on: July 10, 2011, 07:28:32 pm »
Quote
Will SFML contain in the future perhaps a function to write the shader log to a text file? I have some code that the shader is not compiling, but have no idea where the mistake is.

Everything's written to sf::Err() (the console). If the shader doesn't compile you'll know it.
Laurent Gomila - SFML developer

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
uniform struct not working
« Reply #6 on: July 10, 2011, 07:34:18 pm »
Do you also write the InfoLog from the shader to sf::Err? Because that is what contains any information regarding the actual compilation and linkage.

If you want a I got a shader wrapper that handles this, except that it don't handle Samples yet as I can't get a hold of the texture ID from an sf::Image.
NOTE: I can do it trough OpenGL but feels ugly and means I have to bind and rebind images.
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
uniform struct not working
« Reply #7 on: July 10, 2011, 08:34:57 pm »
Quote
Do you also write the InfoLog from the shader to sf::Err? Because that is what contains any information regarding the actual compilation and linkage.

I do.

Quote
it don't handle Samples yet as I can't get a hold of the texture ID from an sf::Image.

You don't need to. sf::Shader doesn't access the internal texture ID, all you need to do is to Bind() the texture.
Basically, nothing else than destroying the texture requires its OpenGL ID. You usually bind it and then call functions that operate on the active texture. That's how OpenGL works with objects ;)
Laurent Gomila - SFML developer

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
uniform struct not working
« Reply #8 on: July 10, 2011, 09:49:21 pm »
Quote from: "Laurent"
I do.


Looked at it and you limit the length of your buffer.... I make sure that I get the entire info log so that nothing is missing.

Code: [Select]
std::string GGE::Graphics::ShaderProgram::GetInfoLog() const
{
assert( myProgramHandle != 0 );
int infoLogSize = 0;
PROGRAM_GET_PARAMETER( myProgramHandle, PROGRAM_INFOLOG_LENGTH, infoLogSize );
std::string log;
if( infoLogSize > 0 )
{
GLchar *infoLogBuffer = new GLchar[ infoLogSize ];
PROGRAM_GET_INFOLOG( myProgramHandle, infoLogSize, infoLogSize, infoLogBuffer );
log = infoLogBuffer;
delete[] infoLogBuffer;
}
return log;
}


This is it for the shader program and the one for the shader is equal. All symbols that is completely in caps are macros for different opengl calls(Just in case I decide to switch from ARB to 2.0)
Code: [Select]
#define PROGRAM_INFOLOG_LENGTH GL_OBJECT_INFO_LOG_LENGTH_ARB
#define PROGRAM_GET_PARAMETER( program, parameter, returnValue ) glGetObjectParameterivARB( program, parameter, &returnValue )
#define PROGRAM_GET_INFOLOG( program, maxSize, usedSize, buffer ) glGetInfoLogARB( program, maxSize, &usedSize, buffer )
Developer and Maker of rbSFML and Programmer at Paradox Development Studio