Jan Wassenberg

Members
  • Content count

    1474
  • Joined

  • Last visited

Community Reputation

999 Good

About Jan Wassenberg

  • Rank
    Contributor
  1. Wonderfully simple OpenGL UI

    Minor rendering update per feedback received (thanks!).. Radio button+slider larger, more corner rounding, different accent color.
  2. Wonderfully simple OpenGL UI

    Let's see how far we can get talking about the interface :) Ooh, that's a pretty one. Looks like three different modes - main menu as extruded 3d text, then the oblique view, then the white 2d one for actually entering text. It's easy enough to get something like the second one by rendering the UI output to texture and incorporating that into some other scene. I'm more interested in `serious' apps that don't need fancy presentation, though. Controller button input is easily supported by calling Interaction::OnKeyDown with a real or fake corresponding SDL key code. "other filed"? You mean whether any data files are necessary? The font renderer has a binary blob that's bundled with the executable (on Linux, it'd be a standalone file), same for the shaders. If you want ALL buttons to look different, that's an easy change in Painter::DrawButton and Layout::ButtonSize (if you're also changing the default size). This is probably debatable, but I prefer separating size, presentation and control logic. What's the use case for switching shaders? Here's the code that drives the demo UI. It's simple enough that auto-generation of code is not necessary :D Note the standard IMGUI if (Button()) { it_was_clicked; } pattern. static void DoUI(Interaction& p_Interaction, Canvas& p_Canvas, TextPainter& p_TextPainter) { Layout layout(p_Interaction.windowSize); Painter painter(p_Canvas, p_TextPainter); UI ui(p_Interaction, layout, painter, p_TextPainter); layout.BeginGroup(GROUP_LEFT_DOWNWARDS); static bool showOptions = true; ui.CheckBox(L"Show options", showOptions); if (showOptions) { layout.BeginGroup(GROUP_TOP_RIGHTWARDS | GROUP_NO_MARGIN); static bool enableBlending = true; ui.CheckBox(L"Enable blending", enableBlending); if (enableBlending) { static float value = 4.0f; ui.Slider(1.0f, 16.0f, value); } layout.EndGroup(); std::vector<UString> labels; labels.push_back(L"YCoCg-DXT5"); labels.push_back(L"DXT1"); labels.push_back(L"RGBA"); static int listSelected = 0; ui.ListBox(&labels[0], labels.size(), listSelected); layout.BeginGroup(GROUP_TOP_RIGHTWARDS); ui.Label(L"Format"); static int formatIdx; ui.ComboBox(&labels[0], labels.size(), formatIdx); layout.EndGroup(); } layout.EndGroup(); if (showOptions) { layout.BeginGroup(GROUP_RIGHT_DOWNWARDS); static bool panelUnfold = true; if (ui.BeginPanel(L"Panel", panelUnfold, GROUP_DEFAULT)) { static int selected; ui.RadioButton(L"Radio1", 0, selected); ui.RadioButton(L"Radio2", 1, selected); static bool checked1, checked2; ui.CheckBox(L"Check1", checked1); ui.CheckBox(L"Check2", checked2); ui.EndPanel(); } if (ui.Button(L"Do things")) { SDL_Log("clicked\n"); } static UString buf(L"edit box"); ui.LineEdit(buf); layout.EndGroup(); } p_Canvas.Draw(); }
  3. Here's a brief writeup of a simple (9 KLOC, 340 KB binary) but capable and portable OpenGL GUI: http://wassenberg.dreamhosters.com/blog/2014-05-17/wonderfully-simple-gui/   Obligatory screenshot: [attachment=21585:ui.png]   Header files are attached: [attachment=21584:ui_headers.zip]   I'd love to get a discussion going on any perceived shortcomings of this approach, missing features, alternative libraries that didn't show up in my search, and your thoughts in general.
  4. Yes, those cases (as well as restricted process affinity) would be detected - if a core/logical processor isn't running/available, its APIC ID will not be counted. Unfortunately I don't remember which of the Windows functions returned inaccurate information. I would advise against the use of GetLogicalProcessorInformation, though - its interface is just about as complex as digging through the APIC IDs and it cannot be relied upon to differentiate logical processors vs cores.
  5. Unfortunately I've even seen the OS (Windows, not sure which version) lie about this. I believe any code that does not look at the APIC IDs (this apparently including libcpuid, after a quick browse) is completely broken in that respect. Intel has long said APIC IDs are not necessarily contiguous (0..#enabled-1). However, even the package/core/logical fields extracted with their recommended algorithm are not contiguous - you might see coreID = {0,1,6,7}. Here's my best attempt at getting it right, successfully tested on some interesting hardware (up to 64 processors) - [url="http://trac.wildfiregames.com/browser/ps/trunk/source/lib/sysdep/arch/x86_x64/topology.cpp"]http://trac.wildfire...64/topology.cpp[/url]
  6. New Tech for the win!

    [quote]Patents are publically available as part of the whole process; you cant patent anything behind closed doors. So give us a few examples, or STFU.[/quote] Bullshit. German, UK and US patent laws - and certainly others - provide for `secret' patents/applications under rather loosely defined circumstances. See [url="http://www.ipo.gov.uk/p-securitylist.pdf"]http://www.ipo.gov.u...ecuritylist.pdf[/url] for examples; in Germany, it's basically "whenever the exterior safety of the Federal Republic might be negatively affected". [quote]Rethoric such as yours is of the same type of creepy as talk of 'final solutions'. Except of course that yours is fashionable.[/quote] Thank you for proving Godwin right yet again. I don't intend to dignify further ridiculous comments along those lines with a reply. [quote]You know better....[/quote] Sadly, it's not apparent he does.
  7. New Tech for the win!

    [quote]any day now corn could mutate into flesh eating plants. We should stop growing corn for this reason.[/quote] Thank you for that valuable contribution, which is the last of its ilk I will comment upon.
  8. New Tech for the win!

    [quote]Why is a jet engine a stretch? Jet fuel is pretty much really high quality diesel fuel with additives.[/quote] The operative words are "high quality". Unlike multi-fuel tank engines, which will run on nearly anything, aircraft fuel systems are much more finicky. For example, Wikipedia tells me there must not be more than 30 parts per million water in jet fuel, which seems quite low. It remains to be seen whether this process can deliver that, especially since they're already having trouble separating fuel from water at all.
  9. New Tech for the win!

    [quote]Well you know that we already grow genetically alltered plants all over the world producing our food?[/quote] You say that as if it might be surprising (large majorities of consumers in Europe are aware of and opposed to GM food, at least until the consequences are better understood) or a good thing. Let's see what the National Research Council's "Committee on Identifying and Assessing Unintended Effects of Genetically Engineered Foods on Human Health" ([url="http://www.nap.edu/catalog.php?record_id=10977"]http://www.nap.edu/c...record_id=10977[/url]) has to say about this: [quote]All evidence evaluated to date indicates that unexpected and unintended compositional changes arise with all forms of genetic modification, including genetic engineering. There is a need, in the committee’s judgment, for a broad research and technology development agenda to improve methods for predicting, identifying, and assessing unintended health effects from the genetic modification of food.[/quote] So which unintended and unforeseen consequences have arisen in the intervening years? [url="http://www.globalresearch.ca/index.php?context=va&aid=12432"]http://www.globalres...xt=va&aid=12432[/url] Oops, looks like it can negatively impact soil microbes and quality. Another retrospective from the Board on Agriculture and Natural Resources ([url="http://www.nap.edu/catalog.php?record_id=12804"]http://www.nap.edu/c...record_id=12804[/url]) says: [quote]The first generation of genetically engineered (GE) crops has mostly delivered effective pest control for a few major crops because farmers producing these crops spend a lot of time and money on the task, because the firms developing the new seed technologies saw considerable profit potential in doing so, and because adding the traits was relatively straightforward [..]. The first generation of GE crops continues a reliance on pesticide technology—in-plant toxins or resistance to herbicides—to mitigate pest problems primarily in corn, cotton, and soybean. Thus, the application of genetic-engineering technology to crops has not developed novel means of pest control, such as developing plant mechanisms to resist pest damage[/quote] So our savior that will supposedly secure the future of agriculture and feed mankind is a new pesticide ("Roundup" := glyphosate) that can be used because plants have been engineered to resist its effects. [quote]However, glyphosate is often applied in higher doses and with greater frequency than the herbicides it replaced. [..] Ten species have evolved resistance to glyphosate independently in glyphosate-resistant crops over 14 years in the United States (from 1996 to 2010) (Heap, 2010). [..] the nearly exclusive reliance on glyphosate for weed control, a practice accelerated by the widespread introduction of glyphosate-resistant crop varieties, has caused substantial changes in weed communities.[/quote] What a big surprise, the quick and easy chemical solution works for a short time and then loses its effectiveness. When will people learn that there is no silver bullet?! [quote]Among the known social facts associated with the dissemination of GE crops are the continued consolidation of the seed industry and its integration with the chemical industry. Another is the change in relationships between farmers and their seed suppliers. Testimony to the committee suggested that farmers of major crops have fewer opportunities to purchase non-GE seed of the best-yielding cultivars even when a GE trait is not perceived to be required in a particular cropping situation.[/quote] And there we have one of the apparent driving forces behind GM - corporate greed. I would be a lot more confident in the technology if it were at least extensively tested before commercialization, which probably necessitates the public sector. Fortunately, China is starting to invest heavily there, so maybe we will see improvements actually aimed at feeding people instead of profits. [quote] I really think people have to step away from the view keep everything as it is.[/quote] Straw man argument. [quote]But here the ethanol is produced directly inside the plant during photosynthesis so its actually a clean product and they can make just like the real stuff.[/quote] The problems listed in my previous post apply to pure ethanol, regardless of its source. I'm not sure whether this bioethanol counts as such, since the article mentions problems separating it from water. [quote]The organism they created can create ethanol OR diesel fuel. It is not just ethanol. That's part of the reason it's such a significant discovery.[/quote] Yep, I saw that in the article, but it also mentions "Jaguars and jet engines". Granted, there are apparently Diesel-fueled Jaguars, but jet engine is still a stretch despite the existence of multi-fuel tank turbines.
  10. New Tech for the win!

    [quote]Using genetically modified bacteria to produce specific molecules is a completely normal part of modern pharmaceutical production.[/quote] Sure, but that's in a factory, whereas I assume wide-scale production of this stuff would occur in much less controlled environments. There are also several problems with bioethanol as fuel for (older) gasoline motors: 1) about 10% of current models can sustain serious damage after a single tankful (corroding aluminum, dissolving gaskets) 2) it only has 2/3 the energy density of gasoline => 1..1.9% less mileage, worse acceleration, higher engine RPMs and increased wear 3) There don't seem to be any long-term studies of the effects on current cars - they're less vulnerable to the corrosion and gasket issues, but who knows what else. The differences in additives and volatilization might also be relevant, but I'm definitely out of my depth here. Anyway, it seems foolish to lean on the bioethanol crutch (with unknown side effects) rather than focusing on true alternatives to fossil fuels. Sources: [url="http://www.focus.de/auto/news/oeko-kraftstoff-e10-deutlicher-mehrverbrauch_aid_601141.html"]http://www.focus.de/...aid_601141.html[/url] [url="http://www.oldtimer-tv.com/oldtimer/DE/news/index.php?Seite=111"]http://www.oldtimer-...x.php?Seite=111[/url]
  11. What are unions good for?

    [quote]What does the standard say on this?[/quote] Reading single paragraphs is not the path to wisdom [quote]And do you know where I can find a copy of the standard for download?[/quote] [url="http://lmgtfy.com/?q=buy+ansi+%22programming+languages%22+%2Bc+standard"]http://lmgtfy.com/?q...2+%2Bc+standard[/url] I don't think you'll find anything but the draft C++0x standard for free legal download, but $30 should be affordable. [quote]For example, generating a hash values out of non-integer types.[/quote] Ah, that's a good example.
  12. What are unions good for?

    [quote]I understand that you can cast a type to char*, but it's not compliant to cast char* back into another type.[/quote] And what is this understanding based on? You can cast until the cows come home. What is important is that all accesses to a stored value occur through the same pointer (or "by an lvalue expression that has .. character type" [ANSI C99 6.5#7]). [quote](This is part of a neat little hack used in some 3D engines to approximate the square root operation)[/quote] Which used to be a good idea 10..15 years ago, but I'd expect it to be slower now than the SQRTSS instruction generated by a simple call to fsqrtf(). [quote]I'd have to do something like this right?[/quote] Ooh. Numerous problems with that code: - unnecessary reinterpret_cast - incorrect end pointer in the second std::copy - using std::copy, which must be able to handle overlapping ranges, instead of memcpy - right-shifts on negative integers are undefined [quote]Clearly this is impractical if the reason for using type punning is performance.[/quote] That is anything but clear. Can you justify that statement? After fixing the above, I see the following code generated (ICC 12.1): 000000013F7B1058 mov edx,dword ptr [dest] 000000013F7B105B shr edx,1 000000013F7B105D mov dword ptr [dest],edx [quote]Speaking of strict aliasing, how does one use the malloc function when it returns a void pointer? Isn't casting this pointer to another type considered a violation?[/quote] Nope. Please see ANSI C99 6.7.3#15.
  13. What are unions good for?

    Please don't write, much less advocate, such non-standard-conforming code. Both C99 and C++03 say only one union member can be active at a time and provide an explicit exception for accessing a common sequence (usually a type tag) in Bearhugger's union-of-structs. This exception would not be necessary if it were generally legal to access a different field than was last written. It's important to stamp out such sloppy and senseless non-conforming code because it interferes with aliasing analysis (arguably one of the most important optimizations).
  14. What are unions good for?

    [quote]and pretty much any form of type pruning relies on compiler specific behaviour.[/quote] You mean "type punning", for which there are actually two standard and perfectly safe methods - serializing through char*, which has a special dispensation concerning aliasing, or memcpy. [quote]I've seen unions used as a crude reinterpret_cast mechanism in C; not exactly 100% safe, but generally they were not a problem if some precautions were taken.[/quote] Is that the way you drive, or want an airline to operate - "not exactly 100% safe, but generally [..] not a problem"? I don't see why an incorrect and illegal solution is preferable to memcpy, which is hardly more complicated. [quote]Yes that and most of what has been posted here is undefined behaviour according to the standard. You really should have an identifier which signals which element is currently stored in the union, then only read this element and none of the others.[/quote] Good advice. Incidentally, I often engage in bit-twiddling, and have yet to find a helpful and safe use for unions in that context.
  15. [quote] The CPU is so fast at decompressing stuff that it frequently sits around waiting for more data from the drive. This is probably less and less true now with SSDs becoming more common[/quote] That is already a problem with Zlib (~100 MB/s). LZOP or FastLZ can keep up with commodity SSDs (300 MB/s), but disk arrays (1000 MB/s) and Fusion IO (1400 MB/s) require new approaches. I am currently writing up a report on a lossless asymmetric SIMD codec that manages 2700 MB/s per core (up to available memory bandwidth), which should make for lots of breathing room.