Jump to content
  • Advertisement

Nahrix

Member
  • Content Count

    100
  • Joined

  • Last visited

Community Reputation

237 Neutral

About Nahrix

  • Rank
    Member

Personal Information

  • Interests
    DevOps
    Programming
  1. Thank you for the information, Hodgman.  Since this exercise is just a learning experience for me, and not intended to be productive, I've decided to investigate the optimized approach.   I have one other question about having a single vertex buffer.  If I were to add a model to the vertex buffer after having already initialized it with vertex data earlier on, the method that I see typically presented is: Create a new vertex array, with a mirror of the data already on the GPU, except sized larger to store the additional model vertex data Map the vertex buffer resource Copy the new vertex array over to the mapped resource My question is, is there a way to append the model's data to the end of the vertex buffer on the GPU, rather than copying over an entire block of redundant data, with the new model at the end?
  2. I've been using the tutorial site http://www.rastertek.com/ to learn DirectX 11 in C++.  I'm a little ways past a tutorial about rendering models to the screen.  The strategy in the tutorial is to create a class for the model, which includes an initialize function which creates a vertex buffer for the model.  I've since expanded and generalized the class to load any number of models, to be rendered to the screen later.   After doing some browsing on other sites related to DirectX, I found what seems to be a consensus opinion that everything should be put into a single vertex buffer, which is different than what I'm doing:  I'm creating a vertex buffer for every model, and in another function in my application, iterating through all the model objects, and calling their Render() function, which in turn call IASetVertexBuffers, IASetIndexBuffer, and IASetPrimitiveTopology, and then runs the shaders on each in turn.  This draws multiple models properly, but I don't want to continue doing it this way if it's wrong.   I have a few questions. Is it best practice to fit everything into a single vertex buffer? If so, how do I efficiently add / remove models to/from the vertex buffer in-between frames? Are there any tutorials out there that illustrate this method for DirectX 11 in C++? Because I'm so new to this, I might even be asking the wrong questions, so please correct any assumptions I might have accidentally made if that's the case.   Thanks!
  3. It could also be that you have to perform: UV.y = 1.0f - UV.y;.     L. Spiro   It's all good;  I just made a typo where I was assigning the same value over and over.  Everything works after modifying my code for triangle fans.  Thanks for all the help; you're the best!
  4. It works! .. sort of.   All the polygons show up now, but both the texture and normals are all out of whack.  It must be due to a combination of the right-hand to left-hand coordinate conversion, and the triangle-fan conversion I've done for the indices.   Edit:  Actually nevermind, it was just a simple typo in my code.  Everything works perfectly now!
  5. Thanks!  I'll go try to implement that right now :)
  6. I'm using this tutorial as a baseline for parsing obj files: http://www.rastertek.com/dx11tut08.html   This works fine if the obj file only contains faces with 3 vertices, but I'm trying to figure out how to make it work for obj files with faces that index 4 or more vertices.   My original thought was that, for faces with more than 3 vertices, (I'll simplify their description as f1, f2, f3, f4...) the first polygon would be built from f1, f2, f3, and the next from f2, f3, f4, etc.  When I parse and render that, however, there are lots of missing polygons in the mesh, so there's something I'm doing wrong.   My next thought was to read in f1, f2, f3 normally (backwards as f3, f2, f1, to convert the right-hand coordinate system to left-hand), and then read f2, f3, f4 in reverse (so in forwards order, f2, f3, f4, to convert coordinate systems again), and alternate that back and forth, since maybe the vertices were supposed to be read in like a stripe in Maya.  That didn't work either.   Anyways, I'm completely new to this, but I gave it my best shot before coming here for help.  Hopefully someone knows exactly how to handle this.
  7.   This analogy is close enough that the solution actually fits really well!  I can just have 2 structs that the primary thread alternates between writing, and then it can stick to just one of the structs while the other thread is busy reading from another one.  I only have to write a single time per loop, too!  Thanks!
  8. Define 'large'? Hundreds of times a second isn't very fast - we are potentially talking 10 milliseconds between copies, which is quite a lot of CPU time...       About 10 megabytes.
  9.   Sorry, I didn't mean it that way.  Let me clarify with an example stripped to the bones:   Let's say you have 2 ints: int1 and int2, and 2 threads: thread1 and thread2.  int1 and int2 are set to 0 by default.  At some point, thread1 takes int1, adds 1 to it, and saves the value to int1 and int2.  int2 will be accessed by thread2 as well at some point, so the write to int2 is done with a mutex.  Later, thread1 reads from int1 (1), adds 1 to it (2), and saves it back to int1.  Thread1 notices that int2 is being read from, so code is added to ignore the attempt to write to it (doesn't wait on the mutex, just skips to whatever else thread1 wants to do next).  What I'm saying is that, specific to the code I'm writing, it logically doesn't matter to me that thread2 is now reading 1 from int2, when the most current version of int1 reads 2.  I'm not talking about race conditions or anything, just that the logic in my code doesn't care that the two threads are dealing with 2 different values at this point in time.   The copy will be happening on large blocks of data hundreds of times per second, so this is an area I'd be willing to find an efficient solution to, even if it's something very complex.
  10. I have a thread that writes to a struct, and it needs access to that struct all the time.  I don't want to use a mutex to allow other threads to access this struct, because I don't want the first thread to ever have to wait for access to the data in the struct.   My solution is to write a copy of the struct every time it modifies the data, so other threads can access the copy of the (now potentially outdated, but that doesn't matter) struct data, without interrupting the primary thread.  If the primary thread needs to read the data, it references its own copy.  If it needs to write the data, it writes to its own struct, and only writes a copy if that copy isn't being read from (otherwise it skips that step).  I'd like to make this as efficient as possible, so I was wondering if there a way to write to 2 identical structs that's more efficient than simply writing, for example:   struct1.data1 = newdata; struct2.data1 = newdata;   assuming that you know the data is identical, and both are being written at the exact same time.
  11. Nahrix

    Counting algorithm

    I've been working on this for a long time. I haven't learned combinatorial mathematics yet, so I have tried to solve this using recursion. This is what I have so far. It doesn't work at all, but will show how I am thinking about the problem: (Java) public static int mapCodeword(String word) { String alphabet = "abcdefghijklmnopqrstuvwxyz"; int total = 0, alphabetLocation = alphabet.indexOf(word.charAt(0)); alphabet = alphabet.substring(alphabetLocation); if (word.length() == 1) return alphabetLocation + 1; for (int i = 0; i < word.length() + alphabetLocation - 1; ++i) total += (alphabet.length() * (word.length() - 1)) + mapCodeword(word.substring(1)); return total; }
  12. Nahrix

    Counting algorithm

    Yeah sorry, I meant implementation. Does it have a name?
  13. I need help devising a counting algorithm using the following rules: I have a string where each character comes lexicographically after the last, ie if the first letter is 'a', then the next letter MUST be between 'b' and 'z'. So some valid words would be: abc abd bcd bdz wxy And invalid words would be: aaa aab zab zy ca Then I want to find its integer value, where it counts up. ie: a = 1 b = 2 ... z = 26 ab = 27 ac = 28 ad = 29 ... az = 51 bc = 52 bd = 53 be = 54 Note that ab = 27 (there is no aa = 27, because aa would be an invalid word, and so bc = 52 after az, because there is no ba, or bb) I'm looking for an algorithm that can determine the numeric value of a valid word based on that counting algorithm.
  14. Nahrix

    Problem with basic DirectX app

    I have resolved the issue by using Visual Studio instead of Eclipse.
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!