PDA

View Full Version : basic opengl beginner



pradeep
04-12-2011, 10:58 PM
As I am using Visual Studio as IDE I am compile this code in OpenGL
Now how I can

//Draws the 3D scene
void drawScene() {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glRotatef(-_cameraAngle, 0.0f, 1.0f, 0.0f);
glTranslatef(0.0f, 1.0f,-5.0f);

glPushMatrix();
glTranslatef(0.0f, -1.0f, 0.0f);
glRotatef(_angle, 0.0f, 0.0f, -5.0f);

glBegin(GL_QUADS);
glColor3f(0.0f, .7f, 0.0f);

glVertex3f(0.10f, 0.20f, 0.0f);

glVertex3f(0.20f, 0.10f, 0.0f);

glVertex3f(0.20f, -0.10f, 0.0f);

glVertex3f(0.10f, -0.20f, 0.0f);

glVertex3f(-0.10f, -0.20f, 0.0f);

glVertex3f(-0.20f, -0.10f, 0.0f);

glVertex3f(-0.20f, 0.10f, 0.0f);

glVertex3f(-0.10f, 0.20f, 0.0f);

glEnd();

glPopMatrix();

glutSwapBuffers();
}

Paras_wolf
04-13-2011, 02:32 AM
how you can What?... buddy

pradeep
04-13-2011, 09:30 PM
i cant get it because m new in this tech...so,plz help me...

Alfonse Reinheart
04-13-2011, 10:13 PM
He's asking what your problem is, because you didn't say. We can't help you unless you tell us what the problem is.

MaxH
04-14-2011, 09:37 AM
Help us to help you:

1) When you post code, enclose it in {code} and {/code} tags (except use [] instead of {}). That will preserve your indentations making it easier for us to understand.

2) Enclose the entire the program, not just the routine where you think the problem is occurring.

3) Tell us what happens when you try to run your code. Does it compile? Does a graphics window open? What do you see in the window?

pradeep
04-15-2011, 11:21 PM
ok i get it i am having any query than plzzzzzzzzz give support

ZbuffeR
04-16-2011, 10:30 AM
Obviously you did not 'get it'.
Re-read MaxH post, do not come back until you provide 1+2+3.

SasMaster
04-17-2011, 12:53 AM
LoL , I know this guy from Unity3D forum.Seems he has got a strong problem to express himself :)

pradeep
04-18-2011, 09:32 PM
ok this is my small basic program in opengl

i am tryig to make a wave shape in opengl


can any one me what is problem in below so, that can move to next step


int n[25];
glBegin(GL_LINES);
{
for(int i=0;i<24;++i)
{
glVertex2f((x(n[i]),y(n[i]));

}
glEnd();




Thanx in Advance

wat is problem inn this can any one can tell me

mhagain
04-19-2011, 02:21 AM
There's no problem in that code.
Or there could be many problems in it.
It's impossible to say.

What we need to know is: What do you expect the code to do? What is the code doing?

pradeep
04-19-2011, 10:31 PM
i am tryig to make a wave shape in opengl


can any one me what is problem in below so, that can move to next step


int n[25];
glBegin(GL_LINES);
{
for(int i=0;i<10;++i)
{
glVertex2f((x(n[i]),y(n[i]));

}
glEnd();




Thanx in Advance

mobeen
04-19-2011, 11:45 PM
The information u r giving to us is incomplete. What do the functions x() and y() return? Why are u using an uninitialized array (n)? The above code is fine (sematically) apart from the redundant { after glBegin but whether it works or not depends on what u r doing in the x,y functions.

pradeep
04-21-2011, 10:07 PM
in above code error is coming that
x and y is not found


Thanx in Advance

CoolBeanJ
04-21-2011, 10:29 PM
I could be way off but if your using visual studio as the ide you will need to have some sort of OpenGL lib.

I use Tao. Why I say this is becuase you are using commands like

glBegin(GL_LINES);

and i'd expect to have seen Gl.glBegin(Gl.GL_LINES);

pradeep
04-22-2011, 09:09 PM
ok CoolBeanJ u r doing in java

pradeep
04-27-2011, 09:16 PM
by the above code i m trying to draw a wave shape line


that is horizontal "8"
i dnt have any of idea specifying x and y values

Kelvin
04-27-2011, 10:27 PM
That sort of shape is called a lemniscate (http://en.wikipedia.org/wiki/Lemniscate). If you follow that link you will find equations for several varieties. I like this one (http://en.wikipedia.org/wiki/Lemniscate_of_Bernoulli). You want the parametric equations, where you supply a sliding "t" parameter.

More commonly, you would pre-compute all the values and store them in a table, instead of doing lots of sines/cosines at run time. If none of the mathematical shapes look like what you want, then make your own table by drawing your shape on a piece of graph paper, and counting squares to find the x and y coordinates that you need.

pradeep
04-28-2011, 09:17 PM
ya Kelvin,
i have done that for drawing a simple triangle but i want to draw a wave shape for showing in flow motion