]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
ortho binds to y
authorClyne Sullivan <tullivan99@gmail.com>
Wed, 4 Nov 2015 13:53:26 +0000 (08:53 -0500)
committerClyne Sullivan <tullivan99@gmail.com>
Wed, 4 Nov 2015 13:53:26 +0000 (08:53 -0500)
1  2 
include/common.h
main.cpp

index 39812c4b627a4a535657cea7095edc25b2a5ca00,bc713af2c5300f0bec994cc72fb288a1a3cb97f1..56e6a38dc87bddff9abca6fd83177a4edc50898b
@@@ -39,8 -39,14 +39,8 @@@ typedef unsigned int uint
   *    This flag lets the compiler know that we are using shaders
  */
  
- #define SHADERSf
+ #define SHADERSd
  
 -/*
 - * This is pi...
 -*/
 -
 -#define PI 3.141592653598723846433
 -
  /*
   *    Create a basic 2-point structure for coordinate saving
  */
diff --cc main.cpp
index 9d7f08547b3f5f287ce57689cf24430538314b86,41e12276efdb11ff9dddb54e281457d49f85d6e8..07e2fb00be803aa8dbb16cbab7f412147b021df9
+++ b/main.cpp
@@@ -778,7 -774,12 +778,7 @@@ void render()
                glUseProgramObjectARB(0);
        #endif //SHADERS
  
-       #define raysNOPE
 -
 -
 -
 -
 -
+       #define rays
  
        #ifdef rays
        //LIGHT
        glColor3f(0.0f, 0.0f, 0.0f);
        for(auto &r : ray){
                r.start = light;
-               angle = 12*a;
-               for(int l = 0;l<lightStr;l+=36){
-                       //switch
-                       switch(angle){
-                       case 0:
+               curCoord = r.start;
+               angle = 2*a;
+               //for length
+               for(int l = 0;l<=lightStr;l++){
+                       //std::cout << a << ": " << curCoord.x << "," << curCoord.y << "\n";
+                       if(angle == 0){
                                curCoord.x += HLINE;
                                curCoord.y += 0;
-                               break;
-                       case 180:
+                       }
+                       if(angle == 90){
+                               curCoord.y += HLINE;
+                               curCoord.x += 0;
+                       }
+                       if(angle == 180){
                                curCoord.x -= HLINE;
-                               curCoord.y -= 0;
-                               break;
-                       case 360:
+                               curCoord.y += 0;
+                       }
+                       if(angle == 270){
+                               curCoord.y -= HLINE;
+                               curCoord.x += 0;
+                       }
+                       if(angle == 360){
                                curCoord.x += HLINE;
                                curCoord.y += 0;
-                               angle = 0;
-                               break;
-                       default:
-                               if(angle > 0 && angle < 90){
-                                       curCoord.x = r.start.x + float(HLINE / cos(angle*PI/180));
-                                       curCoord.y = r.start.y + float(HLINE / sin(angle*PI/180));
-                               }
-                               if(angle > 90 && angle < 180){
-                                       curCoord.x = r.start.x - float(HLINE / cos((90-angle)*PI/180));
-                                       curCoord.y = r.start.y + float(HLINE / sin((90-angle)*PI/180));
-                               }
-                               if(angle > 180 && angle < 270){
-                                       curCoord.x = r.start.x - float(HLINE / cos((270-angle)*PI/180));
-                                       curCoord.y = r.start.y - float(HLINE / sin((270-angle)*PI/180));
-                               }
-                               if(angle > 270 && angle < 360){
-                                       curCoord.x = r.start.x + float(HLINE / cos((360-angle)*PI/180));
-                                       curCoord.y = r.start.y - float(HLINE / sin((360-angle)*PI/180));
-                               }
-                       }//end swtich
-                       /*for(auto &en : entity){
 -                      }
 -                      else{
++                      }else{
+                               curCoord.x += float((HLINE) * cos(angle*PI/180));
+                               curCoord.y += float((HLINE) * sin(angle*PI/180));
+                       }
+                       for(auto &en : entity){
                                if(curCoord.x > en->loc.x && curCoord.x < en->loc.x + en->width){
                                        if(curCoord.y > en->loc.y && curCoord .y < en->loc.y + en->height){
                                                r.end = curCoord;
                //std::cout << angle << "\n";
                a++;
        }
-       #endif //rays
+       glUseProgramObjectARB(shaderProgram);
+       glUniform2f(glGetUniformLocation(shaderProgram, "lightLocation"), 640,300);
+       glUniform3f(glGetUniformLocation(shaderProgram, "lightColor"), 1,1,1);
+       glUniform1f(glGetUniformLocation(shaderProgram, "lightStrength"), 5);
+       glColor4f(1.0f, 1.0f, 1.0f, .5f);
+       for(auto r = 0; r < ray.size(); r++){
+               glBegin(GL_TRIANGLES);
+                       glVertex2f(ray[r].start.x, ray[r].start.y);
+                       glVertex2f(ray[r].end.x, ray[r].end.y);
+                       r==ray.size()-1 ? glVertex2f(ray[0].end.x, ray[0].end.y) : glVertex2f(ray[r+1].end.x, ray[r+1].end.y);
+               glEnd();
+       }
+       glUseProgramObjectARB(0);
+       #endif //ray
  
 -
 -      //LIGHT
        player->inv->draw();
  
        /*