PDA

View Full Version : Beginning OpenGLSL



Songoku
03-20-2004, 06:37 AM
Ok i have a question.
If i want to use an extension, i have to check if my graphicscard does support this extension then i need functionpointers to use the new functions. My question is:
Do i need to have functionpointers for every new funtion which is provided by OpenGLSL. There are so many new functions i cannot believe that this is the only way to use OpenGLSL. Which files do i have to include??? I am a newbie to OpenGLSL and i try to get started using OpenGLSL. Please help me. Thanks.

Corrail
03-20-2004, 07:57 AM
You will need a function pointer for every function you are going to use.
Here you can find a tutorial of how to use extensions: http://developer.nvidia.com/object/opengl_extensions_tutorial.html

Here are some tutorials for GLSL: http://www.clockworkcoders.com/oglsl/tutorials.html

Songoku
03-20-2004, 09:29 AM
And which are the functions i have to have a pointer to in order to use OpenGLSL?

Corrail
03-20-2004, 09:56 AM
See specification of GLSL extensions:
http://oss.sgi.com/projects/ogl-sample/registry/ARB/shading_language_100.txt
http://oss.sgi.com/projects/ogl-sample/registry/ARB/shader_objects.txt
http://oss.sgi.com/projects/ogl-sample/registry/ARB/vertex_shader.txt
http://oss.sgi.com/projects/ogl-sample/registry/ARB/fragment_shader.txt

There the functions and the definitions you will need are specified.

Songoku
03-20-2004, 10:57 AM
Do i realy need all functions? And are the tokens automaticly linked to my program or do i have to rewrite a file including all the tokens???

Ffelagund
03-20-2004, 11:17 AM
You can use a tool to open all function pointers and check all extensions supported by your card. Try http://glew.sourceforge.net

Songoku
03-20-2004, 11:35 AM
Thanks but i think i will write my own classes to get the stuff work. Thanks for all the help.

Songoku
03-20-2004, 11:39 AM
One question left:
I check for extensions, have functionpointer to all the functions and wrote my shaders.
Do i need a compiler for the shader programs or can i compile my code with the compiler i use for my c++ apps?

Ffelagund
03-20-2004, 11:50 AM
If you want develop glsls shaders, try this: www.typhoonlabs.com, (http://www.typhoonlabs.com,) it's my free glslang Shader Designer, If you want to use shaders into your programs, you only need pass the string with the source code to opengl, and opengl will compile the shader for you.
To learn how opengl handle the shaders, download the ogl2sdk form www.3dlabs.com, (http://www.3dlabs.com,) there are sample source code.

Songoku
03-20-2004, 11:57 AM
Do i need any header file to include? Or can i do it without any header files?

Ffelagund
03-20-2004, 12:07 PM
Only need get the function pointers and the new tokens. This new tokens and pointers typedefs are into glext.h in SGI site.

Songoku
03-20-2004, 12:16 PM
But i thougth that i do not need any header files. When i want to use the Multitex-extension i do not need any header files to. I check for the extension and set the functionpointers. Then i use them. Why do i need a header file for the use of these functionpointers? I want to understand the system so that i can do my stuff working realy good.

Ffelagund
03-20-2004, 12:26 PM
This header file has all tokens and all function pointers definitions of all extension until last opengl version supported by this header. If you have a glext.h for opengl 1.4, you will have a lot of stuff into that file. If you dont use this header file, you must search into all extension specification for all tokens and functions needed, and then you must type them into your program. This is a very repetitive task. Maybe you dont want to reinvent the wheel, but use glew, glee or something like this (with only call glewInit(); for have all extensions ready to use).

Sorry for my bad english please http://www.opengl.org/discussion_boards/ubb/smile.gif

Edit->syntax corrections

[This message has been edited by Ffelagund (edited 03-20-2004).]

Songoku
03-20-2004, 12:41 PM
If you can speak german we can speak this language, if not in english.

Songoku
03-20-2004, 01:06 PM
i do not understand the system. If i want to have a extension function i have to have a functionpointer. So how can glew know how many functionpointer glew needs and how can glew name this pointers at the same time?

eror
03-20-2004, 05:42 PM
You ask too many questions. Just add this file.

Ffelagund
03-21-2004, 12:58 AM
I'm Spanish, so I don't speak german http://www.opengl.org/discussion_boards/ubb/smile.gif. Glew has all function pointers and #defines stuff hand coded. If you want more explains I can tell you by private email, to dont continue with this thread, because this is a beginer question http://www.opengl.org/discussion_boards/ubb/smile.gif

Songoku
03-21-2004, 03:51 AM
Thanks but i do not need more explanations.
It would be helpful if you could give me an adress of a page with a tutorial on how to use glew(or are there better extension loader?)

Songoku
03-21-2004, 04:01 AM
And yur Shader Designer do not work on my Radeon9800xt, initialization failed(only wanted to inform you). But it is a nice idea and i think it is realy cool.

Corrail
03-21-2004, 04:51 AM
And yur Shader Designer do not work on my Radeon9800xt, initialization failed(only wanted to inform you). But it is a nice idea and i think it is realy cool.


Which driver do you use? Try to update to Catalyst 4.3!

Songoku
03-21-2004, 05:02 AM
i have the version 04.3

Ffelagund
03-21-2004, 05:47 AM
Do you have the Framework .NET 1.1 installed?
By the way, I think that the best forum for Shader Designer is it: http://www.typhoonlabs.com/opengl/?q=forum/7 http://www.opengl.org/discussion_boards/ubb/smile.gif
If you have any question or problem with the SD, please post there instead of here

Songoku
03-22-2004, 09:11 AM
Ok i use glee (glew does not work glewinit() fails :( . By the way what is the main difference between glew and glee?)
Now i did the stuff to let the shader work but i have one problem :
My shader is used but after a few seconds i cannot see anythink. My vertexshader does nothing
(void main(void){gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex}" ;)
What is wrong with this code?
The only thing which i can see is a triangle for one second(the triangle flickers) and then nothing. What is wrong?

Songoku
03-22-2004, 09:39 AM
Ok i have a solution: i wrote a fragmentshader and everything worked. But do i realy need a fragmentshader if i want to program a vertexshader?

Korval
03-22-2004, 10:19 AM
No. But if you don't, you have to use the standard varying values provided by the vertex shader language spec.

Songoku
03-22-2004, 11:13 AM
I do not understand.
My program will not work if i do not program a fragmentshader too. And if i apply a vertexshader, does the whole "normal" rendering which is performed by Opengl(lighting...) is not performed anymore? I have a simple vertex shader(it does nothing(gl_Position = gl_Vertex) but now i can only see a triangle without the ligthingeffects which are normaly applied by OpenGL. What is wrong?

Tom Nuydens
03-22-2004, 11:41 PM
Originally posted by Songoku:
And if i apply a vertexshader, does the whole "normal" rendering which is performed by Opengl(lighting...) is not performed anymore?Read the spec:


A vertex shader replaces the transformation, texture coordinate generation and lighting parts of OpenGLIf you want any of that, you'll have to implement it yourself.

-- Tom

(Edit: UBB code)

Songoku
03-23-2004, 02:41 AM
That is hard but thanks.

Songoku
03-23-2004, 02:44 AM
Does anyone know how to get the color set by glColorxy() in a fragmentshader?(it is not gl_Color)

PanzerSchreck
03-23-2004, 03:32 AM
You can access the colors of a vertex in a FS through the varyings gl_FrontColor and gl_BackColor, but don't forget to set them in your VS.

bunny
03-23-2004, 05:55 AM
Originally posted by Songoku:
[QB]Ok i use glee (glew does not work glewinit() fails :( . By the way what is the main difference between glew and glee?)To be perfectly honest, (as the developer of GLee), not a great deal. They both support all the GL, GLX and WGL extensions of note, and have very similar interfaces. GLEW does currently have better cross-platform support if you need platforms other than Windows and Linux.

I have a couple of ideas for new features to add over the next couple of months, but don't expect anything major. After all, there are only so many features you need in an extension library, and I'd prefer to keep it slim and uncluttered than overflowing with redundant features.

Songoku
03-23-2004, 05:59 AM
Ok. Can anyone explain the difference between a uniform qualifier and a attribute?

bunny
03-23-2004, 07:36 AM
Originally posted by Songoku:
Ok. Can anyone explain the difference between a uniform qualifier and a attribute?You have read the spec, haven't you?

Songoku
03-23-2004, 07:43 AM
Yes i have but i do not understand realy the difference. You can change uniforms with your c++app and you can change attributes with your c++apps. Where is the difference?

bunny
03-23-2004, 08:07 AM
Uniforms are constant values that you set from your application. Attributes are per-vertex values such as texture coordinates and colours. You can specify attributes using standard texture coordinates and colours etc, or you can use the attribute keyword to specify named uniforms. There's a limit of 16 attributes per vertex, whichever approach you take.

Songoku
03-23-2004, 08:48 AM
Does somebody know a good site to learn more about shaders? Examples or tutorials but with explanation.If there is a site out there for Openglsl tutorials it would be helpful, but other shader tutorials will work too(but please tutorials with explanations of the shader code). Thanks

blur
03-23-2004, 11:21 AM
Originally posted by Songoku:
Does somebody know a good site to learn more about shaders? Examples or tutorials but with explanation.If there is a site out there for Openglsl tutorials it would be helpful, but other shader tutorials will work too(but please tutorials with explanations of the shader code). ThanksSeveral new GLSL demos with source code at:
http://www.3dlabs.com/support/developer/ogl2/downloads/index.htm

The recent "OpenGL Shading Language" book:
http://3dshaders.com/

eirikhm
03-23-2004, 02:03 PM
the openGL Shader Designer (already mentioned by Ffelagund) will ship with a complete set of tutorials for glsl. The first one starting with an introduction to the IDE, and the rest on shaders written in glsl. All the way from the basics to texturing, lighting, bumpmapping, color keying, grayscale, evnmapping, displacement mapping, refraction and more is covered). The editor is currently in heavy development and new features gets added every day.

It's freeware:)

Stay put for more information.

- Eirik Hoem
mail 'at' eirikhoem dot net

Songoku
03-24-2004, 04:36 AM
I have downloaded the shader Designer but there are not any tutorials :( Where to find them?

eirikhm
03-25-2004, 09:05 AM
they are not completed yet, and will be released with the first official release version of the shader designer. we are currently working very hard to improve the SD and maing the UI as easy to use as possible.

ETA : a week or two

PanzerSchreck
03-25-2004, 10:04 AM
I'd suggest you to take a look at ATI's RenderMonkey (http://mirror.ati.com/developer/sdk/radeonSDK/html/Tools/RenderMonkey.html) , a full-fledged Shader-IDE. The current version only supports DX9-HLSL, but ATI said (at GDC'04) that a RenderMonkey-version supporting GLSL will arrive at the end of this month. And I'm quite sure that it'll come (as was the case with it's first version) with plenty of (glsl)samples.

Songoku
03-25-2004, 01:12 PM
Thanks for help. Now i have the RenderMonkey too.

kingjosh
03-25-2004, 01:30 PM
More on RenderMonkey:

http://www.3dlabs.com/whatsnew/pressreleases/pr04/04-03-24-rendermonkey.htm

yooyo
03-25-2004, 02:44 PM
Originally posted by Songoku:
I have downloaded the shader Designer but there are not any tutorials :( Where to find them?Check this link...
GLSL tutorial (http://www.clockworkcoders.com/oglsl/)

PanzerSchreck
03-26-2004, 01:21 AM
And if you can read german (I guess since you said something about that before), take a look at this glSlang-Introduction (http://www.delphigl.com/script/do_show.php?name=glslang&action=2) I wrote for the German Delphi-OpenGL-Community. It's kind of like the shaderspecs in german, but I descriped some parts more in-depth (like how to assign TMUs to samplers) and also discussed some things delphi-developers have to pay attention to when using glsl. But it should also be useful for all non-delphers, since glsl is independend of your programming language.

Cab
03-26-2004, 06:40 AM
I bought the 'Orange' book, I have already read some chapters, and I recomend it to everyone. www.3dshaders.com (http://www.3dshaders.com)

Songoku
03-26-2004, 11:37 AM
The Delphi/OpenGLSL spec is a very good german version thanks.