aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authordrumsetmonkey <abelleisle@roadrunner.com>2016-01-07 08:25:49 -0500
committerdrumsetmonkey <abelleisle@roadrunner.com>2016-01-07 08:25:49 -0500
commitc7e3d72f0ef08cb9463cd8960bc29dad40e3bdcb (patch)
treed6bfde57916863ca9fd6fa2fbfae42338ae8e630 /src
parent0f379ae55e07d4e1e7904a3eb33b1c29c2177ec1 (diff)
parent1b2510a427cea42e6381d60f434b5fdec2b181b0 (diff)
Hey, that's pretty good lighting!
Diffstat (limited to 'src')
-rw-r--r--src/entities.cpp41
-rw-r--r--src/gameplay.cpp22
-rw-r--r--src/inventory.cpp4
-rw-r--r--src/ui.cpp2
-rw-r--r--src/world.cpp223
5 files changed, 193 insertions, 99 deletions
diff --git a/src/entities.cpp b/src/entities.cpp
index cd8d29e..d12a1ca 100644
--- a/src/entities.cpp
+++ b/src/entities.cpp
@@ -1,6 +1,8 @@
#include <entities.h>
#include <ui.h>
+#include <unistd.h>
+
extern FILE* names;
extern unsigned int loops;
@@ -77,7 +79,7 @@ void Entity::spawn(float x, float y){ //spawns the entity you pass to it based o
Player::Player(){ //sets all of the player specific traits on object creation
width = HLINE * 10;
- height = HLINE * 16;
+ height = HLINE * 15;
type = PLAYERT; //set type to player
subtype = 0;
@@ -126,6 +128,7 @@ Structures::Structures(){ //sets the structure type
near = false;
tex = new Texturec(3,"assets/house1.png", "assets/house2.png", "assets/fountain1.png");
+ ntex = new Texturec(1, "assets/house1N.png");
inWorld = NULL;
name = NULL;
@@ -196,6 +199,7 @@ Object::~Object(){
void Entity::draw(void){ //draws the entities
glPushMatrix();
glColor3ub(255,255,255);
+ //glUniform1i(glGetUniformLocation(shaderProgram, "sampler"), 0);
if(type==NPCT){
if(NPCp(this)->aiFunc.size()){
glColor3ub(255,255,0);
@@ -222,23 +226,29 @@ void Entity::draw(void){ //draws the entities
//currentWorld->addParticle(loc.x,loc.y-HLINE,HLINE,HLINE,0,0,{0.0f,.17f,0.0f},1000);
if(up){
if(++texState==2)up=false;
+ glActiveTexture(GL_TEXTURE0);
tex->bindNext();
}else{
if(!--texState)up=true;
+ glActiveTexture(GL_TEXTURE0);
tex->bindPrev();
}
}
if(!ground){
+ glActiveTexture(GL_TEXTURE0 + 0);
tex->bind(0);
}else if(vel.x){
+ glActiveTexture(GL_TEXTURE0 + 0);
tex->bind(texState);
}else{
+ glActiveTexture(GL_TEXTURE0 + 0);
tex->bind(1);
}
break;
case MOBT:
switch(subtype){
case MS_RABBIT:
+ glActiveTexture(GL_TEXTURE0 + 0);
tex->bind(!ground);
break;
case MS_TRIGGER:
@@ -247,6 +257,7 @@ void Entity::draw(void){ //draws the entities
case MS_BIRD:
case MS_DOOR:
default:
+ glActiveTexture(GL_TEXTURE0 + 0);
tex->bind(0);
break;
}
@@ -255,26 +266,39 @@ void Entity::draw(void){ //draws the entities
for(auto &strt : currentWorld->build){
if(this == strt){
if(strt->bsubtype == HOUSE){
+ glActiveTexture(GL_TEXTURE1);
+ ntex->bind(0);
+ //When rendering an objectwith this program.
+ glActiveTexture(GL_TEXTURE0 + 0);
tex->bind(0);
+ //glBindSampler(0, linearFiltering);
+
+
}else if(strt->bsubtype == HOUSE2){
+ glActiveTexture(GL_TEXTURE0 + 0);
tex->bind(1);
}else if(strt->bsubtype == FOUNTAIN){
+ glActiveTexture(GL_TEXTURE0 + 0);
tex->bind(2);
}
}
}
break;
default:
+ glActiveTexture(GL_TEXTURE0 + 0);
tex->bind(0);
break;
}
glColor3ub(255,255,255);
+ glUseProgram(shaderProgram);
+ glUniform1i(glGetUniformLocation(shaderProgram, "sampler"), 0);
glBegin(GL_QUADS);
glTexCoord2i(0,1);glVertex2i(loc.x, loc.y);
glTexCoord2i(1,1);glVertex2i(loc.x + width, loc.y);
glTexCoord2i(1,0);glVertex2i(loc.x + width, loc.y + height);
glTexCoord2i(0,0);glVertex2i(loc.x, loc.y + height);
glEnd();
+ glUseProgram(0);
NOPE:
glDisable(GL_TEXTURE_2D);
glMatrixMode(GL_MODELVIEW);
@@ -393,7 +417,7 @@ void Object::interact(void){
* point to have non-normal traits so it could be invisible or invincible...
*/
-unsigned int Structures::spawn(_TYPE t, BUILD_SUB sub, float x, float y){
+unsigned int Structures::spawn(_TYPE t, BUILD_SUB sub, float x, float y, World *oi){
loc.x = x;
loc.y = y;
type = t;
@@ -404,6 +428,8 @@ unsigned int Structures::spawn(_TYPE t, BUILD_SUB sub, float x, float y){
height = 40 * HLINE;
bsubtype = sub;
+ inWorld = oi;
+
/*
* tempN is the amount of entities that will be spawned in the village. Currently the village
* will spawn bewteen 2 and 7 villagers for the starting hut.
@@ -418,10 +444,7 @@ unsigned int Structures::spawn(_TYPE t, BUILD_SUB sub, float x, float y){
* with type NPC.
*/
- //((World*)(inWorld))->addNPC(loc.x + i * HLINE ,100);
- //inWorld->addNPC(loc.x + i * HLINE, 100);
- currentWorld->addNPC(loc.x + i * HLINE ,100);
-
+ inWorld->addNPC(loc.x + i * HLINE ,100);
}
@@ -463,7 +486,11 @@ void Mob::wander(int timeRun){
case MS_TRIGGER:
if(player->loc.x + player->width / 2 > loc.x &&
player->loc.x + player->width / 2 < loc.x + width ){
- hey(this);
+ //if(!vfork()){
+ hey(this);
+ /*_exit(0);
+ }*/
+
}
break;
case MS_DOOR:
diff --git a/src/gameplay.cpp b/src/gameplay.cpp
index d439814..1c83bd8 100644
--- a/src/gameplay.cpp
+++ b/src/gameplay.cpp
@@ -42,6 +42,7 @@ float gen_worldSpawnHill3(float x){
*/
void worldSpawnHill1_hillBlock(Mob *callee){
+ std::cout<<"oi";
player->vel.x = 0;
player->loc.x = callee->loc.x + callee->width;
ui::dialogBox(player->name,NULL,false,"This hill seems to steep to climb up...");
@@ -93,6 +94,8 @@ static World *worldSpawnHill1;
static World *worldSpawnHill2;
static World *worldSpawnHill3;
+static IndoorWorld *worldSpawnHill2_Building1;
+
/*
* initEverything() start
*/
@@ -118,8 +121,8 @@ void initEverything(void){
worldSpawnHill3->setBGM("assets/music/ozone.wav");
worldSpawnHill3->addMob(MS_TRIGGER,-500,0,worldSpawnHill3_itemGet);
worldSpawnHill3->addMob(MS_TRIGGER,0,0,worldSpawnHill3_itemSee);
- worldSpawnHill3->addObject(TEST_ITEM,false,"",-200,300);
- worldSpawnHill3->addMob(MS_TRIGGER,400,0,worldSpawnHill3_leave);
+ worldSpawnHill3->addObject(FLASHLIGHT,false,"",-200,300);
+ worldSpawnHill3->addMob(MS_TRIGGER,650,0,worldSpawnHill3_leave);
worldSpawnHill3->addHole(800,1000);
worldSpawnHill1->toRight = worldSpawnHill2;
@@ -140,15 +143,20 @@ void initEverything(void){
//playerSpawnHill->addMob(MS_TRIGGER,-1300,0,CUTSCENEEE);*/
- currentWorld = worldSpawnHill1;
- worldSpawnHill2->addStructure(STRUCTURET,HOUSE,(rand()%120*HLINE),100,worldSpawnHill1,worldSpawnHill2);
+ worldSpawnHill2_Building1 = new IndoorWorld();
+ worldSpawnHill2_Building1->generate(300);
+ worldSpawnHill2_Building1->setBackground(BG_WOODHOUSE);
+ worldSpawnHill2_Building1->setBGM("assets/music/theme_jazz.wav");
+
+ worldSpawnHill2->addStructure(STRUCTURET,HOUSE,(rand()%120*HLINE),100,worldSpawnHill2_Building1);
+ worldSpawnHill2->addLight({300,100},{1.0f,1.0f,1.0f});
- worldSpawnHill2->addStructure(STRUCTURET,HOUSE,(rand()%120*HLINE),100,worldSpawnHill1,worldSpawnHill2);
+ //worldSpawnHill2->addStructure(STRUCTURET,HOUSE,(rand()%120*HLINE),100,worldSpawnHill1,worldSpawnHill2);
player = new Player();
player->spawn(200,100);
-
+
+ currentWorld = worldSpawnHill1;
currentWorld->bgmPlay(NULL);
-
atexit(destroyEverything);
}
diff --git a/src/inventory.cpp b/src/inventory.cpp
index c0f4163..b6819d1 100644
--- a/src/inventory.cpp
+++ b/src/inventory.cpp
@@ -291,7 +291,8 @@ void itemDraw(Player *p,ITEM_ID id,ITEM_TYPE type){
default:
hangle = 0.0f;
}
-
+ glUseProgram(shaderProgram);
+ glUniform1i(glGetUniformLocation(shaderProgram, "sampler"), 0);
glTranslatef(itemLoc.x,itemLoc.y,0);
glRotatef(hangle, 0.0f, 0.0f, 1.0f);
glTranslatef(-itemLoc.x,-itemLoc.y,0);
@@ -307,6 +308,7 @@ void itemDraw(Player *p,ITEM_ID id,ITEM_TYPE type){
glDisable(GL_TEXTURE_2D);
glTranslatef(player->loc.x*2,0,0);
glPopMatrix();
+ glUseProgram(0);
}
int Inventory::useItem(void){
diff --git a/src/ui.cpp b/src/ui.cpp
index b759012..b9a44aa 100644
--- a/src/ui.cpp
+++ b/src/ui.cpp
@@ -512,7 +512,7 @@ namespace ui {
glVertex2f(x+1+SCREEN_WIDTH-HLINE*16,y+1);
glVertex2f(x+1+SCREEN_WIDTH-HLINE*16,y-1-SCREEN_HEIGHT/4);
glVertex2f(x-1 ,y-1-SCREEN_HEIGHT/4);
- glVertex2f(x-1 ,y+2);
+ glVertex2f(x ,y+1);
glEnd();
glColor3ub(0,0,0);
diff --git a/src/world.cpp b/src/world.cpp
index 0ecf7ee..b539a87 100644
--- a/src/world.cpp
+++ b/src/world.cpp
@@ -33,6 +33,8 @@ const char *bgPaths[2][7]={
NULL}
};
+Texturec *grassT;
+
const float bgDraw[3][3]={
{100,240,.6 },
{150,250,.4 },
@@ -88,6 +90,7 @@ World::World(void){
star = new vec2[100];
memset(star,0,100 * sizeof(vec2));
+ grassT = new Texturec(1,"assets/grass.png");
}
void World::deleteEntities(void){
@@ -383,27 +386,24 @@ LLLOOP:
width = (-x_start) << 1;
glEnable(GL_TEXTURE_2D);
-
+
bgTex->bind(0);
safeSetColorA(255,255,255,255 - worldShade * 4);
-
glBegin(GL_QUADS);
glTexCoord2i(0,0);glVertex2i( cx_start,SCREEN_HEIGHT);
glTexCoord2i(1,0);glVertex2i(-cx_start,SCREEN_HEIGHT);
glTexCoord2i(1,1);glVertex2i(-cx_start,0);
glTexCoord2i(0,1);glVertex2i( cx_start,0);
glEnd();
-
+
bgTex->bindNext();
- safeSetColorA(255,255,255,worldShade * 4);
-
+ safeSetColorA(255,255,255,worldShade * 4);
glBegin(GL_QUADS);
glTexCoord2i(0,0);glVertex2i( cx_start,SCREEN_HEIGHT);
glTexCoord2i(1,0);glVertex2i(-cx_start,SCREEN_HEIGHT);
glTexCoord2i(1,1);glVertex2i(-cx_start,0);
glTexCoord2i(0,1);glVertex2i( cx_start,0);
glEnd();
-
glDisable(GL_TEXTURE_2D);
/*
@@ -426,13 +426,13 @@ LLLOOP:
}
}
+
glEnable(GL_TEXTURE_2D);
/*
* Draw the mountains.
*/
-
bgTex->bindNext();
safeSetColorA(150-bgshade,150-bgshade,150-bgshade,220);
@@ -551,79 +551,108 @@ LOOP2:
bool hey=false;
glEnable(GL_TEXTURE_2D);
+ glActiveTexture(GL_TEXTURE0);
bgTex->bindNext();
+
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); //for the s direction
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); //for the t direction
+ glUseProgram(shaderProgram);
+ glUniform1i(glGetUniformLocation(shaderProgram, "sampler"), 0);
+ glUniform1f(glGetUniformLocation(shaderProgram, "amb"), float(shade+50.0f)/100.0f);
+ if(light.size() == 0){
+ glUniform2f(glGetUniformLocation(shaderProgram, "lightLocation"), 0,-1000);
+ glUniform3f(glGetUniformLocation(shaderProgram, "lightColor"), 0.0f,0.0f,0.0f);
+ }else{
+ for(auto &l : light){
+ glUniform2f(glGetUniformLocation(shaderProgram, "lightLocation"), l.loc.x-offset.x,l.loc.y);
+ glUniform3f(glGetUniformLocation(shaderProgram, "lightColor"), l.color.red,l.color.green,l.color.blue);
+ }
+ }
+
glBegin(GL_QUADS);
- for(i=is;i<(unsigned)ie-GEN_INC;i++){
- cline[i].y+=(yoff-DRAW_Y_OFFSET); // Add the y offset
- if(!cline[i].y){
- cline[i].y=base;
- hey=true;
- glColor4ub(0,0,0,255);
- }else
- safeSetColorA(150+shade*2,150+shade*2,150+shade*2,255);
- glTexCoord2i(0,0);glVertex2i(cx_start+i*HLINE ,cline[i].y-GRASS_HEIGHT);
- glTexCoord2i(1,0);glVertex2i(cx_start+i*HLINE+HLINE,cline[i].y-GRASS_HEIGHT);
- glTexCoord2i(1,(int)(cline[i].y/64)+cline[i].color);glVertex2i(cx_start+i*HLINE+HLINE,0);
- glTexCoord2i(0,(int)(cline[i].y/64)+cline[i].color);glVertex2i(cx_start+i*HLINE ,0);
- cline[i].y-=(yoff-DRAW_Y_OFFSET); // Restore the line's y value
- if(hey){
- hey=false;
- cline[i].y=0;
- }
+ for(i=is;i<(unsigned)ie-GEN_INC;i++){
+ cline[i].y+=(yoff-DRAW_Y_OFFSET); // Add the y offset
+ if(!cline[i].y){
+ cline[i].y=base;
+ hey=true;
+ glColor4ub(0,0,0,255);
+ }else safeSetColorA(150+shade*2,150+shade*2,150+shade*2,255);
+ glTexCoord2i(0,0);glVertex2i(cx_start+i*HLINE ,cline[i].y-GRASS_HEIGHT);
+ glTexCoord2i(1,0);glVertex2i(cx_start+i*HLINE+HLINE,cline[i].y-GRASS_HEIGHT);
+ glTexCoord2i(1,(int)(cline[i].y/64)+cline[i].color);glVertex2i(cx_start+i*HLINE+HLINE,0);
+ glTexCoord2i(0,(int)(cline[i].y/64)+cline[i].color);glVertex2i(cx_start+i*HLINE ,0);
+ cline[i].y-=(yoff-DRAW_Y_OFFSET); // Restore the line's y value
+ if(hey){
+ hey=false;
+ cline[i].y=0;
}
+ }
glEnd();
+ glUseProgram(0);
glDisable(GL_TEXTURE_2D);
-
/*
* Draw grass on every line.
*/
float cgh[2];
- glBegin(GL_QUADS);
- for(i=is;i<(unsigned)ie-GEN_INC;i++){
-
- /*
- * Load the current line's grass values
- */
-
- if(cline[i].y)memcpy(cgh,cline[i].gh,2*sizeof(float));
- else memset(cgh,0 ,2*sizeof(float));
-
-
-
- /*
- * Flatten the grass if the player is standing on it.
- */
-
- if(!cline[i].gs){
- cgh[0]/=4;
- cgh[1]/=4;
- }
-
- /*
- * Actually draw the grass.
- */
-
- cline[i].y+=(yoff-DRAW_Y_OFFSET);
-
- safeSetColor(shade,100+shade*1.5,shade);
-
- glVertex2i(cx_start+i*HLINE ,cline[i].y+cgh[0]);
- glVertex2i(cx_start+i*HLINE+HLINE/2,cline[i].y+cgh[0]);
- glVertex2i(cx_start+i*HLINE+HLINE/2,cline[i].y-GRASS_HEIGHT);
- glVertex2i(cx_start+i*HLINE ,cline[i].y-GRASS_HEIGHT);
-
- glVertex2i(cx_start+i*HLINE+HLINE/2,cline[i].y+cgh[1]);
- glVertex2i(cx_start+i*HLINE+HLINE ,cline[i].y+cgh[1]);
- glVertex2i(cx_start+i*HLINE+HLINE ,cline[i].y-GRASS_HEIGHT);
- glVertex2i(cx_start+i*HLINE+HLINE/2,cline[i].y-GRASS_HEIGHT);
-
- cline[i].y-=(yoff-DRAW_Y_OFFSET);
+
+ glEnable(GL_TEXTURE_2D);
+ glActiveTexture(GL_TEXTURE0);
+ grassT->bind(0);
+ glUseProgram(shaderProgram);
+ glUniform1i(glGetUniformLocation(shaderProgram, "sampler"), 0);
+ //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); //for the s direction
+ //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); //for the t direction
+ //glBegin(GL_QUADS);
+
+ for(i=is;i<(unsigned)ie-GEN_INC;i++){
+
+ /*
+ * Load the current line's grass values
+ */
+
+ if(cline[i].y)memcpy(cgh,cline[i].gh,2*sizeof(float));
+ else memset(cgh,0 ,2*sizeof(float));
+
+
+
+ /*
+ * Flatten the grass if the player is standing on it.
+ */
+
+ if(!cline[i].gs){
+ cgh[0]/=4;
+ cgh[1]/=4;
}
- glEnd();
-
+
+ /*
+ * Actually draw the grass.
+ */
+
+ cline[i].y+=(yoff-DRAW_Y_OFFSET);
+ safeSetColorA(255,255,255,255);
+ glBegin(GL_QUADS);
+ glTexCoord2i(0,0);glVertex2i(cx_start+i*HLINE ,cline[i].y+cgh[0]);
+ glTexCoord2i(1,0);glVertex2i(cx_start+i*HLINE+HLINE/2,cline[i].y+cgh[0]);
+ glTexCoord2i(1,1);glVertex2i(cx_start+i*HLINE+HLINE/2,cline[i].y-GRASS_HEIGHT);
+ glTexCoord2i(0,1);glVertex2i(cx_start+i*HLINE ,cline[i].y-GRASS_HEIGHT);
+ glEnd();
+
+ glBegin(GL_QUADS);
+ glTexCoord2i(0,0);glVertex2i(cx_start+i*HLINE+HLINE/2,cline[i].y+cgh[1]);
+ glTexCoord2i(1,0);glVertex2i(cx_start+i*HLINE+HLINE ,cline[i].y+cgh[1]);
+ glTexCoord2i(1,1);glVertex2i(cx_start+i*HLINE+HLINE ,cline[i].y-GRASS_HEIGHT);
+ glTexCoord2i(0,1);glVertex2i(cx_start+i*HLINE+HLINE/2,cline[i].y-GRASS_HEIGHT);
+ glEnd();
+
+ cline[i].y-=(yoff-DRAW_Y_OFFSET);
+ }
+ //glEnd();
+ //glUseProgram(0);
+ glDisable(GL_TEXTURE_2D);
+
+ //glUseProgram(0);
+
/*
* Draw non-structure entities.
*/
@@ -903,16 +932,17 @@ LOOOOP:
goto LOOOOP;
}
}
-void World::addStructure(_TYPE t,BUILD_SUB sub, float x,float y,World *outside,World *inside){
+void World::addStructure(_TYPE t,BUILD_SUB sub, float x,float y,World *inside){
build.push_back(new Structures());
- build.back()->spawn(t,sub,x,y);
- build.back()->inWorld=outside;
- build.back()->inside=inside;
+ build.back()->spawn(t,sub,x,y,this);
+ build.back()->inWorld=this;
+ build.back()->inside = (World *)inside;
+ ((IndoorWorld *)inside)->outside = this;
entity.push_back(build.back());
}
-void World::addVillage(int bCount, int npcMin, int npcMax,_TYPE t,float x,float y,World *outside,World *inside){
+void World::addVillage(int bCount, int npcMin, int npcMax,_TYPE t,float x,float y,World *outside){
std::cout << npcMin << ", " << npcMax << std::endl;
int xwasd;
for(int i = 0; i < bCount; i++){
@@ -921,7 +951,7 @@ void World::addVillage(int bCount, int npcMin, int npcMax,_TYPE t,float x,float
for(auto &bu : build){
if(xwasd > bu->loc.x && xwasd < bu->loc.x+bu->width)goto HERE;
}
- addStructure(t,HOUSE,xwasd,y,outside,inside);
+ addStructure(t,HOUSE,xwasd,y,outside);
}
}
void World::addMob(int t,float x,float y){
@@ -958,6 +988,12 @@ void World::addParticle(float x, float y, float w, float h, float vx, float vy,
particles.back()->canMove = true;
}
+void World::addLight(vec2 loc, Color color){
+ light.push_back(Light());
+ light.back().loc = loc;
+ light.back().color = color;
+}
+
/*void World::removeObject(Object i){
object.delete[](i);
}*/
@@ -1094,44 +1130,64 @@ void IndoorWorld::generate(unsigned int width){ // Generates a flat area of wid
void IndoorWorld::draw(Player *p){
unsigned int i,ie;
- int j,x,v_offset;
+ //int j,x,v_offset;
+ int x;
/*
* Draw the background.
*/
glEnable(GL_TEXTURE_2D);
+ glUseProgram(shaderProgram);
+ glUniform1i(glGetUniformLocation(shaderProgram, "sampler"), 0);
+ glUniform1f(glGetUniformLocation(shaderProgram, "amb"), 0.0f);
+ if(light.size() == 0){
+ glUniform2f(glGetUniformLocation(shaderProgram, "lightLocation"), 0,-1000);
+ glUniform3f(glGetUniformLocation(shaderProgram, "lightColor"), 0.0f,0.0f,0.0f);
+ }else{
+ for(auto &l : light){
+ glUniform2f(glGetUniformLocation(shaderProgram, "lightLocation"), l.loc.x-offset.x,l.loc.y);
+ glUniform3f(glGetUniformLocation(shaderProgram, "lightColor"), l.color.red,l.color.green,l.color.blue);
+ }
+ }
bgTex->bind(0);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); //for the s direction
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); //for the t direction
glColor4ub(255,255,255,255);
glBegin(GL_QUADS);
- for(j = x_start - SCREEN_WIDTH / 2;j < -x_start + SCREEN_WIDTH / 2; j += 512){
- glTexCoord2i(1,1);glVertex2i(j ,0);
- glTexCoord2i(0,1);glVertex2i(j+512,0);
- glTexCoord2i(0,0);glVertex2i(j+512,512);
- glTexCoord2i(1,0);glVertex2i(j ,512);
- }
+ //for(j = x_start - SCREEN_WIDTH / 2;j < -x_start + SCREEN_WIDTH / 2; j += 512){
+ glTexCoord2i(0,1); glVertex2i( x_start - SCREEN_WIDTH / 2,0);
+ glTexCoord2i((-x_start*2+SCREEN_WIDTH)/512,1);glVertex2i(-x_start + SCREEN_WIDTH / 2,0);
+ glTexCoord2i((-x_start*2+SCREEN_WIDTH)/512,0);glVertex2i(-x_start + SCREEN_WIDTH / 2,SCREEN_HEIGHT);
+ glTexCoord2i(0,0); glVertex2i( x_start - SCREEN_WIDTH / 2,SCREEN_HEIGHT);
+ //}
glEnd();
+ glUseProgram(0);
glDisable(GL_TEXTURE_2D);
/*
* Calculate the starting and ending points to draw the ground from.
*/
- v_offset = (p->loc.x - x_start) / HLINE;
+ /*v_offset = (p->loc.x - x_start) / HLINE;
j = v_offset - (SCREEN_WIDTH / 2 / HLINE) - GEN_INC;
if(j < 0)j = 0;
i = j;
ie = v_offset + (SCREEN_WIDTH / 2 / HLINE) - GEN_INC;
- if(ie > lineCount)ie = lineCount;
+ if(ie > lineCount)ie = lineCount;*/
+
+ i = 0;
+ ie = lineCount;
/*
* Draw the ground.
*/
-
+ glUseProgram(shaderProgram);
+ glUniform1i(glGetUniformLocation(shaderProgram, "sampler"), 0);
glBegin(GL_QUADS);
for(;i < ie - GEN_INC;i++){
safeSetColor(150,100,50);
@@ -1143,6 +1199,7 @@ void IndoorWorld::draw(Player *p){
glVertex2i(x ,line[i].y - 50);
}
glEnd();
+ glUseProgram(0);
/*
* Draw all entities.