Sunday, July 31, 2016

Vs2015 Update 3:template Does Not Work Anymore.

Vs2015 Update 3:template Does Not Work Anymore.

hi

 

I just updated my vs to vs2015 update 3.  After I created a project, i exported it to a template to be use by my other project.  after i created a new project with the template, I see my file and resource name in the solution explorer.  But when i clicked to open it, it popup a windows and said :

 

The document can not be opened.  It has been removed, renamed or deleted.

 

anyone has any idea?

 

thanks in advance


Rendering Gui Or Hud In A Separate Framebuffer

Rendering Gui Or Hud In A Separate Framebuffer

Hello, I have been trying to render the HUD for my game to a separate FrameBuffer so that I can apply my own shader effects to it that are separated from the 3D scene.

 

The problem is that I am having transparency issues. I use glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); with glClearColor(0.0f, 0.0f, 0.0f, 0.0f);, which creates a transparent black background for the HUD FrameBuffer before rendering the HUD.

 

Whenever I render a transparent HUD element to the FrameBuffer, the black gets mixed in with the original colors of the element, which is not what I want. It ends up making the HUD elements look darker than they are supposed to be when I mix the HUD FrameBuffer with the 3D Scene FrameBuffer.

 

I can change the color for glClearColor() and get different colored results, so I know that that is the root of the problem. I decided to use the blend function:

 

glBlendFuncSeparate(/*For color*/ GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA,
                                    /*For alpha*/ GL_ONE, GL_ONE_MINUS_SRC_ALPHA);

 

which was requested by someone who had a similar issue. Unfortunately it isn't working for me. I am afraid that I might need to do something involving stencil buffers to get it to work, but I want to try to avoid that and find a simpler solution. Can anyone give me any pointers?

 

Also this is made with OpenGL 4.2 with c++ and compiled with MinGW.


Tweeny, A Modern C++ Tweening Library

Tweeny, A Modern C++ Tweening Library

Hello! This post is to announce Tweeny, an inbetweening library for C++. It provides a fluid API for defining tweens, like:

auto tween = tweeny::from(0).to(50).during(100);
while (tween.progress() < 1) tween.step(1);

It supports tweens with multiple points (e.g, from 0 to 100 then to 200), multiple values (from 0, 0 to 100, 200) and multiple types (from 0, 0.0f to 10, 2.5f). It also has 30+ easing functions (based on those by Robert Penner http://ift.tt/1mCMeMf).

 

Here is a demo, compiled with emscripten, of a sprite using tweens: http://ift.tt/2aJELOV

 

- Source: http://ift.tt/2aHCbMg

- Site: http://ift.tt/2aJDZ4r

- API Doc and Manual: http://ift.tt/2aHBl2o

 

For those wondering what a tween is or why is it useful, every Game UI nowadays has some sort of tween in them: panels fade in/out, buttons wobble when hovered, things slide in/out with acceleration/deacceleration, etc. All of those pretty animations are possible through a tween with a specific easing.

 

The purpose of Tweeny is to facilitate that. For instance, to animate a button size, this is a possible solution:

auto tween = tweeny::from(button.w, button.h).to(button.w + 10, button.h + 10).during(200).via(easing::backOut);
tween.onStep([](int w, int h) { button.w = w; button.h = h; return false; });

/* later, in game loop */
tween.step(dt);

Tweeny is MIT licensed.

 

I hope this can be useful to you. Feedback is much appreciated!


Only 12 Enemies, And My Fps Drops To 30, Why Is That?

Only 12 Enemies, And My Fps Drops To 30, Why Is That?

Guys. What I did so far:

 

1.  I wanted to cap the frame rate of my game, but SDL_GetTicks() returns time since app start in Uint32 milliseconds, so I'm getting slightly wrong fps due to small rounding errors and the second reason why frame cap is bad in my case is that SDL_Delay() is not precise, as is said below.

 

fastcall22 says:

 


I would guess that relying on SDL_Delay to regulate framerate is not a good idea, since suspending a thread is not guaranteed to return exactly at the requested duration. From SDL documentation: This function [SDL_Delay] waits a specified number of milliseconds before returning. It waits at least the specified time, but possible longer due to OS scheduling. The delay granularity is at least 10 ms. Some platforms have shorter clock ticks but this is the most common. 

 

 

 

2. That's why I decided to make a frame-independent movement, so I used a variable called deltaTime which is calculated based on the current fps. Sounds cool. But the problem is that I have 7 enemies and in my 'Enemy' class I have various different functions that include movement in some direction, so I somehow need to put the deltaTime variable in all the Enemy objects every frame.

 

The braindead solution, which is what I did, is:

for( int i = 0; i < enemies.size(); i ++ )
{
    enemies[ i ].setDeltaTime( myrpg.deltaTime );
}

But I have to create 'for' loops for every single thing. For example:

        for( int i = 0; i < enemies.size() ; i ++ )
        {
            //If left mouse button is clicked and the bullet ray collides with an enemy AABB, kill the enemy.
            myrpg.kill( playerCam, enemies[ i ] );
        }

        // Clear the screen
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        for( int i = 0; i < enemies.size(); i ++ )
        {
            //If the enemy is not dead, make him run and rotate towards me.
            if( enemies[ i ].getCurrentAnim() == ANIM_RUN )
            {
                enemies[ i ].moveTowardsPlayer( playerCam.getPosition() );
            }
        }

        //Render all enemies
        for( int i = 0; i < enemies.size(); i ++ )
        {
            myrpg.renderAnimatedModel( enemies[ i ], Timer, shaderAnim, shaderStatic );
        }

It seems like I'm using C, not C++. Is there some other way I can make stuff more compact?

 

For example, can I add some virtual base class and just set deltaTime value in that class and make all the enemies inherit the variable somehow, is it possible? (it's a really stupid question, but I decided to ask in case there is something I have missed. ) I haven't used inheritance by now and I kind of don't know what are the pros it offers.

 

And the next question is:

I have 7 animated enemies. And my fps is 62 for now( not capped). But when I add 5 more enemies and make them 12, my fps drops to 31. I traced the problem and I finally found it, it's my BoneTransform() function, which fills my vector of TransformMatrices that I use in the vertex shader in order to animate the skeleton. But it rapes my CPU. ( when I comment the BoneTransform() function, framerate goes from 30 to 166!( sometimes jumps between 166 and 200 ). And I kind of stole most of the function from a tutorial on skeletal animation, and I'm sure it's pretty optimized, so there must be some other reason.

 

I used some models from World of Warcraft. And the interesting thing is that I have the game, and when I play it( when I play WoW ), I can have 20 players around me, and my fps is great, but when I add the same models in my own game, my fps drops like crazy and it's 10 times slower than the original game, why? ( bear in mind that I haven't even loaded any map, I just spawn 12 enemies walking on air, and my cpu runs like a fat truckdriver, wtf is that?? ).


Do I Need A Virtual Class Here?

Do I Need A Virtual Class Here?

Guys. What I did so far:

 

1.  I wanted to cap the frame rate of my game, but SDL_GetTicks() returns milliseconds in Uint32, so I'm getting slightly wrong fps due to small rounding errors and the second reason why frame cap is bad in my case is that SDL_Delay() is not precise, as is said below.

 

fastcall22 says:

 


I would guess that relying on SDL_Delay to regulate framerate is not a good idea, since suspending a thread is not guaranteed to return exactly at the requested duration. From SDL documentation: This function [SDL_Delay] waits a specified number of milliseconds before returning. It waits at least the specified time, but possible longer due to OS scheduling. The delay granularity is at least 10 ms. Some platforms have shorter clock ticks but this is the most common. 

 

 

 

2. That's why I decided to make a frame-independent movement, so I used a variable called deltaTime which is calculated based on the current fps. Sounds cool. But the problem is that I have 7-8 enemies and in my 'Enemy' class I have various different functions that include movement in some direction, so I somehow need to put the deltaTime variable in all the Enemy objects every frame.

 

The braindead solution, which is what I did, is:

for( int i = 0; i < enemies.size(); i ++ )
{
    enemies[ i ].setDeltaTime( myrpg.deltaTime );
}

But I have to create 'for' loops for every single thing. For example:

        for( int i = 0; i < enemies.size() ; i ++ )
        {
            //If left mouse button is clicked and the bullet ray collides with an enemy AABB, kill the enemy.
            myrpg.kill( playerCam, enemies[ i ] );
        }

        // Clear the screen
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        for( int i = 0; i < enemies.size(); i ++ )
        {
            //If the enemy is not dead, make him run and rotate towards me.
            if( enemies[ i ].getCurrentAnim() == ANIM_RUN )
            {
                enemies[ i ].moveTowardsPlayer( playerCam.getPosition() );
            }
        }

        //Render all enemies
        for( int i = 0; i < enemies.size(); i ++ )
        {
            myrpg.renderAnimatedModel( enemies[ i ], Timer, shaderAnim, shaderStatic );
        }

It seems like I'm using C, not C++. Is there some other way I can make stuff more compact?

 

For example, can I add some virtual base class and just set deltaTime value in that class and make all the enemies inherit the variable somehow, is it possible? (it's a really stupid question, but I decided to ask if there is something I have missed. ) I haven't used inheritance by now and I kind of don't know what are the pros it offers.

 

And the next question is:

I have 7 animated enemies. And my fps is 62 for now( not capped). But when I add 5 more enemies and make them 12, my fps drops below 30. I traced the problem and I finally found it, it's my BoneTransform() function, which fills my vector of TransformMatrices that I use in the vertex shader in order to animate the skeleton.

 

I used some models from World of Warcraft. And the interesting thing is that I have the game, and when I play it( when I play WoW ), I can have 20 players around me, and my fps is great, but when I add the same models in my own game, my fps drops like crazy and it's 10 times slower than the original game, why?


Console.writeline Not Printing Out Expression. C#

Console.writeline Not Printing Out Expression. C#

Why does this code not work?

Console.WriteLine(7/2)

It doesn't print anything on the console.


Vs2015:sdl2 Errors While Building Project

Vs2015:sdl2 Errors While Building Project

hi

 

I am just trying to test whether i can setup the SDL2 in vs2015 update 3.

 

I installed sdl2 by nuget package manager.  

 

after i compiled the project, I got the following error output:

 

1>------ Build started: Project: SDL_test, Configuration: Release x64 ------
1>SDL2main.lib(SDL_windows_main.obj) : error LNK2001: unresolved external symbol __imp_fprintf
1>C:\Users\robert\Documents\Visual Studio 2015\Projects\SDL_test\x64\Release\SDL_test.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
 
and my source file sdl2 wiki:
 
// Example program:
// Using SDL2 to create an application window
//
 
#include "SDL.h"
#include <stdio.h>
extern "C" { FILE __iob_func[3] = { *stdin,*stdout,*stderr }; }  // this is one of the suggestions. it does not work with or w/o the fix
 
int main(int argc, char* argv[]) {
 
SDL_Window *window;                    // Declare a pointer
 
SDL_Init(SDL_INIT_VIDEO);              // Initialize SDL2
 
  // Create an application window with the following settings:
window = SDL_CreateWindow(
"An SDL2 window",                  // window title
SDL_WINDOWPOS_UNDEFINED,           // initial x position
SDL_WINDOWPOS_UNDEFINED,           // initial y position
640,                               // width, in pixels
480,                               // height, in pixels
SDL_WINDOW_OPENGL                  // flags - see below
);
 
// Check that the window was successfully created
if (window == NULL) {
// In the case that the window could not be made...
printf("Could not create window: %s\n", SDL_GetError());
return 1;
}
 
// The window is open: could enter program loop here (see SDL_PollEvent())
 
SDL_Delay(3000);  // Pause execution for 3000 milliseconds, for example
 
 // Close and destroy the window
SDL_DestroyWindow(window);
 
// Clean up
SDL_Quit();
return 0;
}
 
I googled lnk2001 but do not understand what it meant, it was as if they are not english.  I also tried some of the suggestions on the web but still can not build the project.
 
any help is welcome.
 
thanks in advance