Hi, Browsing the panel.cxx source to understand how "hotspots" are implemented; looks like we're still using the x & y coordinates of the mouse click to determine which insrument, switch, knob, whatever is activated.
If so, has anyone consider an alternative approach to use pixel colors to identify the mouse region selected? The idea is to create a texture mask with unique RGB color regions that define the hot spots, overlay the texture mask with the visible texture showing the panel. When a mouse click is detected, read the pixel value of the sub-texture in the FBO, decode the color value, and take the appropriate acion as in the following code snippet, void Electrical_Panel::ReadPixel( int x, int y) { int pict; GLRGBQUAD *color; button = 0x00000000; unsigned char red, green, blue; // glReadPixels(x,y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixelColor[0]); // printf("Frame Color:%d %d %d\n",pixelColor[0],pixelColor[1],pixelColor[2]); int xpic = x; int ypic = (1000-y) * 400; // determine location of the pixel pict = (xpic + ypic); // color = frame.GetPixel( pict ); // printf("Frame Color:%d %d %d %d\n", pict, color->red, color->green, color->blue); color = mask.GetPixel( pict ); blue = color->blue; green = color->green; red = color->red; button = ((blue << 16) & 0xFF0000) | ((green << 8) & 0x00FF00) | red; // printf("Mask Color: %2x %2x %2x\n", blue, green, red ); // printf("Button = 0x%x\n\n" ); int knob = button; if ( (button & 0x00FFFF00) == 0 ) { pElec->Display_DC( knob ); return; } if ( (button & 0x00FF00FF) == 0) { // printf("AC rotary\n"); pElec->Display_AC( button ); return; } switch (button) { case 0x00A5CF33: printf("Maintenance key pressed\n"); break; case 0x00C4EC0A: pElec->AutoBusXfer( 1, ON ); // pElec->Process(); break; case 0x0033B3CF: pElec->AutoBusXfer( 1, OFF ); break; case 0x00E74761: pElec->AutoBusXfer( 5, ON ); break; // and so forth.... Logic bit masks can be used to direct program execution and segment the panel(s) based on color values and ranges. Not having worked with panel code just wondering if this would be easier to implement and maintain than the existing code? Advantages? Drawbacks? Comments? Questions? We've been using this approach to design and create complex subsystems ( such as the 737 electrical ) , implement virtual control panels, and test the supporting control and interface logic prior to building and installing the actual hardware panel(s). Also allows further software development and testing without having to fire up the entire sim after the panels are installed. Just a thought.... John W. ------------------------------------------------------------------------------ RSA(R) Conference 2012 Mar 27 - Feb 2 Save $400 by Jan. 27 Register now! http://p.sf.net/sfu/rsa-sfdev2dev2 _______________________________________________ Flightgear-devel mailing list Flightgear-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/flightgear-devel