Sign in to follow this  

OpenGL OpenGL GUI anyone? Updated on 11/17/05

This topic is 4222 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

Quote:
Original post by OpenGL_Guru
Quote:
If you figure out how to implement a timer in Linux and manage to modify my Tools/FPSCounter and Tools/Timer, you're gold


UGHH -- well in linux i really dont care about the FPS counter or keeping track of the FPS counter.


im gonna work on it and try things out though....

also gonan look at the GLUT version you have there.. oh yeah if you still need that favor, whatever that is, lemme know :)


The Timer is crucial for the subtle fading effect that you're seeing in the GUI, as a matter of fact I need to measure the time interval from one frame to the other and provide the GUIFrame with it at rendering time.

Share this post


Link to post
Share on other sites
ahhh i see... ok then...hmm.. well i will have to look into that then...

i guess you couldnt simply use an alpha for the transparency of the texture and just do a increment or decrement to make it opaque or transparent.. cos some computer will render slower or faster...

just out of curiousity did you try doing a GUI like this in just plain 'ol openGL? like just drawing the quads and buttons all in straight openGL. of course you would have to keep up with everything located in ortho mode i would assume.. i dunno.

Share this post


Link to post
Share on other sites
Thanks for the quick tutorial. If I hadn't rated you up all the way already I'd do so now.

Unfortunately for me, the design of how to take action just doesn't appeal to me. I guess I'll just have to finish work on DaedalusGUI :D

Since you asked for other options, here's how I do it. The root widget is actually a kind of manager for the entire GUI (since I can have multiple OS windows, each window has it's own manager/root widget. You can register callbacks with the root like so:

guiRootNew.AddCommand(widgetPointer, GUI::MOUSE1_UP, boost::bind(&GUI::IBase::ProcessMessage, base, GUI::HIDE, mMouse) );
guiRootNew.AddCommand("testbutton2", GUI::MOUSE1_UP, boost::bind(&GUI::IBase::ProcessMessage, base, GUI::SHOW, mMouse) );
guiRootNew.AddCommand("quitbutton", GUI::MOUSE1_UP, boost::bind(&Daedalus::Quit) );


So a combination of the widget you want to attach the callback to (although under the hood, it's stored with the root instead), the message that you want to react to, and a function object that will be called.

At the moment all widgets react to all messages, but I'm going to change that so images for instance don't react to button presses.

To me this design seems cleaner to use than the if/else statements you have. My design is comparable to a kind of signal/slot system as is also available in boost.

Share this post


Link to post
Share on other sites
Quote:
Original post by OpenGL_Guru
ahhh i see... ok then...hmm.. well i will have to look into that then...

i guess you couldnt simply use an alpha for the transparency of the texture and just do a increment or decrement to make it opaque or transparent.. cos some computer will render slower or faster...

just out of curiousity did you try doing a GUI like this in just plain 'ol openGL? like just drawing the quads and buttons all in straight openGL. of course you would have to keep up with everything located in ortho mode i would assume.. i dunno.


That is how I do it, pure OpenGL that is [wink]

Share this post


Link to post
Share on other sites
Quote:
Original post by rick_appleton
Thanks for the quick tutorial. If I hadn't rated you up all the way already I'd do so now.

Unfortunately for me, the design of how to take action just doesn't appeal to me. I guess I'll just have to finish work on DaedalusGUI :D

Since you asked for other options, here's how I do it. The root widget is actually a kind of manager for the entire GUI (since I can have multiple OS windows, each window has it's own manager/root widget. You can register callbacks with the root like so:

guiRootNew.AddCommand(widgetPointer, GUI::MOUSE1_UP, boost::bind(&GUI::IBase::ProcessMessage, base, GUI::HIDE, mMouse) );
guiRootNew.AddCommand("testbutton2", GUI::MOUSE1_UP, boost::bind(&GUI::IBase::ProcessMessage, base, GUI::SHOW, mMouse) );
guiRootNew.AddCommand("quitbutton", GUI::MOUSE1_UP, boost::bind(&Daedalus::Quit) );


So a combination of the widget you want to attach the callback to (although under the hood, it's stored with the root instead), the message that you want to react to, and a function object that will be called.

At the moment all widgets react to all messages, but I'm going to change that so images for instance don't react to button presses.

To me this design seems cleaner to use than the if/else statements you have. My design is comparable to a kind of signal/slot system as is also available in boost.


Yeah I like that design of yours, post binaries and screenshots when you're done mate :)
I had to resort to callback strings in my GUI because in some of my unreleased projects I deal with a lot and lot of widgets, and frankly I'd rather load them all up from a separate file than hardcoding them.
Just a different approach brother [wink]

Share this post


Link to post
Share on other sites
yah..i know you did it in openGL silly..as far as drawing the quads etc etc
but i mean without using xml to help you locate and define all the buttons, widgets etc etc. :)

btw -- i guess there is no mouseover/mousehover function for GLUT, unless its hidden under mousespecialfunc(); ?????

oh yeah about your timer..did you try using the glut TImer? that way it can be cross platform :)

heres the link to GLUT callback functions

Glut Callback Functions

Share this post


Link to post
Share on other sites
OpenGL_guru, I'm gonna have to look into that but unfortunately won't be able to do so until sometimes next week when I'm all settled down in Silicon Valley.
My next priority is fixing the text box and adding DropDown menus, List boxes and text areas.
Stay tuned.
PS: Any luck in porting the GLUT code to Linux anyone? Come on it shouldn't be tough [pig]
Alright off to catch my airplane [smile]

Share this post


Link to post
Share on other sites
Quote:
Original post by rick_appleton
Unfortunately for me, the design of how to take action just doesn't appeal to me. I guess I'll just have to finish work on DaedalusGUI :D

To me this design seems cleaner to use than the if/else statements you have. My design is comparable to a kind of signal/slot system as is also available in boost.


I also used to handle callbacks in this manner and I think this approach works very well if you want to hardcode a lot of the logic to a specific type of object (eg: you know that a Button will react to OnClick but a Label won't). With a little work, you could easily build a central message dispatcher that will delegate the messages out to the respective named widgets. If you send the message straight to the widget and let it be handled internally this should work quite well. Of course, it means that every widget will receive every message, which could result in a speed hit.

Share this post


Link to post
Share on other sites




After alot of brutal messing around got it running on Linux.
Not untill it was to late I realised how to use GNU Autotools to in a good way(tm) to use the source structure JavaCoolDude used so I will need to redo it once I get some more free time (I flattened it and placed all .cpp and .h files in a src directory). And hmm, fix the mouse events cause at the moment they are not being sent to widgets properly so can't use any of the widgets really, bargh, but that should not be to hard to fix, just wanted to show of a screenshot running 2 instances of the GLUT test app on Linux before I went to bed.


Edit: My gosh I spell bad.

Share this post


Link to post
Share on other sites
Have you got any tools for your source? Is it documented? Do you have some kind of an editor for your GUI?
Just curious, because how would you go about locating/positioning your GUI widgets around the screen? Do you use keyboard to move them or a mouse??

A cool looking GUI, can you do any animations with it, like for buttons??

Good work mate.

Share this post


Link to post
Share on other sites
Sempron 2800+
Radeon 9200
256 Mb DDR

I must say I feel kinda bad seeing the hi fps count most people are having...

~330 800x600x16
~190 800x600x32

~420 1024x768x16
~265 1024x768x32

~360 640x480x16
~520 640x480x32

I guess its my crappy sempron and radeon and ram, aka my whole PC, hehe

Anyway, looking awesome, and the fact you're using XML is really cool, keep up the good work mate

cheers

Share this post


Link to post
Share on other sites
Athalon XP 1900 +
Geforce 4 MX 64mb
512mb ddr.
(yeah its old)
a little under 60fps avg

great stuff, I wrote a "customizable" gui a while ago but yours is defintely better looking and easier to customize.

Two little things I noticed though, on your sliders the mouseclick doesn't grab the sliding device if you click past the extents of the white bar even though the cursor is over the orange ball.

Also, am I correct in thinking that you cannot customize the fade speed of he checkboxes after clicking using the xml? I looked at the xml files but did not see an option for that. It may be that I am just exceptionally impatient, but I found myself clicking a checkbox several times because i thought myclick didn't register.

Other than that it works exactly how I've come to expect gui's to work, except for the mouseover glowing, which was a pleasant suprise.
... The whole thing is very well done.

Share this post


Link to post
Share on other sites
It is pretty cool, nice work.

The only thing I would like differently are the edit boxes. You can't select or cut/copy/paste. It is not very hard to do, especially to even link it to the OS clipboard (though this might not be an option for you unless you can find a cross-platform clipboard library, I've never heard of one before). It is very helpful to be able to do that, I really hate games that don't let you copy/paste IPs into their in-game connection screens.

It is also screwy if you try to select by using shift + arrows. It made the ' and % characters show up in the input box.

Share this post


Link to post
Share on other sites
Intel Pentium 4 - 2.80Ghz
512MB DDR400 (PC3200) Ram
256Mb Radeon 9800 Pro

Window - 2200
Fullscreen - 1600

Share this post


Link to post
Share on other sites
Greetings
So yeah I'm without a PC until the weekend when USPS shows up to my door here in Silicon Valley, but I'm definitely taking notes down.
Expect an update this weekend with most of your suggestions.

todderod, you're the man, thanks for porting the GUI to Linux, I'll get in touch with you as soon as I get a new build up and running. Again thank you for your contribution.

nihilisticod, to change the fading speed, add this line to your widget XML declaration:
alphaFadeScale = "2.0"
2.0 will make the fading twice as fast as normal, you get to choose the value you want from 0.01 to 5.0 [smile]
Now regarding the insensitive part of the sliders, I can easily fix that, look forward to the next release this coming weekend brother.

HellRiZZer, there is no documentation yet except the quick tutorial posted in the second page, I'm working on that mate :)
peace

[Edited by - JavaCoolDude on June 20, 2005 10:27:59 PM]

Share this post


Link to post
Share on other sites
Quote:
Original post by JavaCoolDude
thanks for porting the GUI to Linux, I'll get in touch with you as soon as I get a new build up and running.


I fixed the widget problem so now it is working perfectly under Linux, except that the ./configure script is somewhat flawed when it comes to detecting the glpng and pthread libs.

I emailed you the sourcetree, and suggest you use that as basepoint for further updates, I don't feel like re-doing all those modifications :)

Share this post


Link to post
Share on other sites
It looks so cool!! wow, wanderful work.
I write UI myself, inspired by wow. hehe

Share this post


Link to post
Share on other sites
What is the liscence?

Can I use this for my own projects, and later if I decide to make a shareware something still continue to use it without royalties?

Share this post


Link to post
Share on other sites
Quote:
Original post by try_catch_this
What is the liscence?

Can I use this for my own projects, and later if I decide to make a shareware something still continue to use it without royalties?


You're free to use it in any way you want as long as you provide the due credit and maybe a link to my website [wink]

Share this post


Link to post
Share on other sites
Quote:
Original post by JavaCoolDude
Quote:
Original post by try_catch_this
What is the liscence?

Can I use this for my own projects, and later if I decide to make a shareware something still continue to use it without royalties?


You're free to use it in any way you want as long as you provide the due credit and maybe a link to my website [wink]


first of all, this is really great work.

just in case, i would formalize the above into a licence (just pick one, there are tons out there). i know it seems stupid, especially on projects you want to make completely *open* source, but you never know what crazy situation you might get into, and, most importantly, those using your library might need it for legal/company reasons (or be more willing to use it as they'll have, in writing, the relationship between them and you).

edit: err, dont know if you know this, but the GPL is in there, maybe it got stuck in with the linux port...a bit stricter than what you seem to want.

Share this post


Link to post
Share on other sites
Quote:
Original post by justo

edit: err, dont know if you know this, but the GPL is in there, maybe it got stuck in with the linux port...a bit stricter than what you seem to want.


Eeek, that is my misstake. GNU Autotools put that file there by itself, I meant to change that to a (for now) empty file. Same with a few other temporary files now I see, such sloppy work from my part.

Ignore the "COPYING" file and its contents, it is there by misstake.

Share this post


Link to post
Share on other sites
What is the most liberal license out there?
todderod, could you recompile the new release files in Linux and tell me if I broke anything in the process of adding Combo boxes?
Thank you :)

Share this post


Link to post
Share on other sites
Few more updates:
ComboBoxes now high-light the item lying underneath the mouse cursor, check out the first page for an update screenshot.

A click on an already checked RadioButton won't uncheck it.

The zip file with all the resources is now twice as small (750k)

Share this post


Link to post
Share on other sites
Quote:
Original post by JavaCoolDude
What is the most liberal license out there?


I favour the zlib license myself, the long and the short of it being you still own the work but anyone else is free to use, modify and redist it as long as they dont claim the orignal work as their own or modified work as orignal.

the full details.

Share this post


Link to post
Share on other sites

This topic is 4222 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Similar Content

    • By xhcao
      Does sync be needed to read texture content after access texture image in compute shader?
      My simple code is as below,
      glUseProgram(program.get());
      glBindImageTexture(0, texture[0], 0, GL_FALSE, 3, GL_READ_ONLY, GL_R32UI);
      glBindImageTexture(1, texture[1], 0, GL_FALSE, 4, GL_WRITE_ONLY, GL_R32UI);
      glDispatchCompute(1, 1, 1);
      // Does sync be needed here?
      glUseProgram(0);
      glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffer);
      glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
                                     GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, texture[1], 0);
      glReadPixels(0, 0, kWidth, kHeight, GL_RED_INTEGER, GL_UNSIGNED_INT, outputValues);
       
      Compute shader is very simple, imageLoad content from texture[0], and imageStore content to texture[1]. Does need to sync after dispatchCompute?
    • By Jonathan2006
      My question: is it possible to transform multiple angular velocities so that they can be reinserted as one? My research is below:
      // This works quat quaternion1 = GEQuaternionFromAngleRadians(angleRadiansVector1); quat quaternion2 = GEMultiplyQuaternions(quaternion1, GEQuaternionFromAngleRadians(angleRadiansVector2)); quat quaternion3 = GEMultiplyQuaternions(quaternion2, GEQuaternionFromAngleRadians(angleRadiansVector3)); glMultMatrixf(GEMat4FromQuaternion(quaternion3).array); // The first two work fine but not the third. Why? quat quaternion1 = GEQuaternionFromAngleRadians(angleRadiansVector1); vec3 vector1 = GETransformQuaternionAndVector(quaternion1, angularVelocity1); quat quaternion2 = GEQuaternionFromAngleRadians(angleRadiansVector2); vec3 vector2 = GETransformQuaternionAndVector(quaternion2, angularVelocity2); // This doesn't work //quat quaternion3 = GEQuaternionFromAngleRadians(angleRadiansVector3); //vec3 vector3 = GETransformQuaternionAndVector(quaternion3, angularVelocity3); vec3 angleVelocity = GEAddVectors(vector1, vector2); // Does not work: vec3 angleVelocity = GEAddVectors(vector1, GEAddVectors(vector2, vector3)); static vec3 angleRadiansVector; vec3 angularAcceleration = GESetVector(0.0, 0.0, 0.0); // Sending it through one angular velocity later in my motion engine angleVelocity = GEAddVectors(angleVelocity, GEMultiplyVectorAndScalar(angularAcceleration, timeStep)); angleRadiansVector = GEAddVectors(angleRadiansVector, GEMultiplyVectorAndScalar(angleVelocity, timeStep)); glMultMatrixf(GEMat4FromEulerAngle(angleRadiansVector).array); Also how do I combine multiple angularAcceleration variables? Is there an easier way to transform the angular values?
    • By dpadam450
      I have this code below in both my vertex and fragment shader, however when I request glGetUniformLocation("Lights[0].diffuse") or "Lights[0].attenuation", it returns -1. It will only give me a valid uniform location if I actually use the diffuse/attenuation variables in the VERTEX shader. Because I use position in the vertex shader, it always returns a valid uniform location. I've read that I can share uniforms across both vertex and fragment, but I'm confused what this is even compiling to if this is the case.
       
      #define NUM_LIGHTS 2
      struct Light
      {
          vec3 position;
          vec3 diffuse;
          float attenuation;
      };
      uniform Light Lights[NUM_LIGHTS];
       
       
    • By pr033r
      Hello,
      I have a Bachelor project on topic "Implenet 3D Boid's algorithm in OpenGL". All OpenGL issues works fine for me, all rendering etc. But when I started implement the boid's algorithm it was getting worse and worse. I read article (http://natureofcode.com/book/chapter-6-autonomous-agents/) inspirate from another code (here: https://github.com/jyanar/Boids/tree/master/src) but it still doesn't work like in tutorials and videos. For example the main problem: when I apply Cohesion (one of three main laws of boids) it makes some "cycling knot". Second, when some flock touch to another it scary change the coordination or respawn in origin (x: 0, y:0. z:0). Just some streng things. 
      I followed many tutorials, change a try everything but it isn't so smooth, without lags like in another videos. I really need your help. 
      My code (optimalizing branch): https://github.com/pr033r/BachelorProject/tree/Optimalizing
      Exe file (if you want to look) and models folder (for those who will download the sources):
      http://leteckaposta.cz/367190436
      Thanks for any help...

    • By Andrija
      I am currently trying to implement shadow mapping into my project , but although i can render my depth map to the screen and it looks okay , when i sample it with shadowCoords there is no shadow.
      Here is my light space matrix calculation
      mat4x4 lightViewMatrix; vec3 sun_pos = {SUN_OFFSET * the_sun->direction[0], SUN_OFFSET * the_sun->direction[1], SUN_OFFSET * the_sun->direction[2]}; mat4x4_look_at(lightViewMatrix,sun_pos,player->pos,up); mat4x4_mul(lightSpaceMatrix,lightProjMatrix,lightViewMatrix); I will tweak the values for the size and frustum of the shadow map, but for now i just want to draw shadows around the player position
      the_sun->direction is a normalized vector so i multiply it by a constant to get the position.
      player->pos is the camera position in world space
      the light projection matrix is calculated like this:
      mat4x4_ortho(lightProjMatrix,-SHADOW_FAR,SHADOW_FAR,-SHADOW_FAR,SHADOW_FAR,NEAR,SHADOW_FAR); Shadow vertex shader:
      uniform mat4 light_space_matrix; void main() { gl_Position = light_space_matrix * transfMatrix * vec4(position, 1.0f); } Shadow fragment shader:
      out float fragDepth; void main() { fragDepth = gl_FragCoord.z; } I am using deferred rendering so i have all my world positions in the g_positions buffer
      My shadow calculation in the deferred fragment shader:
      float get_shadow_fac(vec4 light_space_pos) { vec3 shadow_coords = light_space_pos.xyz / light_space_pos.w; shadow_coords = shadow_coords * 0.5 + 0.5; float closest_depth = texture(shadow_map, shadow_coords.xy).r; float current_depth = shadow_coords.z; float shadow_fac = 1.0; if(closest_depth < current_depth) shadow_fac = 0.5; return shadow_fac; } I call the function like this:
      get_shadow_fac(light_space_matrix * vec4(position,1.0)); Where position is the value i got from sampling the g_position buffer
      Here is my depth texture (i know it will produce low quality shadows but i just want to get it working for now):
      sorry because of the compression , the black smudges are trees ... https://i.stack.imgur.com/T43aK.jpg
      EDIT: Depth texture attachment:
      glTexImage2D(GL_TEXTURE_2D, 0,GL_DEPTH_COMPONENT24,fbo->width,fbo->height,0,GL_DEPTH_COMPONENT,GL_FLOAT,NULL); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, fbo->depthTexture, 0);
  • Popular Now