Can shaders be used here?

Hello,

I am developing an application which can be used to digitize a geographical map through GUI and mouse interaction. Well, here are the list of objects that need to be created using mouse clicks.

  1. Points
  2. Polyline
  3. Polygon
  4. Rectangle/Square
  5. Ellipse/Circle
  6. Text

Drawing points on mouse click is very easy and I was able to do it. It sounds very much like a CAD based programming. Well, Just wanted to know can shaders be used here for my purpose? After drawing objects, the user may edit objects, by moving/resizing them with the help of mouse. If it is possible, can anyone guide me as how to go ahead with the implementation?

Thanks in advance

Regards
Rakesh Patil

It’s been a long time awaiting, can shading language be used in my above application? If yes, then can anyone guide me how to proceed?

Thanks

Sure. But nothing in your brief description demands it.

We can help with OpenGL specific technical questions. So when you get to the point in your analysis/design that you have some, feel free to follow up. Right now it sounds like you’re just beginning the requirements gathering/analysis phase of your entire application, which likely involves a lot more than just graphics.

[QUOTE=Dark Photon;1240898]Sure. But nothing in your brief description demands it.

We can help with OpenGL specific technical questions. So when you get to the point in your analysis/design that you have some, feel free to follow up. Right now it sounds like you’re just beginning the requirements gathering/analysis phase of your entire application, which likely involves a lot more than just graphics.[/QUOTE]

Hi,

Thanks for your reply. Well, I have actually started up with the development and I’m using normal OpenGL (using glVertex3d() commands). I was wondering whether it can be done with OpenGL SL. The reason behind this is to clearly make a comparison, as speed wise which one will perform faster, normal OpenGL or GLSL?

Secondly, as far as my knowledge is concerned, with the help of Shading Language, only visualization can be done. Please do correct me if I go wrong somewhere. It needs two shader programs, vertex shader and fragment shader. Input data is supplied to vertex shaders, which is in turn processed and passed on to fragment shaders. Now in my case, input is coming from mouse clicks/move events. So, does it mean that after every mouse event, both the shader programs must be executed every time? Will not the execution of the program consume time in executing and indirectly affect the performance? I hope the programs need not be compiled every time, and must only be executed. This is what I have understood after reading some books and going through some tutorials. Please correct me if I am wrong.

Thanks again

Regards

I think you have some misunderstandings.

Using OpenGL without shaders (what you call “normal OpenGL”) is actually “legacy OpenGL”. That’s old-school. On virtually any hardware out there now, when using legacy OpenGL, shaders are still being used, it’s just that the driver is writing and running them internally without you having to be “explicitly” knowledgable of that fact at the GL API level. It works fine, so long as you’re OK with the features and performance associated with the built-in shaders that you have little control over. This old pipeline where the shaders construction and use is totally internal to the OpenGL driver is called “the fixed-function pipeline” (FFP).

“Modern OpenGL” on the other hand, let’s you get under-the-covers and write your own shaders (in GLSL). You can implement shaders to do exactly what the fixed-function pipeline does, or extend/replace it with many better features.

You seem to be interested in whether using modern OpenGL (with shaders) will let you increase performance over legacy OpenGL. That depends on what you’re bottlenecked on. You need to do an analysis to locate that, solve that bottleneck, and repeat until performance is sufficient.

Your mention of glVertex indicates that your application is doing some horribly inefficient things – glVertex is way-old school and the absolute slowest way to submit batches to the GPU (unless you’re submitting these to display lists AND if you’re running on NVidia – and even then they can be slow depending on where you put your glBegin/glEnd calls). So at the very least you should look carefully at your application’s use of immediate mode, and probably just get rid of it because it’s a likely culprit.

And no, there’s nothing that says you need to redraw the screen on every mouse click/motion. There really is no difference at all here between legacy and modern OpenGL. You redraw the window when you want to. The legacy/modern thing just relates to “how” you redraw the screen. Shaders are being used under-the-hood in either case.

Thanks Dark Photon,

To begin with, I would like to create a simple polyline drawing and editing tool using Shaders. From where do I start with.?

Thanks

The OpenGL Programming Guide (Red Book) is a pretty good place to start. If you already know some base OpenGL and just want to pick up shaders, consider the OpenGL Shading Language Guide (Orange Book).

Sounds like you aren’t going to get any benefits from using shaders. Drawing lines is something basic that can be done on any computer.
If you want to do per pixel lighting, bump mapping, toon shading, skeletal animation, etc, then shaders become a must. Shaders are for achieving graphics “effects”.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.