本文整理汇总了C++中texture类的典型用法代码示例。如果您正苦于以下问题:C++ texture类的具体用法?C++ texture怎么用?C++ texture使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了texture类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: blit_texture
void blit_texture(const texture& tex, int x, int y, int w, int h, GLfloat rotate, GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2)
{
if(!tex.valid()) {
return;
}
const int w_odd = w % 2;
const int h_odd = h % 2;
w /= 2;
h /= 2;
glPushMatrix();
tex.set_as_current_texture();
glTranslatef(x+abs(w),y+abs(h),0.0);
glRotatef(rotate,0.0,0.0,1.0);
glBegin(GL_QUADS);
graphics::texture::set_coord(x1,y1);
glVertex3i(-w,-h,0);
graphics::texture::set_coord(x1,y2);
glVertex3i(-w,h+h_odd,0);
graphics::texture::set_coord(x2,y2);
glVertex3i(w+w_odd,h+h_odd,0);
graphics::texture::set_coord(x2,y1);
glVertex3i(w+w_odd,-h,0);
glEnd();
glPopMatrix();
}
开发者ID:x2f,项目名称:wesciv,代码行数:27,代码来源:raster.cpp
示例2:
template<> void uniform<texture>::assign(const texture &value)
{
if (value.bindless()) {
glUniformHandleui64ARB(id, value.handle());
} else {
glUniform1i(id, value.tmu());
}
}
开发者ID:XanClic,项目名称:dake,代码行数:8,代码来源:shader.cpp
示例3: queue_blit_texture
void queue_blit_texture(const texture& tex, int x, int y, int w, int h, int rotate,
GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2)
{
x &= preferences::xypos_draw_mask;
y &= preferences::xypos_draw_mask;
if(&tex != blit_current_texture) {
flush_blit_texture();
blit_current_texture = &tex;
}
x1 = tex.translate_coord_x(x1);
y1 = tex.translate_coord_y(y1);
x2 = tex.translate_coord_x(x2);
y2 = tex.translate_coord_y(y2);
if(w < 0) {
std::swap(x1, x2);
w *= -1;
}
if(h < 0) {
std::swap(y1, y2);
h *= -1;
}
blit_tcqueue.push_back(x1);
blit_tcqueue.push_back(y1);
blit_tcqueue.push_back(x2);
blit_tcqueue.push_back(y1);
blit_tcqueue.push_back(x1);
blit_tcqueue.push_back(y2);
blit_tcqueue.push_back(x2);
blit_tcqueue.push_back(y2);
blit_vqueue.push_back(x);
blit_vqueue.push_back(y);
blit_vqueue.push_back(x + w);
blit_vqueue.push_back(y);
blit_vqueue.push_back(x);
blit_vqueue.push_back(y + h);
blit_vqueue.push_back(x + w);
blit_vqueue.push_back(y + h);
rect r(x,y,w,h);
GLshort* varray = &blit_vqueue[blit_vqueue.size()-8];
rotate_rect(x+(w/2), y+(h/2), rotate, varray);
}
开发者ID:davewx7,项目名称:Wizard-Tactics,代码行数:51,代码来源:raster.cpp
示例4: log_error
void
shader::set_texture(const std::string &name, const texture &set_texture)
{
const auto it = std::find_if(std::begin(m_samplers), std::end(m_samplers), [name](const sampler &samp){ return samp.name == name; });
if(it != m_samplers.end())
{
const GLenum target = set_texture.get_gl_dimention();
m_pending_texture_data.emplace_back(pending_texture{set_texture.get_gl_id(), target, it->index});
}
else
{
log_error(GL_NO_ERROR, "shader::set_texture - couldn't find sampler '" + name + "' for texture.");
}
}
开发者ID:PhilCK,项目名称:mega-texture,代码行数:15,代码来源:shader.cpp
示例5: gen_miplevel
void gen_miplevel(texture &tex, texture &gen) ///call from main mem_alloc func?
{
int size=tex.get_largest_dimension();
int newsize=size >> 1;
gen.c_image.create(newsize, newsize);
for(int i=0; i<newsize; i++)
{
for(int j=0; j<newsize; j++)
{
sf::Color p4[4];
p4[0]=tex.c_image.getPixel(i*2, j*2);
p4[1]=tex.c_image.getPixel(i*2+1, j*2);
p4[2]=tex.c_image.getPixel(i*2, j*2+1);
p4[3]=tex.c_image.getPixel(i*2+1, j*2+1);
sf::Color m=pixel4(p4[0], p4[1], p4[2], p4[3]);
gen.c_image.setPixel(i, j, m);
}
}
}
开发者ID:hominidclint,项目名称:oclrenderer2,代码行数:26,代码来源:obj_mem_manager.cpp
示例6: runtime_error
void glsl_program::set_gl_texture(unsigned loc, const texture& tex, unsigned texunit) const
{
if (used_program != this)
throw runtime_error("glsl_program::set_gl_texture, program not bound!");
glActiveTexture(GL_TEXTURE0 + texunit);
tex.set_gl_texture();
glUniform1i(loc, texunit);
}
开发者ID:AD-530,项目名称:WorldViewer,代码行数:8,代码来源:shader.cpp
示例7: blit_texture
void blit_texture(const texture& tex, int x, int y, GLfloat rotate)
{
if(!tex.valid()) {
return;
}
glEnable(GL_TEXTURE_2D);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
x &= preferences::xypos_draw_mask;
y &= preferences::xypos_draw_mask;
int h = tex.height();
int w = tex.width();
const int w_odd = w % 2;
const int h_odd = h % 2;
h /= 2;
w /= 2;
glPushMatrix();
glTranslatef(x+w,y+h,0.0);
glRotatef(rotate,0.0,0.0,1.0);
tex.set_as_current_texture();
GLfloat varray[] = {
-w, -h,
-w, h+h_odd,
w+w_odd, -h,
w+w_odd, h+h_odd
};
GLfloat tcarray[] = {
texture::get_coord_x(0.0), texture::get_coord_y(0.0),
texture::get_coord_x(0.0), texture::get_coord_y(1.0),
texture::get_coord_x(1.0), texture::get_coord_y(0.0),
texture::get_coord_x(1.0), texture::get_coord_y(1.0)
};
glVertexPointer(2, GL_FLOAT, 0, varray);
glTexCoordPointer(2, GL_FLOAT, 0, tcarray);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glPopMatrix();
}
开发者ID:davewx7,项目名称:Wizard-Tactics,代码行数:46,代码来源:raster.cpp
示例8: add_texture
void add_texture(texture &tex, int &newid)
{
int size=tex.get_largest_dimension();
int num=0;
cl_uchar4 *firstfree=return_first_free(size, num);
sf::Image *T=&tex.c_image;
texture_array_descriptor *Td=&obj_mem_manager::tdescrip;
int which = Td->texture_nums[num];
int blockalongy = which / (max_tex_size/size);
int blockalongx = which % (max_tex_size/size);
int ti=0, tj=0;
for(int i=blockalongx*size; i<(blockalongx+1)*size; i++)
{
for(int j=blockalongy*size; j<(blockalongy+1)*size; j++)
{
sf::Color c=T->getPixel(ti, tj);
setpixel(firstfree, c, i, j, max_tex_size, max_tex_size);
tj++;
}
ti++;
tj=0;
}
///so, num represents which slice its in
///Td->texture_nums[i] represents which position it is in within the slice;
int mod=(num << 16) | Td->texture_nums[num];
newid=mod;
///so, now the upper half represents which slice its in, and the lower half, the number within the slice
obj_mem_manager::tdescrip.texture_nums[num]++;
}
开发者ID:hominidclint,项目名称:oclrenderer2,代码行数:37,代码来源:obj_mem_manager.cpp
示例9: image_handle
image_handle(const texture<target>& texture, GLint level, bool layered, GLint layer, GLenum format) : id_(glGetImageHandleARB(texture.id(), level, layered, layer, format))
{
}
开发者ID:juantresde,项目名称:gl,代码行数:4,代码来源:image_handle.hpp
示例10: init
void init()
{
memset(lastfilename,0,256);
memset(musfilename,0,40);
initGUI();
sprintf(scenelist->name,"Default");
memset(tooltip,0,256);
memset(defaulttooltip,0,256);
sprintf(defaulttooltip,"a.D.D.i.c.t. (c) BoyC 2002");
actualtexture=texturelist;
lasttexture=texturelist;
memset(texturelist,0,sizeof(tTexture));
texturelist->next=NULL;
sprintf(texturelist->name,"Default");
memset(cursorstring,0,256);
for (x=0;x<=7;x++) modellsubmenu[x]=0;
init3dengine();
InitModellerGUI();
BuildFont();
BuildFont2();
BuildFontSmall();
inittextureengine();
generatedtexture.init();
buffertexture.init();
memset(pretextures,0,sizeof(pretextures));
memset(texdata,0,sizeof(texdata));
memset(texsubmenu,0,sizeof(texsubmenu));
texdata[0][3].command[3]=4;
texdata[0][5].command[3]=14;
texdata[0][5].command[4]=100;
texdata[0][6].command[3]=30;
texdata[1][1].command[2]=128;
texdata[2][4].command[3]=128;
texdata[3][2].command[2]=128;
texdata[3][4].command[4]=255;
texdata[3][6].c.param1=255;
texdata[3][6].c.param3=255;
texdata[3][6].c.param5=255;
glGenTextures(1,&mattexture);
glBindTexture(GL_TEXTURE_2D,mattexture);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D,0,4,256,256,0,GL_RGBA,GL_UNSIGNED_BYTE,generatedtexture.layers[0]);
for (x=0;x<4;x++)
{
glGenTextures(1,&(prelayers[x]));
glBindTexture(GL_TEXTURE_2D,prelayers[x]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D,0,4,256,256,0,GL_RGBA,GL_UNSIGNED_BYTE,generatedtexture.layers[x]);
}
for (x=0;x<4;x++)
{
glGenTextures(1,&(texlayers[x]));
glBindTexture(GL_TEXTURE_2D,texlayers[x]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D,0,4,256,256,0,GL_RGBA,GL_UNSIGNED_BYTE,generatedtexture.layers[x]);
}
for (x=0;x<4;x++)
{
glGenTextures(1,&alayers[x]);
glBindTexture(GL_TEXTURE_2D,alayers[x]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D,0,4,256,256,0,GL_RGBA,GL_UNSIGNED_BYTE,generatedtexture.layers[x]);
}
glGenTextures(1,&background);
glBindTexture(GL_TEXTURE_2D, background);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
commandnames[DD_fractal] ="Fractal ";
commandnames[DD_plasma] ="Plasma ";
commandnames[DD_cells] ="Cells ";
commandnames[DD_envmap] ="Envmap ";
commandnames[DD_subplasm] ="Subplasma ";
commandnames[DD_clear] ="Clear ";
commandnames[DD_text] ="Text ";
commandnames[DD_sindist] ="SinDist ";
commandnames[DD_offset] ="Offset ";
commandnames[DD_twirl] ="Twirl ";
commandnames[DD_blur] ="Blur ";
commandnames[DD_map] ="MapDist ";
commandnames[DD_dirblur] ="DirBlur ";
commandnames[DD_xchng] ="Xchange ";
commandnames[DD_copy] ="Copy ";
commandnames[DD_mix] ="Mix ";
commandnames[DD_mul] ="Mul ";
commandnames[DD_add] ="Add ";
commandnames[DD_max] ="Max ";
commandnames[DD_contrast] ="Contrast ";
commandnames[DD_invert] ="Invert ";
commandnames[DD_shade] ="Shade ";
commandnames[DD_bright] ="Brighten ";
commandnames[DD_sincol] ="Color Sine ";
commandnames[DD_scale] ="Scale ";
commandnames[DD_hsv] ="HSV ";
commandnames[DD_colorize] ="Colorize ";
commandnames[DD_mixmap] ="MixMap ";
//.........这里部分代码省略.........
开发者ID:ConspiracyHu,项目名称:2012SourcePack,代码行数:101,代码来源:aDDict.cpp
示例11: main
void main (int argc,char **argv)
{
setlocale(LC_CTYPE, ""); //making autoconverting for non cp866 symbols
// инициализация библиотеки GLUT
glutInit(&argc,argv);
// инициализация дисплея (формат вывода)
glutInitDisplayMode (GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);
// создание окна:
// 1. устанавливаем верхний левый угол окна
glutInitWindowPosition(200,200);
// 2. устанавливаем размер окна
glutInitWindowSize(600,600);
// 3. создаем окно
glutCreateWindow("Anytime, anywhere…");
// устанавливаем обработчик выхода (для освобождения выделенной памяти)
atexit(onExit);
// переходим в полноэкранный режим
//glutFullScreen();
cfg=new Config();
try
{
cfg->readFile(cfgPath.c_str());
} catch (...)
{
printf("Config doesn't parsed\n");
}
// очистка объектов
objects.clear();
cam=new camera();
// загрузка камеры
cam->loadCamera(cfg);
hasVBO=glutExtensionSupported("GL_ARB_vertex_buffer_object")!=0; // check if VBO supported
hasFragmentShader=glutExtensionSupported("GL_ARB_fragment_shader")!=0; // check if fragment shader is supported
hasVertexShader=glutExtensionSupported("GL_ARB_vertex_shader")!=0; // check if fragment shader is supported
newOGL=atof((const char *)glGetString(GL_VERSION))>=1.5f; // check OGL version
// проверяем наличие необходимых расширений
object3DS::checkExtensions();
shader::checkExtensions();
if (!hasVBO) { printf("VBO does not supported\n"); } // no VBO
if (!hasFragmentShader) { printf("Fragment shaders not supported\n"); } // no fragment shader
if (!hasVertexShader) { printf("Vertex shaders not supported\n"); } // no vertex shader
if (!newOGL) { printf("OLG 2.0 functions not supported\n"); } // old OGL
ilInit();
devilError = ilGetError();
if (devilError != IL_NO_ERROR)
{
wprintf(L"Devil Error (ilInit): %s\n", iluErrorString(devilError));
exit(2);
}
iluInit();
ilutInit();
ilutRenderer(ILUT_OPENGL);
// загрузка объектов по файлу конфигурации
loadObjects(objects);
for (unsigned int i=0; i<objects.size(); i++)
{
objects[i]->buffer(); // buffer objects to VBO
}
modelShader.loadVertexShader("Phong.vsh");
modelShader.loadFragmentShader("Phong.fsh");
modelShader.createProgram();
planeShader.loadVertexShader("Phong.vsh");
planeShader.loadFragmentShader("Phong.l3.fsh");
planeShader.createProgram();
// 4. устанавливаем функцию, которая будет вызываться для перерисовки окна
glutDisplayFunc(display);
// 5. устанавливаем функцию, которая будет вызываться при изменении размеров окна
glutReshapeFunc(reshape);
// 6. устанавливаем таймер для перерисовки окна по времени
glutTimerFunc(delayPerFrames,simulation,0);
// 7. устанавливаем обработчик обычных клавиш
glutKeyboardFunc(processNormalKeys);
// 8. устанавливаем обработчик функциональных клавиш
glutSpecialFunc(processSpecialKeys);
glEnable(GL_CULL_FACE);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_LIGHT1);
glEnable(GL_TEXTURE_2D);
glActiveTexture(GL_TEXTURE0);
surfaceTex.load(L"textures\\ceram.jpg");
// вывод строк описывающих OpenGL
// вывод производителя
printf("%s\n",glGetString(GL_VENDOR));
printf("%s\n",glGetString(GL_RENDERER));
//.........这里部分代码省略.........
开发者ID:PaveLiArcH,项目名称:3ds_viewer,代码行数:101,代码来源:main.cpp
示例12: stb_to_texture
void stb_to_texture(ID3D11Device* device, LPCSTR filename, texture& t)
{
bool is_hdr = std::string(filename).find(".hdr") != std::string::npos;
bool is_jpg = std::string(filename).find(".jpg") != std::string::npos;
D3D11_TEXTURE2D_DESC tex_desc;
ZeroMemory(&tex_desc, sizeof(tex_desc));
D3D11_SUBRESOURCE_DATA subdata;
ZeroMemory(&subdata, sizeof(subdata));
int width, height, nc;
unsigned char* ldr_data = nullptr;
float* hdr_data = nullptr;
if (!is_hdr)
{
ldr_data = stbi_load(filename, &width, &height, &nc, 4);
subdata.SysMemPitch = width * 4;
subdata.pSysMem = ldr_data;
if (is_jpg)
tex_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM_SRGB;
else
// TODO: Remap to SRGB later when throwing out D3DX
tex_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
// TODO: Need to create mipmaps
}
else
{
hdr_data = stbi_loadf(filename, &width, &height, &nc, 4);
subdata.SysMemPitch = width * 4 * 4;
subdata.pSysMem = hdr_data;
tex_desc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
}
if (!ldr_data && !hdr_data)
{
tstring error = L"can't load";
if (stbi_failure_reason())
error = to_tstring(std::string(stbi_failure_reason()));
throw exception(tstring(L"stbi: ") + error);
}
tex_desc.Width = width;
tex_desc.Height = height;
tex_desc.MipLevels = 1;
tex_desc.ArraySize = 1;
tex_desc.SampleDesc.Count = 1;
tex_desc.SampleDesc.Quality = 0;
tex_desc.Usage = D3D11_USAGE_DEFAULT;
tex_desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
tex_desc.CPUAccessFlags = 0;
tex_desc.MiscFlags = 0;
t.create(device, tex_desc, &subdata);
if (is_hdr)
stbi_image_free(hdr_data);
else
stbi_image_free(ldr_data);
}
开发者ID:FrostedPenguin,项目名称:dirtchamber,代码行数:66,代码来源:texture_cache.cpp
示例13: save
void texture::settings::apply(const texture &texture) const
{
save_binding_state save(texture);
texture.pixel_unpack_settings().apply();
if (compressed_format(m_internal_format))
{
int compressed_image_size = m_compressed_image_size;
if (!compressed_image_size)
{
switch (m_internal_format)
{
case texture::internal_format::compressed_rgb_s3tc_dxt1:
compressed_image_size = ((m_width + 2) / 3) * ((m_height + 2) / 3) * 6;
break;
case texture::internal_format::compressed_rgba_s3tc_dxt1:
compressed_image_size = ((m_width + 3) / 4) * ((m_height + 3) / 4) * 8;
break;
case texture::internal_format::compressed_rgba_s3tc_dxt3:
case texture::internal_format::compressed_rgba_s3tc_dxt5:
compressed_image_size = ((m_width + 3) / 4) * ((m_height + 3) / 4) * 16;
break;
}
}
__glcheck glCompressedTexImage2D((GLenum)m_parent->get_target(), m_level, (GLint)m_internal_format, m_width, m_height, 0, compressed_image_size, m_pixels);
}
else
{
__glcheck glTexImage2D((GLenum)m_parent->get_target(), m_level, (GLint)m_internal_format, m_width, m_height, 0, (GLint)m_format, (GLint)m_type, m_pixels);
}
__glcheck glTexParameteri((GLenum)m_parent->get_target(), GL_TEXTURE_MAX_LEVEL, m_max_level);
if (m_pixels)
{
__glcheck glTexParameteri((GLenum)m_parent->get_target(), GL_GENERATE_MIPMAP, m_generate_mipmap ? GL_TRUE : GL_FALSE);
}
__glcheck glTexParameteri((GLenum)m_parent->get_target(), GL_TEXTURE_WRAP_S, (GLint)m_wrap_s);
__glcheck glTexParameteri((GLenum)m_parent->get_target(), GL_TEXTURE_WRAP_T, (GLint)m_wrap_t);
__glcheck glTexParameteri((GLenum)m_parent->get_target(), GL_TEXTURE_WRAP_R, (GLint)m_wrap_r);
__glcheck glTexParameteri((GLenum)m_parent->get_target(), GL_TEXTURE_COMPARE_MODE, (GLint)m_compare_mode);
__glcheck glTexParameteri((GLenum)m_parent->get_target(), GL_TEXTURE_COMPARE_FUNC, (GLint)m_compare_func);
__glcheck glTexParameterf((GLenum)m_parent->get_target(), GL_TEXTURE_MIN_LOD, m_max_lod);
__glcheck glTexParameterf((GLenum)m_parent->get_target(), GL_TEXTURE_MAX_LOD, m_min_lod);
__glcheck glTexParameterf((GLenum)m_parent->get_target(), GL_TEXTURE_LOD_BIAS, m_lod);
__glcheck glTexParameterfv((GLenum)m_parent->get_target(), GL_TEXTURE_BORDER_COLOR, m_border_color.rgba);
__glcheck glTexParameteri((GLenum)m_parent->get_target(), GL_TEXTURE_MIN_FILTER, (GLint)m_min_filter);
__glcheck glTexParameteri((GLenum)m_parent->get_target(), GL_TEXTURE_MAG_FILTER, (GLint)m_mag_filter);
__glcheck glTexParameteri((GLenum)m_parent->get_target(), GL_TEXTURE_SWIZZLE_R, (GLint)m_swizzle_r);
__glcheck glTexParameteri((GLenum)m_parent->get_target(), GL_TEXTURE_SWIZZLE_G, (GLint)m_swizzle_g);
__glcheck glTexParameteri((GLenum)m_parent->get_target(), GL_TEXTURE_SWIZZLE_B, (GLint)m_swizzle_b);
__glcheck glTexParameteri((GLenum)m_parent->get_target(), GL_TEXTURE_SWIZZLE_A, (GLint)m_swizzle_a);
__glcheck glTexParameterf((GLenum)m_parent->get_target(), GL_TEXTURE_MAX_ANISOTROPY_EXT, m_aniso);
}
开发者ID:KitoHo,项目名称:rpcs3,代码行数:65,代码来源:GLHelpers.cpp
示例14: display
// функция вызывается при перерисовке окна
// в том числе и принудительно, по командам glutPostRedisplay
void display (void)
{
// отчищаем буфер цвета и буфер глубины
int rst=glGetError();
glClearColor(0.78125,0.78125,0.76171875,1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
// отрисовка осей
// задание толщины линии
glLineWidth(0.5);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
glColorPointer(3,GL_FLOAT,sizeof(vertex),&axes[0].color);
glVertexPointer(3,GL_FLOAT,sizeof(vertex),&axes[0].coordinate);
glDrawArrays(GL_LINES,0,3*2);
glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
glEnable(GL_LIGHTING);
// режим вывода полигонов (выводим в виде линии)
glPolygonMode(GL_FRONT_AND_BACK,/*GL_LINE*/GL_FILL);
// устанавливаем камеру
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
//gluLookAt(0,30,20,0,0,0,0,1,0);
glMultMatrixd(cam->getOrientation());
// позиция камеры
glMultMatrixd(cam->getPosition());
firstLight.use();
secondLight.use(GL_LIGHT1);
planeMaterial.use();
planeShader.activate();
glEnable(GL_TEXTURE_2D);
glClientActiveTexture(GL_TEXTURE0);
GLint texLoc = glGetUniformLocation(planeShader.getProgramId(), "MyTex");
glUniform1i(texLoc,0);
glTexEnvi ( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );
glColor3f(0.4f,0.8f,0.4f);
glNormal3f(0.0,1.0,0.0);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
surfaceTex.bind();
glTexCoordPointer(2,GL_FLOAT,0,surfaceTexCoord);
glVertexPointer(3,GL_FLOAT,sizeof(vertex),&surface[0].coordinate);
glDrawElements(GL_TRIANGLES,18*3,GL_UNSIGNED_INT,surfaceIndex);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
glDisable(GL_TEXTURE_2D);
modelShader.activate();
for(unsigned int i=0; i<objects.size(); i++)
{
objects[i]->render(filterMode); // call to object3ds method for rendering
}
shader::disactivate();
glCullFace(GL_BACK);
glColor3f(0.2f,0.2f,0.2f);
glutWireSphere(0.07, 16, 16);
if (isDrawingFps)
{
drawFps();
}
// смена переднего и заднего буферов
glutSwapBuffers();
};
开发者ID:PaveLiArcH,项目名称:3ds_viewer,代码行数:90,代码来源:main.cpp
注:本文中的texture类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论