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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:36:15+00:00 2026-06-15T21:36:15+00:00

I am attempting to learn OpenGL and LWJGL by making a minecraft clone, but

  • 0

I am attempting to learn OpenGL and LWJGL by making a minecraft clone, but I am stuck

I was able to render blocks easily and have a first-person camera with wasd controls and now I’m trying to be able to place blocks, but I cannot figure out how would I be able to check which cube and which side of that cube I am looking at/is in the center of the screen so I can put another cube adjacent to that cube.

I am using gluPerspective for the 3d perspective and glRotatef to rotate the world, pretty normal stuff

  • 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-15T21:36:16+00:00Added an answer on June 15, 2026 at 9:36 pm

    One technique is to use an id-buffer. You draw your scene to two textures at once using a framebuffer. The first texture will be a typical color texture. The second will be a texture that stores integers. Before drawing the scene, you assign a number to each cube face. You pass these numbers in to the shader (uniform variables work for this). The fragment shader will ‘draw’ these numbers to the integer texture, while at the same time doing normal shading to the color texture. When you need to find what is at the mouse cursor, use glReadPixels().

    This is all assuming you are using modern OpenGL (3 or better). If you are stuck with the fixed function pipeline (lame), you can also assign a unique color to each cube face, and draw to the back buffer with solid coloring. Make sure to turn off texturing etc. When that’s done, use glReadPixels() to find what was drawn at the mouse cursor. Then you draw things again as normal and swap buffers. (Here’s some outdated code that shows what I’m talking about: http://www.lighthouse3d.com/opengl/picking/index.php3?color1)

    Another technique is to ‘cast a ray’ through the screen. Basically, you test a few equations against each shape in your geometry, and if these tests pass, you have an intersection and you know what shape is clicked. I’m not so experienced with this method, so I’ll leave it to someone else to explain if they want to.

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

Sidebar

Related Questions

I'm attempting to learn Spring MVC but have been spoiled by Grails. While I
I'm attempting to learn OOP and have a few questions. I've read the first
I'm following this tutorial attempting to learn XNA, but I'm having issues making my
I have been attempting to learn Grails, however I am running into the following
I'm attempting to learn Scala so I have decided to implement datastructures with it.
I'm trying to learn python and I'm attempting a hangman game. But when I
I have been using SDL with success to learn OpenGL, however I am following
I am attempting to learn about creating windows in c++, I have looked at
I am attempting to learn how to develop on the Android platform but do
I am attempting to learn how to make Android apps(on Jellybean 4.1.2), but I

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.