Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
J

James_722

@James_722
About
Posts
13
Topics
9
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Opengl Multithreading (wglMakeCurrent() & wglShareLists() ) issue
    J James_722

    I am trying to multi-thread my OpenGL code but I have been having trouble. At first, I thought that using opengl inside an alternate thread was impossible, so I just did loading operations and passed the data to opengl in the main thread (I knew once I started passing too much data the main thread would lockup, and noticeably freeze the execution of the program while the data was being moved). I found some forum threads discussing opengl and multi-threading but they don't discuss the details that I'm looking for. namely, how and where do I use wglMakeCurrent() and wglShareLists(). I have been trying to create a display list in the alternate thread with the instructions outlined in the aforementioned forum posts but it crashes every time. I can load the model data, I can even load shaders, but loading a model (of any size) crashes the program. I will show some code snippets but there is really too much to put in one post:

    //This is the code initializing the 2 Render Contexts
    if (!(app.hDC=GetDC(app.hWnd)) || // Get A Device Context?
    !(PixelFormat=ChoosePixelFormat(app.hDC,&pfd)) || // Did Windows Find A Matching Pixel Format?
    !SetPixelFormat(app.hDC,PixelFormat,&pfd) || // Able To Set The Pixel Format?
    !(app.hRC=wglCreateContext(app.hDC)) || // Able To Get A Rendering Context?
    !(app.hRC_thd=wglCreateContext(app.hDC)) || // Get the second context (for loading in parallel thread)
    !(wglShareLists(app.hRC, app.hRC_thd)) ||
    !wglMakeCurrent(app.hDC,app.hRC)) // Try To Activate The Rendering Context
    {
    KillGLWindow();
    return false;
    }

    This next bit is all the initialization and render using opengl

    GLuint o; // display list handle
    vector<v3> v,n; // verts, norms
    vector<v2> u; // texcoords (UVs)
    vector<face> f; // polygons (faces)
    bool done = false;
    void load_thread(void* null) // alternate thread entry point
    {
    wglMakeCurrent(app.hDC, app.hRC_thd); // works fine (seemingly)
    load_rs_shdr(); // works fine
    load_obj("cell.obj", v,n,u,f); // works fine
    gen_display_list(o, v, n, u, f); // crashes my program
    done = true;
    return;
    }

    bool init()
    {
    init_med(v3(0,0,0)); //function to initialize opengl (enable depth, lighting, etc...)

    C / C++ / MFC graphics game-dev help question

  • MinGW dependancies
    J James_722

    I'm not sure if I've given the proper label to my issue, but I have upgraded to the new version of MinGW and am now having trouble compiling my code in Codeblocks. The program runs fine when executed from Codeblocks, but once I try to run it from windows I get an error stating that I need a certain dll file for it to run. I found on a forum a linker option that has covered one of the required dlls but not all of them (-static-libgcc) What linker options can I use to get rid of all these dependancies, I don't care how large it makes my exe; I think its easier to live with a large exe than having to package dlls with my project. I appreciate any advise anyone has to offer.

    C / C++ / MFC help announcement

  • OpenGL integration with SDL, problem
    J James_722

    I tried that, and I get nothing. I've based this on a port of the NeHe basecode to SDL, and even though I can see no differences in the method of either code, mine doesn't work. I tried calling gluLookat(), I tried translating the geometry to be in front of the camera, i tried making the backcolor something other than black, nothing works.

    C / C++ / MFC game-dev help com graphics

  • OpenGL integration with SDL, problem
    J James_722

    I am trying to create a simple game framework that covers all the boilerplate code involved with initializing a opengl/sdl window. I am having a problem getting it to work properly though. I know for sure that I initialized the screen SDL_surface properly but that is about it (the screen goes black); none of the opengl commands work properly. I added code to check to make sure the loop is working (it is). I'm well versed in Opengl but am an SDL noob. Its probably something small I screwed up or overlooked but I cannot figure it out, help on the topic of opengl integration with SDL is scarce. Here is a link to my code. http://pastebay.com/106583[^] If anyone knows what the problem is, I would greatly appreciate some help with this problem.

    C / C++ / MFC game-dev help com graphics

  • fstream, fail()
    J James_722

    I am trying to create a simple to program to encrypt a file but I am having a lot of trouble with accessing the file. Firstly, whenever I try to access the file fstream's fail() always returns true. If I take the check to fail() from my code it works fine encrypting the file but when I go to decrypt it there are artifacts in the file (2 extra bytes in my test file). here is the code in question:

    #define macro_encrypt (int) Byte + 25
    #define macro_decrypt (int) Byte - 25

    void fn_Decrypt()
    {
    char oldFilename[200];
    char newFilename[200];

    cout << "Enter Filename:   ";
    cin >> oldFilename; cout << endl;
    cout << "Enter new Filename:   ";
    cin >> newFilename; cout << endl;
    
    ifstream infile;
    ofstream outfile;
    char Byte;
    
    infile.open(oldFilename, ios::in | ios::binary);
    outfile.open(newFilename, ios::out | ios::binary);
    
    while (!infile.eof())
    {
        char NewByte;
    
        Byte = infile.get();
    
        NewByte = macro\_decrypt;
    
        outfile.put(NewByte);
    }
    
    infile.close();
    outfile.close();
    fn\_start();
    

    }

    I input a text file:

    hello encryption

    I get this (notepad output):

    ~……ˆ9~‡|‹’‰‚ˆ‡

    And when I go to decrypt that file I get this:

    hello encryptionÿæ

    What makes this all the more frustrating is that when I compile the code this is based on it works fine. I can't see why it would work and mine won't, they are functionally identical (from what I can see). Does anyone know why this is happening and/or how to fix it?

    C / C++ / MFC question ios security help tutorial

  • vector class memory usage [modified]
    J James_722

    I am just wondering if this:

    class Vector
    {
    public:
    float x,y,z;
    };
    Vector v;

    differs from this:

    class Vector
    {
    public:
    float x,y,z;
    void Cross(Vector, Vector);
    void Dot(Vector, Vector);
    void Normalize();
    //etc.....
    };
    Vector v;

    in terms of performance.

    modified on Friday, June 4, 2010 1:56 PM

    C / C++ / MFC performance graphics

  • passing variables to GLSL
    J James_722

    Thank you, this has been very helpful, I just have one more question; what about vec3, vec4, etc. This might be a stupid question, there might be a data structure in opengl that can handle data from these types, but what do i do about these data types?

    C / C++ / MFC help graphics game-dev tutorial

  • passing variables to GLSL
    J James_722

    I know that values such as light position can be passed into either the fragment shader or the vertex shader using gl_lightsource, but what if I wanted to use a variable from my code such as an eye vector for a phong equation. In the information on GLSL I have read I have not seen a mention as to how to do something like this. All I have seen is being able to pass data in that would normally be used in OpenGL's lighting model, such as the functions glMaterialfv and glLightfv. I hope this better explains my problem.

    C / C++ / MFC help graphics game-dev tutorial

  • passing variables to GLSL
    J James_722

    I have been working with GLSL for a couple days and I understand the basic concept. I know how to get specific values from my openGL applicaiton to the shader but I don't know how to pass in my own variables. I appreciate your help with this problem.

    C / C++ / MFC help graphics game-dev tutorial

  • Can't compile any code with Dev C++.
    J James_722

    I have Dev-c++ version 4.9.9.2 on my computer. When I try to compile anything, it gives me the same error. Makefile.win [Build Error] [main.o] Error -1073741515 I have two different copies of the program on my computer; one that is installed and a portable one and they both give me the same error. I know that it isn't my code because i use the portable one to compile code at school and it works fine there. In advance, thank you for your help. Here is the compile log I got from trying to compile on the portable version: Compiler: Default compiler Building Makefile: "J:\opengl\Makefile.win" Executing make... make.exe -f "J:\opengl\Makefile.win" all g++.exe -c main.cpp -o main.o -I"J:/Portables/Dev-CppPortable/App/devcpp/lib/gcc/mingw32/3.4.2/include" -I"J:/Portables/Dev-CppPortable/App/devcpp/include/c++/3.4.2/backward" -I"J:/Portables/Dev-CppPortable/App/devcpp/include/c++/3.4.2/mingw32" -I"J:/Portables/Dev-CppPortable/App/devcpp/include/c++/3.4.2" -I"J:/Portables/Dev-CppPortable/App/devcpp/include" make.exe: *** [main.o] Error -1073741515 Execution terminated

    C / C++ / MFC c++ help graphics game-dev

  • Executing batch files in C#.
    J James_722

    I won't go into details, but I would like to start a command line program from a c# form app. What I have been doing is write the file with c# code and execute it. I have been successful in changing the directory (cd ....) in the batch file. What i need now is to have another command called ("make"). I would like to know how to do this with either a batch file line or with something from a FCL class. To better illustrate my problem, here is an example of my programs batch output.

    set path=%path%;C:/pspdev/bin // these lines are static, they don't change
    set PSPSDK=C:/pspdev/psp/sdk
    cmd /k cd C:\pspdev\Projects\HomebewApp // this one changes directory on cmd startup, i tried to repeat the line with the "make" command but it didn't work.

    C# tutorial csharp help

  • xna first person shooter: strafing
    J James_722

    I tried, it didn't work. the object either got stuck in place or shot up in the y direction.

    C# game-dev tutorial

  • xna first person shooter: strafing
    J James_722

    I am creating a (first person shooter)-ish video game for my comp. sci. class and I can't get my character to strafe properly. I can have it move forwards and backwards but not side to side (at least not relative the the object, only the world). here is the code to move the object forward.

    if (keyboardState.IsKeyDown(Keys.W))
    {

                Vector3 pos = GetMissileMuzzlePosition();
                missileLauncherHead.velocity = missileLauncherHead.position - new Vector3(pos.X, 0, pos.Z);
                missileLauncherBase.velocity = new Vector3(0.0f, 0.0f, 0.0f);
                missileLauncherHead.position -= missileLauncherHead.velocity;
                missileLauncherBase.position -= missileLauncherBase.velocity;
            }
    

    and here's the code to make the object (its a cannon at this point) move to the left.

    if (keyboardState.IsKeyDown(Keys.A))
    {
    Vector3 pos = GetMissileMuzzlePosition();
    Vector3 refer = new Vector3(missileLauncherHead.position.X + 5, missileLauncherHead.position.Y,missileLauncherHead.position.Z);
    missileLauncherHead.velocity = refer - missileLauncherHead.position;
    missileLauncherBase.velocity = new Vector3(5.0f, 0.0f, 0.0f);
    missileLauncherHead.position -= missileLauncherHead.velocity;
    missileLauncherBase.position -= missileLauncherBase.velocity;
    }

    I a complete noob when it comes to vectors. I literally just learned how to do this in my calculus/vectors couse a few weeks back.

    C# game-dev tutorial
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups