Jump to content
  • Advertisement

Theo Berlin

Member
  • Content count

    17
  • Joined

  • Last visited

Community Reputation

121 Neutral

About Theo Berlin

  • Rank
    Member

Personal Information

  • Interests
    Programming
  1. You were right, it was the file! I got it sorted, now I just have some other tiny things left to solve before I can get this skybox working properly. I'll post another thread if I can't figure it out. Thanks!
  2. Hi, I've been trying to implement a skybox for some time now and there's probably only a tiny problem left to solve. When I load a texture using DirectXTK's CreateDDSTextureFromFileEx with a TEXTURECUBE flag, the resulting shader resource has its view dimension set to Texture2D and not TextureCube, which means I can't treat it as a TextureCube in HLSL. Also the file I'm loading contains all six faces. Here's snippets of my code where I load the texture, set the shader resource view to the pixel shader and then sample it in HLSL: // Loading the texture HRESULT hr = DirectX::CreateDDSTextureFromFileEx(device, filename, 0, D3D11_USAGE_IMMUTABLE, D3D11_BIND_SHADER_RESOURCE, 0, D3D11_RESOURCE_MISC_TEXTURECUBE, false, &texture, &mSkyboxSRV); // Setting the texture DeviceContext->PSSetShaderResources(0, 1, mSkybox->GetSkyboxSRV()); // HLSL: Sampling the texture TextureCube skyboxTexture : register(t0); SamplerState sampWrap : register(s0); struct PS_IN { float4 Pos : SV_POSITION; float3 lookVector : TEXCOORD0; }; float4 PS_main(PS_IN input) : SV_TARGET { return skyboxTexture.Sample(sampWrap, input.lookVector); } This is the error message being output by DirectX: D3D11 ERROR: ID3D11DeviceContext::Draw: The Shader Resource View dimension declared in the shader code (TEXTURECUBE) does not match the view type bound to slot 0 of the Pixel Shader unit (TEXTURE2D). This mismatch is invalid if the shader actually uses the view (e.g. it is not skipped due to shader code branching). [ EXECUTION ERROR #354: DEVICE_DRAW_VIEW_DIMENSION_MISMATCH] Does anyone have any ideas on what to do? Any help is much appreciated!
  3. Theo Berlin

    Quadratic Formula -1#ind?

    Ah, thanks, I just had to make sure b*b > 4(ac).
  4. Theo Berlin

    Quadratic Formula -1#ind?

    Hi, about a week ago I made a program that calculated quadratic formulas. Now, I'm supposed to change that program and use a function to the calculations. Problem is, it prints both x1 and x2 as "-1.#IND".   I've googled around and apparently it happens when you divide by zero, but a isn't 0. #include "../../std_lib_facilities.h" void quadratic(double a, double b, double c){ // Calculate and print x double x1 = (-b + sqrt(b * b - 4 * a * c)) / (2 *a); cout << "X1 == " << x1 << endl; double x2 = (-b - sqrt(b * b - 4 * a * c)) / (2 *a); cout << "X2 == " << x2 << endl; } int main() { double a = 1, b = 1, c = 1; // Input loop cout << "This program will help you solve ax (squared) + bx + c = 0\nEnter a, b and c\n"; while (cin >> a && cin >> b && cin >> c) quadratic(a, b, c); }
  5. Theo Berlin

    Printing prime numbers 1-100

    How do I keep the window open? I've always used keep_window_open, but I can't do that without std_lib_facilities
  6. Theo Berlin

    Printing prime numbers 1-100

    The string errors are back.
  7. Theo Berlin

    Printing prime numbers 1-100

    Usually, it errors show me where the problem is in the source file I've made. But this time, it's showing me where the problem is inside the header file. To show what I mean, I removed the t from cout. When I opened the SL, I got about ten error messages saying "string is ambiguous". However, these went away when I made a new std_lib_facilties and reloaded it.
  8. Theo Berlin

    Printing prime numbers 1-100

    Okay, thanks!
  9. Theo Berlin

    Printing prime numbers 1-100

      The annoying thing is that visual studio says "line 88" in the std_lib_facilities.h file, not in the actual source file. I tried running Alvaro's solution wth SL and it gives me the exact same error.
  10. Theo Berlin

    Printing prime numbers 1-100

    I'm trying to learn from your code, Alvaro. However, what does this mean?     if (v[p]) Does it mean "if element p exists"? Or does it mean "if element p is true"?   I agree with you, Paradigm, I shouldn't just be given an answer, but since I don't have a teacher and no homework, it's my responsibility to make sure I learn something. And it kinda felt like I was lost (as alvaro mentioned). So in this case, giving me a code isn't a shortcut, it's a source which I can use to learn from. The only downside is that it's not as easy to remember something you read "just like that".
  11. Theo Berlin

    Printing prime numbers 1-100

    Changed the code a bit and checked some stuff. I think the algorithm looks good now, but visual studio still gives me: "error C2440: 'return' : cannot convert from 'std::_Vb_reference<_Alloc>' to 'bool &'". Whenever I try to debug it tells me there were build errors and if I ignore it the app crashes and it says something like "Range_error at memory location...". #include "../../std_lib_facilities.h" int main() { vector<bool>plausible_prime(100, true); plausible_prime[0] = false; plausible_prime[1] = false; for (int p = 2; p < 100; ++p) for (int not_prime = 2; not_prime < 100;) { not_prime += p * p; plausible_prime[not_prime] = false; while (not_prime <= 100) { not_prime += p; plausible_prime[not_prime] = false; if (not_prime >= 100){ if (plausible_prime[p+1] != false) ++p; else if (plausible_prime[p+1] == true){ for (int v = 1; plausible_prime[p+v] == false;) p += v; } } } } for (size_t i = 0; i < plausible_prime.size(); ++i) { if (plausible_prime[i] == true) cout << i+1 << " is prime." << endl; } keep_window_open(); } Also, it's still printing 1 (repeatedly). Thanks a lot for the help you've given me! I'm going to sleep for now.
  12. Theo Berlin

    Printing prime numbers 1-100

    Writing it down on paper was a great idea. Perhaps the algorithm should be something more like this? not_prime = p * p; plausible_prime[not_prime] = false; while (not_prime <= 100) { not_prime += p; plausible_prime[not_prime] = false; }
  13. Theo Berlin

    Printing prime numbers 1-100

    I'm trying to print all the prime (true) numbers with for (size_t i = 0; i < plausible_prime.size(); ++i) { if (plausible_prime[i] == true) cout << plausible_prime[i] << endl; } It's always worked for me, but what am I doing wrong this time?
  14. Theo Berlin

    Printing prime numbers 1-100

      I like your bool solution, and I've changed my code quite a bit. However, the Visual Studio's giving me an error and it can't build it. "error C2440: 'return' : cannot convert from 'std::_Vb_reference<_Alloc>' to 'bool &'". #include "../../std_lib_facilities.h" int main() { vector<bool>plausible_prime(100, true); plausible_prime[0] = false; plausible_prime[1] = false; for (int p = 2; p < 100;) for (int not_prime = 2; not_prime < 100;) { not_prime += p*2; plausible_prime[not_prime] = false; if (not_prime >= 100){ if (plausible_prime[p+1] != false) ++p; else if (plausible_prime[p+1] == true){ for (int v = 1; plausible_prime[p+v] == false;) p += v; } } } for (size_t i = 0; i < plausible_prime.size(); ++i) { if (plausible_prime[i] =! false) cout << plausible_prime[i] << endl; } keep_window_open(); }
  15. Hi, I'm reading Bjorne Stroustrups "Programming Principles and Practice Using C++". Right now I'm doing exercises and I'm supposed to print the prime numbers from one to hundred. I've seen a few other C++ programs that does this, but they use modulo, which I'm not supposed to have learned yet, so I have to come up with a solution without that. Also, I must use a vector to store the prime numbers.   My code is a big mess, and whenever I start it up I get memory problems and the app crashes. Any ideas on how to solve this would be very much appreciated : )   Almost forgot: the program has to use the "Sieve of Eratosthenes" method. http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes #include "../../std_lib_facilities.h" int main() { vector<int>primes; for (int i=0;i < 100; ++i){ primes.push_back(i+1);} vector <int> not_primes; for (int p = 2; p < 100;) for (int not_prime = 2; not_prime < 100;) { not_prime += p*2; not_primes.push_back(not_prime); if (not_prime == 100){ for (int i = 0; i < 99; i++) { if (primes [i+2] = not_primes[i]) primes [i+2] = 0; } if (primes[p+1] != 0) ++p; else if (primes[p+1] == 0){ for (int v = 1; primes[p+v] != 0;) p += v; } } for (int i = 0; i < 100; ++i) { //if (primes[i] =! 0) cout << primes[i] << endl; cout << not_primes[i] << endl; } } keep_window_open(); }
  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!