Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8737795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:36:09+00:00 2026-06-13T10:36:09+00:00

void init(void) { glEnable(GL_DEPTH_TEST); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); } void display(void) { glClearColor(1.0, 1.0, 1.0, 1.0);

  • 0


void init(void)
{
glEnable(GL_DEPTH_TEST);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
}

void display(void)
{
glClearColor(1.0, 1.0, 1.0, 1.0);

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glScalef(1.0,1.0,1.0);
glColor3f(0.0,0.0,0.0);
    glBegin(GL_POLYGON);
    glVertex2f(-0.5, -0.5);
    glVertex2f(-0.5, 0.5);
    glVertex2f(0.5, 0.5);
    glVertex2f(0.5, -0.5);
glEnd();
    glutSwapBuffers();

}

void reshape(int w, int h)
{
int height = h;
int width = w;
glViewport(0, 0, (GLsizei)w, (GLsizei)h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60, (GLfloat)w / (GLfloat)h, 1.0, 100.0);
glMatrixMode(GL_MODELVIEW);
}

int main(int argc, char* argv[])
{
Complex c(0,0);
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
glutInitWindowSize(512, 512);
glutInitWindowPosition(100, 100);
winID = glutCreateWindow(“Fractal”);
init();
glutDisplayFunc(display);
glutIdleFunc(display);
glutReshapeFunc(reshape);
// Compute the update rate here…
glutMainLoop();
return 0;
}

I get a square if I put the code in display(), except the glutSwapBuffers() in if condition which checks whether the code has entered display the first time. If I remove the if, I get a white window

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T10:36:10+00:00Added an answer on June 13, 2026 at 10:36 am

    Put an extra glTranslatef(0.0f, 0.0f, -5.0f) in your display function, to push everything 5 units back into the scene, otherwise you wont see what you’re drawing at the origin.

    Btw, the line glScalef(1.0,1.0,1.0) doesn’t do anything, remove it to avoid unnecessary calculations.

    EDIT:
    There is no “eye” in OpenGL. More specifically, it is always fixed at (0,0,0) looking down at the negative z-axis. You have to move the whole scene with the inverse of the eye transformations. You can either move the scene manually so your eye can see it, or use gluLookAt, where you can specify the “eye”, but in the background it just transforms the scene so the fixed “eye” can see it.

    Further reading: http://www.opengl.org/archives/resources/faq/technical/viewing.htm

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my GL init code: gl.glEnable(GL10.GL_TEXTURE_2D); gl.glShadeModel(GL10.GL_SMOOTH); gl.glEnable(GL10.GL_BLEND); gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA); gl.glDisable(GL10.GL_DEPTH_TEST); gl.glMatrixMode(GL10.GL_PROJECTION); gl.glLoadIdentity();
#include <GL/gl.h> #include <GL/glut.h> void display(); void init(); int main(int argc, char* argv[]) {
I try to run the following code: public void Init(Url rootUrl) { var web
-(void) readProductsFromDatabase { // Setup the database object sqlite3 *database; // Init the animals
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Init(); backthread tr=new backthread(); tr.execute(0,0,0); } backthread
Trying to add init parameter names to a list in init(ServletConfig) method. public void
Take the following example: public void init() { final Environment env = new Environment();
At the moment I am using the following code: public void init() { question
I have an interface. public interface Module { void init(); void actions(); } What
//src/com/test/animal/Animal.java package com.test.animal; public class Animal { Animal() { init(); } public void init()

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.