Jump to content

  • Log In with Google      Sign In   
  • Create Account

Calling all IT Pros from Canada and Australia.. we need your help! Support our site by taking a quick sponsored surveyand win a chance at a $50 Amazon gift card. Click here to get started!


slicer4ever

Member Since 02 Nov 2008
Online Last Active Today, 06:40 AM

#5246995 Time Based Movement: NPCs Spawning Too Slow when Framerates are High...

Posted by slicer4ever on 16 August 2015 - 06:32 PM

last_time = current_time; should be last_time += (1000.0f/60.0f);

edit: scratch that, i didn't realize you had that logic commented out. it's actually in your spawn timer:

m_spawn_timer = m_spawn_speed; should be m_spawn_timer+=m_spawn_speed;


edit2:

Too explain, you are not carrying over whatever negative value the last spawn timer was at. let's say m_spawn_speed = 2; and m_delta_speed is 3. then in the next frame m_delta_speed is 1. in your current logic, m_spawn_timer would end up at 2, and by the second frame 1(which really should be 0) so now you've missed a spawning event. by incrementing by the frequency instead of resetting it, you don't lose any accumulation time.


#5244701 Error: pixel shader must minimally write all four components of SV_Target0

Posted by slicer4ever on 05 August 2015 - 12:25 PM

What do you expect to happen with that shader? You have to actually write a pixel out, i.e:


Wrong. If you are rendering to a depth buffer with no render targets bound you still need the pixel shader for alpha testing, but there is no need for any return value.
Well then, how about you tell us the correct way to fix his issue?

I'm on mobile so I can't research his exact issue, but what I'm gathering from the error is that regardless that you have no color buffer bound, the api still expects him to output something, which is likely discarded when no colorbuffer is bound.


#5244688 Error: pixel shader must minimally write all four components of SV_Target0

Posted by slicer4ever on 05 August 2015 - 11:08 AM

What do you expect to happen with that shader? You have to actually write a pixel out, i.e:
struct VS_OUT
{
        float4 PosH : SV_POSITION;
        float2 Tex  : TEXCOORD;
};
 
SamplerState Sampler : register(s0);
 
Texture2D DiffuseMap;
float4 main(VS_OUT pin) : SV_TARGET
{
        float4 Diffuse = DiffuseMap.Sample(Sampler, pin.Tex);
 
        //clip pixels having alpha value < 0.15 (nearly transparent)
        clip(Diffuse.a - 0.15f);
        return Diffuse:
 
}



#5244331 Constructor Initializer List and Heap Allocation

Posted by slicer4ever on 03 August 2015 - 11:36 AM

For the purpose of error-checking, a better alternative is, as you mention, initialize mem-pointers to nullptr in the constructor. Then implement another class function such as bool Init(). In that Init() call, you can perform required allocations and other initializations as desired. The benefit of a separate Init() call: you can return an error indication if any part of your initialization fails.

I'm pretty certain this goes against the RAII pattern. While i will say it can be better than a bad allocation in the constructor, i would say that this is an explicit case where exception handling is well suited.

Another option if exceptions are unwarranted is not to directly call your constructor, instead call an intermediary function which does the actual allocation/checks, and then passes that data to your actual object constructor, or reports an error if allocations failed.


#5243626 How does each pixel in Shadow Map correspond to each pixel in scene?

Posted by slicer4ever on 30 July 2015 - 01:13 PM

you render the scene from your lights perspective, and save the depth buffer. you then take another render of your scene from your cameras perspective, but you also tell it the light's position as well, so when you translate your point by your camera matrix, you also translate it by your light's matrix as well. now you have 2 pixels, one for where it would be if seen by the light, and one for your camera. you then can compare if that pixel's light position depth is > then the pixel the light saw at that position. if it is, that means it's shadowed, if it isn't, that means it is visible to the light, and not shadowed.




#5243611 Is flash still relevant for mobile platforms?

Posted by slicer4ever on 30 July 2015 - 12:04 PM

As far as I know Apple haven't wanted to support flash for some time. So is there any point in making a flash game for iOS/Android? Also if you did use flash for say Android, how would you use C++ with it?


I do believe adobe air allows you to package flash games to be distributed for iOS/android(but don't take my word on that, it's just what i've gleamed over time). The workflow flash offers is pretty decent for 2D games, so I'd still recommend it even today, but for web based games, i'd recommend HTML5 over flash.
As for integrating C++ with flash, I have no idea if this is even possible to be perfectly honest.


#5243283 Old-School 3D Wireframe Modelling Tool

Posted by slicer4ever on 28 July 2015 - 04:55 PM

why can't you simply set draw mode to wireframe?

 
..and use Blender you mean?

 
yes.

why can't you simply set draw mode to wireframe?
(OpenGL: glPolygonMode, DX11: rastdescriptor.fillmode)

Create/model, not draw.


I assume his end goal is to draw those models like they were wireframed. instead of adding the overhead of generating a bunch of redundant vertices for his model in line mode, to instead just use built in api features for drawing models as wiremeshs.
if this is not his end goal, then disregard my comment.


#5243279 Old-School 3D Wireframe Modelling Tool

Posted by slicer4ever on 28 July 2015 - 04:48 PM

Hi, I would like to make some simple 3D wireframe models - such as Elite spaceships, Mercenary buildings, Battlezone etc. I'm talking 80-90's retro wireframe modles here.
 
Rather than writing my own, I'd like to find something out there which will let me create relatively simple models and export vertex and line information to a simple file format or even C arrays etc.
 
I don't really want to use something as complicated as Blender if I can avoid it.
 
Can somebody recommend such a tool?
 
Thanks.


why can't you simply set draw mode to wireframe?
(OpenGL: glPolygonMode, DX11: rastdescriptor.fillmode)


#5243276 Defining a struct in a header so that I can use my varaible anywhere

Posted by slicer4ever on 28 July 2015 - 04:35 PM

I'm trying to define a struct within my header file to use  the new struct variable  all over my code. I'm having some difficulties doing this. Any examples please? I looked around before coming here but nothing is working. A bare bone example would be appreciated.


I'm ganna go another route, and assume you mean to do the following:

 
//MyHeader.h
#ifndef MYHEADER_H
#define MYHEADER_H

struct Struct{
   int x;
};
extern Struct mStruct;
#endif
//MyHeader.cpp
#include "MyHeader.cpp"
Struct mStruct = {0}; //note we initialize it's members to 0.
//main.cpp
#include "MyHeader.h"
#include <iostream>

int main(int argc, char **argv){
    std::cout << mStruct.x << std::endl;
}
The keyword your looking for is extern, it's basically like forward-declaring a function, but for a global variable. you define it in a single implementation file(in this case MyHeader.cpp), and when linking is done the linker will find it and use it for other implementation files.

With that said, I do not advocate the use of extern, and that using it generally means something bad is going on(this is really true if you are using any global variables). as such i don't advocate it's use at all.

edit: ninja'd by frob.


#5243273 Am i missing something, can i sweep like this?

Posted by slicer4ever on 28 July 2015 - 04:27 PM

there is a problem with this method: missing small objects. what happens if object B is small enough to fit between your raycasts?
it's an idea i toyed with before, but imo it has potentials for missis.


#5243270 Organizing rendering code

Posted by slicer4ever on 28 July 2015 - 04:21 PM

So I could use an abstract class from which API specific code inherits:
But using virtual functions in rendering code could bring performance issues to something very time-critical such as the rendering.

Honestly, i think your severely overestimating the performance impact a virtual call has. yes it's a bit of indirect with looking at vtables, but I'm extremely doubtful this is going to ever be your bottleneck.
yet again it comes back to a case of pre-mature optimzations, demonstrate it is an actual issue before looking for complex patterns that results in overcomplicating your design because you think that it might be an issue.


#5243028 Breaking out of a nested loop

Posted by slicer4ever on 27 July 2015 - 12:40 PM

https://derpibooru.org/883523


Not a site i ever expected would be linked to on gamedev :P


#5243002 Can game development excel with abstract concepts?

Posted by slicer4ever on 27 July 2015 - 10:57 AM

I'm sorry i'm on mobile so i can't quote the relevant passage i want to respond to.

AlwayBiased i find the attiude of saying things like "you can't understand, you've never dealt with such a bug" a bit egotistical. Many of us here have been programmers for a long time, maybe we havent done your particular problem, but we've likely ran into similarly complex bugs. The thing is we also are trying to tell you there are alternatives to debugging then stepping over an entire loop to find your bug.

For example, you say you can visually see that their is an error in your output. This likely means for a given input you can produce said bug(making your bug reproducable is the start to solving it). Once you've isolated how to make your bug appear, you can begin narrowing down the code associated with that data and since this is a problem you can visually inspect, it's likely you could say "break on index x/y" after having inspected where in the image the bug first appears.

If this isn't a viable tatic, another tatic is to dump the output at each iteration, rather than walk through your code, dump lots of data about your code. Then you can go through this data and start to narrow down where things go wrong.

There are a multitude of ways to tackle solving complex bugs, but saying things like "you can't possible understand" is not helpful to yourself or those trying to help.


#5242854 Breaking out of a nested loop

Posted by slicer4ever on 26 July 2015 - 04:32 PM

If you've got two for loops you're looking at O(n*n) execution times.

I'd be tempted to refactor the code and eliminate the for loops if possible but that's just me...


In all seriousness, I'd be interested to see that.

for(int i = 0; i < 100; ++i)
{
    if(((i / 10) - 1) == ((i % 10) + 1))
        break;
}
at least 1 is gone and we only need a normal break tongue.png

And suddenly the code is more complicated and about 10-100x slower, because the divisions are taking many more cycles than the other simple operations.


for(int i=0,n=0; n<10; n += ((i+1)==10), i+=((i+1)==10)*-9+((i+1)!=10)){
}
look ma, no division or additional branching tongue.png


#5237016 Can't convert array of strings to char array

Posted by slicer4ever on 26 June 2015 - 07:33 PM

I want to help you, but their is just so much wrong here i don't know where to begin.  I'd recommend going back and reading about how arrays, and pointers work(i'd even say their's abit of basic fundamental programming concepts you don't understand, considering the use of unnecessary copying, printing of individual characters, declaration of static strings, etc).

 

as well, this is a good opportunity to learn how to debug, you have alot of issues here that required you just typing out the code without actually testing what the results are(most noticeable how you calculate stringcount).






PARTNERS