# OpenGL Autocomplete Tool in GLSL Editor

## Recommended Posts

Hey guys, i'm a kind of begginer on OpenGL. I have created a TextBox in C++ with an Input Event Manager, what that's actually getting if some key of the kkeyboard was pressed and update the text on the textbox with these key pressed. I have too a text file with all the reserved words of GLSL sintaxys(gl_Position, uniform variable, vec3, ect....). Since here everything is okay, now the problems comes when i want to add the autocompletion tool (a string that get these input keys pressed and if some of them is actually same as some of the words of these text files, create a box with an scrollbar to shows this up and write it into the textbox is some of these words was selected clicking enter or with left mouse button, and then delete the memory size of these string to make a loop). As you can see in these longer parenthesys i have more or less the theory but, i don't have any idea how to start to developing it, cuz as far as i know there are no functions that actually makes that in the windows header(yeh im using Windows.h to create the textbox and the input manager, i thought i should had added these at the start). SO i would have to develop it by my own, which is hard for a newbie c++ programmer(i start learn it as same time ago as opengl). So if anybody here gives me an idea about how to start or how draw a box where you include all the words of these syntaxis glsl file, it would be awesome :D.

##### Share on other sites

If you are a newbie c++ programmer I would recommend switching to c# for this. It is far easier to do any type of form programming. I just had a go since I was curious and I got the basics going in about 10 minutes (a window with a text box in, when you start typing it opens up a little box at the end of your word with a list of suggestions. It only works for one word but that's easily solved (finding the last word in a text box is simple enough). It's just a form with a textbox and a listbox on it and then one event function for the textbox:

private void textBox1_TextChanged(object sender, EventArgs e)
{
string[] words = new string[5];
words[0] = "gl_Position";
words[1] = "uniform";
words[2] = "varying";
words[3] = "vec2";
words[4] = "vec3";

listBox1.Hide();

TextBox tb = (TextBox)sender;
string text = tb.Text;
if (text.Length == 0)
return;

List<int> potential = new List<int>();
for(int i = 0; i < 5; i++)
{
if (text.Length >= words[i].Length)
continue;
if(!words[i].StartsWith(text))
continue;
}
if (potential.Count == 0)
return;
Point pos = tb.GetPositionFromCharIndex(text.Length-1);
pos.X += tb.Location.X + 10;
pos.Y += tb.Location.Y + 20;

listBox1.Items.Clear();
foreach(var item in potential)
{
}
listBox1.Location = pos;
listBox1.Show();
}
I can't say that code is the best but it does show how little is needed to get going.

Choose the right tool for the job, c++ is great but not so great when you want a simple form type program. Java or c# beat it easily and are much friendlier to work with. I would recommend c# since you are into c++.

##### Share on other sites

I knew that C# with windows forms was easy to get this kid of job, but when i noticed that the Autocomplete class doesn't support multi-line TextBox's i come to try out with c++, after trying to create a custom listbox as an autocomplete class. But if you suggest me to forget about C++ then i would do that on C#. Thx :D, i would publish that editor as fast i can get it developed(that would have a little window at the left of the textbox that wikl show up your shader rendered in some different primitives polygons forms, something like ShaderToy but as local app).

##### Share on other sites

that would have a little window at the left of the textbox that wikl show up your shader rendered in some different primitives polygons forms, something like ShaderToy but as local app

Sounds like a cool idea.

## Create an account

Register a new account

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627682
• Total Posts
2978622
• ### Similar Content

• Both functions are available since 3.0, and I'm currently using glMapBuffer(), which works fine.
But, I was wondering if anyone has experienced advantage in using glMapBufferRange(), which allows to specify the range of the mapped buffer. Could this be only a safety measure or does it improve performance?
Note: I'm not asking about glBufferSubData()/glBufferData. Those two are irrelevant in this case.
• By xhcao
Before using void glBindImageTexture(    GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format), does need to make sure that texture is completeness.
• By cebugdev
hi guys,
are there any books, link online or any other resources that discusses on how to build special effects such as magic, lightning, etc. in OpenGL? i mean, yeah most of them are using particles but im looking for resources specifically on how to manipulate the particles to look like an effect that can be use for games,. i did fire particle before, and I want to learn how to do the other 'magic' as well.
Like are there one book or link(cant find in google) that atleast featured how to make different particle effects in OpenGL (or DirectX)? If there is no one stop shop for it, maybe ill just look for some tips on how to make a particle engine that is flexible enough to enable me to design different effects/magic
let me know if you guys have recommendations.
• By dud3
How do we rotate the camera around x axis 360 degrees, without having the strange effect as in my video below?
Mine behaves exactly the same way spherical coordinates would, I'm using euler angles.
Tried googling, but couldn't find a proper answer, guessing I don't know what exactly to google for, googled 'rotate 360 around x axis', got no proper answers.

References:
Code: https://pastebin.com/Hcshj3FQ
The video shows the difference between blender and my rotation:

• By Defend
I've had a Google around for this but haven't yet found some solid advice. There is a lot of "it depends", but I'm not sure on what.
My question is what's a good rule of thumb to follow when it comes to creating/using VBOs & VAOs? As in, when should I use multiple or when should I not? My understanding so far is that if I need a new VBO, then I need a new VAO. So when it comes to rendering multiple objects I can either:
* make lots of VAO/VBO pairs and flip through them to render different objects, or
* make one big VBO and jump around its memory to render different objects.
I also understand that if I need to render objects with different vertex attributes, then a new VAO is necessary in this case.
If that "it depends" really is quite variable, what's best for a beginner with OpenGL, assuming that better approaches can be learnt later with better understanding?

• 9
• 14
• 12
• 10
• 12