PDA

View Full Version : making a spiral



Tralfas
05-01-2006, 12:41 PM
here be the code

#include <gl/glut.h>

void changesize(GLsizei w, GLsizei h)
{
GLfloat nRange = 100.0f;
if(h==0)
h=1;
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();

if(w <= h)
glOrtho (-nRange, nRange, -nRange*h/w, nRange*h/w, -nRange, nRange);
else
glOrtho (-nRange*w/h, nRange*w/h, -nRange, nRange, -nRange, nRange);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}

glBegin(GL_POINTS);
glVertex3f(0.0f, 0.0f, 0.0f);
glvertex3f(50.0f, 50.0f, 50.0f);
glEnd();

glBegin(GL_POINTS);
glvertex3f(0.0f, 0.0f, 0.0f);
glEnd();

glBegin(GL_POINTS);
glvertex3f(50.0f, 50.0f, 50.0f);
glEnd();

#define GL_PI 3.1415f
void SetupRC()
{
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);

glColor3f(0.0f, 1.0f, 0.0f);
}

void RenderScene(void)
{
GLfloat x, y, z, angle;
glClear(GL_COLOR_BUFFER_BIT);

glPushMatrix();
glRotatef(xRot, 1.0f, 0.0f, 0.0f);
glRotatef(yRot, 0.0f, 1.0f, 0.0f);
glBegin(GL_POINTS);
z = -50.0f;
for(angle = 0.0f; angle <= (2.0f * GL_PI) * 3.0f; angle += 0.1f)
{
x = 50.0f * sin(angle);
y = 50.0f * cos(angle);

glVertex3f(x, y, z);
z += 0.5f;
}

glEnd();
glPopMatrix();

glFlush();
} it makes a spiral and for some reason it doesnt work it gives errors like these when i compile it

21 C:\Dev-Cpp\spiral.cpp expected constructor, destructor, or type conversion before '(' token
21 C:\Dev-Cpp\spiral.cpp expected `,' or `;' before '(' token


can anyone help please
thanks in advance
tralfas

k_szczech
05-01-2006, 02:12 PM
You have '}' in the wrong place - you placed it in the middle of first function!

zeoverlord
05-01-2006, 02:14 PM
The code at line 21 (and a few lines below) does not seem to belong to a function.

jide
05-01-2006, 02:54 PM
Use this function at the first line of your program:


glCorrectMyCode (GL_TRUE);

05-01-2006, 06:24 PM
If a question sounds stupid, it probably is.

If you don't respond to nonsense like this, maybe it will go away...

These people thrive on reaction, any reaction. I've seen it before :rolleyes:

05-01-2006, 08:11 PM
what???

Tralfas
05-01-2006, 08:17 PM
I dont know if you have noticed but this is the begginer board. just because I have a problem doesn't mean you have to poke fun at my question because you think your soooo much better.

so can you help or are you just going to keep putting useless posts on this thread???

There seems to be a trend on the opengl message board.

andhell
05-01-2006, 09:13 PM
Where did you get this code? Or in which code do you base your own code? Your code seems something incomplete.
It needs a main function and another functions for the use of GLUT.
Do you want to use your code with GLUT or with the windows callbacks?

Tralfas
05-01-2006, 09:14 PM
never mind i found the answer to my problems

05-02-2006, 08:07 PM
I've also noticed this trend on this beginner board.
The is a tendency to mock and be sarcastic of posters. why even the board moderator is guilty of this. Maybe he is the one who has set this tone for this forum.
This isn't good at all. OpenGL is way more friendly than this. :)
I usually stay away from here, what is the reason for the sarcasm and rudeness to beginners on here? any opinions?

jide
05-03-2006, 04:10 AM
Don't take it badly, anyone can just kidding. I'm not sarcastic at all (I hope!). I spend most of the time I'm here trying to help others.
I just try to explain (obviously not in a well manner) that this is not a forum about C or any other language. That's all.

Shreyu
08-22-2008, 06:51 AM
its been executed and also showing thw window but iam not able to see the picture