Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411423 Posts in 69363 Topics- by 58416 Members - Latest Member: JamesAGreen

April 18, 2024, 08:26:58 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)General thread for quick questions
Pages: 1 ... 30 31 [32] 33 34 ... 69
Print
Author Topic: General thread for quick questions  (Read 134658 times)
shellbot
Guest
« Reply #620 on: April 07, 2016, 03:30:03 AM »

Poking in just so I remember to comment in this thread next time I get stuck. I'll throw in a question to save face (answer if you so desire):

How do you guys find Python3 performance for dev?

I've been developing in it for a while, and honestly, the shit holds up for 2D. However I'm constantly afraid that I'll hit some form of ceiling. Hasn't happened yet, but it could be right around the corner.
Logged
Shephf
Level 1
*



View Profile WWW
« Reply #621 on: April 07, 2016, 03:34:58 AM »

Quote
Next question, how does OpenGL handle changing colour buffers? I want a bunch of televisions in my game, each displaying a unique animated procedurally generated image, and I'm not sure the best way to do this. Should I give each television it's own colour buffer? Or should I make one that's used by all? The problem is I can't give an upward limit to how many TVs will be on screen at once, so giving each their own seems terribly inefficient, but if I share one amongst hundreds will openGL manage? Does openGL handle a colorbuffer being changed while it may be still in use in the pipeline? Or am I not understanding something? Or is constantly switching buffer a bad way to go anyway, should I try making the screens render all in the main FBO.
You can use a single separate FBO for that and continuously attach it to different color buffers and render. No need to have many FBOs, it's more efficient to use single FBO per-format (i.e. per widhtxheightxbpp), there's even a note on that on opengl.org, but I can't find that right now.
Different color buffers are different textures in your case. Using one texture will be causing stalls, consider 10 TVs and 1 texture, you render the first one, the command batch for GPU is extended, now you render the next one using the same texture, the OpenGL implementation will have no choice but to flush your command batch and wait for it to complete in order to be able to render another TV. IMO the best way here is to use X different textures, where X is configurable parameter (m.b. platform-dependent) and stream those TVs to those X textures and use them, that way, unless you have more than X TVs on screen you'll have no stalls, if you have more, you'll hove a couple of stalls, but not that many.
Logged

randomThrowAway
Level 0
***


View Profile
« Reply #622 on: April 07, 2016, 05:27:38 AM »

Excuse me if this is obvious, but I'm bad at Math.
Is there a simple way to make a weighted range for random with 3 inputs (MIN, MAX, AVERAGE)?

Something like
Code:
new RandomRange(0, 10, 4)
would be able to spit out a number 0-10, with the average number being 4.
Logged
Shephf
Level 1
*



View Profile WWW
« Reply #623 on: April 07, 2016, 07:41:05 AM »

m.b. RNG with normal distribution can help you, i.e. in C++ you can do it like this: http://www.cplusplus.com/reference/random/normal_distribution/
If you're using some other language, then it probably has something similar, no need to implement this.
Logged

randomThrowAway
Level 0
***


View Profile
« Reply #624 on: April 07, 2016, 07:59:13 AM »

Thanks, is triangular distribution a valid choice as well?
I've found something for Java which sounds good at first glance:

randomTriangular(float min, float max, float mode)
Returns a triangularly distributed random number between min (inclusive) and max (exclusive), where values around mode are more likely.

But then I googled for the difference between normal and triangular distribution and, uh, wtf?

Edit: "more likely" sounds ambiguous, i.e. I don't think randomTriangular(0, 1000, 5) would make 5 be the actual average, but as long as it's strongly weighted by the "mode" it'll work fine for my purposes.
« Last Edit: April 07, 2016, 08:04:48 AM by randomThrowAway » Logged
Shephf
Level 1
*



View Profile WWW
« Reply #625 on: April 07, 2016, 08:03:33 AM »

I think triangular will do for you too. The difference is the distribution function:
tri:

normal:
Logged

randomThrowAway
Level 0
***


View Profile
« Reply #626 on: April 07, 2016, 08:05:23 AM »

Perfect, thanks Smiley
Logged
oahda
Level 10
*****



View Profile
« Reply #627 on: April 23, 2016, 11:13:35 AM »

Is there any good SDL2 GUI add-on?

I don't mean implemented in OpenGL or whatever, because that would interfere with my own engine's rendering pipeline too much, but a wrapper for actual native GUI stuff on top of everything?

I'd use Qt but I couldn't get it to embed the OpenGL context last time (had a long thread or a subthread here on that before and we never figured it out, and I don't think we can), and it'd be nice not to depend on such a heavy library for a cross-platform application anyway.

So something basically like Qt (not necessarily as complex, but all the standard stuff, including text input and a menu bar), but built for/in/as SDL2, in a cross-platform wrapper?

EDIT:
Hm, here's an otherwise seemingly promising one, tho, which while it is not native, seems to have been implemented in a clever way: it gives you the vertex buffers and you render them yourself.

https://github.com/ocornut/imgui

That's pretty neat. I might try this. Could be used for in-game GUI's too, not just engine/editor stuff.

EDIT 2:
Success! Gomez I got ImGui into my game/engine. Time to play around.



EDIT 3:
Agh, where's proper docs/tutorials, tho? Page and readme tell me to look in main and demo source files but they're not good at all and don't help much. I can find lots of impressive examples of applications using the framework but nothing on how to do it...

EDIT 4:
I can't see what I'm doing differently from what little code I can find online, but I seem to be unable to render anything to my ImGui window. Buttons, inputs... Nothing. Empty window. I wonder if there's something wrong with the rendering. But then I wouldn't expect it to render the window or its caption properly either.

EDIT 5:
Wooh, figured it out. Was indeed a rendering issue: glScissor() values were wrong. That's incredibly odd, tho, considering I was using rendering code that came along with ImGui in an example project. Oh well. The built-in test window now working fine:



And here's the best page I found for it so far: http://labs.domipheus.com/blog/dear-imgui-thanks-the-tpu-emulator/
« Last Edit: April 23, 2016, 05:08:39 PM by Prinsessa » Logged

InfiniteStateMachine
Level 10
*****



View Profile
« Reply #628 on: April 25, 2016, 08:39:28 AM »

Imgui is amazing. That's my default goto for a quick UI.

There's also nuklear which is similar but done in ansi C and inspired by imgui https://github.com/vurtun/nuklear
Logged

JWki
Level 4
****


View Profile
« Reply #629 on: April 26, 2016, 06:43:46 AM »

Yeah dear ImGui is the best GUI library I've ever used. I even use it for rather complex UIs. I hadn't heard of nuklear before, looks very nice, too - is it as fully featured as dear ImGui?
Logged
InfiniteStateMachine
Level 10
*****



View Profile
« Reply #630 on: April 26, 2016, 08:08:23 AM »

I havent played with it too much simply because it's already so similar to imgui and I'm comfortable with imgui now.

That said those styling shots in nuklear look pretty cool! You could almost use it for a decent game ui.
Logged

Shephf
Level 1
*



View Profile WWW
« Reply #631 on: April 26, 2016, 11:19:13 PM »

I strongly recommend libRocket - http://librocket.com It's lightweight, engine agnostic and can be easily integrated. I've recently reworked my game's UI using it, here's the result:


All those menus and controls are custom-made using css/html, it was fairly easy to do. BTW, I also though about using imgui first, but then I realized that imgui is better suited for in-game debugging, it doesn't allow one to customize stuff and make everything look pretty, so I went with libRocket and I'm pretty happy Smiley

P.S: BTW, libRocket integration into my OpenGL-based engine took a little less than 1 day
Logged

oahda
Level 10
*****



View Profile
« Reply #632 on: April 27, 2016, 04:23:01 AM »

then I realized that imgui is better suited for in-game debugging, it doesn't allow one to customize stuff and make everything look pretty, so I went with libRocket and I'm pretty happy Smiley
Yeah, that was my primary use case so it doesn't matter to me. But thanks for the suggestion! Might look into that at some point too.
Logged

zilluss
Level 1
*



View Profile
« Reply #633 on: April 27, 2016, 08:05:48 AM »

Personally, I would've been perfectly fine with one GUI framework but now you've given me the liability of choice  Angry
Logged

@zilluss | Devlog  Hand Point Right
ProgramGamer
Administrator
Level 10
******


aka Mireille


View Profile
« Reply #634 on: May 03, 2016, 11:16:25 AM »

I'm trying to use python to log into a website and retrieve some information, and for that I'm using urllib. The tutorial that I'm following warns about a flaw in security if I use basic authentication for this. My question is, how do I implement a better form of security? Shouldn't it just involve encrypting my username and password with a better security protocol that the website can decode? How would I even do this in Python?

Thanks in advance.
Logged

zilluss
Level 1
*



View Profile
« Reply #635 on: May 04, 2016, 12:40:56 AM »

The problem with basic auth (and form based auth) is that your credentials are sent in clear text. Thus a man-in-the-middle can intercept the communication and accquire your username and password. This problem does not occur when the website uses https, as the communication between you and the website is encrypted.
An alternative auth scheme is digest access, where the password is basically encrypted.

However, for you to use digest auth, the website has to offer it. If the website you want to log into doesn't offer digest auth and/or https, your credentials are vulnerable to interception and you have no way of notching up the security.
Logged

@zilluss | Devlog  Hand Point Right
ProgramGamer
Administrator
Level 10
******


aka Mireille


View Profile
« Reply #636 on: May 04, 2016, 03:01:04 AM »

Thanks for your answer!

Does this mean that, even if I use the basic auth function in urllib, my username/password won't be compromised as long as the site is https?
Logged

zilluss
Level 1
*



View Profile
« Reply #637 on: May 04, 2016, 12:00:40 PM »

Well the official answer is that there are no 100% secure systems. Unless security is really critical, you should be good to go with https.

Here is a good summary of the flaws in basic auth with regard to HTTPS, but they are mostly relevant for browsers: http://security.stackexchange.com/a/990

Logged

@zilluss | Devlog  Hand Point Right
Eendhoorn
Level 6
*

Quak


View Profile
« Reply #638 on: May 04, 2016, 01:04:00 PM »

I'm working on localisation, and I always use '%' to replace characternames in the localisation files, and then replace them in runtime (C#).
Right now I have a scenario where I have this result; '%' vs '%'. Where the first '%' and the second '%' are 2 different names for characters.

Right now I'm simply using
Code:
  vsText.Replace( '%', Localisation.GetTranslation( "TRANSLATION_KEY" ) );

So yeah that just replaces all the instances of '%' with the same translation.

string.indexOf only returns one index, so I can't use that to search for all indexes (indice?) and replace them manually.

Any smart way to handle this? I've never did localisation before so I have no clue how this is usually handled.
Logged

zilluss
Level 1
*



View Profile
« Reply #639 on: May 04, 2016, 01:48:56 PM »

Code:
String.Format("{0} vs. {1}", Localisation.GetTranslation( "TRANSLATION_KEY1" ), Localisation.GetTranslation( "TRANSLATION_KEY2" ))
Logged

@zilluss | Devlog  Hand Point Right
Pages: 1 ... 30 31 [32] 33 34 ... 69
Print
Jump to:  

Theme orange-lt created by panic