Jump to content
  • Advertisement
Sign in to follow this  
ismakefire

OpenGL Issue with loading shaders

This topic is 4909 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

First, I can load a shader, INFACT I can load three and render them all at once and at different time, blah blah blah, why would I be upset? The problem is the order at which I load them effects which ones work. Now I've doen the same thing an "OGLexample" I got from 3dlabs, but I've noticed that I'll get errors on lines that don't exist. Since it's reading from a string, I'd think all I'd have to do is NULL off the end, which I've done and it's all my example did as well. So I guess my question would be: Is there some special way to end a string so OpenGL knows it's the end of a file(it's not like fileBuffer[size-1] = EOF is going to work) or do I need to set a perameter saying the mamimum string length or am I missing something? Thanx in advance! IsMakeFire

Share this post


Link to post
Share on other sites
Advertisement
how are you loading the shaders in? all into the same memory space before uploading them? if so memset() the space to 0 before each load, it should clear up any problems

Share this post


Link to post
Share on other sites
Ok thanx, but ewww! It reaaly shoudlnt' be reading past the end point of this string! How is it even ending it's read of the buffer in the first place? Anyway, I'll take your suggestion for now, but their must be a way to tell it to end where the file buffer SHOULD END!

As for the code, it's a very many lines, but basiclly:
vertexShaderHandle= glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);
glShaderSourceARB(vertexShaderHandle, 1, (const GLcharARB**)&vertData, &vertSize);
glCompileShaderARB(vertexShaderHandle);
glGetObjectParameterivARB(vertexShaderHandle, GL_OBJECT_COMPILE_STATUS_ARB, &vertexShaderCompiled);

This is the loading of a fragment shader without error checking code, and yes, it works but my issue is with keep it from reading past the end point.

UPDATE:
Sorry, but clearing the memory with memset didn't change the effects, since the memory (which is allocated on the spot) is filled with the file. The array is one byte larger then the file... grrr

Thanx,
IsMakeFire

[Edited by - ismakefire on May 16, 2005 12:11:37 AM]

Share this post


Link to post
Share on other sites
Well, for those of you who have asked your C teacher why somebody couldn't just put an EOF character in the middle of a file instead of the end, this post is devoted to you.

As we all should, file input like fread or fgetc(my fav) reads the file byte by byte till it hits the end. Unlike a string, this file can have 0x00 or any other combination of bytes in it because it isn't termenated by an EOF, but EOF is the integer value that's returned when there are no more bytes to read. Well, OGLSL thinks it's better then this.
Rather then just taking the parameter that I sent(which is the size of the damn file I sent) or ending when a NULL is retched(which is what their OGLexample tried) it thought to end at the sign of an EOF. But how? How in the great name of the holy goat did you write an EOF into a single byte... oh, but used four. Rather then using the file buffer as if it where a file you use it as if it where a string that termenates at 4 bytes of 0xFF, which just so happens to be EOF(0xFFFFFFFF = -1)... it would have been nice for them to metion that somewhere...

I think the "slapi" refers to your face after to find the lies
http://developer.3dlabs.com/openGL2/slapi/ShaderSourceARB.htm

Share this post


Link to post
Share on other sites
i couldnt really understand what youre on about but
um where here (http://developer.3dlabs.com/openGL2/slapi/ShaderSourceARB.htm) does it mention file

Share this post


Link to post
Share on other sites
this thread I created a while back links to some code which correctly loads multiple shaders, either use it directly or compare it to what you've got to see what the problem is with your code.

The whole memset() thing is odd, but I was having troubles with strange errors until I did it so I'm just not questioning it now, its one operation on startup, hardly a killer [grin]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!