Added basic textures for now

This commit is contained in:
andreja6
2018-06-10 21:02:38 -07:00
parent 0bd49da8f4
commit 018c4a1557
6 changed files with 54 additions and 5 deletions

View File

@@ -5,8 +5,10 @@ int const Globals::gen = 0;
int const Globals::major = 0;
int const Globals::minor = 4;
int const Globals::patch = 2;
int Globals::surfaceId = 2;
bool Globals::showMouse = true;
bool Globals::useMousePoint = false;
G3D::TextureRef Globals::surface;
POINT Globals::mousepoint;
Globals::Globals(void){}

View File

@@ -1,5 +1,6 @@
#pragma once
#include "DataModelInstance.h"
#include <G3DAll.h>
class Globals
{
@@ -14,4 +15,6 @@ public:
static const int major;
static const int minor;
static const int patch;
static G3D::TextureRef surface;
static int surfaceId;
};

View File

@@ -1,4 +1,5 @@
#include "PhysicalInstance.h"
#include "Globals.h"
bool canCollide = true;
bool anchored = false;
Vector3 size;
@@ -130,36 +131,77 @@ void PhysicalInstance::render(RenderDevice* rd)
{
if(changed)
Box box = getBox();
glColor(color);
glBegin(GL_QUADS);
/*glEnable( GL_TEXTURE_2D );
glEnable(GL_BLEND);// you enable blending function
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glBindTexture( GL_TEXTURE_2D, Globals::surfaceId);
glBegin(GL_QUADS);*/
for(int i = 0; i < 96; i+=16)
{
double add = 0.8;
Surface face;
if(i == 0)//Back
{
face = back;
}
if(i == 16)//Right
else if(i == 16)//Right
{
face = right;
}
if(i == 32)//Front
else if(i == 32)//Front
{
face = front;
}
else if(i == 48)//Top
{
face = top;
}
else if(i == 64)//Left
{
face = left;
}
else if(i == 80)//Bottom
{
face = bottom;
}
if(face == Snaps)
add = 0.0;
else if(face == Inlets)
add = 0.2;
Vector3 v0 = Vector3(vertecies[i], vertecies[i+1], vertecies[i+2]), v1 = Vector3(vertecies[i+3], vertecies[i+4], vertecies[i+5]), v3 = Vector3(vertecies[i+9], vertecies[i+10], vertecies[i+11]);
glNormal3fv((v1 - v0).cross(v3 - v0).direction());
/*glNormal3fv((v1 - v0).cross(v3 - v0).direction());
glTexCoord2f(0.0F,0.0F);
glVertex3fv(v0);
glTexCoord2f(1.0F,0.0F);
glVertex3fv(v1);
glTexCoord2f(1.0F,0.25F);
glVertex3f(vertecies[i+6], vertecies[i+7], vertecies[i+8]);
glTexCoord2f(0.0F,0.25F);
glVertex3fv(v3);*/
glEnable( GL_TEXTURE_2D );
glEnable(GL_BLEND);// you enable blending function
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glBindTexture( GL_TEXTURE_2D, Globals::surfaceId);
glBegin( GL_QUADS );
glNormal3fv((v1 - v0).cross(v3 - v0).direction());
glTexCoord2d(0.0,0.0+add);
glVertex3fv(v0);
glTexCoord2d( 1.0,0.0+add);
glVertex3fv(v1);
glTexCoord2d(1.0,0.2+add);
glVertex3f(vertecies[i+6], vertecies[i+7], vertecies[i+8]);
glTexCoord2d( 0.0,0.2+add);
glVertex3fv(v3);
glEnd();
glDisable( GL_TEXTURE_2D );
}
glEnd();
/*glEnd();
glDisable(GL_TEXTURE_2D);*/
glColor(Color3::white());
if(!children.empty())
{

BIN
content/images/surface.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@@ -1428,6 +1428,8 @@ void Demo::run() {
// Load objects here=
cursor = Texture::fromFile(GetFileInPath("/content/cursor2.png"));
Globals::surface = Texture::fromFile(GetFileInPath("/content/images/surfacebr.png"));
Globals::surfaceId = Globals::surface->getOpenGLID();
fntdominant = GFont::fromFile(GetFileInPath("/content/font/dominant.fnt"));
fntlighttrek = GFont::fromFile(GetFileInPath("/content/font/lighttrek.fnt"));
cameraSound = GetFileInPath("/content/sounds/SWITCH3.wav");