land.cpp

来自「此文档是用vistual studio 2005 开发的用来描述3D-tree 」· C++ 代码 · 共 61 行

CPP
61
字号
#include "stdafx.h"
#include "Land.h"
#include "ChGL.h"
#include <GL/glut.h>

Land::Land( float size, char* bmpPath ) {
	this->size = size;
	visible = true;
	ChGL::loadTexture( bmpPath, &texture, false );
}

void Land::draw() {
	if ( visible == true ) {
		glPushMatrix();
			// enableFog();
			glEnable( GL_CULL_FACE );
			glBindTexture( GL_TEXTURE_2D, texture );
			glBegin( GL_QUADS );
				glNormal3f( 0.0f, 1.0f, 0.0f );

				glTexCoord2f( 0.0f, 0.0f );
				glVertex3f( -size, 0.0f, -size );
				glTexCoord2f( 0.0f, 8.0f );
				glVertex3f( -size, 0.0f, size );
				glTexCoord2f( 8.0f, 8.0f );
				glVertex3f( size, 0.0f, size );
				glTexCoord2f( 8.0f, 0.0f );
				glVertex3f( size, 0.0f, -size );
			glEnd();
			glDisable( GL_CULL_FACE );
			// disableFog();
		glPopMatrix();
	}
}

void Land::setSize( float size ) {
	this->size = size;
}

void Land::setVisible( bool visible ) {
	this->visible = visible;
}

void Land::setTexture( char* bmpPath ) {
	ChGL::loadTexture( bmpPath, &texture, 0 );
}

float Land::getSize() {
	return size;
}

bool Land::getVisible() {
	return visible;
}

unsigned int Land::getTexture() {
	return texture;
}

Land::~Land() {
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?