Thanks pitchatan for your kind help but probably I'm dumb or my FTE/CEF installation is!
Using your identical code
Code: Select all
float cef_active; // check variable.
void CSQC_Init(float apilevel, string enginename, float engineversion)
{
cvar_set("cef_allowcvars","1");
gecko_create("cef_test"); // performing navigate here will not do anything.
}
void CSQC_UpdateView(float vwidth, float vheight, float notmenu)
{
setcursormode(TRUE);
vector mouse = getmousepos();
vector cef_position;
vector screen_size = [vwidth,vheight];
cef_position_x = mouse_x / screen_size_x;
cef_position_y = mouse_y / screen_size_y;
//
clearscene();
renderscene();
//
if(!cef_active){
gecko_navigate("cef_test","fte://data/index.html"); // navigate to our page.
cef_active = TRUE;
}
else{
gecko_resize("cef_test",screen_size_x,screen_size_y);
drawpic([0,0],"cef_test",screen_size,[1,1,1],1);
}
}
it will simply display nothing(not even web page).
Using modified version (without the cef_active check)
Code: Select all
float cef_active; // check variable.
void CSQC_Init(float apilevel, string enginename, float engineversion)
{
cvar_set("cef_allowcvars","1");
gecko_create("cef_test"); // performing navigate here will not do anything.
}
void CSQC_UpdateView(float vwidth, float vheight, float notmenu)
{
setcursormode(TRUE);
vector mouse = getmousepos();
vector cef_position;
vector screen_size = [vwidth,vheight];
cef_position_x = mouse_x / screen_size_x;
cef_position_y = mouse_y / screen_size_y;
//
clearscene();
renderscene();
//
gecko_navigate("cef_test","fte://data/index.html"); // navigate to our page.
cef_active = TRUE;
gecko_resize("cef_test",screen_size_x,screen_size_y);
drawpic([0,0],"cef_test",screen_size,[1,1,1],1);
}
will display web page but resolution it's too low, so I used Spike method that use virtual screen and physical screen. Plus you declared cef_position but you never used it.
So I did
Code: Select all
float cefSuccess;
vector inputCursorOrg,cefCursorOrg;
void CSQC_Init(float apilevel, string enginename, float engineversion)
{
cefSuccess = gecko_create("cef_test"); // performing navigate here will not do anything.
}
float CSQC_InputEvent(float evtype, float scanx, float chary, float devid)
{
switch(evtype){
case IE_KEYUP:
if(scanx == K_MOUSE1){
gecko_keyevent("cef_test",scanx,evtype);
return TRUE;
}
break;
case IE_MOUSEABS:
inputCursorOrg_x = scanx;
inputCursorOrg_y = chary;
cefCursorOrg = normalize(inputCursorOrg);
//avoid -coords
if(cefCursorOrg_x < 0){
cefCursorOrg_x = 0;
}
if(cefCursorOrg_y < 0){
cefCursorOrg_y = 0;
}
return TRUE;
}
return 0;
}
void Gecko_Draw(vector gpos, vector gsize)
{
vector psize = (vector)getviewprop(VF_SCREENPSIZE); //query the current physical screen size
vector vsize = (vector)getviewprop(VF_SCREENVSIZE); //query the current virtual screen size
gecko_resize("cef_test", gsize_x * psize_x / vsize_x, gsize_y * psize_y / vsize_y); //tell the media decoder the actual size in pixels (or rather, texels) instead of virtual sizes (those come from the size arg of drawpic).
gecko_navigate("cef_test","fte://data/index.html"); // navigate to our page.
drawpic(gpos, "cef_test", gsize, [1,1,1],1, 0); //draw the shader.
gecko_mousemove("cef_test", cefCursorOrg_x,cefCursorOrg_y); //report the mouse coords in terms of 0-1, instead of pixels or anything.
gecko_keyevent("cef_test",K_MOUSE1,IE_KEYUP);
}
void CSQC_UpdateView(float vwidth, float vheight, float notmenu)
{
setcursormode(TRUE);
//
clearscene();
renderscene();
//
Gecko_Draw([0,0,0],[vwidth,vheight,0]);
}
and I added
cef_allowcvars 1 in default.cfg because FTE can't read that value when map is loaded, you should need some sort of timer but map should be restart to make changes to take effect, so.. it's better to put it in .cfg, at least for now
This is the "best" solution so far, because web page resolution is normal now, mouse moves and cvars are seen on screen. But click event is NOT send, not even hover position.
As you can see, I used gecko_keyevent() both in CSQC_InputEvent and CSQC_UpdateView() but it doesn't work anyway. Instead, when old code (the one using the shader with videomap syntax, instead of gecko_navigate()), when I hover mouse on slider, it changes slightly brightness, so it means it intercepts mouse move..