1. Post #201

    March 2017
    23 Posts
    Trying to rewrite in NGINX conf to a MVC format.

    Code:
    		location / { 
    		    try_files $uri $uri/ @rules; 
    		} 
    
    		location @rules { 
    		    rewrite ^/(.*)$ /index.php?url=$1; 
    		}
    http://localhost/dashboard/ Returns:

    Code:
    /dashboard//dashboard/
    I can't figure out why it's repeating it twice, instead of once, any ideas?

  2. Post #202
    FISSION MAILED
    PredGD's Avatar
    January 2010
    9,371 Posts
    Anyone see what's wrong with my code? I'm trying to get the snake tail in my snake clone to follow each other so the tail segments are independent of the head. So if the second to last tail segment has the direction 'r' or 'right', it'll store that in a lastDir variable in the tail object so the next segment knows which direction to go. This doesn't work like I want to though. The tail decides to go a different direction altogether which leaves me with no tail.

    Code:
            public void Update(GameTime gameTime)
            {
                speedCountdown += gameTime.ElapsedGameTime.TotalMilliseconds;
    
                KeyboardState state = Keyboard.GetState();
                if (state.IsKeyDown(Keys.Right))
                    direction = 'r';
                if (state.IsKeyDown(Keys.Left))
                    direction = 'l';
                if (state.IsKeyDown(Keys.Up))
                    direction = 'u';
                if (state.IsKeyDown(Keys.Down))
                    direction = 'd';
    
                if (speedCountdown >= 250)
                {
                    if (direction == 'r')
                        position.X += speed;
                    if (direction == 'l')
                        position.X -= speed;
                    if (direction == 'u')
                        position.Y -= speed;
                    if (direction == 'd')
                        position.Y += speed;
    
                    if (tail.Count > 1)
                    {
                        foreach (var tail in tail)
                        {
                            if (this.tail[this.tail.Count - 2].lastDir == 'r')
                                tail.position.X += speed;
                            if (this.tail[this.tail.Count - 2].lastDir == 'l')
                                tail.position.X -= speed;
                            if (this.tail[this.tail.Count - 2].lastDir == 'u')
                                tail.position.Y -= speed;
                            if (this.tail[this.tail.Count - 2].lastDir == 'd')
                                tail.position.Y += speed;
                        }
                    }
                    else if (tail.Count == 1)
                    {
                        if (lastDir == 'r')
                            tail[0].position.X += speed;
                        if (lastDir == 'l')
                            tail[0].position.X -= speed;
                        if (lastDir == 'u')
                            tail[0].position.Y -= speed;
                        if (lastDir == 'd')
                            tail[0].position.Y += speed;
                    }
    
                    if (tail.Count > 0)
                    {
                        if (tail.Last().lastDir == 'n' && tail.Count == 1)
                            tail.Last().lastDir = lastDir;
    
                        else if (tail.Last().lastDir == 'n' && tail.Count > 1)
                        {
                            tail.Last().lastDir = tail[tail.Count - 2].lastDir;
                        }
                    }
    
                    lastDir = direction;
                    speedCountdown = 0;
                }
            }


    I've been trying to solve this for the last few days without much result. You guys see what I'm doing wrong?

  3. Post #203
    Gold Member
    jung3o's Avatar
    October 2011
    2,626 Posts
    hey guys, so i really want something like the windows media player thing on the task bar for spotify

    (I'm using windows 10)


    and couldn't find anything like that. Can someone give me like little guidance to where i can start from?
    So I've never made a program before for windows and don't really know where I should be starting. I've never really touched with c# before... and with c++, only used for school assignments with pre-added in codes.
    So i got visual studio 2015, is there something extra I would need for something like this?

    Would using spotify's web api be okay with this? I'd be running spotify desktop app on the side. I don't see anything about a desktop hook...

    I got lots of time in my hands right now, so starting off with something smaller wouldn't bother me at all... Don't know what I should be looking at though.

  4. Post #204
    Gold Member
    huntingrifle's Avatar
    January 2009
    2,752 Posts
    I'm trying to fix some bugs in some older mods for Killing Floor 2, and I'm a fairly big noob at UnrealScript/modding so please bear with me.

    If I have Classes A, B, and C, where Class A extends B, but B does not extend from C. Currently, Class A is using structs from Class C, but when I try to compile the mod I get an error saying that it doesn't know of those data types. Is there a way I can double extend Class A or be able to use Class C's structs?

  5. Post #205
    Gold Member
    Karmah's Avatar
    December 2007
    6,600 Posts
    Do you mean like have something that is 2 other things at once?
    Like:
    Code:
    struct Thing_That_Eats {
    };
    struct Thing_That_Shits {
    };
    struct Cat : public Thing_That_Eats, public Thing_That_Shits {
    };
    ?

  6. Post #206
    Gold Member
    huntingrifle's Avatar
    January 2009
    2,752 Posts
    Do you mean like have something that is 2 other things at once?
    Like:
    Code:
    struct Thing_That_Eats {
    };
    struct Thing_That_Shits {
    };
    struct Cat : public Thing_That_Eats, public Thing_That_Shits {
    };
    ?
    Like that, but with using UnrealScript, and instead of structs they are all classes. Class A uses a struct defined in Class C, but does not inherit from Class C.
    Figured it out with some more Google-fu, I could use the dependsOn specifier for class delcaration like so:
    Code:
    Class A extends Class B
        dependsOn( Class C)

  7. Post #207
    Gold Member
    Karmah's Avatar
    December 2007
    6,600 Posts
    Should I be using a specular or a metallic workflow for my PBR materials in my engine? The idea is to use this engine for a game later on.
    At one point I decided on specular haphazardly, but I just renamed metalness textures to specular and IDK if I even use proper shader code for the workflow anyways.

  8. Post #208

    May 2016
    138 Posts
    Should I be using a specular or a metallic workflow for my PBR materials in my engine? The idea is to use this engine for a game later on.
    At one point I decided on specular haphazardly, but I just renamed metalness textures to specular and IDK if I even use proper shader code for the workflow anyways.
    If you're basing your stuff off the Unreal Engine presentations you're most likely implementing the roughness/metallic workflow - tbqh if you don't know what model you implemented you should revisit your code to figure it out first.

    I quite like roughness/metallic because it seems very intuitive to me, but I'm not an artist really.

  9. Post #209
    Gold Member
    huntingrifle's Avatar
    January 2009
    2,752 Posts
    Like that, but with using UnrealScript, and instead of structs they are all classes. Class A uses a struct defined in Class C, but does not inherit from Class C.
    Figured it out with some more Google-fu, I could use the dependsOn specifier for class delcaration like so:
    Code:
    Class A extends Class B
        dependsOn( Class C)
    I've returned with pretty much the exact same issue: my solution to use the DependsOn( Class C ) specifier works, but only if Class C is inside the same mod. If I have two mods, where Classes A and B are inside Mod1 while Class C is in Mod2, and the same situation exists where Class A extends Class B but needs Class C, then what can I do?

    The current code is using this command:
    Code:
    const LoadClassC=Class'Mod2.ClassC';
    Then an instance of that class in made like so:
    Code:
    local ClassC myClassC;
    but I get a compiler error:
    Code:
    Error, Unrecognized type 'ClassC'

  10. Post #210
    Gold Member
    Karmah's Avatar
    December 2007
    6,600 Posts
    If you're basing your stuff off the Unreal Engine presentations you're most likely implementing the roughness/metallic workflow - tbqh if you don't know what model you implemented you should revisit your code to figure it out first.

    I quite like roughness/metallic because it seems very intuitive to me, but I'm not an artist really.
    IIRC, I could never really find a unified tutorial on implementing physically based shaders, so I kinda winged it, learning from dozens of different websites.
    In my code I use specular + roughness, but the only places where my surface specular is used is in the brdf for the fresnel term, and for the diffuse ratio for energy conservation.

    I'm reviewing my code now, double checking all my maths, comparing them against this guide, and planning on switching over to a metallic workflow.
    I've downloaded a bunch of pbr textures and built materials out of them, and they all have metal/roughness.
    Reply With Quote Edit / Delete Reply Windows 10 Chrome Canada Show Events Agree Agree x 1 (list)

  11. Post #211
    Gold Member
    Karmah's Avatar
    December 2007
    6,600 Posts
    I think I've successfully switched over to metalness workflow for PBR materials.
    My lighting code in a nutshell:
    Code:
    vec3 radiance = lightColor * LightIntensity * NdotL; //multiply by attenuation, shadow factor, spot factor, etc...
    
    vec3 diffuse = albedo / PI;
    
    vec3 Fs = Fresnel_Shlick( mix(vec3(0.03), albedo, metalness), VdotH );
    float D = NDF_GGX_TrowBridge_Reitz( NdotH_2, Alpha_2 );
    float G = Geometry_Schlick_Beckmann( Alpha, NdotL, NdotV );
    vec3 specular = (Fs * D * G) / (4.0 * NdotL * NdotV + EPSILON);
    
    float ratio = (vec3(1.0f) - Fs) * (1.0 - Metalness); 
    
    vec3 Direct_Lighting = ratio * diffuse + specular * radiance;
    However some dot products get clamped.

    The 3 functions I reference here are just straight up calculations pulled from that blog I cited in my last post.



    A question regarding gamma correction:
    I gamma correct my albedo textures in my geometry pass by raising them to the power of 2.2.
    At the very end of my rendering pass, I gamma correct the final image by raising it to the power of (1 / user_gamma).
    Even though I end up applying the user's desired gamma correction at the end, at any point should I gamma correct again to revert back into sRGB (1 / 2.2)?

  12. Post #212

    May 2016
    138 Posts
    I think I've successfully switched over to metalness workflow for PBR materials.
    My lighting code in a nutshell:
    Code:
    vec3 radiance = lightColor * LightIntensity * NdotL; //multiply by attenuation, shadow factor, spot factor, etc...
    
    vec3 diffuse = albedo / PI;
    
    vec3 Fs = Fresnel_Shlick( mix(vec3(0.03), albedo, metalness), VdotH );
    float D = NDF_GGX_TrowBridge_Reitz( NdotH_2, Alpha_2 );
    float G = Geometry_Schlick_Beckmann( Alpha, NdotL, NdotV );
    vec3 specular = (Fs * D * G) / (4.0 * NdotL * NdotV + EPSILON);
    
    float ratio = (vec3(1.0f) - Fs) * (1.0 - Metalness); 
    
    vec3 Direct_Lighting = ratio * diffuse + specular * radiance;
    However some dot products get clamped.

    The 3 functions I reference here are just straight up calculations pulled from that blog I cited in my last post.



    A question regarding gamma correction:
    I gamma correct my albedo textures in my geometry pass by raising them to the power of 2.2.
    At the very end of my rendering pass, I gamma correct the final image by raising it to the power of (1 / user_gamma).
    Even though I end up applying the user's desired gamma correction at the end, at any point should I gamma correct again to revert back into sRGB (1 / 2.2)?
    Yeah that looks about right to me, that's pretty much what I did last time I implemented a PBR pipeline if I'm not mistaken.
    Reply With Quote Edit / Delete Reply Windows 10 Chrome Germany Show Events Informative Informative x 1 (list)

  13. Post #213
    Gold Member
    Foda's Avatar
    April 2006
    2,846 Posts
    hey guys, so i really want something like the windows media player thing on the task bar for spotify

    (I'm using windows 10)


    and couldn't find anything like that. Can someone give me like little guidance to where i can start from?
    So I've never made a program before for windows and don't really know where I should be starting. I've never really touched with c# before... and with c++, only used for school assignments with pre-added in codes.
    So i got visual studio 2015, is there something extra I would need for something like this?

    Would using spotify's web api be okay with this? I'd be running spotify desktop app on the side. I don't see anything about a desktop hook...

    I got lots of time in my hands right now, so starting off with something smaller wouldn't bother me at all... Don't know what I should be looking at though.
    you won't be able to do anything other than control playback, and you'll need the spotify app running to have music playing (spotify doesn't allow playback outside the app, so if you really want to do that you'll need a web-view).

    if you're using c# (which will make most of this easy...):
    * Use Refit to define the Spotify API
    * You'll want to use the Deskband API -- which is a complete pain in the ass to use. Specifically, you'll need to use the "IDeskband2" interface in Win7+. Keep in mind that MS doesn't recommend using Deskbands anymore, but that's up to you.

  14. Post #214
    Gold Member
    Karmah's Avatar
    December 2007
    6,600 Posts
    I'm working on implementing Parallax Occlusion mapping.
    So far I've gotten some pretty nice results (as long as the height scale is low), but I'm not entire sure if my results are completely correct.

    I know that at grazing angles the naive parallax mapping effect breaks, but other tweaks exist to minimize those errors.

    My question is this: is it normal for the perceived depth into a parallax mapped surface to stretch and scale depending on the viewing angle? Like, the effect works pretty good, but when I start looking at it at a shallow angle the depth into the map seems to drop:


    I'm doing this effect during my gbuffer filling pass, and modify the incoming texture coordinates as so:
    Code:
    const vec3 ViewTangentEyePos     = mat3(InvVMatrix) * ViewTBN * EyePosition.xyz; // ViewTBN is the viewspace Tangent,Bitangent,Normal (TBN) matrix
    const vec3 ViewTangentFragPos     = mat3(InvVMatrix) * ViewTBN * m_vertex.xyz;
    const vec3 View_Dir        = normalize(ViewTangentEyePos - (mMatrix * vec4(vertex,1.0)));
    
    const float View_Angle        = abs(dot(vec3(0.0, 0.0, 1.0), View_Dir));
    const float minLayers         = 8.0;
    const float maxLayers         = 32.0;
    const float numLayers        = mix(maxLayers, minLayers, View_Angle);  
    const float layerDepth        = 1.0f / numLayers;
    const vec2 P             = View_Dir.xy * height_scale; 
    const vec2 deltaTexCoords     = P / numLayers;
        
    vec2  currentTexCoords         = TexCoord0;
    float currentDepthMapValue    = 1.0f - texture(MaterialMap, vec3(currentTexCoords, 1)).a; // Height stored in alpha channel
    float currentLayerDepth     = 0.0;    
    while(currentLayerDepth < currentDepthMapValue) 
    {
        currentTexCoords     -= deltaTexCoords;
        currentDepthMapValue     = 1.0f - texture(MaterialMap, vec3(currentTexCoords, 1)).a;
        currentLayerDepth     += layerDepth;  
    }    
    const vec2 prevTexCoords     = currentTexCoords + deltaTexCoords;
    const float afterDepth      = currentDepthMapValue - currentLayerDepth;
    const float beforeDepth     = 1.0f - texture(MaterialMap, vec3(prevTexCoords, 1)).a - currentLayerDepth + layerDepth;
    const float weight         = afterDepth / (afterDepth - beforeDepth);
    
    const vec2 Parallax_TexCoord     = prevTexCoords * weight + currentTexCoords * (1.0 - weight);
    Edited:
    Fixed, I needed to divide View_Dir.xy by its Z component in vec2 P, so it now reads:
    Code:
    const vec2 P = View_Dir.xy / View_Dir.z * height_scale;

  15. Post #215
    Gold Member
    Karmah's Avatar
    December 2007
    6,600 Posts
    I'm trying to generate per-vertex normals for my terrain. To aid with this, I've built a struct which for each vertex tracks information about all the faces that vertex comes into contact with.

    So to calculate the per-vertex normals, I added up all the normals of each face the vertex is a part off, and normalize.

    Is this same approach valid for tangents and bitangents?
    Code:
    // Vertex_Adjacency holds reference to all the triangles that surrounds a vertex
    for each (const Vertex_Adjacency &vertex in vertex_adj) {
        vec3 vertex_normal(0), vertex_tangent(0), vertex_bitangent(0);
        for each (Triangle *triangle in vertex.triangles) { // All its neighbors
            vertex_normal += triangle->normal;
            vertex_tangent += triangle->tangent;
            vertex_bitangent += triangle->bitangent;
        }
        vertex_tangent = vertex_tangent - vertex_normal * glm::dot(vertex_normal, vertex_tangent);
        normals.push_back(glm::normalize(vertex_normal));
        tangents.push_back(glm::normalize(vertex_tangent));
        bitangents.push_back(glm::normalize(vertex_bitangent));
    }
    This shouldn't be a problem, right? I mean, since we are using the same faces for the normals, tangents, and bitangents, then the average tangent and average bitangent should be orthogonal to the average normal?

  16. Post #216
    Gold Member
    Tamschi's Avatar
    December 2009
    8,212 Posts
    Do any of you know any entry level books on Kotlin and/or Android app development?
    I haven't touched Java in years and never made anything for Android, so I'm more or less starting from very little knowledge here.
    Going through a relatively verbose but consistent introduction once is going to be faster for me than figuring out which standalone tutorials to use for each basic platform concept I don't know.

  17. Post #217

    January 2011
    491 Posts
    Do any of you know any entry level books on Kotlin and/or Android app development?
    I haven't touched Java in years and never made anything for Android, so I'm more or less starting from very little knowledge here.
    Going through a relatively verbose but consistent introduction once is going to be faster for me than figuring out which standalone tutorials to use for each basic platform concept I don't know.
    https://commonsware.com/Android/ this book is a constantly updated E-Book. I was using it for work; solid enough!

  18. Post #218
    Agenda21Dev's Avatar
    July 2017
    1 Posts
    I'm trying to texture some models in 3DSMax, is there any tool or scripts I can use to hasten the process?

    Unwrapping UV's seems like a real nightmare.

  19. Post #219
    Gold Member

    November 2012
    1,718 Posts
    C noob here, just going through some basics:

    Code:
    int main() {
        float fahr, celsius;
        float lower, upper, step;
        
        lower = 0.0;      // Lower limit of temperature scale
        upper = 300.0;    // Upper limit
        step = 20.0;      // Step size
        
        fahr = lower;
        while (fahr <= upper){
            celsius = (5.0/9.0) * (fahr-32.0);
            printf("%3.0f\t%1.0f\n", fahr, celsius);
            fahr = fahr + step;
        }
    }
    "The printf conversion specification %3.0f says that a floating-point number (here fahr) is to be printed at least three characters wide, with no decimal point and no fraction digits. %6.1f describes another number (celsius) that is to be printed at least six characters wide, with 1 digit after the decimal point."


    What do they mean by "three characters wide" or "six characters wide"? If I change %3.0f to %2.0f it doesn't make the numbers like 101 or 201 any shorter? They are still 101 and 201

  20. Post #220
    Gold Member
    WTF Nuke's Avatar
    March 2009
    5,158 Posts
    3 characters wide means 3 characters, that is to say "abcdef" is 6 chars wide, a character being an alphanumeric. So if you wanted to print 20 with %3.0f it would print " 20" (note the space at the front). However, since 101/201 are already longer or equal to three characters it doesn't have an affect. Try doing %6.0f instead to better illustrate what I mean.
    Reply With Quote Edit / Delete Reply Windows 10 Firefox Canada Show Events Friendly Friendly x 1 (list)

  21. Post #221

    March 2017
    23 Posts
    https://www.cloudindexuk.com/home

    Suggestions for design and layout?

    It's running on a demo account for the domain itself.

  22. Post #222
    Grammar Nazi General
    Adelle Zhu's Avatar
    April 2009
    1,807 Posts
    I'm still working on my laboratory software and I finally finished the label printing feature. However, when I press the print label button, it prints a label for the order that is open in the window as well as every order that I viewed before it.

    I'm getting the feeling that it has something to do with the order object (a parameter to the print label function) not being destroyed properly after the order info window is closed.

    Does anyone have any ideas

  23. Post #223
    Gold Member

    November 2012
    1,718 Posts
    3 characters wide means 3 characters, that is to say "abcdef" is 6 chars wide, a character being an alphanumeric. So if you wanted to print 20 with %3.0f it would print " 20" (note the space at the front). However, since 101/201 are already longer or equal to three characters it doesn't have an affect. Try doing %6.0f instead to better illustrate what I mean.
    So if I understand you correct, changing the number can extend the character length with spaces but not truncate it to a shorter length than it already is?

  24. Post #224
    Gold Member
    WTF Nuke's Avatar
    March 2009
    5,158 Posts
    More or less, yep. If you want to truncate the length you can use something like a modulo. You can also extend the length with leading 0s instead of spaces by adding a 0 before the length, such as %03.0f.
    Reply With Quote Edit / Delete Reply Windows 10 Firefox Canada Show Events Friendly Friendly x 1 (list)

  25. Post #225
    Gold Member
    Megalan's Avatar
    October 2005
    1,506 Posts
    I've stumbled upon a website with insanely low rate limits while trying to write a parser for it. Does anybody know easiest (and cheapest) way to get around those limits? I'm far from putting a huge load on the server but I still trigger those limits and they are progressive so it's even worse each time I trigger it. The app is designed to automatically run every hour so I need a method which doesn't require babysitting.

  26. Post #226
    Gold Member
    Tamschi's Avatar
    December 2009
    8,212 Posts
    I've stumbled upon a website with insanely low rate limits while trying to write a parser for it. Does anybody know easiest (and cheapest) way to get around those limits? I'm far from putting a huge load on the server but I still trigger those limits and they are progressive so it's even worse each time I trigger it. The app is designed to automatically run every hour so I need a method which doesn't require babysitting.
    Can you stagger the requests over a longer time period?

  27. Post #227
    Gold Member
    Megalan's Avatar
    October 2005
    1,506 Posts
    Can you stagger the requests over a longer time period?
    I'm already following website's guidelines which say something like "make 1 minute pause if you get over the rate limit. Make your pause 1 minute longer each time you get rate limit error". After a while even after reaching pause time of ~5 minutes I'm getting rate limit error just after sending 5 requests because their progressive rate limit does not reset unless you don't make requests for like an hour. ~50 requests per hour is a complete bullshit. Right now the only idea I have is VPN but I have no idea which VPN service has stable connection and random ip's for each new session.

  28. Post #228
    Mechanical43's Avatar
    July 2007
    1,084 Posts
    I'm trying to setup a nice Unix c++ workflow for myself but I find it really hard to get to something I could use day in day out.

    I think VS spoiled me.


    edit: a question for you guys, what does your workflow looks like ?

  29. Post #229

    May 2016
    138 Posts
    I'm trying to setup a nice Unix c++ workflow for myself but I find it really hard to get to something I could use day in day out.

    I think VS spoiled me.


    edit: a question for you guys, what does your workflow looks like ?
    My linux workflow is

    - write the thing on Windows
    - push to git repo
    - pull on linux machine
    - gcc that shit on the command line
    - fix the 150 lines of template errors using vim or whatever I find that can edit text
    - optionally if it's a project that involves hardware rendering, fix all OpenGL/Vulkan runtime errors
    - push the fixed thing
    - fix windows build

    Uhm yeah so I guess same question, can someone recommend a *healthy* linux workflow?
    Reply With Quote Edit / Delete Reply Windows 10 Chrome Germany Show Events Agree Agree x 1 (list)

  30. Post #230
    tschumann's Avatar
    March 2009
    553 Posts
    My linux workflow is

    - write the thing on Windows
    - push to git repo
    - pull on linux machine
    - gcc that shit on the command line
    - fix the 150 lines of template errors using vim or whatever I find that can edit text
    - optionally if it's a project that involves hardware rendering, fix all OpenGL/Vulkan runtime errors
    - push the fixed thing
    - fix windows build

    Uhm yeah so I guess same question, can someone recommend a *healthy* linux workflow?
    Me too although a lot of what I do is Half-Life/Source modding so it generally compiles without too much issue when I pull on Linux.
    I use PHPStorm for work and it's pretty good - I imagine CLion is too but I've never got around to trying it. I don't really like CMake either.

  31. Post #231
    I am the Asian Ed Sheeran Rabbit - My sister
    gokiyono's Avatar
    June 2012
    4,735 Posts
    I'm trying to setup a nice Unix c++ workflow for myself but I find it really hard to get to something I could use day in day out.

    I think VS spoiled me.


    edit: a question for you guys, what does your workflow looks like ?
    I usually just do webdev, but I thibk using makefiles would be a help. And then setting up your favourite editor to make that when a hot key is pressed

    Or you could go the simple route and use something like NetBeans

  32. Post #232
    Gold Member
    WTF Nuke's Avatar
    March 2009
    5,158 Posts
    I use the bash for linux subsystem to check if the linux code works well, so I just try to compile, fix template errors x2, run tests and call it a day.

  33. Post #233

  34. Post #234
    Gold Member
    proboardslol's Avatar
    December 2008
    6,604 Posts
    Reply With Quote Edit / Delete Reply Linux Chrome Show Events Winner Winner x 2 (list)

  35. Post #235
    joshthesmith's Avatar
    August 2016
    301 Posts
    Code:
    position: fixed
    Thank you!

       Been at this too long :v:   

  36. Post #236
    Gold Member
    blacksam's Avatar
    July 2007
    2,324 Posts
    Anyone know a painless way to port 2d unity game to android without having to rewrite controls?

    I have a simple pong game I wrote for a class and I don't want to rewrite using touch events since I've already mapped everything to W & S and up &down for 2 players.

  37. Post #237
    Gold Member
    thelurker1234's Avatar
    June 2011
    9,837 Posts
    Would it be bad to go through a 1993 c++ book I have? Specifically lippmanns c++ primer 2nd ed. I'm pretty new to programming and I made that fuckup of not checking the edition when ordering it.

    I know there's been quite a lot of changes like smart pointers so maybe it won't be?

  38. Post #238
    Gold Member
    WTF Nuke's Avatar
    March 2009
    5,158 Posts
    Probably not the best idea, the way you do modern C++ is quite substantially different than pre 2011 C++ (no explicit new/delete as an example).
    Reply With Quote Edit / Delete Reply Windows 10 Firefox Canada Show Events Agree Agree x 2Informative Informative x 1 (list)

  39. Post #239
    Gold Member
    thelurker1234's Avatar
    June 2011
    9,837 Posts
    Getting the new version then. Thank you.

    I'll probably still keep this somewhere since I do enjoy history, it might be neat eventually to take a look at how things were done differently at that time.

  40. Post #240
    daigennki's Avatar
    December 2014
    1,179 Posts
    Trying to make a dialogue box with running (if that is the right word) text, the kind you see in RPGs and such. I put this code together:
    Code:
    //Dialogue box
    class DialogueBox : public GUIElement
    {
    private:
    	GUIText textElement[2];
    	std::wstring dispText;
    	std::wstring lines[2];
    	std::wstring lastText;
    
    public:
    	std::wstring text;
    
    	//draw the box
    	void draw(float delta)
    	{
    		calcOutlineRect();
    
    		//Background box
    		glColor3f(1.0f, 1.0f, 0.8f);
    		glBegin(GL_POLYGON);
    		glVertex2i(outlineRect.x, outlineRect.y);
    		glVertex2i(outlineRect.x + outlineRect.w, outlineRect.y);
    		glVertex2i(outlineRect.x + outlineRect.w, outlineRect.y + outlineRect.h);
    		glVertex2i(outlineRect.x, outlineRect.y + outlineRect.h);
    		glEnd();
    
    		//Outline
    		glLineWidth(2.0f);
    		glColor3f(0.2f, 0.4f, 0.8f);
    		glBegin(GL_LINE_LOOP);
    		glVertex2i(outlineRect.x, outlineRect.y);
    		glVertex2i(outlineRect.x + outlineRect.w, outlineRect.y);
    		glVertex2i(outlineRect.x + outlineRect.w, outlineRect.y + outlineRect.h);
    		glVertex2i(outlineRect.x, outlineRect.y + outlineRect.h);
    		glEnd();
    
    		//draw text
    		if (lastText != text) dispText = L"";
    		lastText = text;
    
    		if (dispText != text)
    		{
    			dispText += text.at(dispText.length());
    
    			int newlinePos = dispText.find_first_of(L"\n");
    			if (newlinePos != -1)
    			{
    				lines[1] = dispText.substr(0, newlinePos - 1);
    				lines[2] = dispText.substr(newlinePos + 1);
    			}
    			else
    			{
    				lines[1] = dispText;
    				lines[2] = L"";
    			}
    		}
    
    		for (int i = 1; i <= 2; i++)
    		{
    			if (lines[i] != L"")
    			{
    				textElement[i].x = outlineRect.x + 8;
    				textElement[i].y = outlineRect.y + 8 + 32 * i - 32;
    				textElement[i].text = lines[i];
    				textElement[i].fontFile = "ipaexg.ttf";
    				textElement[i].size = 32;
    				textElement[i].fgcolor = { 0, 0, 0 };
    				textElement[i].draw();
    			}
    		}
    	}
    };
    Gave it text of "The quick brown fox jumps\nover the lazy dog.", but I only got "T" and it stops there.

    Any ideas what I might be doing wrong?

    Edited:

    Found the cause, looks like dispText kept on getting reset every frame for some reason. Moved "lastText = text" to the end of the function, works now.