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 8835083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:10:43+00:00 2026-06-14T09:10:43+00:00

private void init_video () { uint32 video_flags = SurfaceFlag.SWSURFACE | SurfaceFlag.OPENGL; screen = Screen.set_video_mode

  • 0
private void init_video () {
    uint32 video_flags = SurfaceFlag.SWSURFACE | SurfaceFlag.OPENGL;
    screen = Screen.set_video_mode (SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, video_flags);
    if (screen == null) stderr.printf ("Could not set video mode.\n");

    glClearColor (0.0f, 0.0f, 0.0f, 1.0f);
    glMatrixMode (GL_PROJECTION);
    glLoadIdentity ();
    glFrustum (-2.0f, 2.0f, -2.0f, 2.0f, 1.0f, 300.0f);
    glMatrixMode (GL_MODELVIEW);
    glEnable (GL_DEPTH_TEST);
    glEnable (GL_TEXTURE_2D);

    SDL.WindowManager.set_caption ("Title", "Title");
}

That is the function where I set up the camera for a game I’m working on. I have this function to draw a cube:

public void draw () {
    glLoadIdentity ();
    glTranslatef (x, y, z);
    glScalef (size, size, size);
    glRotatef (x_angle, 1.0f, 0.0f, 0.0f);
    glRotatef (y_angle, 0.0f, 1.0f, 0.0f);
    glRotatef (z_angle, 0.0f, 0.0f, 1.0f);
    glBegin (GL_QUADS);

    /* Front face */
    glColor3f (1.0f, 0.0f, 0.0f);
    glVertex3f (0.5f, 0.5f, 0.5f);
    glVertex3f (-0.5f, 0.5f, 0.5f);
    glVertex3f (-0.5f, -0.5f, 0.5f);
    glVertex3f (0.5f, -0.5f, 0.5f);

    /* Left face */
    glColor3f (0.0f, 1.0f, 0.0f);
    glVertex3f (-0.5f, 0.5f, 0.5f);
    glVertex3f (-0.5f, -0.5f, 0.5f);
    glVertex3f (-0.5f, -0.5f, -0.5f);
    glVertex3f (-0.5f, 0.5f, -0.5f);

    /* Back face */
    glColor3f (0.0f, 0.0f, 1.0f);
    glVertex3f (0.5f, 0.5f, -0.5f);
    glVertex3f (-0.5f, 0.5f, -0.5f);
    glVertex3f (-0.5f, -0.5f, -0.5f);
    glVertex3f (0.5f, -0.5f, -0.5f);

    /* Right face */
    glColor3f (1.0f, 1.0f, 0.0f);
    glVertex3f (0.5f, 0.5f, 0.5f);
    glVertex3f (0.5f, -0.5f, 0.5f);
    glVertex3f (0.5f, -0.5f, -0.5f);
    glVertex3f (0.5f, 0.5f, -0.5f);

    /* Top face */
    glColor3f (0.0f, 1.0f, 1.0f);
    glVertex3f (0.5f, 0.5f, 0.5f);
    glVertex3f (-0.5f, 0.5f, 0.5f);
    glVertex3f (-0.5f, 0.5f, -0.5f);
    glVertex3f (0.5f, 0.5f, -0.5f);

    /* Bottom face */
    glColor3f (1.0f, 0.0f, 1.0f);
    glVertex3f (0.5f, -0.5f, 0.5f);
    glVertex3f (-0.5f, -0.5f, 0.5f);
    glVertex3f (-0.5f, -0.5f, -0.5f);
    glVertex3f (0.5f, -0.5f, -0.5f);
    glEnd ();
}

How can I draw points as if it was a 2D Context? Any ideas?

  • 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-14T09:10:44+00:00Added an answer on June 14, 2026 at 9:10 am

    There is no thing as a 2D context in OpenGL. Everything is 3d.
    But you can emulate 2d using a parallel projection with glOrtho

    // Setup Orthogonal projection to window coordiantes
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0, WindowWidth-1, 0, WindowHeight-1, -1, 1);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    
    // draw quad in screen coodinates
    glBegin(GL_QUADS);
        glColor3f(1.0f, 1.0f, 1.0f);
        glVertex2i(10, 10);
        glVertex2i(10, 80);
        glVertex2i(80, 80);
        glVertex2i(80, 10);
    glEnd (); 
    

    glVertex2 is like glVertex3 with the third coorinate set to 0.

    With OpenGL 4 all the above commands are removed. But the glOrtho documentation shows you the matrix you need to create to set up rendering in windows coordinates.

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

Sidebar

Related Questions

private void CopyAssets2() { AssetManager assetManager = getAssets(); String[] files = null; try {
private void SaveAsPicture_Click(object sender, RoutedEventArgs e) { WriteableBitmap bmp = new WriteableBitmap(MyUIElement, null); var
private void EnsureCurrentlyValid() { //I'm valid if IDataErrorInfo.this[] returns null for every property var
private void button1_Click(object sender, EventArgs e) { for (int i = 0; i <
private void getSelectedTime(final String json){ Calendar now = Calendar.getInstance(); int year = now.get(Calendar.YEAR); int
private void setFPAlarm() { Intent intent = new Intent(this, FPService.class); PendingIntent pi = PendingIntent.getService(this,
private void StringAction(string aString) // method to be called { return; } private void
private void validateXML(DOMSource source) throws Exception { URL schemaFile = new URL(http://www.csc.liv.ac.uk/~valli/modules.xsd); SchemaFactory schemaFactory
private void save(Rectangle src, Rectangle dest, string fName, int width, int height, Bitmap file)
private void Form1_FormClosing(object sender, FormClosingEventArgs e) { if (e.CloseReason == CloseReason.UserClosing) { if (MessageBox.Show(this,

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.