mathew_653

Members
  • Content count

    4
  • Joined

  • Last visited

Community Reputation

107 Neutral

About mathew_653

  • Rank
    Newbie
  1. Screen fade, blanking instead of fading.

    An update, i have found a solution to the issue, i was having altough, it is a issue i had not encountered for ages, relating to transparancy and glColor4f using 0,0,0 for color. I have tested my code with clolor 1.0,1.0,1.0 and found it worked fine, so that isolated my fault downto an old thing that i have seen with glColor4f(0,0,0,A); and alpha blending.     Altough i did try all the ones, prior, i thank you kind people for your assistance, i hope mentioning this, prevents anyone else being cought out.
  2. Screen fade, blanking instead of fading.

    Gonna get on with decuppleing the code to produce a minimal build example. But first i will clarify some more on my code. Colors[] defined as float Colors[4]; it is initalised in CEffectFade's constructor. pAppState is a pointer from the main thread, passed as an argument. It is incremented from a saperate thread, like so(excuse the mess, the project is still prealpha and i have been tinkering around with stuff). const int TICKS_PER_SECOND = 950; const int SKIP_TICKS = 1000 / TICKS_PER_SECOND; const int MAX_FRAMESKIP = 5; DWORD NextFrame = timeGetTime(); //Get our current timeing. DWORD LastFrame = timeGetTime(); // int loops=0; float interpolation=0.0f; while (pAppState->status & STATUS_ACTIVE) { CPlayerEntity *pPlayer = (CPlayerEntity *)pAppState->SharedTable[ID_PLAYER]; CEffectFade *pFade = (CEffectFade *)pAppState->SharedTable[ID_OVERLAY]; CLoadAnimation *pLoadAnim = (CLoadAnimation *)pAppState->SharedTable[ID_LOADANIMATION]; //loops=0; if (timeGetTime() > NextFrame && loops < MAX_FRAMESKIP) { if (pAppState->status & STATUS_LOADING) { if (pLoadAnim != NULL) { //printf("LoadThink.\n"); pLoadAnim->Tick(); } } else { pFade->SetRate(0.0002); pFade->TransitionIn(); if (pPlayer != NULL) { pPlayer->Think(); } } NextFrame += SKIP_TICKS; if (abs(LastFrame-NextFrame) > 1) { printf("Warning : delta is %i, game might be lagging.\n", abs(LastFrame-NextFrame)); } LastFrame = NextFrame; //loops++; } else { //Give our time to something else. SwitchToThread(); } interpolation = (float) timeGetTime() + SKIP_TICKS - NextFrame / (float)SKIP_TICKS; pAppState->Interp = interpolation; //printf("Interpolation : %i\n", interpolation); // Old approach(Replaced with a high resolution timer) //Sleep(1); } Two two refrenced functions here SetRate and TransitionIn are as so(raterate is a float). void CEffectFade::TransitionIn(){ //printf("Fade : %f\n", Colors[4]); Colors[4]+= RateRate; //Colors[4]=0.5f; if (Colors[4] > 1.0) { Colors[4] = 1.0; } if (Colors[4] < 0.0) { Colors[4] = 0.0; } } void CEffectFade::SetRate(float Rate){ RateRate = Rate;} I removed GL_ALPHA_TEST while cleaning code up. I draw the screen and map prior to the call to pfade->draw(); inbetween the glEnable block and the glBindTexture(GL_TEXTURE_2D, 0) call.
  3. Clashing Enemies

    I can see two possable solutions, if an enemy is collideing, apply velocity to the one to push em away from each other. or use the enemy that is collided with and the players position to recalculate a path.   Hope i am being helpful.
  4. Hello, i have looked at the other subforms of this forum and feel this is the best place. I shall first off explain my issue and my own observations, before showing the relivent code.   The goal is to create a fade out effect. At first i suspected multithreading, i have seen weird stuff happen in the past with it.   But this has prooved not to be the case, the float being past appears to be incrementing at the correct rate, but where the fault occurs is that instead of a fade, i get a flick of the screen then blankness as if the fade is at 100% when it is not(the printf in fade drawing showed that).   Additional infomation, the platform i am using is windows but i use SDL to handle all the initalising and stuff, as i do plan to port the code later to other platforms.   I shall now quote my code, starting with relivent render code(Cut down for cleaness):   Renderer _GL_Color ClearColor = RGBtoFloat({0,0,0,255}); glClearColor(ClearColor.r,ClearColor.g,ClearColor.b,ClearColor.a); glClear( GL_COLOR_BUFFER_BIT ); glEnable(GL_COLOR_MATERIAL); glEnable( GL_CULL_FACE ); //Enable alpha masking here for non background element drawing. glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable( GL_BLEND ); glEnable( GL_ALPHA_TEST ); //Set to no texture glBindTexture(GL_TEXTURE_2D, 0); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); if (pFade != NULL) { pFade->Draw(); } glDisable( GL_ALPHA_TEST ); glDisable( GL_BLEND ); glDisable( GL_CULL_FACE ); glDisable(GL_COLOR_MATERIAL); SDL_GL_SwapBuffers();   Fade draw function(inside fade class) if (Colors[4] <= 0.0f) { return; } printf("Colors[4] = %f\n", Colors[4]); glBegin( GL_QUADS ); //Bottom left glColor4f( Colors[1], Colors[2], Colors[3], Colors[4] ); glVertex3f( 0, ScreenY, 0.0f ); //Bottom right glColor4f( Colors[1], Colors[2], Colors[3], Colors[4] ); glVertex3f( ScreenX, ScreenY, 0.0f ); //Top right glColor4f( Colors[1], Colors[2], Colors[3], Colors[4] ); glVertex3f( ScreenX, 0, 0.0f ); //Top left glColor4f( Colors[1], Colors[2], Colors[3], Colors[4] ); glVertex3f( 0, 0, 0.0f ); glEnd();   In advance, thank you for any help you can provide.