zumwalt Posted April 30, 2013 Share Posted April 30, 2013 I used the first tutorial which works for drawing the text to the screen, had to add in the context->clear for it to work, but now I am having a totally different problem, I looked at the documentation at URL http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/font/fontload-r43 This has something called "Draw" in the code sample that is not defined so I have on clue what that is in C++ because when I try to use it, c++ has no clue what it is, so my code that I tried is: bool App::Loop() { //Close the window to end the program if (window->Closed()) return false; //Press escape to end freelook mode if (window->KeyHit(Key::Escape)) { if (!freelookmode) return false; freelookmode=false; window->ShowMouse(); } lib.update(); jText = lib.getStateString(); text = jText.UTF8Representation(); // lets draw that text context->Clear(); context->SetColor(120,120,0); context->SetBlendMode(Blend::Alpha); context->DrawText(text,pos.x,pos.y); context->SetBlendMode(Blend::Solid); context->SetColor(0,0,0); //context->Sync(); if (freelookmode) { //Keyboard movement float strafe = (window->KeyDown(Key:) - window->KeyDown(Key::A))*Time::GetSpeed() * 0.05; float move = (window->KeyDown(Key::W) - window->KeyDown(Key::S))*Time::GetSpeed() * 0.05; camera->Move(strafe,0,move); //Get the mouse movement float sx = context->GetWidth()/2; float sy = context->GetHeight()/2; Vec3 mouseposition = window->GetMousePosition(); float dx = mouseposition.x - sx; float dy = mouseposition.y - sy; //Adjust and set the camera rotation camerarotation.x += dy / 10.0; camerarotation.y += dx / 10.0; camera->SetRotation(camerarotation); //Move the mouse to the center of the screen window->SetMousePosition(sx,sy); } Time::Update(); world->Update(); world->Render(); context->Sync(false); return true; } The problem is that this code, the text does not show, if I remove the remark lines from //context->Sync(); then it draws the text but the scene is black, but if I leave it commented out the scene shows but the text doesn't show, so how do I get both the text to show (and yes the text changes per game loop) and have the scene show? Quote Link to comment Share on other sites More sharing options...
Rick Posted April 30, 2013 Share Posted April 30, 2013 What I know your text should be drawn between world->Render(); /// all 2D drawing here (text and images) context->Sync(false); This is probably why you had to clear and all because I never do that. 1 Quote Link to comment Share on other sites More sharing options...
Admin Posted April 30, 2013 Share Posted April 30, 2013 Thanks, I updated the code sample. The problem is you are rendering the world after drawing text, which clears the color buffer. Render the text after drawing the world instead. Quote Link to comment Share on other sites More sharing options...
zumwalt Posted April 30, 2013 Author Share Posted April 30, 2013 Ok so two new things to learn off this, if you do the text draw before rendering the world, you get stacked text and looks like ****, if you do it after you render the world then it looks good. Now here is my code that works thanks to both of you. bool App::Loop() { //Close the window to end the program if (window->Closed()) return false; //Press escape to end freelook mode if (window->KeyHit(Key::Escape)) { if (!freelookmode) return false; freelookmode=false; window->ShowMouse(); } lib.update(); jText = lib.getStateString(); text = jText.UTF8Representation(); if (freelookmode) { //Keyboard movement float strafe = (window->KeyDown(Key:) - window->KeyDown(Key::A))*Time::GetSpeed() * 0.05; float move = (window->KeyDown(Key::W) - window->KeyDown(Key::S))*Time::GetSpeed() * 0.05; camera->Move(strafe,0,move); //Get the mouse movement float sx = context->GetWidth()/2; float sy = context->GetHeight()/2; Vec3 mouseposition = window->GetMousePosition(); float dx = mouseposition.x - sx; float dy = mouseposition.y - sy; //Adjust and set the camera rotation camerarotation.x += dy / 10.0; camerarotation.y += dx / 10.0; camera->SetRotation(camerarotation); //Move the mouse to the center of the screen window->SetMousePosition(sx,sy); } Time::Update(); world->Update(); world->Render(); // lets draw that text, do this after render world context->SetColor(0,0,0); //context->Clear(); context->SetBlendMode(Blend::Alpha); context->SetColor(120,120,0); context->DrawText(text,pos.x,pos.y); context->SetBlendMode(Blend::Solid); context->Sync(false); return true; } And I can see that the networking component is now working, just got to figure out the lag. Quote Link to comment Share on other sites More sharing options...
Rick Posted April 30, 2013 Share Posted April 30, 2013 ?? networking component Quote Link to comment Share on other sites More sharing options...
zumwalt Posted April 30, 2013 Author Share Posted April 30, 2013 Just my little pet project... Incomplete but is working for testing purposes obviously, I just needed to figure out how to get this to work in Leadwekrs and I am happy I did. http://www.exitgames.com/ Attached is my current header and code files, for now the client simply attachs to my server and send/receives test packets, all the other methods I have in the header aren't ready yet. PhotonLib.h PhotonLib.cpp Quote Link to comment Share on other sites More sharing options...
Rick Posted April 30, 2013 Share Posted April 30, 2013 Ah ok cool. Quote Link to comment Share on other sites More sharing options...
Admin Posted April 30, 2013 Share Posted April 30, 2013 Interesting. Can you tell us more about your project? Quote Link to comment Share on other sites More sharing options...
zumwalt Posted April 30, 2013 Author Share Posted April 30, 2013 Simple really, using Photon networking engine (which anyone can download and have 100 CCU license for free), I am building up the code where in one line of code you connect up to the server and then you can send serialized player data to the server for broadcast, etc, same for creatures, only thing that doesn't get sent is the obvious things like maps, etc, onlything anyone will have to do is download Photon and using the win32 SDK or iPhone / Android SDK setup instructions, get the basic setup done for the project then drop in the header and cpp files and off they go. Make simple calls such as Player->Send(); and Enemy->Send(); would be almost enough, trying to make it generic enough for any type of game. Right now I have the client talking to the server and getting data back from the server which was enough proof of concept using the Native C++ libraries. 2 Quote Link to comment Share on other sites More sharing options...
Guest Red Ocktober Posted April 30, 2013 Share Posted April 30, 2013 This Is Really Decent Zum... Everyone Take A Look... --Mike Quote Link to comment Share on other sites More sharing options...
Josh Posted April 30, 2013 Share Posted April 30, 2013 What does their system allow that you couldn't just do in ENet? What part of the process does this simplify? Is it establishing the initial connection? Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
zumwalt Posted April 30, 2013 Author Share Posted April 30, 2013 They support every possible platform on the market today, not to mention they have server loadbalancing available and cloud deployment. As far as total comparison between products, you would have to look at all of the features side by side with ENet to answer that question, I personally have never used ENet. I can seamlessly shift from one server to another in the event of heavy server load without the player knowing it, basically one game world can in theory have unlimited players. Only limit at that point is the rendering engine. To get any deeper into the pro's and con's between Photon and ENet you literally would have to look at what is available in both along with licensing and packet size. Photon is truly streamlined with great compression. Check out their reference section: https://www.exitgames.com/References Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.