如何在蓝色中没有所有感觉颜色的蓝色颜色QUADS? [英] How to color QUADS in blue color without all sense color in the blue؟

查看:80
本文介绍了如何在蓝色中没有所有感觉颜色的蓝色颜色QUADS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好我正在使用过滤器和opengl与c ++,我有家我想在其中绘制蓝色QUADS我的问题当我用蓝色绘制QUADS所有感应颜色时,我怎么能只用蓝色和QUADS颜色和我想错了如何从所有的感觉和颜色中删除蓝色只有我的QUAD?我的尝试:



hello I am using glut and opengl with c++ , I have home I want to draw blue QUADS in it my problem when I draw the QUADS all the sense color in blue , so how I can to color only QUADS in blue color and Prevents to color all sense in blue color what I do wrong how to remove the blue color from all the sense and color only my QUAD? my try:

void drawSquare1()
{
     glBegin(GL_QUADS);
    glColor3d(1,0,0);
    glVertex3f(-0.5,-0.5,-0.5);
    glColor3d(1,1,0);
    glVertex3f(0.5,-0.5,-0.5);
    glColor3d(1,1,1);
    glVertex3f(0.5,0.5,-0.5);
    glColor3d(0,1,1);
    glVertex3f(-0.5,0.5,-0.5);
glEnd();
}

void render(void)                                                   // Our Rendering Is Done Here
{

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);             // Clear The Screen And The Depth Buffer
    glLoadIdentity();                                               // Reset The View

    GLfloat xtrans = -g_xpos;
    GLfloat ztrans = -g_zpos;
    GLfloat ytrans = -g_ypos;
    if(g_yrot > 360)
        g_yrot -= 360;
    else if(g_yrot < 0)
        g_yrot += 360;
    GLfloat sceneroty = (360.0f - g_yrot);


    int numpolygons;

    glRotatef(g_lookupdown,1.0f,0,0);
    glRotatef(sceneroty,0,1.0f,0);

    glTranslatef(xtrans, ytrans, ztrans);

    numpolygons = g_sector1.numpolygons;

    for (int loop_m = 0; loop_m < numpolygons; loop_m++)
        texture_object(loop_m); 

    gluQuadricDrawStyle(my_shape[0],GLU_FILL);
    glBindTexture(GL_TEXTURE_2D, textures[1].texID);
    glScalef(0.1,0.1,0.1);
    glTranslatef(0.78,14.3,-4.2);
    gluSphere(my_shape[0], 1.0,50,50);

    gluQuadricDrawStyle(my_shape[1],GLU_FILL);
    glBindTexture(GL_TEXTURE_2D, textures[8].texID);
    glTranslatef(-20,0,0);
    gluSphere(my_shape[1], 1.0,50,50);

    gluQuadricDrawStyle(my_shape[2],GLU_FILL);
    glBindTexture(GL_TEXTURE_2D, textures[22].texID);
    glTranslatef(40,0,0);
    gluSphere(my_shape[2], 1.0,50,50);

    glMatrixMode(GL_PROJECTION);                                    // Select The Projection Matrix
    glPushMatrix();                                                 // Store The Projection Matrix
    glLoadIdentity();                                               // Reset The Projection Matrix

    glOrtho(-10,window_width,0,window_height,-10,10);                   // Set Up An Ortho Screen
    glMatrixMode(GL_MODELVIEW);                                     // Select The Modelview Matrix
drawSquare1();
glMatrixMode(GL_PROJECTION);                                    // Select The Projection Matrix
    glPopMatrix();                                                  // Restore The Old Projection Matrix
    //glPushMatrix();
    drawSquare1();
    //glPopMatrix();
    glMatrixMode(GL_MODELVIEW);                                     // Select The Modelview Matrix
    glutSwapBuffers ( );
}

int main(int argc, char** argv)                                 // Main Function For Bringing It All Together.
{
    //cout << "Hello World!" << endl;
    //cin.get();
    glutInit(&argc, argv);                                      // GLUT Initializtion
    glutInitDisplayMode(GLUT_DEPTH | GLUT_RGBA | GLUT_DOUBLE);  // (CHANGED)
    if (g_gamemode) 
    {
        glutGameModeString("640x480:16");                       // Select The 640x480 In 16bpp Mode
        if (glutGameModeGet(GLUT_GAME_MODE_POSSIBLE))
            glutEnterGameMode();                                // Enter Full Screen
        else g_gamemode = false;                                // Cannot Enter Game Mode, Switch To Windowed
    }
    screen_width = glutGet(GLUT_SCREEN_WIDTH);
    screen_height = glutGet(GLUT_SCREEN_HEIGHT);
    window_width = screen_width/1.4;
    window_height = screen_height/1.4;

    if (!g_gamemode) 
    {
        glutInitWindowSize(window_width,window_height);           // Window Size If We Start In Windowed Mode
        glutInitWindowPosition((screen_width-window_width)/2,(screen_height-window_height)/2);
        glutCreateWindow("Frank's 3-D House");                  // Window Title 
    }

    init();


    glutIgnoreKeyRepeat(true);                                  // Disable Auto Repeat (NEW)
    //  glutKeyboardFunc(myKey); // register the key handler.

    glutDisplayFunc(render);                                    // Register The Display Function
    glutReshapeFunc(reshape);                                   // Register The Reshape Handler
    glutKeyboardFunc(keyboard);                                 // Register The Keyboard Handler
    //glRasterPos2f(lineMargin, currentHight); // set the cursor to the initial position.
    glutSpecialFunc(special_keys);                              // Register Special Keys Handler
    glutSpecialUpFunc(special_keys_up);                         // Called When A Special Key Released (NEW)
    glutIdleFunc(game_function);                                // Process User Input And Does Rendering (CHANGED)
    glutMouseFunc(mouse) ;
    glutMainLoop();                                             // Go To GLUT Main Loop
    return 0;





我尝试过:



我的上面尝试所以任何人都可以帮忙?



What I have tried:

my try above so any body can help ?

推荐答案

你需要有一些信息你的四边形不是蓝色,所以不要画它们。



我会创建一个bool数组来存储这些信息并以简单的方式使用它。
You need to have some informations which of your quads arent blue, so than draw them not.

I would create an array of bools to store that information and use it in a simple manner.


这篇关于如何在蓝色中没有所有感觉颜色的蓝色颜色QUADS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆