FTE + WEB browsing = libCEF or Berkelium
Re: FTE + WEB browsing = libCEF or Berkelium
I don't intend to support file:/// at all. It violates the premise of sandboxing. fte://data/ should be used instead.
yes libcef appears to be a little crashy still. I don't know what I can do about that, many of the crashes I've seen appear to come from outside of my code (they may still be my fault, but I've no idea how to avoid them). the one I've been getting lately crashes the browser process, rather than any of my code.
yes libcef appears to be a little crashy still. I don't know what I can do about that, many of the crashes I've seen appear to come from outside of my code (they may still be my fault, but I've no idea how to avoid them). the one I've been getting lately crashes the browser process, rather than any of my code.
-
- Posts: 1395
- Joined: Tue Feb 24, 2009 4:39 pm
- Location: Italy
Re: FTE + WEB browsing = libCEF or Berkelium
No Spike, I never used file:// (I'm not that noob). fte://data/ and fte://csqc give same cross origin problem (I noticed that thanks to the great ced_devtools cvar, awesome!).
Could you help me to pass a var from qc to cef and vice-versa? Because in Crafter I created CUI (Crafter User Interface) where I intercept mouse click state. Since onmouseover works on cef, if I can pass that var in Javascript I could do if onmouseover && clickevent == true -> click event trigger, and we're good. Otherwise all the good work you did, without mouse click, becomes very difficult to use.
Yes you could use onmouseover to click but, meh...
**EDIT**: I noticed you updated FTE trunk to use last version of CEF.. awesome!
Could you help me to pass a var from qc to cef and vice-versa? Because in Crafter I created CUI (Crafter User Interface) where I intercept mouse click state. Since onmouseover works on cef, if I can pass that var in Javascript I could do if onmouseover && clickevent == true -> click event trigger, and we're good. Otherwise all the good work you did, without mouse click, becomes very difficult to use.
Yes you could use onmouseover to click but, meh...
**EDIT**: I noticed you updated FTE trunk to use last version of CEF.. awesome!
Meadow Fun!! - my first commercial game, made with FTEQW game engine
Re: FTE + WEB browsing = libCEF or Berkelium
toneddu2000 wrote:Ok, little step forward. For those who want to know how to do this:In your csqc project add a Cef_GeneratePage() function like this:Spike wrote: I did create an 'fte' scheme, so fte://data/* reads files from quake's filesystem, fte://ssqc/* fte://csqc/* fte://menu/* will invoke the Cef_GeneratePage qc function to generate page requests (make requests to your qc if you feel like doing so, maybe in conjunction with uri_unescape).
You should also be able to call window.fte_query("getstats", function(req,ret){alert(ret);}); and get a list of stats. getseats, getserverinfo, getplayers should also work. note the delay.Then you can access it throughCode: Select all
string Cef_GeneratePage() { local string htmlheader = "<html><head><title>CSQC startpoint</title></head>"; local string htmlbodyopen = "<body>"; local string htmlbodyclose = "</body></html>"; local string htmlmsg = strcat("Player health: <span style='font-size:12pt;color:red;font-weight:bold;'>",ftos(player.health),"</span>"); return strcat(htmlheader,htmlbodyopen,htmlmsg,htmlbodyclose); }
The cool thing is that you can use CSS to decorate your page!
- commandline via cef fte://csqc/index.html or just cef fte://csqc and then click in the browser window on the sign "Or try here"
- via shader will make FTE crash, so try by yourself but on my pc it's a no-go
- via gecko_navigate() call like gecko_navigate(yourshadername,"fte://csqc/index.html");
Yay for reading engine code!
Reason why your shader might be crashing your client is because you aren't using videomap.
Try replacing whatever you are using in your shader to videomap cef:http://www.google.com
Other option is to create a cef/gecko shader in qc and point your shader toward that.
-
- Posts: 1395
- Joined: Tue Feb 24, 2009 4:39 pm
- Location: Italy
Re: FTE + WEB browsing = libCEF or Berkelium
Yeah, you were right, pitchatan, thanks a lot, it worked!pitchatan wrote: Reason why your shader might be crashing your client is because you aren't using videomap.
Try replacing whatever you are using in your shader to videomap cef:http://www.google.com
I was using videomap in my shader, but I was using it wrong.
Wrong version
Code: Select all
cefcsqc
{
//remember inner curly braces or videmap will not be initialized!
{
videomap fte://csqc/index.html
}
}
Correct version
Code: Select all
cefcsqc
{
//remember inner curly braces or videmap will not be initialized!
{
videomap cef:fte://csqc/index.html
}
}
Thanks again for the tip! If you know, now, how to pass a var from csqc to browser and back that would be really appreciated!
Meadow Fun!! - my first commercial game, made with FTEQW game engine
Re: FTE + WEB browsing = libCEF or Berkelium
You pass variables through calling the javascript function in cef and passing a string.toneddu2000 wrote:pitchatan wrote: how to pass a var from csqc to browser and back that would be really appreciated!
Code: Select all
float our_unique_variable = 1234;
string java = strcat("javascript:","var foo =", ftos(our_unique_variable));
gecko_navigate(your_cef_session,java);
It essentially works the same way as chrome and chrome/chromium based browsers.
Take care of calling it every frame though as it can be very slow at times.
When it comes to grabbing variables from cef i am a bit unsure, think you need to parse the entire html string or similar.
Better off asking Spike about it.
Re: FTE + WEB browsing = libCEF or Berkelium
toneddu2000 wrote:pitchatan wrote: how to pass a var from csqc to browser and back that would be really appreciated!
Took a quick look through the engine sources and can shed some further light on this.
Right now you can't pass engine variables, but you can pass cvar variables (both ways) as well as get a summary of serverinfo,players etc in json form.
Code: Select all
window.fte_query('getplayers' function(req,ret){}); // req being your request string, ret being the return.
other requests available are.
getcvar_ // ex: getcvar_name
setcvar_ // ex: setcvar_name=foo
getstats
getseats
getserverinfo
getplayers
Code: Select all
<div onclick="window.fte_query('getcvar_sensitivity',function(req,ret){ alert('sensitivity: '+ret)});"> get sensitivity </div>
<div onclick="window.fte_query('setcvar_sensitivity=12',function(req,ret){ alert('new sensitivity: '+ret)}); /* will not return anything if you do not parse the call string */"> set sensitivity 12</div>
Quick example:
Code: Select all
<html>
<head>
<style>
.menu { background: rgba(0,0,0,0.4); padding: 2px;}
</style>
<script>
var cvar_sensitivity; // our sensitivity variable
window.fte_query('getcvar_sensitivity', function(req,ret){
cvar_sensitivity = ret; // sets the cvar_sensitivity variable based on the return value.
document.getElementById('mySens').value = cvar_sensitivity; // sets mySens element.
document.getElementById('mySens_bar').value = cvar_sensitivity; // sets mySens_bar element.
}); // call this onload to set our input buttons and whatnot.
</script>
</head>
<body style="color: black; background: white;">
<form id="settings">
<div class="menu" onclick="window.fte_query('getcvar_sensitivity', function(req,ret){alert(req+' : '+ret);});">get sensitivity</div>
<div class="menu">set sensitivity: <input type="range" id="mySens" min="0" max="30" onchange="cvar_sensitivity=document.forms['settings']['mySens'].value; window.fte_query('setcvar_sensitivity='+cvar_sensitivity, function(req,ret){ /*alert(req+' : '+ret);*/}); document.getElementById('mySens_bar').value = cvar_sensitivity;"></input><input id="mySens_bar"></input></div>
<div style="margin: 20px;">other stuff...<br>
<div class="menu" onclick="window.fte_query('getplayers', function(req,ret){alert(req+' : '+ret);});">get players</div>
<div class="menu" onclick="window.fte_query('getserverinfo', function(req,ret){alert(req+' : '+ret);});">get serverinfo</div>
<div class="menu" onclick="window.fte_query('getstats', function(req,ret){alert(req+' : '+ret);});">get stats</div>
<div class="menu" onclick="window.fte_query('getseats', function(req,ret){alert(req+' : '+ret);});">get seat</div>
</div>
</form>
</body>
</html>
Happy hunting.
-
- Posts: 1395
- Joined: Tue Feb 24, 2009 4:39 pm
- Location: Italy
Re: FTE + WEB browsing = libCEF or Berkelium
Thanks a lot pitchatan! Very interesting the idea of using cvars! Unfortunately it doesn't work for me!
I mean, did it work for you the example you posted? If you put that html file as a shader on a wall or paint it on screen via drawpic() in csqc, can you click on slider or get cvar value?
Because my problem is that click event is not passed from csqc to cef, so I can click as many times I want but nothing happens. So I change evento to 'onmouseover' on setsensitivity and hovering on slider makes appear the value of '15' for sensitivity but if I try to read sensitivity value, hovering on getsensitivity input box, it alerts "getcvar_sensitivity " without any value.
Get stats buttons on the bottom of the page, instead, they work
If, instead, I use console cef fte://data/index.html, of course click event works, slider works, but getcvar_sensitivity alert value is always blank
Anyway you give me a great input with cvars: I'll make some test and I'll post them here
I mean, did it work for you the example you posted? If you put that html file as a shader on a wall or paint it on screen via drawpic() in csqc, can you click on slider or get cvar value?
Because my problem is that click event is not passed from csqc to cef, so I can click as many times I want but nothing happens. So I change evento to 'onmouseover' on setsensitivity and hovering on slider makes appear the value of '15' for sensitivity but if I try to read sensitivity value, hovering on getsensitivity input box, it alerts "getcvar_sensitivity " without any value.
Get stats buttons on the bottom of the page, instead, they work
If, instead, I use console cef fte://data/index.html, of course click event works, slider works, but getcvar_sensitivity alert value is always blank
Anyway you give me a great input with cvars: I'll make some test and I'll post them here
Meadow Fun!! - my first commercial game, made with FTEQW game engine
Re: FTE + WEB browsing = libCEF or Berkelium
toneddu2000 wrote:Thanks a lot pitchatan! Very interesting the idea of using cvars! Unfortunately it doesn't work for me!
I mean, did it work for you the example you posted? If you put that html file as a shader on a wall or paint it on screen via drawpic() in csqc, can you click on slider or get cvar value?
Because my problem is that click event is not passed from csqc to cef, so I can click as many times I want but nothing happens. So I change evento to 'onmouseover' on setsensitivity and hovering on slider makes appear the value of '15' for sensitivity but if I try to read sensitivity value, hovering on getsensitivity input box, it alerts "getcvar_sensitivity " without any value.
Get stats buttons on the bottom of the page, instead, they work
If, instead, I use console cef fte://data/index.html, of course click event works, slider works, but getcvar_sensitivity alert value is always blank
Anyway you give me a great input with cvars: I'll make some test and I'll post them here
You are most likely not passing click events (keydown,keyup), both are needed to work properly.
In CSQC_Input_Event
float(string name, float key, float eventtype) gecko_keyevent
Try this out in your gecko calls and see if it works.
Code: Select all
if(evtype == IE_KEYDOWN || evtype == IE_KEYUP)
{
if(scanx == K_MOUSE1)
{
gecko_keyevent(your_cef_session,scanx,evtype);
return TRUE;
}
}
As for the other issues you are having i don't know, i haven't sat down and gone through things in detail in a good while.
-
- Posts: 1395
- Joined: Tue Feb 24, 2009 4:39 pm
- Location: Italy
Re: FTE + WEB browsing = libCEF or Berkelium
nah, it doesn't work, already tried with Spike some day ago. Plus Spike said that gecko_keyevent() return value probably is not even set
You didn't answer my question though: does the demo you posted work on your fte installation(using csqc and drawpic, NOT using cef command by console)? Because, if it does, then it's something I set wrong, if it doesn't, simply cef implementation right now is not usable and it's counterproductive to put so much effort on trial and error
PS: when you sayfor "your_cef_session" you mean "your cef shader",right? Because for every other cef functions, I always used shader (with videomap stuff) as argument
But thanks anyway pitchatan, I appreciate your effort!Spike wrote: gecko_keyevent's return value isn't useful. don't bother with it (apparently fte doesn't even set it. hurrah for undefined values).
You didn't answer my question though: does the demo you posted work on your fte installation(using csqc and drawpic, NOT using cef command by console)? Because, if it does, then it's something I set wrong, if it doesn't, simply cef implementation right now is not usable and it's counterproductive to put so much effort on trial and error
PS: when you say
Code: Select all
gecko_keyevent(your_cef_session,scanx,evtype);
Meadow Fun!! - my first commercial game, made with FTEQW game engine
Re: FTE + WEB browsing = libCEF or Berkelium
Think i understand what the problem is now.toneddu2000 wrote:nah, it doesn't work, already tried with Spike some day ago. Plus Spike said that gecko_keyevent() return value probably is not even setBut thanks anyway pitchatan, I appreciate your effort!Spike wrote: gecko_keyevent's return value isn't useful. don't bother with it (apparently fte doesn't even set it. hurrah for undefined values).
You didn't answer my question though: does the demo you posted work on your fte installation(using csqc and drawpic, NOT using cef command by console)? Because, if it does, then it's something I set wrong, if it doesn't, simply cef implementation right now is not usable and it's counterproductive to put so much effort on trial and error
PS: when you sayfor "your_cef_session" you mean "your cef shader",right? Because for every other cef functions, I always used shader (with videomap stuff) as argumentCode: Select all
gecko_keyevent(your_cef_session,scanx,evtype);
You are using it straight in a shader, which wont really work when passing keypresses and mouse positions properly. I think there was a way to do it but i haven't really touched the cef stuff in over a year. You also need to to set cef_allowcvars for cvar manipulation/reading to work.
Try this.
Code: Select all
void(float apilevel, string enginename, float engineversion) CSQC_Init =
{
set_cvar("cef_allowcvars","1");
gecko_create("cef_test"); // performing navigate here will not do anything.
}
float cef_active; // check variable.
void(float vwidth, float vheight, float notmenu) CSQC_UpdateView =
{
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);
}
}
Here is my example with the html i provided before in action: https://www.youtube.com/watch?v=9PlRLyx ... e=youtu.be
-
- Posts: 1395
- Joined: Tue Feb 24, 2009 4:39 pm
- Location: Italy
Re: FTE + WEB browsing = libCEF or Berkelium
Thanks pitchatan for your kind help but probably I'm dumb or my FTE/CEF installation is!
Using your identical code
it will simply display nothing(not even web page).
Using modified version (without the cef_active check)
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
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..
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);
}
}
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);
}
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]);
}
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..
Meadow Fun!! - my first commercial game, made with FTEQW game engine
Re: FTE + WEB browsing = libCEF or Berkelium
Reason why input doesn't work is because you are sending only the IE_KEYUP event, think of IE_KEYDOWN, IE_KEYUP as +click -click.toneddu2000 wrote: 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..
This is to allow you to be able to drag elements and such and an element in the browser process will only be called after both have been used.
Another problem i noticed with your code is that you are still trying to call gecko_navigate every frame, this doesn't work and is what is most likely stopping you from being able to hover over your html elements. I think spike even warned you about this in this very thread.
Reason why i had the cef_active boolean was to give the cef process enough time to start, apparently my computer is slightly faster than yours and your cef process hasn't started before the gecko_navigate function was called. Asynchronous is a bitch mistress..
Furthermore you can apparently use a normal shader ex:
Code: Select all
cef_session1 { {videomap cef:fte://data/index.html }}
Code: Select all
gecko_navigate("cef_session1",yoururl);
And yes, i missed passing the gecko_mouse stuff. My bad
-
- Posts: 1395
- Joined: Tue Feb 24, 2009 4:39 pm
- Location: Italy
Re: FTE + WEB browsing = libCEF or Berkelium
Thanks A LOT pitchatan! Thanks to your help and Spike's, I managed to solve it.
I was committing an error in CSQC_InputEvent() for the click part. It was like you said: it needs both IE_KEYDOWN and IE_KEYUP at the same time to trigger the mouse click, and using the switch syntax "case IE_KEYDOWN || IE_KEYUP:" won't work.
And then, for mouse coords, instead of using normalized input vectors, I should have used regular mouse coordinates. I replaced your getmousepos() with CSQC_InputEvent() because Spike wrote on defs file that it's better to use CSQC_InputEvent() for this stuff since it's a DP implementation and not a FTE native one, but, honestly I don't know why. Your getmousepos() code worked great though.
Here's the finished code. I reccommend everyone to use a .tga image for cursor image because, sometimes webpage are white coloured in the background and it's impossible to see mouse movements.
Now I'll dig into cvars exchange! Thanks again pitchatan for all your great help!
I was committing an error in CSQC_InputEvent() for the click part. It was like you said: it needs both IE_KEYDOWN and IE_KEYUP at the same time to trigger the mouse click, and using the switch syntax "case IE_KEYDOWN || IE_KEYUP:" won't work.
And then, for mouse coords, instead of using normalized input vectors, I should have used regular mouse coordinates. I replaced your getmousepos() with CSQC_InputEvent() because Spike wrote on defs file that it's better to use CSQC_InputEvent() for this stuff since it's a DP implementation and not a FTE native one, but, honestly I don't know why. Your getmousepos() code worked great though.
Yeah, infact I used a timer of 5 secs. If someone still shouldn't see webpage, it's possible to: a) increase CEF_TIME_LOAD constant value or b)use Space key to trigger gecko_navigate() func on demandpitchatan wrote:Reason why i had the cef_active boolean was to give the cef process enough time to start, apparently my computer is slightly faster than yours and your cef process hasn't started before the gecko_navigate function was called. Asynchronous is a bitch mistress..
Ah..busted!pitchatan wrote:Another problem i noticed with your code is that you are still trying to call gecko_navigate every frame, this doesn't work and is what is most likely stopping you from being able to hover over your html elements. I think spike even warned you about this in this very thread.
Here's the finished code. I reccommend everyone to use a .tga image for cursor image because, sometimes webpage are white coloured in the background and it's impossible to see mouse movements.
Code: Select all
const float CEF_TIME_LOAD = 5;
float cefSuccess;
vector inputCursorOrg;
void Gecko_Error()
{
error("Gecko couldn't be initialized\n");
}
void Gecko_Navigate()
{
if(cefSuccess == TRUE){
gecko_navigate("cef_session","fte://data/index.html");
}
else{
Gecko_Error();
}
}
void Gecko_NavigateThink()
{
world.nextthink = time + CEF_TIME_LOAD;
world.think = Gecko_Navigate;
}
void CSQC_Init(float apilevel, string enginename, float engineversion)
{
cefSuccess = gecko_create("cef_session"); // performing navigate here will not do anything.
Gecko_NavigateThink();
}
float CSQC_InputEvent(float evtype, float scanx, float chary, float devid)
{
if(evtype == IE_KEYDOWN || evtype == IE_KEYUP){
if(scanx == K_MOUSE1){
gecko_keyevent("cef_session",scanx,evtype);
return TRUE;
}
}
if(evtype == IE_MOUSEABS){
inputCursorOrg_x = scanx;
inputCursorOrg_y = chary;
return TRUE;
}
if(evtype == IE_KEYDOWN){
if(scanx == K_SPACE){
Gecko_Navigate();
return TRUE;
}
}
return 0;
}
void Gecko_Mouse(float vwidth,float vheight)
{
local vector cef_position;
local vector screen_size = [vwidth,vheight];
if(cefSuccess == TRUE){
setcursormode(TRUE,"textures/cef/cursor.tga");
cef_position_x = inputCursorOrg_x / screen_size_x;
cef_position_y = inputCursorOrg_y / screen_size_y;
gecko_mousemove("cef_session", cef_position_x,cef_position_y);
}
else{
Gecko_Error();
}
}
void Gecko_Draw(vector gpos, vector gsize)
{
local vector psize = (vector)getviewprop(VF_SCREENPSIZE);
local vector vsize = (vector)getviewprop(VF_SCREENVSIZE);
if(cefSuccess == TRUE){
//it renders browser window taking in account of screen resolution
gecko_resize("cef_session", gsize_x * psize_x / vsize_x, gsize_y * psize_y / vsize_y);
drawpic(gpos, "cef_session", gsize, [1,1,1],1, 0);
}
else{
Gecko_Error();
}
}
void CSQC_UpdateView(float vwidth, float vheight, float notmenu)
{
Gecko_Mouse(vwidth,vheight);
clearscene();
renderscene();
Gecko_Draw([0,0,0],[vwidth,vheight,0]);
}
Meadow Fun!! - my first commercial game, made with FTEQW game engine
Re: FTE + WEB browsing = libCEF or Berkelium
http://triptohell.info/moodles/win32/ft ... ef_x86.dll tweaks a few things. Hopefully you'll find it to be a little more reliable.
and gecko_create can accept two args, which avoids the need for a separate navigate call.
and gecko_create can accept two args, which avoids the need for a separate navigate call.
-
- Posts: 1395
- Joined: Tue Feb 24, 2009 4:39 pm
- Location: Italy
Re: FTE + WEB browsing = libCEF or Berkelium
Thanks Spike for all your effort! For those who want to try it, you should also download cef lib package from Spike's repo, because if you (like me) try to download and use cef from official cef repo, fte won't find it, dunno why.
Unfortunately, this new version seems a little step backwards because:
Thanks again!
Unfortunately, this new version seems a little step backwards because:
- gecko_create now accepts 2 args but it's quite pointless because, without a timer func that slow down cef initialization, web page won't be loaded at all. Probably an asynchronous mechanism should be taken in consideration but, on my slow pc, using
it won't display anything (just checkers-like drawpic background). And you if you use a flag like
Code: Select all
gecko_create("cef_session","http://google.com");
And then you put and if(!geckoSuccess)->error it will prints an errorCode: Select all
cefSuccess = gecko_create("cef_session");
- mouse doesn't work again on webpages . Weird things is that it works with fte://data/index.html (the example that pitchatan kindly posted), but it doesn't work with external sites like Google or so (hover works though). Instead old version works great with both local and external sites (the code I used it's THE SAME)
- cef commandline now doesn't accept mouse click! Which, with older releases it was the only part where mouse clicks work without problems!
Thanks again!
Meadow Fun!! - my first commercial game, made with FTEQW game engine