hi, i tried to simplify my code as much as possible and extract exactly where my problem is occuring, so the code below if copied and pasted wil compile, i have just included the neccessary pieces from multiple files where i have found a problem,
the problem, i set my window as a desktop_mode, then i draw a 2dpanel at the bottom of the viewport that overlays the 3d viewport, if the mouse cursor is over the black 'drag-line' and left mouse is held down, the panel can be resized/dragged up and down,
there could be a problem in my code, but from tests i am guessing something else, if i load the program up and without resizing i try to drag the panel, it misses the mark by about 20px, as soon as i resize by any amount it behaves as it should, the code shouldn't be wrong as i have used it before, but i might be wrong,please check for me,you can just copy paste code....
sorry if it is a bit long but i have tried to preserve exactly how i use it,not usually in one file though
#include <SFML/Window.h>
#include<SFML/System.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <stdio.h>
#include <stdlib.h>
typedef struct GUI{
int high, wide;
}GUI;
GUI *mygui;
int init_gui_panel(int w, int h, GUI *gui);
void guidraw();
sfEvent Event;
sfWindow* mywin;
enum actions {DRAGS, NONE};
static int action = NONE;
void guidraw(){
glColor3f(0.1,0.1,0.1);
glBegin(GL_QUADS);
glVertex2i(mygui->wide, (mygui->high-5));
glVertex2i(0,(mygui->high-5));
glVertex2i(0, mygui->high);
glVertex2i(mygui->wide, mygui->high);
glColor3f(0.7,0.7,0.7);
glVertex2i(mygui->wide, 0);
glVertex2i(0,0);
glVertex2i(0, (mygui->high-5));
glVertex2i(mygui->wide, (mygui->high-5));
glEnd();
}
int init_gui_panel(int w, int h, GUI *gui){
//this function should encapsulate more than this later!!
gui->high = (h/4);
gui->wide = w;
return gui;
}
int main(){
sfWindow* mywin;
sfWindowSettings Settings = {24,8,4};
mywin = sfWindow_Create(sfVideoMode_GetDesktopMode(), "Quirk", sfResize | sfClose, Settings);
GUI initgui;
mygui = init_gui_panel(sfWindow_GetWidth(mywin), sfWindow_GetHeight(mywin),&initgui);
while(sfWindow_IsOpened(mywin)){
const sfInput* input = sfWindow_GetInput(mywin);
if(sfWindow_GetEvent(mywin, &Event)){
switch(Event.Type)
{
case sfEvtClosed:
sfWindow_Close(mywin);
break;
case sfEvtMouseButtonPressed:
switch(Event.MouseButton.Button){
case sfButtonLeft:
if( (sfInput_GetMouseY(input) > sfWindow_GetHeight(mywin)-mygui->high) && ( sfInput_GetMouseY(input) < sfWindow_GetHeight(mywin)-mygui->high+5) ){
action=DRAGS;
}
break;
}
break;
case sfEvtMouseButtonReleased:
if( Event.MouseButton.Button == sfButtonLeft)
{
action = NONE;
}
break;
case sfEvtMouseMoved:
switch(action){
case DRAGS:
mygui->high = (sfWindow_GetHeight(mywin)-(Event.MouseMove.Y));
if( ((sfWindow_GetHeight(mywin)-Event.MouseMove.Y) > (sfWindow_GetHeight(mywin)-30)) )
{
mygui->high = (sfWindow_GetHeight(mywin)-30);
}
if( Event.MouseMove.Y > (sfWindow_GetHeight(mywin)-30))
{
mygui->high = 30;
}
break;
}
break;
}
}
sfWindow_SetActive(mywin, 1);
glClearColor(0.5,0.5,0.5,1.0);
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
//3d
float aspect;
aspect = ((float)sfWindow_GetWidth(mywin))/((float)sfWindow_GetHeight(mywin));
glViewport(0,0,sfWindow_GetWidth(mywin), sfWindow_GetHeight(mywin));
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gluPerspective(45.0, aspect, 0.1, 200.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
//2d
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gluOrtho2D(0, sfWindow_GetWidth(mywin), 0, sfWindow_GetHeight(mywin));
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
guidraw();
sfWindow_Display(mywin);
}
return 0;
}
help appreciated