Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


Golden Rectangle!


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 sweeneyt0dd   Members   -  Reputation: 97

Like
-1Likes
Like

Posted 25 October 2013 - 10:51 AM

Hello guys.I need help.Really.. I have homework about golden rectangle.I didn't know anything about this homework.If i won't do this i won't pass this lesson just help me please. 

 

I need golden rectangle codes in opengl

 
 
I ATTACHED MY HOMEWORK 

Attached Files


Edited by sweeneyt0dd, 25 October 2013 - 11:53 AM.


Sponsor:

#2 haegarr   Crossbones+   -  Reputation: 4602

Like
0Likes
Like

Posted 25 October 2013 - 11:37 AM

Forum rules are quite clear about homework: Its your job to do it! We may help, but we don't solve it for you. So ... what is your problem in detail? Understanding the golden ratio? Understanding the assignment text? Knowledge of OpenGL? Knowledge of GLUT?

 


I didn't anything about this homework.

(Is this sentence complete?) What have you done / tried so far?



#3 sweeneyt0dd   Members   -  Reputation: 97

Like
0Likes
Like

Posted 25 October 2013 - 11:52 AM

Forum rules are quite clear about homework: Its your job to do it! We may help, but we don't solve it for you. So ... what is your problem in detail? Understanding the golden ratio? Understanding the assignment text? Knowledge of OpenGL? Knowledge of GLUT?

 

 

 


I didn't anything about this homework.

(Is this sentence complete?) What have you done / tried so far?

dude..I'm new in this lesson in class.Just want golden rectangle codes likes 

 
#include "stdafx.h"
#include <glut.h>
#include <math.h>
 
GLfloat G = (1 + (sqrt(float (5))))/2;
 
GLfloat gla1 = 0; 
GLfloat glb1 = 0;
GLfloat gla2; 
GLfloat glb2;
 
bool flip = true;  
 
 
void genNextRect(void)
{
        if (flip == false)
        {
                gla2 = gla2;
                glb2 = gla2/G;
               
        }
        else
        {
                glb2 = glb2;
                gla2 = gla2/G;
               
        }
}
 
void init(void)
{
        glClearColor(1.0, 1.0, 1.0, 0.0);
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        glOrtho(0.0, 600.0, 0.0, 400.0, -15.0, 15.0);
 
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
}
 
void display()
{
        glClear(GL_COLOR_BUFFER_BIT);
glLineWidth(4.0);
    
        
        gla2 = glutGet(GLUT_WINDOW_WIDTH) - 10; 
        glb2 = glutGet(GLUT_WINDOW_HEIGHT) - 10;  
 
  
        glBegin(GL_LINE_LOOP);
                glColor3f(0, 0, 1);
                glVertex3f(gla1, glb1, 0);
                glVertex3f(gla1, glb2, 0);
                glVertex3f(gla2, glb2, 0);
                glVertex3f(gla2, glb1, 0);
        glEnd();
        glutSwapBuffers();
}
 
void myReshape(GLsizei w, GLsizei h)
{
        glViewport(0,0,w,h);
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        gluOrtho2D(0.0, w, 0.0, h);
}
 
int main (int argc, char **argv)
{
        glutInit(&argc, argv);
        glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB); 
        glutInitWindowPosition(50, 50);
glutInitWindowSize(600, 500);
        glutCreateWindow("");
        glutDisplayFunc(display);
        glutReshapeFunc(myReshape);
init();
        glutMainLoop();
   
}


#4 fastcall22   Crossbones+   -  Reputation: 4475

Like
0Likes
Like

Posted 25 October 2013 - 11:54 AM

If i won't do this i won't pass this lesson just help me please.

... >_>


At this rate, how do you expect to complete the course?
c3RhdGljIGNoYXIgeW91cl9tb21bMVVMTCA8PCA2NF07CnNwcmludGYoeW91cl9tb20sICJpcyBmYXQiKTs=

#5 sweeneyt0dd   Members   -  Reputation: 97

Like
0Likes
Like

Posted 25 October 2013 - 11:58 AM

 

If i won't do this i won't pass this lesson just help me please.

... >_>


At this rate, how do you expect to complete the course?

 

 

 

You are right what u want to say.But you don't know why i don't understand nothing this lesson.I didn't go lessons because my family problems. I'm sorry buti just want a help thats all



#6 fastcall22   Crossbones+   -  Reputation: 4475

Like
0Likes
Like

Posted 25 October 2013 - 12:38 PM

Okay, don't panic. It's simpler than it looks. Looking at genNextRect, it takes the width and height of a rectangle as global parameters, gla2 and glb2, and sets them to the next smallest golden rectangle. Note, genNextRect assumes the gla2 and glb are already a golden rectangle. This is done by taking one of the dimensions and dividing by the golden ratio, which will result in a smaller length. The flip flag determine which dimension to shorten. It is the side with the longest length that is shortened. You will need to keep track of flip such that, when genNextRect is called, that the longest length of the rectangle is shortened. Alternatively, you could remove flip entirely and change the condition in genNextRect to select the longer edge. You may want to check that your rectangle's aspect ratio matches (or is close enough to) the golden ratio after calling genNextRect.

After you have called genNextRect you will need to draw it as demonstrated in the glBegin/glEnd block in display. The assignment requires you continue drawing rectangles until the rectangles are too small to display. So, all that's left to complete the assignment is finding the first golden rectangle in the screen and a loop that calls genNextRect and draws the new rectangle until the rectangle is too small to display.

P.S.
Don't panic.
Spoiler

Edited by fastcall22, 25 October 2013 - 12:54 PM.

c3RhdGljIGNoYXIgeW91cl9tb21bMVVMTCA8PCA2NF07CnNwcmludGYoeW91cl9tb20sICJpcyBmYXQiKTs=

#7 sweeneyt0dd   Members   -  Reputation: 97

Like
0Likes
Like

Posted 25 October 2013 - 01:00 PM

Okay, don't panic. It's simpler than it looks. Looking at genNextRect, it takes the width and height of a rectangle as global parameters, gla2 and glb2, and sets them to the next smallest golden rectangle. Note, genNextRect assumes the gla2 and glb are already a golden rectangle. This is done by taking one of the dimensions and dividing by the golden ratio, which will result in a smaller length. The flip flag determine which dimension to shorten. It is the side with the longest length that is shortened. You will need to keep track of flip such that, when genNextRect is called, that the longest length of the rectangle is shortened. Alternatively, you could remove flip entirely and change the condition in genNextRect to select the longer edge. You may want to check that your rectangle's aspect ratio matches (or is close enough to) the golden ratio after calling genNextRect.

After you have called genNextRect you will need to draw it as demonstrated in the glBegin/glEnd block in display. The assignment requires you continue drawing rectangles until the rectangles are too small to display. So, all that's left to complete the assignment is finding the first golden rectangle in the screen and a loop that calls genNextRect and draws the new rectangle until the rectangle is too small to display.

P.S.
Don't panic.

Spoiler

 

thank you very much. I will do this with your help :) 






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS