1. Post #1281
    Richy19's Avatar
    May 2010
    5,368 Posts
    For some reason if I have a static class inside the class that defines it, its fine

    
    namespace SOGLF
    {
        class WindowSettingsClass
        {
            WindowSettingsClass();
        public:
            std::string Title;
            int Height, Width;
            short OGLMajor, OGLMinor;
            short rBits, gBits, bBits, aBits;
            short depthBufferBits, stencilBufferBits;
            bool FullScreen;
            int AntiAliasing;
            int FramesPerSecond;
            bool HideMouse;
            static WindowSettingsClass Settings;
        };
    
    
    }
    

    but if I have the static class in the namespace directly, it doesnt work.

    
    namespace SOGLF
    {
        class WindowSettingsClass
        {
        public:
            WindowSettingsClass();
            std::string Title;
            int Height, Width;
            short OGLMajor, OGLMinor;
            short rBits, gBits, bBits, aBits;
            short depthBufferBits, stencilBufferBits;
            bool FullScreen;
            int AntiAliasing;
            int FramesPerSecond;
            bool HideMouse;
        };
    
        static WindowSettingsClass Settings;
    
    
    }
    
    By this I mean for example I change the title but it doesnt take effect, and the title set in the constructor gets used.
    Reply With Quote Edit / Delete Linux United Kingdom Show Events

  2. Post #1282
    Icedshot's Avatar
    April 2010
    2,312 Posts
    I'm trying to use OpenCL -> OpenGL interop, however i have pretty much 0 knowledge of OpenGL. Currently, i'm using SFML to set up the window (there doesn't appear to be anything special needed to make it work with opengl)

    Unfortunately opencl is telling me that i've allocated my buffer wrong. I don't know what's wrong with it, anyone fancy taking a look? The code goes:

     
            glGenTextures(1 ,&gltscreen_id);
            glBindTexture(GL_TEXTURE_2D, gltscreen_id);
    
    
    
            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
            glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 2048, 2048, 0, GL_RGB, GL_FLOAT, NULL);
    
            gscreen_rgb=clCreateFromGLTexture2D(cl::context, CL_MEM_WRITE_ONLY, GL_TEXTURE_2D, 0, gltscreen_id, &cl::error);
    

    Edit:
    Might be this bug: http://www.opengl.org/wiki/Common_Mi...der_To_Texture

    Though i honestly have no idea what texture completeness is

    Edit 2:

    Turns out it was the issue of 'texture completeness' (seems rather arbitrary but there you go). Changed the code to:

            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
            glTexImage2D(GL_TEXTURE_2D, 0 , GL_RGBA, 2048,2048,0, GL_RGBA,GL_FLOAT,NULL);

    Edit 3:

    I've been trying to work out how on earth i draw a 2d texture to the screen using non immediate mode. Does anyone have any idea how I can do this? Currently I'm trying to see how you might store a quad and then draw that quad textured, but the OpenGL API is obtuse and completely unclear as to how you might do this

    Edit 4:

    Going down the FBO route. Turns out the functions don't really exist by default, so you have to import them manually with:

            PFNGLGENFRAMEBUFFERSEXTPROC glGenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC)wglGetProcAddress("glGenFramebuffersEXT");
            PFNGLBINDFRAMEBUFFEREXTPROC glBindFramebufferEXT = (PFNGLBINDFRAMEBUFFEREXTPROC)wglGetProcAddress("glBindFramebufferEXT");
            PFNGLGENRENDERBUFFERSEXTPROC glGenRenderbuffersEXT = (PFNGLGENRENDERBUFFERSEXTPROC)wglGetProcAddress("glGenRenderbuffersEXT");
            PFNGLBINDRENDERBUFFEREXTPROC glBindRenderbufferEXT = (PFNGLBINDRENDERBUFFEREXTPROC)wglGetProcAddress("glBindRenderbufferEXT");
            PFNGLRENDERBUFFERSTORAGEEXTPROC glRenderbufferStorageEXT = (PFNGLRENDERBUFFERSTORAGEEXTPROC)wglGetProcAddress("glRenderbufferStorageEXT");
    Reply With Quote Edit / Delete Windows Vista United Kingdom Show Events

  3. Post #1283
    Gold Member
    Naelstrom's Avatar
    June 2010
    2,648 Posts
    For some reason if I have a static class inside the class that defines it, its fine
    <code>
    By this I mean for example I change the title but it doesnt take effect, and the title set in the constructor gets used.
    You need to create a function to access the static variable. For example:

    SOGLF.h:
    namespace SOGLF
    {
    static WindowSettingsClass Settings;
    WindowSettingsClass* GetWindowSettings();
    }
    SOGLF.cpp
    WindowSettingsClass* SOGLF::GetWindowSettings(){
    return &Settings;
    }
    And then use GetWindowSettings() whenever you want to use your Settings variable.
    Reply With Quote Edit / Delete Linux United States Show Events

  4. Post #1284
    Gold Member
    Number-41's Avatar
    August 2005
    4,246 Posts
    snip
    Reply With Quote Edit / Delete Windows 7 Belgium Show Events

  5. Post #1285
    Richy19's Avatar
    May 2010
    5,368 Posts
    You need to create a function to access the static variable. For example:

    SOGLF.h:
    namespace SOGLF
    {
    static WindowSettingsClass Settings;
    WindowSettingsClass* GetWindowSettings();
    }
    SOGLF.cpp
    WindowSettingsClass* SOGLF::GetWindowSettings(){
    return &Settings;
    }
    And then use GetWindowSettings() whenever you want to use your Settings variable.
    Ohh, that gives me the same inconvenence as just having the static variable in the class.
    I will just keep it as it is
    Reply With Quote Edit / Delete Linux United Kingdom Show Events

  6. Post #1286
    Gold Member
    JLea's Avatar
    June 2007
    5,410 Posts
    I'm trying to get the angle between 2 lines.

    So usually I'd go result = secondAngle - firstAngle;
    However if the second angle is negative, and the first is positive, I get the wrong answer.

    Eg. -3-5 = -8. In my program it should be 2.

    http://blog.lexique-du-net.com/index...eping-the-sign

    This link didn't help :/

    My code

    Code:
    //the horizontal
                float difference = (angles2.z - angles.z); 
                z = RAD2DEG(difference);
                weaponAngleOffset.z = z;
    Reply With Quote Edit / Delete Windows 7 Australia Show Events

  7. Post #1287
    wizardsbane's Avatar
    January 2008
    372 Posts
    I'm trying to get the angle between 2 lines.

    So usually I'd go result = secondAngle - firstAngle;
    However if the second angle is negative, and the first is positive, I get the wrong answer.

    Eg. -3-5 = -8. In my program it should be 2.

    http://blog.lexique-du-net.com/index...eping-the-sign

    This link didn't help :/

    My code

    Code:
    //the horizontal
                float difference = (angles2.z - angles.z); 
                z = RAD2DEG(difference);
                weaponAngleOffset.z = z;
    From your link:
    if you only want to know the absolute difference then you can use
    Code:
    DEL = PI - ABS(PI - ABS(A - B)) in radians.
    DEL = 180 - ABS(180- ABS(A - B)) in degrees.
    I believe that's what you're asking for, no?
    Reply With Quote Edit / Delete Windows Vista United States Show Events

  8. Post #1288
    Gold Member
    JLea's Avatar
    June 2007
    5,410 Posts
    Well no, because the final angle offset should range from - (on the left) to positive (on the right). Unless I need to use a dot product?

    Edited:

    Oh yeah, I just needed to use a dot product to see where I was facing and then multiply the final result based on what I got. Thanks
    Reply With Quote Edit / Delete Windows 7 Australia Show Events

  9. Post #1289

    January 2012
    68 Posts
    Well, I have some dumb question.

    How do I create a vector of Sprites using SFML and vector header?
    i started the vector like

    vector<sf::Sprite> test;

    and Im trying to do a push_back(), but i dont know what i need to put inside the "()".

    Anyway, my vector will be 41x31, so there is a way t do something like
    vector<vector<sf::Sprite> > test (41,vector<sf::Sprite>(31,??)) ?
    Reply With Quote Edit / Delete Windows 7 Brazil Show Events

  10. Post #1290
    Richy19's Avatar
    May 2010
    5,368 Posts
    Well, I have some dumb question.

    How do I create a vector of Sprites using SFML and vector header?
    i started the vector like

    vector<sf::Sprite> test;

    and Im trying to do a push_back(), but i dont know what i need to put inside the "()".

    Anyway, my vector will be 41x31, so there is a way t do something like
    vector<vector<sf::Sprite> > test (41,vector<sf::Sprite>(31,??)) ?
     vector<sf::Sprite> test;
    sf::Texture t;
    t.loadFromFile("foo.png");
    sf::Sprite s(t);
    test.push_back(s);
    

    Edited:

    If the size is always going to be 41x31 you are probably better of just using an array.
    Also if this is just for background have a look at sf::VertexArray

    Edited:

    If in OpenGL(2.1) I have a scene like the left, therefore the user views the right.
    Does the cube actually get rendered?



    The reason im asking is because in a voxel game(like minecraft for example) would it be necesairy to actually call or not call the draw for sides of cubes that are connected to other cubes?
    Reply With Quote Edit / Delete Linux United Kingdom Show Events

  11. Post #1291
    Gold Member
    Lord Ned's Avatar
    April 2006
    3,702 Posts

    If in OpenGL(2.1) I have a scene like the left, therefore the user views the right.
    Does the cube actually get rendered?



    The reason im asking is because in a voxel game(like minecraft for example) would it be necesairy to actually call or not call the draw for sides of cubes that are connected to other cubes?
    The GPU renders exactly what you tell it to, regardless of position. You'd have to devise your own culling method to reduce objects/faces/etc.
    Reply With Quote Edit / Delete Windows 7 United States Show Events Informative Informative x 1 (list)

  12. Post #1292
    Gold Member
    layla's Avatar
    March 2010
    2,499 Posts
    The reason im asking is because in a voxel game(like minecraft for example) would it be necesairy to actually call or not call the draw for sides of cubes that are connected to other cubes?
    So you're asking if you should draw faces that are hidden by other faces that are touching? No, obviously not, why would you?
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  13. Post #1293
    Gold Member
    darkrei9n's Avatar
    November 2007
    5,138 Posts
    Code:
    	float d;
    	int v;
    	float a;
    	float b;
    	float c;
    	for(int p = 0; p < 1; p++)
    	{
    		v = rand();
    		a = sin(v);
    		b = cos(v);
    		d = sqrt(pCols*pCols + pRows*pRows);
    		c = (rand() / RAND_MAX) * d - d/2;
    		for(int i = 0; i < pCols * pRows; i++)
    		{
    			if(a*vertexLoad[i].position.x + b*vertexLoad[i].position.z - c > 0)
    			{
    				vertexLoad[i].position.y += 1;
    			}
    			else
    			{
    				vertexLoad[i].position.y -= 1;
    			}
    		}
    	}
    For some reason this causes an unhandled exception. The thing is, that if I increase p to 100, it will work perfectly all the way up the last pass then fail. So I don't know what the fuck is wrong with it. If I remove the offending line (d = sqrt(pCols*pCols + pRows*pRows);) the next line down causes the same error, and if I remove that cos(v) causes it.
    Reply With Quote Edit / Delete Windows 8 United States Show Events

  14. Post #1294
    Richy19's Avatar
    May 2010
    5,368 Posts
    So you're asking if you should draw faces that are hidden by other faces that are touching? No, obviously not, why would you?
    It was more, does the GPU automatically not render them due to there being something infront of them, so the user doesnt see them
    Reply With Quote Edit / Delete Linux United Kingdom Show Events

  15. Post #1295
    dajoh's Avatar
    March 2011
    625 Posts
    For some reason this causes an unhandled exception. The thing is, that if I increase p to 100, it will work perfectly all the way up the last pass then fail. So I don't know what the fuck is wrong with it. If I remove the offending line (d = sqrt(pCols*pCols + pRows*pRows);) the next line down causes the same error, and if I remove that cos(v) causes it.
    Most likely a floating point exception.
    Reply With Quote Edit / Delete Windows 7 Sweden Show Events

  16. Post #1296
    Gold Member
    darkrei9n's Avatar
    November 2007
    5,138 Posts
    Most likely a floating point exception.
    Access Violation.
    Reply With Quote Edit / Delete Windows 8 United States Show Events

  17. Post #1297
    Gold Member
    layla's Avatar
    March 2010
    2,499 Posts
    It was more, does the GPU automatically not render them due to there being something infront of them, so the user doesnt see them
    No, you're still drawing faces that you don't need, just don't add them.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  18. Post #1298
    Follow me on GitHub!
    Ziks's Avatar
    June 2011
    1,982 Posts
    Is there a standard way in my .NET (C#) application of telling nVidia to use the main graphics card on laptops with both an integrated crap card and main powerful one? I've been doing it manually through the nVidia control panel but it would be nice if users wouldn't have to.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  19. Post #1299
    kill yourself
    Protocol7's Avatar
    June 2006
    25,736 Posts
    Code:
    	float d;
    	int v;
    	float a;
    	float b;
    	float c;
    	for(int p = 0; p < 1; p++)
    	{
    		v = rand();
    		a = sin(v);
    		b = cos(v);
    		d = sqrt(pCols*pCols + pRows*pRows);
    		c = (rand() / RAND_MAX) * d - d/2;
    		for(int i = 0; i < pCols * pRows; i++)
    		{
    			if(a*vertexLoad[i].position.x + b*vertexLoad[i].position.z - c > 0)
    			{
    				vertexLoad[i].position.y += 1;
    			}
    			else
    			{
    				vertexLoad[i].position.y -= 1;
    			}
    		}
    	}
    For some reason this causes an unhandled exception. The thing is, that if I increase p to 100, it will work perfectly all the way up the last pass then fail. So I don't know what the fuck is wrong with it. If I remove the offending line (d = sqrt(pCols*pCols + pRows*pRows);) the next line down causes the same error, and if I remove that cos(v) causes it.
    Debug it, see what the variables are set to when it throws an error.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  20. Post #1300
    Gold Member
    darkrei9n's Avatar
    November 2007
    5,138 Posts
    Debug it, see what the variables are set to when it throws an error.
    Already figured it out. Had some code after it that was causing it. I do not know why it threw the error there though.

    Code:
    for(int y = 0; y < pCols*pRows; y++)
    {
         vertexLoad[i].color = RED;
    }
    I was using i instead of y.
    Reply With Quote Edit / Delete Windows 8 United States Show Events

  21. Post #1301
    Gold Member
    WTF Nuke's Avatar
    March 2009
    4,423 Posts
    I am trying to get threads to work, and have a few questions. Firstly, I am trying to get a thread to use a function in a class(the thread is being created in a class as well). How can I get the function to cause the thread to sleep? I have this right now:
    boost::this_thread.sleep(boost::posix_time::millisec(80));

    But the compiler says that "this_thread" is illegal use of namespace identifier in expression. Secondly, will a thread delete itself once it's finished running a function? And if a thread goes out of scope, will it get deleted even if the thread is still running? If so, what kind of pointer would I use for the thread to exist until it is done running.

    Edit: I accidentally used .sleep instead of ::sleep. Now, how can I use a function defined in a class to pass to a thread? Do I have to make the function static?

    I used boost::bind to make it work.
    Reply With Quote Edit / Delete Windows 7 Canada Show Events

  22. Post #1302
    Hup, 2, 3, 4
    Maksim's Avatar
    October 2009
    1,448 Posts
    Can anyone help me with this? I'm making a simple minecraft launcher (Extra features, ect) and I go to try it on my friends computer, and the launcher comes up fine, but when he logs in to start minecraft, it doesn't work. Here is the snippet of code that starts it (works fine by me)

    Code:
            Dim process As New Process
            Dim info As New ProcessStartInfo
            Dim jarPath As String = "C:\Users\Dylan\AppData\Roaming\.minecraft\bin\minecraft.jar"
            info.FileName = "javaw"
            info.CreateNoWindow = True
            info.Arguments = "-cp " & Chr(34) & jarPath & ";%APPDATA%\.minecraft\bin/lwjgl.jar;%APPDATA%\.minecraft\bin/lwjgl_util.jar;%APPDATA%\.minecraft\bin/jinput.jar;" & Chr(34) & " " & Chr(34) & "-Djava.library.path=%APPDATA%\.minecraft\bin\natives" & Chr(34) & " -Xmx1024M -Xms512M net.minecraft.client.Minecraft " + player + " " + result(3)
            info.Arguments = info.Arguments.Replace("%APPDATA%", GetFolderPath(SpecialFolder.ApplicationData))
            process.StartInfo = info
            process.Start()
            End
    Edit: I'm an idiot..... Dim jarPath As String = "C:\Users\Dylan\AppData\Roaming\.minecraft\bin\minecraft.jar"
    Reply With Quote Edit / Delete Windows 7 United States Show Events Programming King Programming King x 1 (list)

  23. Post #1303
    Fat & Ugly
    elih595's Avatar
    October 2009
    786 Posts
    http://pastebin.com/PVbfMQG8

    I'm trying make the player collide with the wall. The wall is a 31x31 cube but I can only make the player collide on the left face of the cube. I can't figure out how to add more sides without them overriding each other.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  24. Post #1304
    Gold Member

    March 2005
    3,028 Posts
    If in OpenGL(2.1) I have a scene like the left, therefore the user views the right.
    Does the cube actually get rendered?
    The vertex transformations and whatnot will always occur. The GPU will try to create fragments for every polygon, but the actual shading may or may not occur depending on the results of depth testing. This is why a lot of games do early-z passes or render front-to-back; it saves on shading overhead in forward renderers.

    Effectively, you may save on some fragment shading, but you still have to actually process the primitives. This is why we have visibility testing and occlusion queries in games.
    Reply With Quote Edit / Delete Windows 7 Show Events Informative Informative x 1 (list)

  25. Post #1305
    Dennab
    September 2011
    3,417 Posts
    Hello again folks, I require assistance once again in Visual basic 2010. I wouldn't ask this if I hadn't committed hours trying to solve it myself. But I need to get this nifty little simulation give somewhat logical numbers instead of astronomical coordinates and infinite decimals.

    Here's what I have trouble with in my nuclear strike simulator.
    There's a certain percentage of people from the total population of the city in certain range, and certain percent of those people in those ranges die.

    Code:
    Public Class Form1
        Dim Oulu As Integer = 150000 ' Population of this city
        Dim Oulun_pinta_ala As Double = (1000 * 1410.17) ^ 2  'Area of whole city turned from square kilometers(1410.17) to meters
        Dim Oulun_asukastiheys As Integer = Oulu / Oulun_pinta_ala 'population density
        Dim Asukkaita_1140m_säteellä As Double = (1140 * 1140) * 3.14 / Oulun_pinta_ala * Oulu 'population in this range in meters
        Dim Asukkaita_3050m_säteellä As Double = (3050 * 3050) * 3.14 / Oulun_pinta_ala * Oulu 'population in this range in meters
        Dim Asukkaita_6200m_säteellä As Double = (6200 * 6200) * 3.14 / Oulun_pinta_ala * Oulu 'population in this range in meters
    Code:
        Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
            If lblAsukasmaara.Text = "0" Then
                MsgBox("Valitse Kaupunki")
            End If
    
            If lblAsukasmaara.Text = Oulu Then
    
                kuollut1 = (100 - 88) / 100.0 * Asukkaita_1140m_säteellä 'death toll in these ranges
                kuollut2 = (100 - 33) / 100.0 * Asukkaita_3050m_säteellä
                kuollut3 = (100 - 11) / 100.0 * Asukkaita_6200m_säteellä
                yht = kuollut1 + kuollut2 + kuollut3
                tulo1 = kuollut1
                tulo2 = kuollut2
                tulo3 = kuollut3

    But I get results like this (note that "kuollut", "kuolleita" etc means "dead")
    Code:
    Kuolleita 1140 metrin säteellä: 0,0369376203597919
    Kuolleita 3050 metrin säteellä: 1,47622462665414
    Kuolleita 6200 metrin säteellä: 8,10310283100606
    Kuolleita yhteensä: 9,61626507801999
    please forgive my stupidity :c
    Reply With Quote Edit / Delete Windows 7 Finland Show Events

  26. Post #1306
    Commando123's Avatar
    August 2009
    552 Posts
    Hey everyone. I am in c++ programming in college and I could use a little help with a final project.
    This is my project;
    Code:
    Your programming assignment is to develop a program to find out the winner of the gymnastics competition.  The winner is the gymnast with the highest score.  Each gymnast will receive a score from seven (7) judges.  The highest and lowest score will be thrown out. The remaining five scores will be averaged to determine the gymnast final score. The output will list each gymnast with their final score followed by the overall winner.
    
     
    
    Your input will come from a file with the name - OLYMPICS.TXT and have the data listed as follows
    
    OLGA KORBUT 8.8 7.8 3.4 8.9 10.0 6.5 9.9
    
    MARY LOU RETTON 5.6 5.5 6.5 7.5 4.8 2.1 4.5
    
    NADIA COMANECI 9.9 8.9 9.4 9.3 9.6 8.8 9.2
    
    The number of Gymnasts in the file will vary.
    
     
    
    The results will be written to a file called - FINAL.TXT and have the format of
    
    Gymnast                                    Score
    
    OLGA KORBUT                            8.38
    
    MARY LOU RETTON                    5.38
    
    NADIA COMANECI                       9.28
    
     
    
    The winner is NADIA COMANECI

    I am having trouble with this concept. All we have learned this year is basic stuff. This one has to do with loops and files. I am not sure how to go about this. I have tried doing some code for the past few days and cant figure this out correctly. Any tips or help will be greatly appreciated.
    What I know I should do is create a loop that inputs all the values and creates a high low type deal. I am not sure how to go about that correctly.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  27. Post #1307
    Gold Member
    darkrei9n's Avatar
    November 2007
    5,138 Posts
    Code:
    		case WM_MOUSEMOVE:
    			mousePT.x = (int)LOWORD(lParam);
    			mousePT.y = (int)HIWORD(lParam);
    
    			dx = mousePT.x - gOldPos.x;
    			dy = mousePT.y - gOldPos.y;
    
    			Camera().onPitch(dx);
    			Camera().onYaw(dy);
    
    			gOldPos = mousePT;
    			break;
    Ran into an issue with using the Win API for input, for some reason this does not work at all in moving the camera.

    (Camera Code)

    Code:
    void Camera::onPitch(float angle)
    {
    	D3DXMATRIX R;
    	D3DXMatrixRotationAxis(&R, &gRight, angle);
    
    	D3DXVec3TransformNormal(&gUp, &gUp, &R);
    	D3DXVec3TransformNormal(&gLook, &gLook, &R);
    }
    
    void Camera::onYaw(float angle)
    {
    	D3DXMATRIX R;
    	D3DXMatrixRotationY(&R, angle);
    
    	D3DXVec3TransformNormal(&gRight, &gRight, &R);
    	D3DXVec3TransformNormal(&gUp, &gUp, &R);
    	D3DXVec3TransformNormal(&gLook, &gLook, &R);
    }
    
    void Camera::onRoll(float angle)
    {
    	D3DXMATRIX R;
    	D3DXMatrixRotationZ(&R, angle);
    
    	D3DXVec3TransformNormal(&gUp, &gUp, &R);
    	D3DXVec3TransformNormal(&gRight, &gRight, &R);
    }
    Reply With Quote Edit / Delete Windows 8 United States Show Events

  28. Post #1308
    Gold Member
    Naelstrom's Avatar
    June 2010
    2,648 Posts
    Hey everyone. I am in c++ programming in college and I could use a little help with a final project.
    This is my project;
    Code:
    Your programming assignment is to develop a program to find out the winner of the gymnastics competition.  The winner is the gymnast with the highest score.  Each gymnast will receive a score from seven (7) judges.  The highest and lowest score will be thrown out. The remaining five scores will be averaged to determine the gymnast final score. The output will list each gymnast with their final score followed by the overall winner.
    
     
    
    Your input will come from a file with the name - OLYMPICS.TXT and have the data listed as follows
    
    OLGA KORBUT 8.8 7.8 3.4 8.9 10.0 6.5 9.9
    
    MARY LOU RETTON 5.6 5.5 6.5 7.5 4.8 2.1 4.5
    
    NADIA COMANECI 9.9 8.9 9.4 9.3 9.6 8.8 9.2
    
    The number of Gymnasts in the file will vary.
    
     
    
    The results will be written to a file called - FINAL.TXT and have the format of
    
    Gymnast                                    Score
    
    OLGA KORBUT                            8.38
    
    MARY LOU RETTON                    5.38
    
    NADIA COMANECI                       9.28
    
     
    
    The winner is NADIA COMANECI

    I am having trouble with this concept. All we have learned this year is basic stuff. This one has to do with loops and files. I am not sure how to go about this. I have tried doing some code for the past few days and cant figure this out correctly. Any tips or help will be greatly appreciated.
    What I know I should do is create a loop that inputs all the values and creates a high low type deal. I am not sure how to go about that correctly.
    Use sscanf to parse the data for each line, then loop through the numbers to find the highest and lowest score to discard them. Then get the remaining five scores and average them. It'd look something like this:
    Code:
    std::ifstream File;
    File.open("path/to/file.txt");
    while (File.good())
    {
    char FirstName[32];
    char LastName[32];
    float Scores[7];
    char Buffer[256];
    File.getline(Buffer,256);
    sscanf(Buffer,"%s %s %f %f %f %f %f %f %f",FirstName,LastName,&Scores[0],&Scores[1],&Scores[2],&Scores[3],&Scores[4],&Scores[5],&Scores[6]);
    float Min =10;
    float Max = 0;
    for (unsigned int i=0;i<7;i++)
    {
    if (Scores[i]>Max)
    {
    Max = Scores[i];
    }
    if (Scores[i]<Min)
    {
    Min = Scores[i];
    }
    }
    float Average = 0;
    for (unsigned int i=0;i<7;i++)
    {
    if (Scores[i] != Min && Scores[i] != Max)
    {
    Average += Scores[i];
    }
    }
    Average/=5;
    std::cout << FirstName << " " << LastName << " average score is " << Average << "\n";
    }
    Sorry for the lack of formatting, chrome won't let me tab.
    Reply With Quote Edit / Delete Linux United States Show Events

  29. Post #1309
    Commando123's Avatar
    August 2009
    552 Posts
    Would you be able to do it with like simple looping and basic file i/o? We have not done arrays. I am completely lost. I am very new to this stuff and we only covered basic input, basic control structures, and functions.. lol Basically where I am thrown off in the file is how to get the names first then loop through the 7 numbers, knock off high and low, then move on to the next one infinitely. I'm not sure how to go about that. I understand your code but we are not to that level yet and I need to write it in more simpler terms.. The professor would not like me using arrays when he has not even hit them.

    I made myself a basic High Low code but I dont know where to go from here.

    Code:
     #include <fstream>
    using namespace std;
    
    int main()
    {
    	ifstream scores;
    	ofstream winners;
    	int number, high, low;
    
    	scores.open("scores.txt");
    	winners.open("winners.txt");
    
    	scores >> number;
    	low = number;
    	high = number;
    
    	while (number >= 0)
    	{
    		if (number > high)
               high = number;
    
    		if (number < low)
    			low = number;
    
    		scores >> number;
    
    	}
    
    	winners << "the highest number in the list is " << high
    		    << endl << endl;
    
    	winners << "the lowest number in the list is " << low
    		    << endl << endl;
    
    	scores.close();
    	winners.close();
    
    	return(0);
    }
    I just made the input file a string of numbers.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  30. Post #1310
    I gave ••••• enough money to buy a soda.
    Funley's Avatar
    May 2010
    1,389 Posts
    In XNA, is 'matrix.Backward' the same as '-matrix.Forward'?
    Reply With Quote Edit / Delete Windows 7 Finland Show Events

  31. Post #1311
    Gold Member
    darkrei9n's Avatar
    November 2007
    5,138 Posts
    In XNA, is 'matrix.Backward' the same as '-matrix.Forward'?
    I do not think it is. The order of matrix calculations does matter.
    Reply With Quote Edit / Delete Windows 8 United States Show Events

  32. Post #1312

    January 2012
    68 Posts
    I made a game using code::blocks and sfml,
    but how do I build the release version without the "terminal" window and including variables, imgs, sounds, etc.. in the .exe file?

    thanks in advance
    Reply With Quote Edit / Delete Linux Brazil Show Events

  33. Post #1313
    Gold Member
    Naelstrom's Avatar
    June 2010
    2,648 Posts
    Would you be able to do it with like simple looping and basic file i/o?
    It seems really pointless to avoid useful tools and abilities of the language. Your teacher shouldn't punish you for going above and beyond
    Reply With Quote Edit / Delete Linux United States Show Events

  34. Post #1314
    kill yourself
    Protocol7's Avatar
    June 2006
    25,736 Posts
    Stringstream can help you when you have 3 names. Or one. So instead of parsing a first and last name you can just cin into a string.

    Also, write a function to split up a string with space delimiters, and return a string vector full of it. Then use a stringstream to test if the vector index is a string or a double ( istringstream >> int won't do anything if the stringstream can't be converted to int) and then do stuff accordingly.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  35. Post #1315
    Richy19's Avatar
    May 2010
    5,368 Posts
    I keep getting this:

    |36|undefined reference to `SOGLF::Keyboard::IsKeyDown(SOGLF::Keyboard::Keys) '|
    I have it declared as:
    namespace SOGLF
    {
    class Keyboard
    {
    enum Keys{...};
    static inline bool IsKeyDown(SOGLF::Keyboard::Keys key);
    };
    }
    
    and defined in a cpp file as:
    bool SOGLF::Keyboard::IsKeyDown(SOGLF::Keyboard::Keys key)
    {
        bool result = false;
    
        switch (key)
        {
            ....
        }
        return result;
    }
    
    Reply With Quote Edit / Delete Linux United Kingdom Show Events

  36. Post #1316
    Gold Member
    layla's Avatar
    March 2010
    2,499 Posts
    So I needed a position to screen method which is pretty much gluProject, so I wrote that:

    bool Renderer::Project(const Vector3f& position, const Vector2i& windowSize, Vector2f& result) const
    {
    	Vector4f in(position.x, position.y, position.z, 1.0f);
    	in = m_projection * (m_modelView * in);
    
    	if (in.w == 0.0f)
    	{
    		return false;
    	}
    
    	in.x /= in.w;
    	in.y /= in.w;
    	in.z /= in.w;
    
    	in.x = in.x * 0.5f + 0.5f;
    	in.y = in.y * 0.5f + 0.5f;
    	in.z = in.z * 0.5f + 0.5f;
    
    	result.x = in.x * windowSize.x;
    	result.y = windowSize.y - (in.y * windowSize.y);
    
    	return true;
    } 

    The only problem is that the screen position is still on the screen when the position I'm projecting is behind the near clipping plane. So in that situation, I either need a way to make it return a position thats outside the screen (so I can clamp sprites to the edge to see what direction something is in) or find out if the point is behind the near clipping plane.

    Edited:

    It seems I can just return out if the w component is less than 0.001, seems to work and that's what the source engine does, so whatever, it's good enough for me.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  37. Post #1317
    Gold Member
    HeroicPillow's Avatar
    July 2009
    4,479 Posts
    I keep getting this:

    I have it declared as:
    namespace SOGLF
    {
    class Keyboard
    {
    enum Keys{...};
    static inline bool IsKeyDown(SOGLF::Keyboard::Keys key);
    };
    }
    
    and defined in a cpp file as:
    bool SOGLF::Keyboard::IsKeyDown(SOGLF::Keyboard::Keys key)
    {
        bool result = false;
    
        switch (key)
        {
            ....
        }
        return result;
    }
    
    You should define inline functions within the header file. Also, make sure you actually want/need an inline function.

    http://www.parashift.com/c++-faq-lit...s.html#faq-9.7
    It's usually imperative that the function's definition (the part between the {...}) be placed in a header file. If you put the inline function's definition into a .cpp file, and if it is called from some other .cpp file, you'll get an "unresolved external" error from the linker.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  38. Post #1318
    ben1066's Avatar
    August 2009
    960 Posts
    Time to ask for help at Facepunch too I guess. I'm trying to add physics to my 3D game engine however the mesh is ending up horribly mis-aligned.




    I'm using Jitter since it seems quite nice and it doesn't want to do everything for you. I'm trying to build a compound shape of convex hulls, one for each mesh in the model. Currently however the different hulls are being transformed incorrectly, resulting in a misaligned mesh.

    http://pastebin.com/PNkWVfsz is my current physics entity class. Any help is much appreciated.
    Reply With Quote Edit / Delete Windows 8 United Kingdom Show Events

  39. Post #1319
    AlienCat's Avatar
    October 2011
    508 Posts
    http://pastebin.com/PVbfMQG8

    I'm trying make the player collide with the wall. The wall is a 31x31 cube but I can only make the player collide on the left face of the cube. I can't figure out how to add more sides without them overriding each other.
    You could save the movement direction of the player and move it back with the reversed speed.

    Else you do something like this inside the block collision test:

    Code:
    if((playerX+26 >= wallX)and(playerX <= wallX+26)and(playerY+26 >= wallY)and(playerY <= wallY+26))then
        if(playerX+13 <= wallX+13) then
            //Move player to left
        else then
            //Move player to right
        end
    end
    I could be wrong with those values, I basically are trying to determinate if the player is to the right/left of the block.


    I made a game using code::blocks and sfml,
    but how do I build the release version without the "terminal" window and including variables, imgs, sounds, etc.. in the .exe file?

    thanks in advance
    Did some searching and found this, pretty much what you ask about the terminal: http://en.sfml-dev.org/forums/index.php?topic=595.0

    Baking images and sounds in the exe is NOT recommended since it will make the exe file giant. Instead, encrypt your resources or make them to binary or something if you want to protect them. However I found this: http://en.sfml-dev.org/forums/index....46783#msg46783
    Reply With Quote Edit / Delete Windows 7 Sweden Show Events

  40. Post #1320
    Gold Member
    JohanGS's Avatar
    January 2009
    3,436 Posts
    (In C#) How do I create a menu in which I can choose between different options?


    ^like that
    Reply With Quote Edit / Delete Windows 7 Sweden Show Events