• Advertisement
Sign in to follow this  

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

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

~ 800fps windowed.
~200 fullscreen

AMD 3000+
ATI Radeon 256mb 9600xt
1gb of RAM

Just an idea...

Maybe the ability to select the text in the text box.

The ability to put radio buttons into different groups so that each group of radio buttons could only have one selected at a time.

Maybe like a grid box or a grid of editable fields(forget what its called..lol).

Able to have different colored characters in a string for a label or button, ie a smiple text markup language ^1 would represent red or ^3 green, etc...

Maybe a Messagebox system (modal non-modal).

How about a custom cusor?

Hope that helps and I'll try and come up with more later.

Share this post


Link to post
Share on other sites
Advertisement
Thanks for your feedback guys, I appreciate it a lot.
Ok so I went ahead and implemented few more things like Vertical sliders, and tiled textured buttons.
Also I simplified the setup file by breaking it into several smaller files, look into the Data/GUI folder for more details [smile]
Check the main post for the updated binaries and pictures, ok back to implementing the rest of the suggested features.
Peace
PS: Kusma, I set the radio buttons to fade and come back three times as fast as anything else in the current frame, you can change the timing by modifying the alphaFadeScale in the XML files.

[Edited by - JavaCoolDude on June 15, 2005 7:56:36 PM]

Share this post


Link to post
Share on other sites
Looks like a great GUI, can't wait to see it in some games. The one improvment that I found immediately is the fact that arrows keys don't work in the text boxes, and I use the arrow keys all the time. Just an idea.

Other than that, and the improvements already stated, looks really nice, can't wait to see the code :)

~Zix~

EDIT: And it runs at ~1000 FPS on my system, 2.6 ghz, Gefroce 6600

Share this post


Link to post
Share on other sites
Really good job! :D

430 FPS with default windowed size
210 FPS with 1280*1024 windowed size

CPU: Intel P4 3GHz (Prescott 478)
RAM: 1GB PC3200
Card: ATI Radeon 9600 256MB DDR (Sapphire)

Share this post


Link to post
Share on other sites
hmm as this is an on going thread which might be of intrest to some people i'm gonna sticky it for a while, as a decent GUI is something alot of people have been asking for [smile]

Share this post


Link to post
Share on other sites
W00t, thanks Phantom my man :D
Now I am trying to remove the GUI dependance from my own engine, I would like one of you fellas to provide me with a simple GLUT application with a mouse and keyboard listener as well as a main loop [smile]

[Edited by - JavaCoolDude on June 15, 2005 9:21:41 PM]

Share this post


Link to post
Share on other sites
Quote:
Original post by JavaCoolDude
Now I would like one of you fellas to provide me with a simple GLUT application with a mouse and keyboard listener and a main loop; I'm trying to remove the GUI dependance from my own engine :)



#include "glut.h"

void changeSize( int w, int h )
{
// Prevent a divide by zero, when window is too short
// (you cant make a window of zero width).
if(h == 0)
h = 1;

float ratio = 1.0f * w / h;
// Reset the coordinate system before modifying
glMatrixMode(GL_PROJECTION);
glLoadIdentity();

// Set the viewport to be the entire window
glViewport(0, 0, w, h);

// Set the clipping volume
gluPerspective( 45, ratio, 1, 1000 );
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
}

void initScene()
{
glEnable(GL_DEPTH_TEST);
}

void renderScene(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glutSwapBuffers();
}

void processNormalKeys(unsigned char key, int x, int y)
{
if (key == 27)
exit(0);
}

void inputKey(int key, int x, int y)
{
switch (key)
{
case GLUT_KEY_LEFT :
break;

case GLUT_KEY_RIGHT :
break;

case GLUT_KEY_UP :
break;

case GLUT_KEY_DOWN :
break;
}
}

void processMouse(int button, int state, int x, int y)
{
int specialKey = glutGetModifiers();

// if both a mouse button, and the ALT key, are pressed then
if ((state == GLUT_DOWN) && (specialKey == GLUT_ACTIVE_ALT))
{
// set the color to pure red for the left button
// if (button == GLUT_LEFT_BUTTON)

// set the color to pure green for the middle button
//else if (button == GLUT_MIDDLE_BUTTON)

// set the color to pure blue for the right button
// else
}
}

void processMouseActiveMotion(int x, int y) {

//if (specialKey == GLUT_ACTIVE_SHIFT)

//else if (specialKey == GLUT_ACTIVE_CTRL)

//else if (specialKey == GLUT_ACTIVE_ALT)

//else
}

void processMousePassiveMotion(int x, int y)
{
//if (specialKey == GLUT_ACTIVE_SHIFT)

//else if (specialKey == GLUT_ACTIVE_CTRL)

//else if (specialKey == GLUT_ACTIVE_ALT)

//else
}

void processMouseEntry(int state)
{
//if ( state == GLUT_LEFT )

//if( state == GLUT_ENTERED )
}

int main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowPosition(100,100);
glutInitWindowSize(640,360);
glutCreateWindow("GLUT");

initScene();

// Keyboard
glutKeyboardFunc(processNormalKeys);
glutSpecialFunc(inputKey);

// Display and Idle
glutDisplayFunc(renderScene);
glutIdleFunc(renderScene);

glutReshapeFunc(changeSize);

// Mouse stuff
glutMouseFunc(processMouse);
glutMotionFunc(processMouseActiveMotion);
glutPassiveMotionFunc(processMousePassiveMotion);
glutEntryFunc(processMouseEntry);

glutMainLoop();

return(0);
}



Ok here is something put together from a lot of the LightHouse3D Glut tutorials. If you take a look at the tutorials under the 'Input' category, it shows the mouse and keyboard stuff in more detail as to what you can use.

For more information on stuff that you can use, right click on a define'd expression and 'Go to declaration' to see more of it's kind. Good luck!

Share this post


Link to post
Share on other sites
WOW! it ran steady at 1000fps.

athlon 3200 (32bit)
1gb pc3200
9800pro

btw dude ive seen your work, absolutely awesome!!! u seem to be a god of graphic programming. i hope to be as good as you someday...

Share this post


Link to post
Share on other sites
Quote:
Original post by Drew_Benton
Ok here is something put together from a lot of the LightHouse3D Glut tutorials. If you take a look at the tutorials under the 'Input' category, it shows the mouse and keyboard stuff in more detail as to what you can use.

For more information on stuff that you can use, right click on a define'd expression and 'Go to declaration' to see more of it's kind. Good luck!


Thanks dude, the code you posted helped me out a lot.

Ok ladies and gentlemen, announcing SXML GUI 0.5 for WIN users, grab it right here while it's still hot.
Here's a list of what you get:
Buttons, TextBoxes, vertical and horizontal sliders, Radio Buttons, CheckBoxes, Panels, Separators, Labels.
A TextureLoader and manager, no image would be loaded twice ;)
A MediaPathManager.
A lousy XML loader [pig]
Some other cool stuff.

I haven't used Linux that much therefore I have no clue on how to go about implementing a robust timer in the said environment. If anyone out there can look at the code and modify Tools/FPSCounter and Tools/Benchmark to whatever Linux uses you'll be my hero...well for a day or two :D

Share this post


Link to post
Share on other sites
Oh wow, that's great! I just tried it in the GLUT example and I must say, quite impressive! When I get my dev computer up and running in a week or so, I will definitly start messing with this library [wink] Thanks for all the hard work!

Share this post


Link to post
Share on other sites
yeah nice work mate, the demo run's just fine ...haven't had a chance yet to play around with it but will do in the next few days

Share this post


Link to post
Share on other sites
okay, i think you kinda misunderstood me ;)
the fade i was talking about wasn't the hover-fade, but rather the selection-change-fade. another note is that in the 0.5-release, moving the cursor in textboxes with the arrow-keys seems to be broken. as a user, i would also like to be able to select a chunk of text with both shift+arrow-keys and the mouse-cursor if possible. other than that, this seems like a really nice gui-library, by the way :)

Share this post


Link to post
Share on other sites
how would you make this GUI in pure openGL/glut style mode..kinda like what JavaDude was asking about? i mean yeah you have your textures and your font etc etc but i guess how do you make them react to each other.. i guess by checking mouse over or something, i concur that someone would get some major props for writing a tut on this :)

Share this post


Link to post
Share on other sites
Although I think it's great what you've done, what I'm interested in is how does one link actions to the widgets? If I have a void Quit(void) function, how do I bind it to a button? I've taken a quick look at the source of the demo, but the widgets there don't seem to be connected to anything. Could you give an example of how you bind functions?

Share this post


Link to post
Share on other sites
Yup, in the GLUT example if look for this section of the code in the Main.cpp file:


void EventsHandler::actionPerformed(GUIEvent evt)
{
const String &callbackString = evt.getCallbackString();
GUIRectangle *sourceRectangle = evt.getEventSource();
int widgetType = sourceRectangle->getWidgetType();

if(widgetType == CHECK_BOX)
{
GUICheckBox *checkBox = (GUICheckBox*)sourceRectangle;
}

if(widgetType == SLIDER)
{
GUISlider *slider = (GUISlider*)sourceRectangle;
if(callbackString == "s1")
slider->setLabelString(String("Slider 1: ") + int(slider->getProgress()*10));

if(callbackString == "s2")
slider->setLabelString(String("Slider 2: ") + int(slider->getProgress()*10));
}

if(widgetType == BUTTON)
{
GUIButton *button = (GUIButton*)sourceRectangle;
if(callbackString == "exit")
if(button->isClicked())
exit(0);
}

if(widgetType == RADIO_BUTTON)
{
GUIRadioButton *radioButton = (GUIRadioButton*)sourceRectangle;
}

}




If the user performs any of the following actions on a given widget


bool isMouseOver();
bool isReleased();
bool isFocused();
bool isDragged();
bool isClicked();
bool isPressed();


the actionPerformed function in the EventHandler will be called. Let's concentrate on this particular chunk:


if(widgetType == BUTTON)
{
GUIButton *button = (GUIButton*)sourceRectangle;
if(callbackString == "exit")
if(button->isClicked())
exit(0);
}


The code says if the widget that the user interacted with is of type BUTTON, the above chunk will be executed. More precisely, if your button has a callback string "exit" defined in your XML GUI layout, the function exit(0) will be called when your said widget is clicked "isClicked()"

Remember to register an EventHandler to stream all of your widgets events into a particular location [smile]

Share this post


Link to post
Share on other sites
Ouch.

I thought that was where it was happening.It works ok for small programs and demos, but if you need to make the GUI for an RTS or a RPG like this it'll be terrible.

Share this post


Link to post
Share on other sites
Not necessarily, one can always retrieve the name of the parent panel and direct the event to another function, check this out:


GUIPanel *parentPanel = (GUIPanel *)evt.getEventSource()->getParent();
const String &callbackString = evt.getCallbackString();
const String &parentName = parentPanel->getCallbackString();

if(parentName == "SomeRandomName")
{
someOtherEventHandler.actionPerformed(evt);
return;
}


That way we can separate things out depending on the panel where the action has occured, besides there are few other tricks as well, let me finish this tutorial and I'll come back to you. Unless you have a better way to approach this problem [smile]

Share this post


Link to post
Share on other sites
Ok here comes a quick tutorial:
Here we want to implement three sliders that control the background color of our application.
Since we don't want to stuff more code in the existent XML files, for simplicity sake we will create another file: ColorSliders.xml
We want the sliders to be grouped all together and located in the upper-right corner of our window, let's start off by creating the panel that will hold em together


<Panel name = "Color Sliders Group"
layout = "CEN_YAXIS"
anchorPoint = "CORNERRU"
drawBounds = "true"
drawBackground = "true">
</Panel>




In the above code, the group name is "Color Sliders Group", every group need a name otherwise it won't be attached to the GUI at runtime.
The layout is "cascading and centered around the y axis", meaning that anything added to the group will be relocated right under the previous element.
The anchor point is where we want the center of the Panel to be considered, there are five options explained in the next ASCII drawing:


CORNERLU CORNERRU
( )-----------------( )
| |
| CENTER |
| |
( )-----------------( )
CORNERLD CORNERRD




drawBounds tells the Panel whether we want visible bounds or not.
drawBackground tells the Panel whether we want a visible background or not.
Since we want our panel to sit in the top-right corner of our main window, let's add this line:


<Position x = "-10" y = "10"/>


If x is negative, it tells the parent panel that the current widget's center should be placed n pixels away from its right border.

Ok let's add a visible title to our panel


<Panel name = "Color Sliders Group"
layout = "CEN_YAXIS"
anchorPoint = "CORNERRU"
drawBounds = "true"
drawBackground = "true">

<Position x = "-10" y = "10"/>

<Label name = "Title">
<Text string = "Color Sliders" fontIndex ="1" wScale = "0.5" hScale = "0.5">
<Color r = "255" g = "180" b = "40" />
</Text>
</Label>
</Panel>




The title is simply a Label, we want the font to be the SECOND decalred one in the main GUILayout.xml file. Since the original size of the font is too big, we scale it down along the xaxis by half (wScale = "0.5") and do the same for the height of the label (hScale = "0.5").
The Color components are defined as:
Red could be x, X, r or R
Green could be g, G, Y or y
Blue could be b, B, z, Z
If the value of any color component is above 1, it will automatically be divided by 255. Therefore for a totally blue color, we set r and g to 0, and b to either 1.0 or 255.0.

Ok now that we're done with the title, let's add a thin line to separate things out:


<Panel name = "Color Sliders Group"
layout = "CEN_YAXIS"
anchorPoint = "CORNERRU"
drawBounds = "true"
drawBackground = "true">
<Label name = "Title">
<Text string = "Color Sliders" fontIndex ="1" wScale = "0.5" hScale = "0.5">
<Color r = "255" g = "180" b = "40" />
</Text>
</Label>

<Separator ratio = "1.0" />
</Panel>




The line will stretch from one side to the other since the ratio is "1.0", ratio will always be clamped to the [0.01 1.0] range.

Now here comes the important part, the sliders:
A single slider will look like this

 
<Slider callbackString = "red"
progress = "0.0">
<Text string = "Red" />
</Slider>


From that code we get to know that the slider disc will be initially set all the way to the left since progress is zero, the callback string is "red" and the visible title is also "Red". Using this same example we extend our panel to include two more sliders, here's the final result:


<Panel name = "Color Sliders Group"
layout = "CEN_YAXIS"
anchorPoint = "CORNERRU"
drawBounds = "true"
drawBackground = "true">

<BordersColor x = "216" y = "169" z = "0" />
<BGColor x = "50" y = "50" z = "50" />
<Position x = "-10" y = "10"/>


<Label name = "Title">
<Text string = "Color Sliders" fontIndex ="1" wScale = "0.5" hScale = "0.5">
<Color r = "255" g = "180" b = "40" />
</Text>
</Label>

<Separator ratio = "1.0" />

<Slider callbackString = "red"
progress = "0.0">
<Text string = "Red" />
</Slider>

<Slider callbackString = "green"
progress = "0.0">
<Text string = "Green" />
</Slider>

<Slider callbackString = "blue"
progress = "0.0">
<Text string = "Blue" />
</Slider>

</Panel>




Copy and save that code into let's say ColorSliders.xml

Once we're done with that, let's go ahead an open the main GUI file, GUILayout.xml:
Let's add this entry under Font

<Panel description = "ColorSliders.xml" />

Voila, we have our sliders [smile]

We're not done yet, we want them to modify the background color as we drag them around.
In Main.cpp, let's add these 3 float variables:


float red = 0.0f,
green = 0.0f,
blue = 0.0f;


In the renderScene() function, let's add this line right after counter.markFrameStart();

[code]
glClearColor(red, green, blue, 0.0f);
[code]

Now in "void EventsHandler::actionPerformed(GUIEvent evt)" right after

if(callbackString == "s2")
slider->setLabelString(String("Slider 2: ") + int(slider->getProgress()*10));


add these lines


if(callbackString == "red") red = slider->getProgress();
if(callbackString == "blue") blue = slider->getProgress();
if(callbackString == "green") green = slider->getProgress();




TADA, we're done compile and give it a go [smile]

Share this post


Link to post
Share on other sites
++rating for you javacooldude :) that will get me started at least. ive NEVER doen any xml so all this is new to me. i was wondering where all the string functions were coming from but realized i guess this is built into the xml language. one question now.. is this portable.. i mean will this work on lets say a linux system? :)

Share this post


Link to post
Share on other sites
Quote:
Original post by OpenGL_Guru
++rating for you javacooldude :) that will get me started at least. ive NEVER doen any xml so all this is new to me. i was wondering where all the string functions were coming from but realized i guess this is built into the xml language. one question now.. is this portable.. i mean will this work on lets say a linux system? :)


If you figure out how to implement a timer in Linux and manage to modify my Tools/FPSCounter and Tools/Timer, you're gold [smile]

Share this post


Link to post
Share on other sites
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 :)

Share this post


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

  • Advertisement
  • Advertisement
  • Popular Now

  • Advertisement
  • Similar Content

    • By reenigne
      For those that don't know me. I am the individual who's two videos are listed here under setup for https://wiki.libsdl.org/Tutorials
      I also run grhmedia.com where I host the projects and code for the tutorials I have online.
      Recently, I received a notice from youtube they will be implementing their new policy in protecting video content as of which I won't be monetized till I meat there required number of viewers and views each month.

      Frankly, I'm pretty sick of youtube. I put up a video and someone else learns from it and puts up another video and because of the way youtube does their placement they end up with more views.
      Even guys that clearly post false information such as one individual who said GLEW 2.0 was broken because he didn't know how to compile it. He in short didn't know how to modify the script he used because he didn't understand make files and how the requirements of the compiler and library changes needed some different flags.

      At the end of the month when they implement this I will take down the content and host on my own server purely and it will be a paid system and or patreon. 

      I get my videos may be a bit dry, I generally figure people are there to learn how to do something and I rather not waste their time. 
      I used to also help people for free even those coming from the other videos. That won't be the case any more. I used to just take anyone emails and work with them my email is posted on the site.

      I don't expect to get the required number of subscribers in that time or increased views. Even if I did well it wouldn't take care of each reoccurring month.
      I figure this is simpler and I don't plan on putting some sort of exorbitant fee for a monthly subscription or the like.
      I was thinking on the lines of a few dollars 1,2, and 3 and the larger subscription gets you assistance with the content in the tutorials if needed that month.
      Maybe another fee if it is related but not directly in the content. 
      The fees would serve to cut down on the number of people who ask for help and maybe encourage some of the people to actually pay attention to what is said rather than do their own thing. That actually turns out to be 90% of the issues. I spent 6 hours helping one individual last week I must have asked him 20 times did you do exactly like I said in the video even pointed directly to the section. When he finally sent me a copy of the what he entered I knew then and there he had not. I circled it and I pointed out that wasn't what I said to do in the video. I didn't tell him what was wrong and how I knew that way he would go back and actually follow what it said to do. He then reported it worked. Yea, no kidding following directions works. But hey isn't alone and well its part of the learning process.

      So the point of this isn't to be a gripe session. I'm just looking for a bit of feed back. Do you think the fees are unreasonable?
      Should I keep the youtube channel and do just the fees with patreon or do you think locking the content to my site and require a subscription is an idea.

      I'm just looking at the fact it is unrealistic to think youtube/google will actually get stuff right or that youtube viewers will actually bother to start looking for more accurate videos. 
    • By Balma Alparisi
      i got error 1282 in my code.
      sf::ContextSettings settings; settings.majorVersion = 4; settings.minorVersion = 5; settings.attributeFlags = settings.Core; sf::Window window; window.create(sf::VideoMode(1600, 900), "Texture Unit Rectangle", sf::Style::Close, settings); window.setActive(true); window.setVerticalSyncEnabled(true); glewInit(); GLuint shaderProgram = createShaderProgram("FX/Rectangle.vss", "FX/Rectangle.fss"); float vertex[] = { -0.5f,0.5f,0.0f, 0.0f,0.0f, -0.5f,-0.5f,0.0f, 0.0f,1.0f, 0.5f,0.5f,0.0f, 1.0f,0.0f, 0.5,-0.5f,0.0f, 1.0f,1.0f, }; GLuint indices[] = { 0,1,2, 1,2,3, }; GLuint vao; glGenVertexArrays(1, &vao); glBindVertexArray(vao); GLuint vbo; glGenBuffers(1, &vbo); glBindBuffer(GL_ARRAY_BUFFER, vbo); glBufferData(GL_ARRAY_BUFFER, sizeof(vertex), vertex, GL_STATIC_DRAW); GLuint ebo; glGenBuffers(1, &ebo); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ebo); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices,GL_STATIC_DRAW); glVertexAttribPointer(0, 3, GL_FLOAT, false, sizeof(float) * 5, (void*)0); glEnableVertexAttribArray(0); glVertexAttribPointer(1, 2, GL_FLOAT, false, sizeof(float) * 5, (void*)(sizeof(float) * 3)); glEnableVertexAttribArray(1); GLuint texture[2]; glGenTextures(2, texture); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, texture[0]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); sf::Image* imageOne = new sf::Image; bool isImageOneLoaded = imageOne->loadFromFile("Texture/container.jpg"); if (isImageOneLoaded) { glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, imageOne->getSize().x, imageOne->getSize().y, 0, GL_RGBA, GL_UNSIGNED_BYTE, imageOne->getPixelsPtr()); glGenerateMipmap(GL_TEXTURE_2D); } delete imageOne; glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, texture[1]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); sf::Image* imageTwo = new sf::Image; bool isImageTwoLoaded = imageTwo->loadFromFile("Texture/awesomeface.png"); if (isImageTwoLoaded) { glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, imageTwo->getSize().x, imageTwo->getSize().y, 0, GL_RGBA, GL_UNSIGNED_BYTE, imageTwo->getPixelsPtr()); glGenerateMipmap(GL_TEXTURE_2D); } delete imageTwo; glUniform1i(glGetUniformLocation(shaderProgram, "inTextureOne"), 0); glUniform1i(glGetUniformLocation(shaderProgram, "inTextureTwo"), 1); GLenum error = glGetError(); std::cout << error << std::endl; sf::Event event; bool isRunning = true; while (isRunning) { while (window.pollEvent(event)) { if (event.type == event.Closed) { isRunning = false; } } glClear(GL_COLOR_BUFFER_BIT); if (isImageOneLoaded && isImageTwoLoaded) { glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, texture[0]); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, texture[1]); glUseProgram(shaderProgram); } glBindVertexArray(vao); glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, nullptr); glBindVertexArray(0); window.display(); } glDeleteVertexArrays(1, &vao); glDeleteBuffers(1, &vbo); glDeleteBuffers(1, &ebo); glDeleteProgram(shaderProgram); glDeleteTextures(2,texture); return 0; } and this is the vertex shader
      #version 450 core layout(location=0) in vec3 inPos; layout(location=1) in vec2 inTexCoord; out vec2 TexCoord; void main() { gl_Position=vec4(inPos,1.0); TexCoord=inTexCoord; } and the fragment shader
      #version 450 core in vec2 TexCoord; uniform sampler2D inTextureOne; uniform sampler2D inTextureTwo; out vec4 FragmentColor; void main() { FragmentColor=mix(texture(inTextureOne,TexCoord),texture(inTextureTwo,TexCoord),0.2); } I was expecting awesomeface.png on top of container.jpg

    • By khawk
      We've just released all of the source code for the NeHe OpenGL lessons on our Github page at https://github.com/gamedev-net/nehe-opengl. code - 43 total platforms, configurations, and languages are included.
      Now operated by GameDev.net, NeHe is located at http://nehe.gamedev.net where it has been a valuable resource for developers wanting to learn OpenGL and graphics programming.

      View full story
    • By TheChubu
      The Khronos™ Group, an open consortium of leading hardware and software companies, announces from the SIGGRAPH 2017 Conference the immediate public availability of the OpenGL® 4.6 specification. OpenGL 4.6 integrates the functionality of numerous ARB and EXT extensions created by Khronos members AMD, Intel, and NVIDIA into core, including the capability to ingest SPIR-V™ shaders.
      SPIR-V is a Khronos-defined standard intermediate language for parallel compute and graphics, which enables content creators to simplify their shader authoring and management pipelines while providing significant source shading language flexibility. OpenGL 4.6 adds support for ingesting SPIR-V shaders to the core specification, guaranteeing that SPIR-V shaders will be widely supported by OpenGL implementations.
      OpenGL 4.6 adds the functionality of these ARB extensions to OpenGL’s core specification:
      GL_ARB_gl_spirv and GL_ARB_spirv_extensions to standardize SPIR-V support for OpenGL GL_ARB_indirect_parameters and GL_ARB_shader_draw_parameters for reducing the CPU overhead associated with rendering batches of geometry GL_ARB_pipeline_statistics_query and GL_ARB_transform_feedback_overflow_querystandardize OpenGL support for features available in Direct3D GL_ARB_texture_filter_anisotropic (based on GL_EXT_texture_filter_anisotropic) brings previously IP encumbered functionality into OpenGL to improve the visual quality of textured scenes GL_ARB_polygon_offset_clamp (based on GL_EXT_polygon_offset_clamp) suppresses a common visual artifact known as a “light leak” associated with rendering shadows GL_ARB_shader_atomic_counter_ops and GL_ARB_shader_group_vote add shader intrinsics supported by all desktop vendors to improve functionality and performance GL_KHR_no_error reduces driver overhead by allowing the application to indicate that it expects error-free operation so errors need not be generated In addition to the above features being added to OpenGL 4.6, the following are being released as extensions:
      GL_KHR_parallel_shader_compile allows applications to launch multiple shader compile threads to improve shader compile throughput WGL_ARB_create_context_no_error and GXL_ARB_create_context_no_error allow no error contexts to be created with WGL or GLX that support the GL_KHR_no_error extension “I’m proud to announce OpenGL 4.6 as the most feature-rich version of OpenGL yet. We've brought together the most popular, widely-supported extensions into a new core specification to give OpenGL developers and end users an improved baseline feature set. This includes resolving previous intellectual property roadblocks to bringing anisotropic texture filtering and polygon offset clamping into the core specification to enable widespread implementation and usage,” said Piers Daniell, chair of the OpenGL Working Group at Khronos. “The OpenGL working group will continue to respond to market needs and work with GPU vendors to ensure OpenGL remains a viable and evolving graphics API for all its customers and users across many vital industries.“
      The OpenGL 4.6 specification can be found at https://khronos.org/registry/OpenGL/index_gl.php. The GLSL to SPIR-V compiler glslang has been updated with GLSL 4.60 support, and can be found at https://github.com/KhronosGroup/glslang.
      Sophisticated graphics applications will also benefit from a set of newly released extensions for both OpenGL and OpenGL ES to enable interoperability with Vulkan and Direct3D. These extensions are named:
      GL_EXT_memory_object GL_EXT_memory_object_fd GL_EXT_memory_object_win32 GL_EXT_semaphore GL_EXT_semaphore_fd GL_EXT_semaphore_win32 GL_EXT_win32_keyed_mutex They can be found at: https://khronos.org/registry/OpenGL/index_gl.php
      Industry Support for OpenGL 4.6
      “With OpenGL 4.6 our customers have an improved set of core features available on our full range of OpenGL 4.x capable GPUs. These features provide improved rendering quality, performance and functionality. As the graphics industry’s most popular API, we fully support OpenGL and will continue to work closely with the Khronos Group on the development of new OpenGL specifications and extensions for our customers. NVIDIA has released beta OpenGL 4.6 drivers today at https://developer.nvidia.com/opengl-driver so developers can use these new features right away,” said Bob Pette, vice president, Professional Graphics at NVIDIA.
      "OpenGL 4.6 will be the first OpenGL release where conformant open source implementations based on the Mesa project will be deliverable in a reasonable timeframe after release. The open sourcing of the OpenGL conformance test suite and ongoing work between Khronos and X.org will also allow for non-vendor led open source implementations to achieve conformance in the near future," said David Airlie, senior principal engineer at Red Hat, and developer on Mesa/X.org projects.

      View full story
    • By _OskaR
      Hi,
      I have an OpenGL application but without possibility to wite own shaders.
      I need to perform small VS modification - is possible to do it in an alternative way? Do we have apps or driver modifictions which will catch the shader sent to GPU and override it?
  • Advertisement