[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.2

SDL Render Problems w/ Visual Studio .net 2003

Asked by dx100 in 3D Game Programming, Microsoft Visual C++, OpenGL Graphics & Game Programming

Tags: sdl, visual, studio

When initialising, nothing displays on the screen, it goes black for about 1 second then parts of visual studio show through and thats it. Any ideas?

Here's the code ;
   
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#include <windows.h>
#include <gl/gl.h>
#include <gl/glu.h>
#include <sdl/sdl.h>


#define PI 3.141592654

// Pre-define some colour triplets
float colours[7][3] = {
      0.5, 0.5, 0.5,      /*  Red            */
      0.5, 0.5, 0.5,      /*  Green      */
      0.5, 0.5, 0.5,      /*  Blue      */
      0.5, 0.5, 0.5,      /*  Yellow      */
      0.5, 0.5, 0.5,      /*  Magenta      */
      0.5, 0.5, 0.5,      /*  Cyan      */
      0.5, 0.5, 0.5,      /*  White      */
};

static  SDL_Surface *gScreen;      /* A pointer to the video screen */
GLuint  smallDot;                        /* An identifier for the GL description of a single dot */

/* Dot & Display parameters */
double      dotX[500], dotY[500], dotLifeL[500];
double      dotXR[500], dotYR[500], dotLifeR[500];
double  dotDirectionL[500];
double  dotDirectionR[500];
int            NumberOfDotsBase = 200;    //This is the TOTAL number of dots - signal+noise.
int            NumberOfRandomDotsBase = 100;  //This is the number of random dots in the display. Subtract this from the int above to int
//int            NumberOfRandomDotsBaseL = 100;  //This is the number of random dots in the L display. ADDED Poss need to add? PC  
//int            NumberOfRandomDotsBaseR = 100;  //This is the number of random dots in the R display. ADDED Poss need to add? PC
int            NumberOfDotsInc = 200;    //This is the TOTAL number of dots - signal+noise.
int            NumberOfRandomDotsInc = 60;  //This is the number of random dots in the display. Subtract this from the int above to int
int            NumberOfRandomDotsIncR = 60;  //This is the number of random dots in the display. Subtract this from the int above to int ADDED PC            
int            NumberOfDotsDec = 200;    //This is the TOTAL number of dots - signal+noise.

int            NumberOfRandomDotsDec = 140;  //This is the number of random dots in the display. Subtract this from the int above to int
int            DotLifetime = 10;
float   DotSpeed = 15;
int            MaxStimulusRadius = 230;      // Controls size of drawing area
int            fps = 75;
double  centerX = 1024/2;
double  centerY = 768/2;
double  centerX_L = 200;
double  centerY_L = 768/2;
double  centerX_R = 800;
double  centerY_R = 768/2;
double  phi = PI;
double  SPOT_PHI_DELTA = 0.026667;
int            fixCol = 0;

/* fMRI design parameters */
int            numBlocks = 1;            // 1 block = 2 trials (ie S1-S2, S1-S1)

float      S1length = 1.5;
float      ISI = 0.0;
float      S2length = 1.5;
float      ITI2 = 2.0;
float      ITI3 = 3.0;
float      ITI4 = 4.0;
float      ITI5 = 5.0;
float      ITI6 = 6.0;
float      ITI7 = 7.0;
float      ITI8 = 8.0;
float      ITI9 = 9.0;
float      ITI10 = 10.0;
float      bufferlength = 10.0;

int      startStim,stopStim;

/* ============== Graphics Maintanance Functions ============== */

static void createSurface (int fullscreen)
{
    Uint32 flags = 0;
   
    // Don't set color bit sizes (SDL_GL_RED_SIZE, etc)
    //    Mac OS X will always use 8-8-8-8 ARGB for 32-bit screens and
    //    5-5-5 RGB for 16-bit screens
   
    // Request a 16-bit depth buffer (without this, there is no depth buffer)
    SDL_GL_SetAttribute (SDL_GL_DEPTH_SIZE, 16);
   
      // Request double-buffered OpenGL
    //     The fact that windows are double-buffered on Mac OS X has no effect
    //     on OpenGL double buffering.
    SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1);
            
    flags = SDL_OPENGL;
    if (fullscreen) flags |= SDL_FULLSCREEN;
   
    // Create window
    gScreen = SDL_SetVideoMode (1024, 768, 0, flags);
    if (gScreen == NULL) {            
        fprintf (stderr, "Couldn't set 1024x768 OpenGL video mode: %s\n", SDL_GetError());
            SDL_Quit();
            exit(2);
      }
}

static void initGL (int Width, int Height)
{
      glViewport(0, 0, Width, Height);
      glClearColor(0.0f, 0.0f, 0.0f, 0.0f);            // This Will Clear The Background Color To Black

      glMatrixMode(GL_PROJECTION);
      glLoadIdentity();
      gluOrtho2D(0.0f,(GLdouble)(Width),0.0f,(GLdouble)(Height));

      glMatrixMode(GL_MODELVIEW);
}

/* ============== Graphics Drawing Functions ============== */

void createDot() {
      GLint i;
      GLint circle_points = 10;
      GLfloat angle;
      GLint dot_radius = 4;      // Change this to increase/decrease size of dots
      
      /* The dot is created around 0,0 so need to translate its position */
      smallDot =glGenLists(1);
      glNewList(smallDot, GL_COMPILE);
            glColor3f(1.0f,1.0f,1.0f);
            glBegin(GL_POLYGON);
                  for (i=0; i<circle_points; i++) {
                        angle = 2*PI*i/circle_points;
                        glVertex2f(dot_radius*cos(angle), dot_radius*sin(angle));
                  }
            glEnd();
      glEndList();
}


void drawFixation(int frameNumber) {
      int newCol;
      int framesPerColour = 30;
      
      glLoadIdentity();
      if (frameNumber%framesPerColour==0) {
            newCol = rand()%7;
            glColor3f(colours[newCol][0],colours[newCol][1],colours[newCol][2]);
            fixCol = newCol;
      }
      else
            glColor3f(colours[fixCol][0],colours[fixCol][1],colours[fixCol][2]);
      glLineWidth(3.0);
      glBegin(GL_POLYGON);
            glVertex2i(504,376);
            glVertex2i(504,392);
            glVertex2i(520,392);
            glVertex2i(520,376);
      glEnd();
}

void drawIndicatorFixationL(int frameNumber) {
      int newCol;
      int framesPerColour = 30;
      
            glColor3f(1,1,1);
            glLineWidth(2.0);
            glBegin(GL_POLYGON);
            glVertex2i(504,380);
            glVertex2i(500,388);
            glVertex2i(520,388);
            glVertex2i(520,380);
      glEnd();
}



void drawIndicatorFixationR(int frameNumber) {
      int newCol;
      int framesPerColour = 30;
      
            glColor3f(1,1,1);
      glLineWidth(2.0);
      glBegin(GL_POLYGON);
            glVertex2i(504,380);
            glVertex2i(504,388);
            glVertex2i(520,388);
            glVertex2i(524,380);
      glEnd();
}




static void drawMorroneBase_RL(int frameNumber)
{
      double theta, r, delta_r, delta_theta, delta_x, delta_y;
      int j, temp;

      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
      
      for (j=0; j<NumberOfDotsBase; j++){
      

            /* Now calculate the next position of the dot */
            // tried changed to make specific to L: NumberOfRandomDotsBaseL
            if (j<NumberOfRandomDotsBase)
            {
                  delta_x = DotSpeed*cos(dotDirectionL[j]);
                  delta_y = DotSpeed*sin(dotDirectionL[j]);
                  dotX[j] += delta_x;
                  dotY[j] += delta_y;
            }
            else
            {
            theta = atan2((dotY[j]-centerY_L), (dotX[j]-centerX_L));
            r = sqrt(((dotX[j]-centerX_L)*(dotX[j]-centerX_L))+((dotY[j]-centerY_L)*(dotY[j]-centerY_L)));
            delta_r = DotSpeed*cos(phi);
            delta_theta = (DotSpeed*sin(phi))/r;
            dotX[j] = ((r+delta_r)*cos(theta+delta_theta)) + centerX_L;
            dotY[j] = ((r+delta_r)*sin(theta+delta_theta)) + centerY_L;
            }
            /* Dot drawn, so increase its life count */
            dotLifeL[j]++;
            /* And finally a series of checks on the status of the dot */
            if (dotLifeL[j]>DotLifetime) {
                  temp = rand()%(2*MaxStimulusRadius);
                  dotX[j] = (temp < MaxStimulusRadius) ? (centerX_L - temp) : (centerX_L + (temp-MaxStimulusRadius));
                  temp = rand()%(2*MaxStimulusRadius);
                  dotY[j] = (temp < MaxStimulusRadius) ? (centerY_L - temp) : (centerY_L + (temp-MaxStimulusRadius));
                  dotLifeL[j] = rand()%DotLifetime;
            }
            if (dotX[j]>(centerX_L+MaxStimulusRadius) || dotX[j]<(centerX_L-MaxStimulusRadius)
                  || dotY[j]>(centerY_L+MaxStimulusRadius) || dotY[j]<(centerY_L-MaxStimulusRadius)) {
                  temp = rand()%(2*MaxStimulusRadius);
                  dotX[j] = (temp < MaxStimulusRadius) ? (centerX_L - temp) : (centerX_L + (temp-MaxStimulusRadius));
                  temp = rand()%(2*MaxStimulusRadius);
                  dotY[j] = (temp < MaxStimulusRadius) ? (centerY_L - temp) : (centerY_L + (temp-MaxStimulusRadius));
            }
            /* Draw the dot */
            glLoadIdentity();
            glTranslatef(dotX[j],dotY[j],0.0f);      
            glCallList(smallDot);
            }

            
            //Still 2 loops in, so add R statements, beginnig with the first statement following clear//
            // this meanss that the theta and clear statements will be shared for both R and L//
            
            /* Now calculate the next position of the dot */
            // tried changed to make specific to R: NumberOfRandomDotsBaseR
            
            int k, tempR;
            double thetaR, rR, delta_rR, delta_thetaR, delta_xR, delta_yR;
            
            for (k=0; k<NumberOfDotsBase; k++){      


            if (k<NumberOfRandomDotsBase)
            {
                  delta_xR = DotSpeed*cos(dotDirectionR[k]);
                  delta_yR = DotSpeed*sin(dotDirectionR[k]);
                  dotXR[k] += delta_xR;
                  dotYR[k] += delta_yR;
            }
            else
            {
            thetaR = atan2((dotYR[k]-centerY_R), (dotXR[k]-centerX_R));
            rR = sqrt(((dotXR[k]-centerX_R)*(dotXR[k]-centerX_R))+((dotYR[k]-centerY_R)*(dotYR[k]-centerY_R)));
            delta_rR = DotSpeed*cos(phi);
            delta_thetaR = (DotSpeed*sin(phi))/rR;
            dotXR[k] = ((rR+delta_rR)*cos(thetaR+delta_thetaR)) + centerX_R;
            dotYR[k] = ((rR+delta_rR)*sin(thetaR+delta_thetaR)) + centerY_R;
            }
            /* Dot drawn, so increase its life count */
            dotLifeR[k]++;
            /* And finally a series of checks on the status of the dot */
            if (dotLifeR[k]>DotLifetime) {
                  tempR = rand()%(2*MaxStimulusRadius);
                  dotXR[k] = (tempR < MaxStimulusRadius) ? (centerX_R - tempR) : (centerX_R + (tempR-MaxStimulusRadius));
                  tempR = rand()%(2*MaxStimulusRadius);
                  dotYR[k] = (tempR < MaxStimulusRadius) ? (centerY_R - tempR) : (centerY_R + (tempR-MaxStimulusRadius));
                  dotLifeR[k] = rand()%DotLifetime;
            }
            if (dotXR[k]>(centerX_R+MaxStimulusRadius) || dotXR[k]<(centerX_R-MaxStimulusRadius)
                  || dotYR[k]>(centerY_R+MaxStimulusRadius) || dotYR[k]<(centerY_R-MaxStimulusRadius)) {
                  tempR = rand()%(2*MaxStimulusRadius);
                  dotXR[k] = (tempR < MaxStimulusRadius) ? (centerX_R - tempR) : (centerX_R + (tempR-MaxStimulusRadius));
                  tempR = rand()%(2*MaxStimulusRadius);
                  dotYR[k] = (tempR < MaxStimulusRadius) ? (centerY_R - tempR) : (centerY_R + (tempR-MaxStimulusRadius));
            }
            /* Draw the dot */
            glLoadIdentity();
            //glTranslatef(dotXR[k],dotYR[k],0.0f);      
            glTranslatef(dotXR[k],dotYR[k],0.0f);
            glCallList(smallDot);

            
            
      }
      /* Finished with all the dots, so update phi */
      phi = phi-(SPOT_PHI_DELTA*PI);
      if (phi <= (-1.0*PI)) phi = PI;

      /* Superimpose fixation mark */
      drawFixation(frameNumber);
}


static void drawMorroneInc_L(int frameNumber)
{
      double theta, r, delta_r, delta_theta, delta_x, delta_y;
      int j, temp;

      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
      for (j=0; j<NumberOfDotsInc; j++){

            /* Now calculate the next position of the dot */
            if (j<NumberOfRandomDotsInc)
            {
                  delta_x = DotSpeed*cos(dotDirectionL[j]);
                  delta_y = DotSpeed*sin(dotDirectionL[j]);
                  dotX[j] += delta_x;
                  dotY[j] += delta_y;
            }
            else
            {
            theta = atan2((dotY[j]-centerY_L), (dotX[j]-centerX_L));
            r = sqrt(((dotX[j]-centerX_L)*(dotX[j]-centerX_L))+((dotY[j]-centerY_L)*(dotY[j]-centerY_L)));
            delta_r = DotSpeed*cos(phi);
            delta_theta = (DotSpeed*sin(phi))/r;
            dotX[j] = ((r+delta_r)*cos(theta+delta_theta)) + centerX_L;
            dotY[j] = ((r+delta_r)*sin(theta+delta_theta)) + centerY_L;
            }
            /* Dot drawn, so increase its life count */
            dotLifeL[j]++;
            /* And finally a series of checks on the status of the dot */
            if (dotLifeL[j]>DotLifetime) {
                  temp = rand()%(2*MaxStimulusRadius);
                  dotX[j] = (temp < MaxStimulusRadius) ? (centerX_L - temp) : (centerX_L + (temp-MaxStimulusRadius));
                  temp = rand()%(2*MaxStimulusRadius);
                  dotY[j] = (temp < MaxStimulusRadius) ? (centerY_L - temp) : (centerY_L + (temp-MaxStimulusRadius));
                  dotLifeL[j] = rand()%DotLifetime;
            }
            if (dotX[j]>(centerX_L+MaxStimulusRadius) || dotX[j]<(centerX_L-MaxStimulusRadius)
                  || dotY[j]>(centerY_L+MaxStimulusRadius) || dotY[j]<(centerY_L-MaxStimulusRadius)) {
                  temp = rand()%(2*MaxStimulusRadius);
                  dotX[j] = (temp < MaxStimulusRadius) ? (centerX_L - temp) : (centerX_L + (temp-MaxStimulusRadius));
                  temp = rand()%(2*MaxStimulusRadius);
                  dotY[j] = (temp < MaxStimulusRadius) ? (centerY_L - temp) : (centerY_L + (temp-MaxStimulusRadius));
            }
            /* Draw the dot */
            glLoadIdentity();
            glTranslatef(dotX[j],dotY[j],0.0f);      
            glCallList(smallDot);
      }
      /* Finished with all the dots, so update phi */
      phi = phi-(SPOT_PHI_DELTA*PI);
      if (phi <= (-1.0*PI)) phi = PI;

      /* Superimpose fixation mark */
      drawFixation(frameNumber);
}


static void drawMorroneInc_RL(int frameNumber)
{
      double theta, r, delta_r, delta_theta, delta_x, delta_y;
      int j, temp;
      
      double thetaR, rR, delta_rR, delta_thetaR, delta_xR, delta_yR;
      int tempR;

      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
      for (j=0; j<NumberOfDotsInc; j++){

            /* Now calculate the next position of the dot */
            if (j<NumberOfRandomDotsInc)
            {
                  delta_x = DotSpeed*cos(dotDirectionL[j]);
                  delta_y = DotSpeed*sin(dotDirectionL[j]);
                  dotX[j] += delta_x;
                  dotY[j] += delta_y;
            }
            else
            {
            theta = atan2((dotY[j]-centerY_L), (dotX[j]-centerX_L));
            r = sqrt(((dotX[j]-centerX_L)*(dotX[j]-centerX_L))+((dotY[j]-centerY_L)*(dotY[j]-centerY_L)));
            delta_r = DotSpeed*cos(phi);
            delta_theta = (DotSpeed*sin(phi))/r;
            dotX[j] = ((r+delta_r)*cos(theta+delta_theta)) + centerX_L;
            dotY[j] = ((r+delta_r)*sin(theta+delta_theta)) + centerY_L;

            }
            
            /* Dot drawn, so increase its life count */
            dotLifeL[j]++;
            /* And finally a series of checks on the status of the dot */
            if (dotLifeL[j]>DotLifetime) {
                  temp = rand()%(2*MaxStimulusRadius);
                  dotX[j] = (temp < MaxStimulusRadius) ? (centerX_L - temp) : (centerX_L + (temp-MaxStimulusRadius));
                  temp = rand()%(2*MaxStimulusRadius);
                  dotY[j] = (temp < MaxStimulusRadius) ? (centerY_L - temp) : (centerY_L + (temp-MaxStimulusRadius));
                  dotLifeL[j] = rand()%DotLifetime;
            }
            if (dotX[j]>(centerX_L+MaxStimulusRadius) || dotX[j]<(centerX_L-MaxStimulusRadius)
                  || dotY[j]>(centerY_L+MaxStimulusRadius) || dotY[j]<(centerY_L-MaxStimulusRadius)) {
                  temp = rand()%(2*MaxStimulusRadius);
                  dotX[j] = (temp < MaxStimulusRadius) ? (centerX_L - temp) : (centerX_L + (temp-MaxStimulusRadius));
                  temp = rand()%(2*MaxStimulusRadius);
                  dotY[j] = (temp < MaxStimulusRadius) ? (centerY_L - temp) : (centerY_L + (temp-MaxStimulusRadius));
            }
            /* Draw the dot */
            glLoadIdentity();
            glTranslatef(dotX[j],dotY[j],0.0f);      
            glCallList(smallDot);
            
            // R added, 2 loops in//
            
            /* Now calculate the next position of the dot */
            if (j<NumberOfRandomDotsIncR)
            {
                  
                  delta_xR = DotSpeed*cos(dotDirectionR[j]);
                  delta_yR = DotSpeed*sin(dotDirectionR[j]);
                  dotXR[j] += delta_xR;
                  dotYR[j] += delta_yR;
            }
            else
            {
            thetaR = atan2((dotYR[j]-centerY_R), (dotXR[j]-centerX_R));
            rR = sqrt(((dotXR[j]-centerX_R)*(dotXR[j]-centerX_R))+((dotYR[j]-centerY_R)*(dotYR[j]-centerY_R)));
            delta_rR = DotSpeed*cos(phi);
            delta_thetaR = (DotSpeed*sin(phi))/rR;
            dotXR[j] = ((r+delta_rR)*cos(thetaR+delta_thetaR)) + centerX_R;
            dotYR[j] = ((r+delta_rR)*sin(thetaR+delta_thetaR)) + centerY_R;
            }
                        
            /* Dot drawn, so increase its life count */
            dotLifeR[j]++;
            /* And finally a series of checks on the status of the dot */
            if (dotLifeR[j]>DotLifetime) {
                  tempR = rand()%(2*MaxStimulusRadius);
                  dotXR[j] = (tempR < MaxStimulusRadius) ? (centerX_R - tempR) : (centerX_R + (tempR-MaxStimulusRadius));
                  tempR = rand()%(2*MaxStimulusRadius);
                  dotYR[j] = (tempR < MaxStimulusRadius) ? (centerY_R - tempR) : (centerY_R + (tempR-MaxStimulusRadius));
                  dotLifeR[j] = rand()%DotLifetime;
            }
            if (dotXR[j]>(centerX_R+MaxStimulusRadius) || dotXR[j]<(centerX_R-MaxStimulusRadius)
                  || dotYR[j]>(centerY_R+MaxStimulusRadius) || dotYR[j]<(centerY_R-MaxStimulusRadius)) {
                  tempR = rand()%(2*MaxStimulusRadius);
                  dotXR[j] = (tempR < MaxStimulusRadius) ? (centerX_R - tempR) : (centerX_R + (tempR-MaxStimulusRadius));
                  tempR = rand()%(2*MaxStimulusRadius);
                  dotYR[j] = (tempR < MaxStimulusRadius) ? (centerY_R - tempR) : (centerY_R + (tempR-MaxStimulusRadius));
                  
            }
            /* Draw the dot */
            glLoadIdentity();
            // glTranslatef(dotX[j],dotY[j],0.0f);      
            glTranslatef(dotXR[j],dotYR[j],0.0f);
            glCallList(smallDot);

            
      }
      /* Finished with all the dots, so update phi */
      phi = phi-(SPOT_PHI_DELTA*PI);
      if (phi <= (-1.0*PI)) phi = PI;

      /* Superimpose fixation mark */
      drawFixation(frameNumber);
}



static void drawMorroneDec_L(int frameNumber)
{
      double theta, r, delta_r, delta_theta, delta_x, delta_y;
      int j, temp;

      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
      for (j=0; j<NumberOfDotsDec; j++){
            /* Now calculate the next position of the dot */
            if (j<NumberOfRandomDotsDec)
            {
                  delta_x = DotSpeed*cos(dotDirectionL[j]);
                  delta_y = DotSpeed*sin(dotDirectionL[j]);
                  dotX[j] += delta_x;
                  dotY[j] += delta_y;
            }
            else
            {
            theta = atan2((dotY[j]-centerY_L), (dotX[j]-centerX_L));
            r = sqrt(((dotX[j]-centerX_L)*(dotX[j]-centerX_L))+((dotY[j]-centerY_L)*(dotY[j]-centerY_L)));
            delta_r = DotSpeed*cos(phi);
            delta_theta = (DotSpeed*sin(phi))/r;
            dotX[j] = ((r+delta_r)*cos(theta+delta_theta)) + centerX_L;
            dotY[j] = ((r+delta_r)*sin(theta+delta_theta)) + centerY_L;
            }
            /* Dot drawn, so increase its life count */
            dotLifeL[j]++;
            /* And finally a series of checks on the status of the dot */
            if (dotLifeL[j]>DotLifetime) {
                  temp = rand()%(2*MaxStimulusRadius);
                  dotX[j] = (temp < MaxStimulusRadius) ? (centerX_L - temp) : (centerX_L + (temp-MaxStimulusRadius));
                  temp = rand()%(2*MaxStimulusRadius);
                  dotY[j] = (temp < MaxStimulusRadius) ? (centerY_L - temp) : (centerY_L + (temp-MaxStimulusRadius));
                  dotLifeL[j] = rand()%DotLifetime;
            }
            if (dotX[j]>(centerX_L+MaxStimulusRadius) || dotX[j]<(centerX_L-MaxStimulusRadius)
                  || dotY[j]>(centerY_L+MaxStimulusRadius) || dotY[j]<(centerY_L-MaxStimulusRadius)) {
                  temp = rand()%(2*MaxStimulusRadius);
                  dotX[j] = (temp < MaxStimulusRadius) ? (centerX_L - temp) : (centerX_L + (temp-MaxStimulusRadius));
                  temp = rand()%(2*MaxStimulusRadius);
                  dotY[j] = (temp < MaxStimulusRadius) ? (centerY_L - temp) : (centerY_L + (temp-MaxStimulusRadius));
            }
            /* Draw the dot */
            glLoadIdentity();
            glTranslatef(dotX[j],dotY[j],0.0f);      
            glCallList(smallDot);
      }
      /* Finished with all the dots, so update phi */
      phi = phi-(SPOT_PHI_DELTA*PI);
      if (phi <= (-1.0*PI)) phi = PI;

      /* Superimpose fixation mark */
      drawFixation(frameNumber);
}


static void drawMorroneDec_RL(int frameNumber)
{
      double theta, r, delta_r, delta_theta, delta_x, delta_y;
      int j, temp;
      
      double thetaR, rR, delta_rR, delta_thetaR, delta_xR, delta_yR;
      int tempR;

      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
      for (j=0; j<NumberOfDotsDec; j++){
            /* Now calculate the next position of the dot */
            if (j<NumberOfRandomDotsDec)
            {
                  delta_x = DotSpeed*cos(dotDirectionR[j]);
                  delta_y = DotSpeed*sin(dotDirectionR[j]);
                  dotX[j] += delta_x;
                  dotY[j] += delta_y;            }
            else
            {
            
            theta = atan2((dotY[j]-centerY_R), (dotX[j]-centerX_R));
            r = sqrt(((dotX[j]-centerX_R)*(dotX[j]-centerX_R))+((dotY[j]-centerY_R)*(dotY[j]-centerY_R)));
            delta_r = DotSpeed*cos(phi);
            delta_theta = (DotSpeed*sin(phi))/r;
            dotX[j] = ((r+delta_r)*cos(theta+delta_theta)) + centerX_R;
            dotY[j] = ((r+delta_r)*sin(theta+delta_theta)) + centerY_R;

            }
            /* Dot drawn, so increase its life count */
            dotLifeL[j]++;
            /* And finally a series of checks on the status of the dot */
            
            if (dotLifeL[j]>DotLifetime) {
                  temp = rand()%(2*MaxStimulusRadius);
                  dotX[j] = (temp < MaxStimulusRadius) ? (centerX_L - temp) : (centerX_L + (temp-MaxStimulusRadius));
                  temp = rand()%(2*MaxStimulusRadius);
                  dotY[j] = (temp < MaxStimulusRadius) ? (centerY_L - temp) : (centerY_L + (temp-MaxStimulusRadius));
                  dotLifeL[j] = rand()%DotLifetime;
            }
            if (dotX[j]>(centerX_L+MaxStimulusRadius) || dotX[j]<(centerX_L-MaxStimulusRadius)
                  || dotY[j]>(centerY_L+MaxStimulusRadius) || dotY[j]<(centerY_L-MaxStimulusRadius)) {
                  temp = rand()%(2*MaxStimulusRadius);
                  dotX[j] = (temp < MaxStimulusRadius) ? (centerX_L - temp) : (centerX_L + (temp-MaxStimulusRadius));
                  temp = rand()%(2*MaxStimulusRadius);
                  dotY[j] = (temp < MaxStimulusRadius) ? (centerY_L - temp) : (centerY_L + (temp-MaxStimulusRadius));
            }
            /* Draw the dot */
            glLoadIdentity();
            glTranslatef(dotX[j],dotY[j],0.0f);      
            glCallList(smallDot);
            
            
            //R added//
            
            /* Now calculate the next position of the dot */
            if (j<NumberOfRandomDotsDec)
            {
            
                  delta_xR = DotSpeed*cos(dotDirectionR[j]);
                  delta_yR = DotSpeed*sin(dotDirectionR[j]);
                  dotXR[j] += delta_xR;
                  dotYR[j] += delta_yR;
            }
            else
            {
            thetaR = atan2((dotYR[j]-centerY_R), (dotXR[j]-centerX_R));
            rR = sqrt(((dotXR[j]-centerX_R)*(dotXR[j]-centerX_R))+((dotYR[j]-centerY_R)*(dotYR[j]-centerY_R)));
            delta_rR = DotSpeed*cos(phi);
            delta_thetaR = (DotSpeed*sin(phi))/rR;
            dotXR[j] = ((r+delta_rR)*cos(thetaR+delta_thetaR)) + centerX_R;
            dotYR[j] = ((r+delta_rR)*sin(thetaR+delta_thetaR)) + centerY_R;

            }
            /* Dot drawn, so increase its life count */
            dotLifeR[j]++;
            /* And finally a series of checks on the status of the dot */
                  
                  if (dotLifeR[j]>DotLifetime) {
                  tempR = rand()%(2*MaxStimulusRadius);
                  dotXR[j] = (tempR < MaxStimulusRadius) ? (centerX_R - tempR) : (centerX_R + (tempR-MaxStimulusRadius));
                  tempR = rand()%(2*MaxStimulusRadius);
                  dotYR[j] = (tempR < MaxStimulusRadius) ? (centerY_R - tempR) : (centerY_R + (tempR-MaxStimulusRadius));
                  dotLifeR[j] = rand()%DotLifetime;
            }
            if (dotXR[j]>(centerX_R+MaxStimulusRadius) || dotXR[j]<(centerX_R-MaxStimulusRadius)
                  || dotYR[j]>(centerY_R+MaxStimulusRadius) || dotYR[j]<(centerY_R-MaxStimulusRadius)) {
                  tempR = rand()%(2*MaxStimulusRadius);
                  dotXR[j] = (tempR < MaxStimulusRadius) ? (centerX_R - tempR) : (centerX_R + (tempR-MaxStimulusRadius));
                  tempR = rand()%(2*MaxStimulusRadius);
                  dotYR[j] = (tempR < MaxStimulusRadius) ? (centerY_R - tempR) : (centerY_R + (tempR-MaxStimulusRadius));
                  
            }
            /* Draw the dot */
            glLoadIdentity();
            // glTranslatef(dotX[j],dotY[j],0.0f);      
            glTranslatef(dotXR[j],dotYR[j],0.0f);
            glCallList(smallDot);

            
      }
      /* Finished with all the dots, so update phi */
      phi = phi-(SPOT_PHI_DELTA*PI);
      if (phi <= (-1.0*PI)) phi = PI;

      /* Superimpose fixation mark */
      drawFixation(frameNumber);
}


static void drawMorroneBase_R(int frameNumber)
{
      double theta, r, delta_r, delta_theta, delta_x, delta_y;
      int j, temp;

      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
      for (j=0; j<NumberOfDotsBase; j++){
      
            /* Now calculate the next position of the dot */
            if (j<NumberOfRandomDotsBase)
            {
                  delta_x = DotSpeed*cos(dotDirectionR[j]);
                  delta_y = DotSpeed*sin(dotDirectionR[j]);
                  dotX[j] += delta_x;
                  dotY[j] += delta_y;
            }
            else
            {
            theta = atan2((dotY[j]-centerY_R), (dotX[j]-centerX_R));
            r = sqrt(((dotX[j]-centerX_R)*(dotX[j]-centerX_R))+((dotY[j]-centerY_R)*(dotY[j]-centerY_R)));
            delta_r = DotSpeed*cos(phi);
            delta_theta = (DotSpeed*sin(phi))/r;
            dotX[j] = ((r+delta_r)*cos(theta+delta_theta)) + centerX_R;
            dotY[j] = ((r+delta_r)*sin(theta+delta_theta)) + centerY_R;
            }
            /* Dot drawn, so increase its life count */
            dotLifeR[j]++;
            /* And finally a series of checks on the status of the dot */
            if (dotLifeR[j]>DotLifetime) {
                  temp = rand()%(2*MaxStimulusRadius);
                  dotX[j] = (temp < MaxStimulusRadius) ? (centerX_R - temp) : (centerX_R + (temp-MaxStimulusRadius));
                  temp = rand()%(2*MaxStimulusRadius);
                  dotY[j] = (temp < MaxStimulusRadius) ? (centerY_R - temp) : (centerY_R + (temp-MaxStimulusRadius));
                  dotLifeR[j] = rand()%DotLifetime;
            }
            if (dotX[j]>(centerX_R+MaxStimulusRadius) || dotX[j]<(centerX_R-MaxStimulusRadius)
                  || dotY[j]>(centerY_R+MaxStimulusRadius) || dotY[j]<(centerY_R-MaxStimulusRadius)) {
                  temp = rand()%(2*MaxStimulusRadius);
                  dotX[j] = (temp < MaxStimulusRadius) ? (centerX_R - temp) : (centerX_R + (temp-MaxStimulusRadius));
                  temp = rand()%(2*MaxStimulusRadius);
                  dotY[j] = (temp < MaxStimulusRadius) ? (centerY_R - temp) : (centerY_R + (temp-MaxStimulusRadius));
            }
            /* Draw the dot */
            glLoadIdentity();
            glTranslatef(dotX[j],dotY[j],0.0f);      
            glCallList(smallDot);
      }
      /* Finished with all the dots, so update phi */
      phi = phi-(SPOT_PHI_DELTA*PI);
      if (phi <= (-1.0*PI)) phi = PI;

      /* Superimpose fixation mark */
      drawFixation(frameNumber);
}

                              

static void drawMorroneBase_L(int frameNumber)
{
      double theta, r, delta_r, delta_theta, delta_x, delta_y;
      int j, temp;

      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
      for (j=0; j<NumberOfDotsBase; j++){
      
            /* Now calculate the next position of the dot */
            if (j<NumberOfRandomDotsBase)
            {
                delta_x = DotSpeed*cos(dotDirectionL[j]);
                  delta_y = DotSpeed*sin(dotDirectionL[j]);
                  dotX[j] += delta_x;
                  dotY[j] += delta_y;
                  
            }else
            {
            theta = atan2((dotY[j]-centerY_L), (dotX[j]-centerX_L));
            r = sqrt(((dotX[j]-centerX_L)*(dotX[j]-centerX_L))+((dotY[j]-centerY_L)*(dotY[j]-centerY_L)));
            delta_r = DotSpeed*cos(phi);
            delta_theta = (DotSpeed*sin(phi))/r;
            dotX[j] = ((r+delta_r)*cos(theta+delta_theta)) + centerX_L;
            dotY[j] = ((r+delta_r)*sin(theta+delta_theta)) + centerY_L;
            }
            /* Dot drawn, so increase its life count */
            dotLifeL[j]++;
            /* And finally a series of checks on the status of the dot */
            if (dotLifeL[j]>DotLifetime) {
                  temp = rand()%(2*MaxStimulusRadius);
                  dotX[j] = (temp < MaxStimulusRadius) ? (centerX_L - temp) : (centerX_L + (temp-MaxStimulusRadius));
                  temp = rand()%(2*MaxStimulusRadius);
                  dotY[j] = (temp < MaxStimulusRadius) ? (centerY_L - temp) : (centerY_L + (temp-MaxStimulusRadius));
                  dotLifeL[j] = rand()%DotLifetime;
            }
            if (dotX[j]>(centerX_L+MaxStimulusRadius) || dotX[j]<(centerX_L-MaxStimulusRadius)
                  || dotY[j]>(centerY_L+MaxStimulusRadius) || dotY[j]<(centerY_L-MaxStimulusRadius)) {
                  temp = rand()%(2*MaxStimulusRadius);
                  dotX[j] = (temp < MaxStimulusRadius) ? (centerX_L - temp) : (centerX_L + (temp-MaxStimulusRadius));
                  temp = rand()%(2*MaxStimulusRadius);
                  dotY[j] = (temp < MaxStimulusRadius) ? (centerY_L - temp) : (centerY_L + (temp-MaxStimulusRadius));

            }
            /* Draw the dot */
            glLoadIdentity();
            glTranslatef(dotX[j],dotY[j],0.0f);      
            glCallList(smallDot);
      }
      /* Finished with all the dots, so update phi */
      phi = phi-(SPOT_PHI_DELTA*PI);
      if (phi <= (-1.0*PI)) phi = PI;

      /* Superimpose fixation mark */
      drawFixation(frameNumber);
}



static void drawMorroneInc_R(int frameNumber)
{
      double theta, r, delta_r, delta_theta, delta_x, delta_y;
      int j, temp;

      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
      for (j=0; j<NumberOfDotsInc; j++){
            /* Now calculate the next position of the dot */
            if (j<NumberOfRandomDotsInc)
            {
                  delta_x = DotSpeed*cos(dotDirectionR[j]);
                  delta_y = DotSpeed*sin(dotDirectionR[j]);
                  dotX[j] += delta_x;
                  dotY[j] += delta_y;
            }
            else
            {
            theta = atan2((dotY[j]-centerY_R), (dotX[j]-centerX_R));
            r = sqrt(((dotX[j]-centerX_R)*(dotX[j]-centerX_R))+((dotY[j]-centerY_R)*(dotY[j]-centerY_R)));
            delta_r = DotSpeed*cos(phi);
            delta_theta = (DotSpeed*sin(phi))/r;
            dotX[j] = ((r+delta_r)*cos(theta+delta_theta)) + centerX_R;
            dotY[j] = ((r+delta_r)*sin(theta+delta_theta)) + centerY_R;
            }
            /* Dot drawn, so increase its life count */
            dotLifeR[j]++;
            /* And finally a series of checks on the status of the dot */
            if (dotLifeR[j]>DotLifetime) {
                  temp = rand()%(2*MaxStimulusRadius);
                  dotX[j] = (temp < MaxStimulusRadius) ? (centerX_R - temp) : (centerX_R + (temp-MaxStimulusRadius));
                  temp = rand()%(2*MaxStimulusRadius);
                  dotY[j] = (temp < MaxStimulusRadius) ? (centerY_R - temp) : (centerY_R + (temp-MaxStimulusRadius));
                  dotLifeR[j] = rand()%DotLifetime;
            }
            if (dotX[j]>(centerX_R+MaxStimulusRadius) || dotX[j]<(centerX_R-MaxStimulusRadius)
                  || dotY[j]>(centerY_R+MaxStimulusRadius) || dotY[j]<(centerY_R-MaxStimulusRadius)) {
                  temp = rand()%(2*MaxStimulusRadius);
                  dotX[j] = (temp < MaxStimulusRadius) ? (centerX_R - temp) : (centerX_R + (temp-MaxStimulusRadius));
                  temp = rand()%(2*MaxStimulusRadius);
                  dotY[j] = (temp < MaxStimulusRadius) ? (centerY_R - temp) : (centerY_R + (temp-MaxStimulusRadius));
            }
            /* Draw the dot */
            glLoadIdentity();
            glTranslatef(dotX[j],dotY[j],0.0f);      
            glCallList(smallDot);
      }
      /* Finished with all the dots, so update phi */
      phi = phi-(SPOT_PHI_DELTA*PI);
      if (phi <= (-1.0*PI)) phi = PI;

      /* Superimpose fixation mark */
      drawFixation(frameNumber);
}



static void drawMorroneDec_R(int frameNumber)
{
      double theta, r, delta_r, delta_theta, delta_x, delta_y;
      int j, temp;

      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
      for (j=0; j<NumberOfDotsDec; j++){
      
            /* Now calculate the next position of the dot */
            if (j<NumberOfRandomDotsDec)
            {
                  delta_x = DotSpeed*cos(dotDirectionR[j]);
                  delta_y = DotSpeed*sin(dotDirectionR[j]);
                  dotX[j] += delta_x;
                  dotY[j] += delta_y;
            }
            else
            {
            theta = atan2((dotY[j]-centerY_R), (dotX[j]-centerX_R));
            r = sqrt(((dotX[j]-centerX_R)*(dotX[j]-centerX_R))+((dotY[j]-centerY_R)*(dotY[j]-centerY_R)));
            delta_r = DotSpeed*cos(phi);
            delta_theta = (DotSpeed*sin(phi))/r;
            dotX[j] = ((r+delta_r)*cos(theta+delta_theta)) + centerX_R;
            dotY[j] = ((r+delta_r)*sin(theta+delta_theta)) + centerY_R;
            }
            /* Dot drawn, so increase its life count */
            dotLifeR[j]++;
            /* And finally a series of checks on the status of the dot */
            if (dotLifeR[j]>DotLifetime) {
                  temp = rand()%(2*MaxStimulusRadius);
                  dotX[j] = (temp < MaxStimulusRadius) ? (centerX_R - temp) : (centerX_R + (temp-MaxStimulusRadius));
                  temp = rand()%(2*MaxStimulusRadius);
                  dotY[j] = (temp < MaxStimulusRadius) ? (centerY_R - temp) : (centerY_R + (temp-MaxStimulusRadius));
                  dotLifeR[j] = rand()%DotLifetime;
            }
            if (dotX[j]>(centerX_R+MaxStimulusRadius) || dotX[j]<(centerX_R-MaxStimulusRadius)
                  || dotY[j]>(centerY_R+MaxStimulusRadius) || dotY[j]<(centerY_R-MaxStimulusRadius)) {
                  temp = rand()%(2*MaxStimulusRadius);
                  dotX[j] = (temp < MaxStimulusRadius) ? (centerX_R - temp) : (centerX_R + (temp-MaxStimulusRadius));
                  temp = rand()%(2*MaxStimulusRadius);
                  dotY[j] = (temp < MaxStimulusRadius) ? (centerY_R - temp) : (centerY_R + (temp-MaxStimulusRadius));
            }
            /* Draw the dot */
            glLoadIdentity();
            glTranslatef(dotX[j],dotY[j],0.0f);      
            glCallList(smallDot);
      }
      /* Finished with all the dots, so update phi */
      phi = phi-(SPOT_PHI_DELTA*PI);
      if (phi <= (-1.0*PI)) phi = PI;

      /* Superimpose fixation mark */
      drawFixation(frameNumber);
}


int drawStimulusAB(int whichOne, int numFrames)
{
      float delayLength;
    int done;
      int delay = 1000/fps;
    int thenTicks = -1;
    int nowTicks;
      int phaseStart;
       
      /* First establish how long the stim/interval should last */
      switch (whichOne) {
            case 1:
            case 178:
                  delayLength = bufferlength;
                  break;
            case 2:
            case 6:
            case 10:
            case 14:
            case 18:
            case 22:
            case 26:
            case 30:
            case 34:
            case 38:
            case 42:
            case 46:
            case 50:
            case 54:
            case 58:
            case 62:
            case 66:
            case 70:
            case 74:
            case 78:
            case 82:
            case 86:
            case 90:
            case 94:
            case 98:
            case 102:
            case 106:
            case 110:
            case 114:
            case 118:
            case 122:
            case 126:
            case 130:
            case 134:
            case 138:
            case 142:
            case 146:
            case 150:
            case 154:
            case 158:
            case 162:
            case 166:
            case 170:
            case 174:
                  delayLength = S1length;
                  break;
            case 3:
            case 7:
            case 11:
            case 15:
            case 19:
            case 23:
            case 27:
            case 31:
            case 35:
            case 39:
            case 43:
            case 47:
            case 51:
            case 55:
            case 59:
            case 63:
            case 67:
            case 71:
            case 75:
            case 79:
            case 83:
            case 87:
            case 91:
            case 95:
            case 99:
            case 103:
            case 107:
            case 111:
            case 115:
            case 119:
            case 123:
            case 127:
            case 131:
            case 135:
            case 139:
            case 143:
            case 147:
            case 151:
            case 155:
            case 159:
            case 163:
            case 167:
            case 171:
            case 175:
                  delayLength = ISI;
                  break;
            case 12:
            case 24:
            case 32:
            case 36:
            case 44:
            case 48:
            case 52:
            case 56:
            case 72:
            case 76:
            case 92:
            case 96:
            case 100:
            case 108:
            case 116:
            case 124:
            case 132:
            case 140:
            case 144:
            case 152:
            case 156:
            case 168:
            case 4:
            case 8:
            case 16:
            case 20:
            case 28:
            case 40:
            case 60:
            case 64:
            case 68:
            case 80:
            case 84:
            case 88:
            case 104:
            case 112:
            case 120:
            case 128:
            case 136:
            case 148:
            case 160:
            case 164:
            case 172:
            case 176:
                  delayLength = S2length;
                  break;
            case 113:
                  delayLength = ITI2;
                  break;
            case 17:
            case 45:
            case 153:
                  delayLength = ITI3;
                  break;
            case 13:
            case 5:
            case 29:
            case 33:
            case 41:
            case 73:
            case 77:
            case 125:
            case 137:
                  delayLength = ITI4;
                  break;
            case 49:
            case 57:
            case 61:
            case 69:
            case 85:
            case 105:
            case 129:
            case 157:
            case 161:
            case 173:
            case 177:
                  delayLength = ITI5;
                  break;
            case 25:
            case 9:
            case 81:
            case 89:
            case 97:
            case 101:
            case 117:
            case 141:
            case 165:
            case 169:
                  delayLength = ITI6;
                  break;
            case 21:
            case 53:
            case 109:
            case 121:
                  delayLength = ITI7;
                  break;
            case 37:
            case 133:
            case 149:
                  delayLength = ITI8;
                  break;
            case 65:
            case 145:
                  delayLength = ITI9;
                  break;
            case 93:
                  delayLength = ITI10;
                  break;
      }

      phaseStart = SDL_GetTicks();
      done = 0;
      while ( !done ) {
            /* Figure out which one to draw */
            switch (whichOne) {
            case 6:
            case 14:
            case 22:
            case 30:
            case 34:
            case 38:
            case 50:
            case 54:
            case 66:
            case 74:
            case 82:
            case 86:
            case 94:
            case 114:
            case 118:
            case 126:
            case 130:
            case 142:
            case 150:
            case 158:
            case 162:
            case 174:
                        drawMorroneBase_RL(numFrames);
                        break;
                        
            
            
            case 2:
            case 10:
            case 26:
            case 46:
            case 62:
            case 102:
            case 106:
            case 134:
            case 138:
            case 166:
            case 170:
                        drawMorroneBase_R(numFrames);
                        break;
                  // BaseL below checked and correct      
            case 18:
            case 58:
            case 70:
            case 78:
            case 90:
            case 98:
            case 110:
            case 122:
            case 146:
            case 154:
                        drawMorroneBase_L(numFrames);
                        break;            
            case 1:
            case 178:
            case 113:
            case 45:
            case 13:
            case 25:
            case 29:
            case 33:
            case 73:
            case 125:
            case 137:
            case 49:
            case 61:
            case 85:
            case 105:
            case 129:
            case 157:
            case 161:
            case 173:
            case 177:
            case 9:
            case 101:
            case 165:
            case 169:
            case 133:
      
                        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
                        drawFixation(numFrames);
                        // indicator added below//
                        drawIndicatorFixationR(numFrames);
                        break;
            case 5:
            case 81:
            case 89:
            case 97:
            case 117:
            case 141:
            case 21:
            case 53:
            case 109:
            case 121:
            case 37:
            case 149:
            case 65:
            case 145:
            case 93:
            case 17:
            case 41:
            case 57:
            case 69:
            case 77:
            case 153:
                        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
                        drawFixation(numFrames);
                        // indicator added below//
                        drawIndicatorFixationL(numFrames);
                        break;
            case 8:
            case 16:
            case 40:
            case 42:
            case 52:
            case 84:
            case 88:
            case 120:
            case 128:
            case 160:
            case 176:  
                        drawMorroneInc_RL(numFrames);
                        break;
            case 24:
            case 32:
            case 36:
            case 56:
            case 68:
            case 96:
            case 116:
            case 132:
            case 144:
            case 164:
            case 152:  
                        drawMorroneDec_RL(numFrames);
                        break;
            case 4:
            case 28:
            case 64:
            case 104:
            case 136:
            case 172:  
                        drawMorroneInc_R(numFrames);
                        break;
            case 12:
            case 48:
            case 108:
            case 140:
            case 168:  
                        drawMorroneDec_R(numFrames);
                        break;
                        
            case 20:
            case 60:
            case 80:
            case 112:
            case 148:
                        drawMorroneInc_L(numFrames);
                        break;
            case 44:
            case 72:
            case 92:
            case 100:
            case 124:
            case 156:  
                        drawMorroneDec_L(numFrames);
                        break;            
                        
            }
            SDL_GL_SwapBuffers();
            numFrames++;

            // Time how long each draw-swap-delay cycle takes
            // and adjust delay to get closer to target framerate
            if (thenTicks > 0) {
                  nowTicks = SDL_GetTicks();
                  delay += (1000/fps - (nowTicks-thenTicks));
                  thenTicks = nowTicks;
                  if (delay < 0)
                        delay = 1000/fps;
            }
            else {
                  thenTicks = SDL_GetTicks();
            }
            SDL_Delay(delay);
            
            /* Check to make sure that we havent gone over the block
               length - if we have, we can exit the animatopn loop */
            if ((SDL_GetTicks() - phaseStart) > (delayLength*1000)) done = 1;
      }
      
      return(numFrames);
}

/* ============== Stimulus Presentation Flow Control ============== */

static void mainLoop ()
{
      int i,j;
      int numFrames;
   
      startStim = SDL_GetTicks();
      for (i=1; i<=numBlocks; i++) {
            numFrames = 0;
            /* Check to see whether we are in an odd numbered block */
            if (i&0x01) {
                  /* Drawing A-B ie: [S1 S2][S1 S1] */
                  for (j=1; j<=178; j++) numFrames = drawStimulusAB(j, numFrames);
            }
            /* Otherwise, must be in an even numbered block.... */
      /*      else {
                  /* Drawing B-A ie: [S1 S1][S1 S2]
                  for (j=1; j<=8; j++) numFrames = drawStimulusBA(j, numFrames);
            }*/
      }
      stopStim = SDL_GetTicks();
}

/* ============== Main Program - Init graphics & start stimulus presentation ============== */

int main(int argc, char *argv[])
{
      int i, temp, tempR, done;
    SDL_Event event;
      
      // Init SDL video subsystem
      if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
        fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
            exit(1);
      }

    // Create GL context (1=fullscreen, 0=windowed... handy for debugging)
    createSurface(1);
   
    // Init GL state
    initGL(1024,768);
   
      // Create a model of the dots for drawing
      createDot();
      
      // Initialise dot coordinates
      for (i=0; i<NumberOfDotsBase; i++) {
            temp = rand()%(2*MaxStimulusRadius);
            dotX[i] = (temp < MaxStimulusRadius) ? (centerX - temp) : (centerX + (temp-MaxStimulusRadius));
            temp = rand()%(2*MaxStimulusRadius);
            dotY[i] = (temp < MaxStimulusRadius) ? (centerY - temp) : (centerY + (temp-MaxStimulusRadius));
            // added code AHH
            tempR = rand()%(2*MaxStimulusRadius);
            dotXR[i] = (tempR < MaxStimulusRadius) ? (centerX - tempR) : (centerX + (tempR-MaxStimulusRadius));
            tempR = rand()%(2*MaxStimulusRadius);
            dotYR[i] = (tempR < MaxStimulusRadius) ? (centerY - tempR) : (centerY + (tempR-MaxStimulusRadius));
            // end of added code
            dotLifeL[i] = rand()%DotLifetime;
            dotLifeR[i] = rand()%DotLifetime;
            // ADDITIONAL LINE ADDED TO MAKE DOTLIFE R AND L//
            dotDirectionL[i] = (rand()%360)*(PI/180.0);
            dotDirectionR[i] = (rand()%360)*(PI/180.0);
      }

    /* Clear display & remove the mouse cursor */
    SDL_ShowCursor(SDL_DISABLE);
      
    /* Ready to start stimulus - wait for mouse click & go */
      done = 0;
      while ( !done ) {
            /* Check for any events */
            while ( SDL_PollEvent(&event) ) {
                  switch (event.type) {
                /* Were only interested if we have a mouse button down */
                case SDL_MOUSEBUTTONDOWN:
                              done = 1;
                              break;
                        default:
                              break;
                  }
            }
      }
    /* OK - Lets go... */
    mainLoop();
   
      /* Finished, so return the mouse cursor to the display */
    SDL_ShowCursor(SDL_ENABLE);

    /* Cleanup & quit */
      SDL_Quit();
      
      printf("%f",(float)(stopStim-startStim)/1000);
      
    return 0;
}
[+][-]06/20/07 05:29 AM, ID: 19323924Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06/20/07 05:49 AM, ID: 19324048Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06/20/07 05:53 AM, ID: 19324082Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/01/07 09:32 AM, ID: 19610444Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/01/07 10:42 AM, ID: 19611088Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: 3D Game Programming, Microsoft Visual C++, OpenGL Graphics & Game Programming
Tags: sdl, visual, studio
Sign Up Now!
Solution Provided By: ikework
Participating Experts: 3
Solution Grade: A
 
[+][-]10/11/07 02:21 AM, ID: 20055244Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-89