Click here to Skip to main content
15,915,093 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralThanks. Re: Dialog Active in Background Pin
goosegg22-Jun-06 0:06
goosegg22-Jun-06 0:06 
QuestionGetting ip of client using winsock Pin
darkcloud.42o21-Jun-06 21:55
darkcloud.42o21-Jun-06 21:55 
AnswerRe: Getting ip of client using winsock Pin
_AnsHUMAN_ 21-Jun-06 22:07
_AnsHUMAN_ 21-Jun-06 22:07 
GeneralRe: Getting ip of client using winsock Pin
darkcloud.42o21-Jun-06 22:15
darkcloud.42o21-Jun-06 22:15 
AnswerRe: Getting ip of client using winsock Pin
Viorel.21-Jun-06 22:21
Viorel.21-Jun-06 22:21 
QuestionProblem while using SMPP Pin
johnalek21-Jun-06 21:46
johnalek21-Jun-06 21:46 
AnswerRe: Problem while using SMPP [modified] Pin
johnalek21-Jun-06 22:23
johnalek21-Jun-06 22:23 
QuestionWhich line of code do i need to change in order to get the circle shape? [modified] Pin
tillandran21-Jun-06 21:41
tillandran21-Jun-06 21:41 
Hello everyone...
Below is a complete sample application.
How can i get the same output but the shape must be circle??
which line of coding do i need to change?

Please help me here.
It is urgent.
Thanks alot

Tillandran



-----------------------------------------------------------------------------

#include <windows.h>
#include <gl\gl.h>
#include <gl\glaux.h>
#include<math.h>



//initial square position and its size
GLfloat x=250.0f;
GLfloat y=0.0f;
GLsizei rsize=50;

GLfloat x2=0.0f;
GLfloat y2=0.0f;

GLfloat x3=250.0f;
GLfloat y3=250.0f;

GLfloat x4=0.0f;
GLfloat y4=250.0f;

//step size in x and y directions
//number of pixels to move each time
GLfloat xstep=0.10f;
GLfloat ystep=0.10f;

GLfloat x2step=0.10f;
GLfloat y2step=0.10f;

GLfloat x3step=0.10f;
GLfloat y3step=0.10f;


GLfloat x4step=0.10f;
GLfloat y4step=0.10f;

//keep track of window's changing width and height

GLfloat windowWidth;
GLfloat windowHeight;

//called by AUX library when the windows has changed size

void CALLBACK ChangeSize(GLsizei w, GLsizei h)
{
//prevent a divide by zero. when window is too short
// you cannot make a window zero width

if(h==0)
h=1;

//set the viewport to be the entire window
glViewport(0,0,w,h);

//Reset the coordinate system before modifying
glLoadIdentity();

//keep the square square, this time, save calculated width and height for later use

if(w<=h)
{
windowHeight=250.0f*h/w;
windowWidth=250.0f;
}
else
{
windowWidth=250.0f * w/h;
windowHeight=250.0f;
}

//set the clipping volume
glOrtho(1.0f, windowWidth, 0.01, windowHeight, 1.0f, -1.0f);

}

//called by AUX library to update window
void CALLBACK RenderScene(void)
{
glClearColor(0.0f,0.0f,1.0f,0.0f);
glClear(GL_COLOR_BUFFER_BIT);
//set drawing color to red and draw rectangle at current position
glColor3f(0.0f,1.0f,0.0f);
glRectf(x2,y2,x2+rsize,y2+rsize);

glColor3f(1.0f,0.0f,0.0f);
glRectf(x3,y3,x3+rsize,y3+rsize);

glColor3f(1.0f,0.0f,0.0f);
glRectf(x4,y4,x4+rsize,y4+rsize);


glColor3f(1.0f, 1.0f, 0.0f);
glRectf(x,y,x+rsize,y+rsize);
glFlush();
}

//called by AUX library when idle(window not being resized or moved)

void CALLBACK IdleFunction(void)
{
//reverse direction when you reach let or right edge

if(x>windowWidth-rsize || x<0)
xstep=-xstep;

//reverse direction when you reach top or bottom edge
if(y>windowHeight-rsize || y<0)
ystep=-ystep;

//check bounds. This is in case the window is made smaller and the retangle is outside the new clipping volume

if(x>windowWidth-rsize)
x=windowWidth-rsize-1;

if(y>windowHeight-rsize)
y=windowHeight-rsize-1;

//Actually move the square
x+=xstep;
y+=ystep;

//reverse direction when you reach left or right edge
if(x2>windowWidth-rsize || x2<0)
x2step=-x2step;

//reverse direction when you reach top or bottom edge
if(y2>windowHeight-rsize || y2<0)
y2step=-y2step;

//check bounds. This is in case the window is made smaller and the rectangle is outside the new clipping volume
if(x2>windowWidth-rsize)
x2=windowWidth-rsize-1;

if(y2>windowHeight-rsize)
y2=windowHeight-rsize-1;

if(x3>windowWidth-rsize || x3<0)
x3step=-x3step;

//reverse direction when you reach top or bottom edge
if(y3>windowHeight-rsize || y3<0)
y3step=-y3step;

//check bounds. This is in case the window is made smaller and the rectangle is outside the new clipping volume
if(x3>windowWidth-rsize)
x3=windowWidth-rsize-1;

if(y3>windowHeight-rsize)
y3=windowHeight-rsize-1;

if(x4>windowWidth-rsize || x4<0)
x4step=-x4step;

//reverse direction when you reach top or bottom edge
if(y4>windowHeight-rsize || y4<0)
y4step=-y4step;

//check bounds. This is in case the window is made smaller and the rectangle is outside the new clipping volume
if(x4>windowWidth-rsize)
x4=windowWidth-rsize-1;

if(y4>windowHeight-rsize)
y4=windowHeight-rsize-1;


//Actually move the square
x2+=x2step;
y2+=y2step;

x3+=x3step;
y3+=y3step;

x4+=x4step;
y4+=y4step;
//redraw the scene with new coordinates
RenderScene();
}

//main body of the program
void main(void)
{
//aux window setup and initialization
auxInitDisplayMode(AUX_DOUBLE || AUX_RGBA);
auxInitPosition(100,100,250,250);
auxInitWindow("Assignment 1");

//set function to call when window is resized
auxReshapeFunc(ChangeSize);
auxIdleFunc(IdleFunction);

//start main loop

auxMainLoop(RenderScene);
}

//GLAUX.LIB GLU32.LIB glut32.lib glut.lib OPENGL32.LIB


-- modified at 3:43 Thursday 22nd June, 2006
QuestionRe: Which line of code do i need to change in order to get the circle shape? Pin
Hamid_RT21-Jun-06 22:06
Hamid_RT21-Jun-06 22:06 
JokeRe: Which line of code do i need to change in order to get the circle shape? Pin
toxcct21-Jun-06 22:09
toxcct21-Jun-06 22:09 
JokeRe: Which line of code do i need to change in order to get the circle shape? Pin
Hamid_RT21-Jun-06 22:20
Hamid_RT21-Jun-06 22:20 
JokeRe: Which line of code do i need to change in order to get the circle shape? Pin
toxcct21-Jun-06 22:21
toxcct21-Jun-06 22:21 
JokeRe: Which line of code do i need to change in order to get the circle shape? Pin
Hamid_RT21-Jun-06 22:31
Hamid_RT21-Jun-06 22:31 
AnswerRe: Which line of code do i need to change in order to get the circle shape? Pin
tillandran21-Jun-06 23:27
tillandran21-Jun-06 23:27 
QuestionHiding a folder Pin
djg21-Jun-06 20:23
djg21-Jun-06 20:23 
AnswerRe: Hiding a folder Pin
FarPointer21-Jun-06 20:29
FarPointer21-Jun-06 20:29 
GeneralRe: Hiding a folder Pin
djg21-Jun-06 21:03
djg21-Jun-06 21:03 
GeneralRe: Hiding a folder Pin
toxcct21-Jun-06 21:05
toxcct21-Jun-06 21:05 
GeneralRe: Hiding a folder Pin
djg21-Jun-06 21:52
djg21-Jun-06 21:52 
GeneralRe: Hiding a folder Pin
toxcct21-Jun-06 22:02
toxcct21-Jun-06 22:02 
GeneralRe: Hiding a folder Pin
kakan21-Jun-06 22:07
professionalkakan21-Jun-06 22:07 
GeneralRe: Hiding a folder Pin
djg21-Jun-06 22:18
djg21-Jun-06 22:18 
GeneralRe: Hiding a folder Pin
kakan21-Jun-06 22:38
professionalkakan21-Jun-06 22:38 
GeneralRe: Hiding a folder Pin
djg21-Jun-06 22:58
djg21-Jun-06 22:58 
GeneralRe: Hiding a folder Pin
kakan22-Jun-06 0:05
professionalkakan22-Jun-06 0:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.