PDA

View Full Version : glutMouseFunc(mouse);



OGforever
11-10-2005, 09:07 AM
Helllo...

I was checking this out:

http://www.zeuscmd.com/tutorials/glut/03-MouseInput.php

, and they start their mouseHandling-chapter
telling me to use this code


bool lbuttonDown = false;

bool init()
{
return true;
}

void display()
{

}And I think it just doesn't make any sense:
Why should "display" be empty?
Why is this init thing return true always?

KR // OGforever

Bob
11-10-2005, 10:00 AM
The answer is in the previous tutorials.

init returns a bool to indicate whether the init function succeeded or not, and an empty init function obviously can't fail, so it returns true.

display is empty because nothing needs to be displayed.

OGforever
11-11-2005, 01:35 AM
Thanks...

Now I'm trying to make the program to react to a click on the right mousebutton. But nothing happens...Why?

KR// OG
</font><blockquote><font size="1" face="Verdana, Arial">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">#include <stdio.h>
#include <stdlib.h>

#include <GL/gl.h>
#include <GL/glut.h>

#include "givengui.h"

using namespace std;
bool lbuttonDown = false;

bool init() ;
void mouse(int button, int state, int x, int y) ;

/******** Callbacks called by the GUI ********/
void primitiveMode(int primitive)
{
printf("Primitive %s selected\n", primitive == LINE ? "line" : "circle");
}

void antialias(int doAA)
{
printf("Anti-aliasing %s\n", doAA ? "enabled" : "disabled");
}

void clearScreen()
{
printf("Clear screen\n");
}

void circleMode(int mode, int segments)
{
if(mode == MIDPOINT)
printf("Circle mode set to midpoint\n");
else
printf("Circle mode set to polygon with %d segments\n", segments);
}
/********* End GUI callbacks *********/

/********* GLUT callbacks ***********/
void display()
{
/* Draw a grid on the screen */
int x, y, w, h;

w = glutGet(GLUT_WINDOW_WIDTH);
h = glutGet(GLUT_WINDOW_HEIGHT);

/* Clear the screen */
glClear(GL_COLOR_BUFFER_BIT);

/* Begin drawing points */
glBegin(GL_POINTS);
/* Set color to light grey */
glColor3f(0.7, 0.7, 0.7);
/* Loop over all points and set those that are on a multiple of five in
either coordinate to grey, this will give a 5x5 grid */
for(x = 0; x < w; x++)
for(y = 0; y < h; y++)
if(x % 5 == 0

Bob
11-12-2005, 03:20 AM
The code you posted is not complete.