|
Need some help with the Shader addon |
Dario ff
Member #10,065
August 2008
|
I've been coding these days the ALLEGRO_SHADER add-on, but I've come to realise something. My ignorance is working against me too much here, and I've spent two days trying to figure out the problem, failing miserably. I'm pretty sure that anyone here with barely a grasp of Direct3D and OpenGL might know the solution to my problem. What's the problem? I've got everything working, except 1 feature common to all shaders... Setting textures. They refuse to change, and nothing I change will make them behave otherwise. I hope that the problem isn't related to Allegro resetting some needed parameters when drawing, and it's surely my fault of how I set them. The question is, would anybody help me on this one? I don't want to delay the shader addon because of my ignorance. I'll make my best on documenting and cleaning it, and leave handy TODOs in the functions needed. That's the only thing that isn't working. If only 1 would work, maybe I could figure out the rest. But the answer evades me If the devs give me the OK with it, I'll post it here and let you take care of it. I'm just frustrating myself over something that could be easily solved by anyone with more experience in this. UPDATE:Ok, I'm gonna post it here. I don't know if it's good by the coding standards of Allegro, but that can be fixed. I didn't take the time to make it an add-on or something because setting textures doesn't work, so just build the files. Download source with example You'll need to link to the following libs: And for using CG Support: There's an AL_SHADER_SUPPORT_CG define in case you don't have CG and want to build it anyways. BUT, you'd be left wiht GLSL support only. Check out first ex_shader.cpp. It shows how the API is used, and I left commented various options for loading different types of shaders. Second, al_shader.h has explations for every method, how it's used, but not how it works internally. What I need done is left in "TODO:" (Just search for it, there's only two). It's just two functions for setting the textures. Any comments in improving the API, the coding or something are welcome. Any help would be really appreciated. TranslatorHack 2010, a human translation chain in a.cc. |
Elias
Member #358
May 2000
|
Sure, post it when you think it's ready. -- |
Dario ff
Member #10,065
August 2008
|
Ok, it's attached. Check the first post. TranslatorHack 2010, a human translation chain in a.cc. |
Peter Wang
Member #23
April 2000
|
Sorry, I only had a really superficial look at it so far but thought this required a reply. Have you considered looking at Ogre to see how they do it? As far as the API is concerned, the first thing that sticks out is the maximum line length parameter to al_load_shader(). It shouldn't be required. (more later)
|
Dario ff
Member #10,065
August 2008
|
Didn't notice your answer until today Peter, I had given up hope about this. Peter Wang said: As far as the API is concerned, the first thing that sticks out is the maximum line length parameter to al_load_shader(). It shouldn't be required. Ah, forgot to take it out. I should use fread and look for the line carriages to separate the lines(GLSL needs a 2 dimensional array, while CG uses a single string separated by line carriages). Quote: Have you considered looking at Ogre to see how they do it? CG comes already with a good handful of examples about setting the textures, so I based myself mostly on that. TranslatorHack 2010, a human translation chain in a.cc. |
gnolam
Member #2,030
March 2002
|
dario ff said: I should use fread and look for the line carriages to separate the lines(GLSL needs a 2 dimensional array, while CG uses a single string separated by line carriages). While glShaderSource() takes a double pointer, and you may use that to separate the shader source into an array of strings, you don't actually have to. Using a single C string is perfectly legal. -- |
Dario ff
Member #10,065
August 2008
|
gnolam said: While glShaderSource() takes a double pointer, and you may use that to separate the shader source into an array of strings, you don't actually have to. Using a single C string is perfectly legal. Then that makes a chunk of my code useless and would make it look much cleaner, and I can easily simplify everything with a single string. Thanks for the detail gnolam, I should've tried that in the first place. TranslatorHack 2010, a human translation chain in a.cc. |
|