PDA

View Full Version : I need help for simple code



d7om_5757
05-09-2017, 10:37 PM
Hi everyone,

i need an OpenGL program that draws many colored objects in response to user input from keyboard.

The following objects are:

If the user input l, ot L Draw Line, Color RED.
If the user input t, ot T Draw Triangle, Color BLUE.
If the user input p, ot P Draw a polyline, Color Orange, select its vertex by MOUSE (number of vertex = 6)


please help me as soon as you can , thank you ..

mhagain
05-10-2017, 02:04 AM
And what is your actual problem?

mhagain
05-11-2017, 04:20 AM
i need an OpenGL program that draws many colored objects in response to user input from keyboard.

Can you not write one yourself? Have you even tried to write one yourself? Nobody's going to write one for you, you know. You'll have to demonstrate that you're at least capable of being self-sufficient here.

d7om_5757
05-11-2017, 05:27 AM
yes , I have tried to write this code myself and this is what I wrote I need simple help I am a beginner


void myKeyboard(unsigned char theKey, int mouseX, int mouseY)
{
GLint x = mouseX;
GLint y = screenHeight - mouseY; // flip the y value as always
switch(theKey)
{
case I or L:
drawLine(x1, y1, x2, y2);
setLine(x1, y1, x2, y2, 1.0, 0.0, 0.0);

break;

case I or L:
float vertices[] = {
x1f, y1f, // Vertex 1 (X, Y)
x2f, y2f, // Vertex 2 (X, Y)
x3f, y3f // Vertex 3 (X, Y)
};

glUniform3f(uniColor, 1.0f, 0.0f, 0.0f);

break;



default:
break;
}
}


Is it true or not and want code for number 3

thanks for help

Carmine
05-12-2017, 06:38 PM
yes , I have tried to write this code myself and this is what I wrote I need simple help I am a beginner


void myKeyboard(unsigned char theKey, int mouseX, int mouseY)
{
GLint x = mouseX;
GLint y = screenHeight - mouseY; // flip the y value as always
switch(theKey)
{
case I or L:
drawLine(x1, y1, x2, y2);
setLine(x1, y1, x2, y2, 1.0, 0.0, 0.0);

break;

case I or L:
float vertices[] = {
x1f, y1f, // Vertex 1 (X, Y)
x2f, y2f, // Vertex 2 (X, Y)
x3f, y3f // Vertex 3 (X, Y)
};

glUniform3f(uniColor, 1.0f, 0.0f, 0.0f);

break;

default:
break;
}
}


Is it true or not and want code for number 3

thanks for help

So what happens when you try to run this code?